Much easier to use:
<something> => extraRestrictingQualifier = {
"band" = "session.user.band";
} [ERDDelayedExtraQualifierAssignment]
QueryPage:
public EODataSource queryDataSource() {
EODataSource ds = null;
if(ds == null) {
ds = super.queryDataSource();
}
if (ds != null && (ds instanceof EODatabaseDataSource)) {
EOFetchSpecification fs =
((EODatabaseDataSource)ds).fetchSpecification();
EOQualifier q = fs.qualifier();
EOQualifier extraQualifier =
(EOQualifier)d2wContext().valueForKey("extraRestrictingQualifier");
if(q != null && extraQualifier != null) {
q = new EOAndQualifier(new NSArray(new Object[] {q,
extraQualifier}));
} else if(extraQualifier != null) {
q = extraQualifier;
}
fs.setQualifier(q);
fs.setUsesDistinct(true);
}
return ds;
}
Am 13.04.2012 um 16:02 schrieb David LeBer:
> Ted,
>
> You can look at restrictingFetchSpecification for your list pages, or
> queryDataSourceDelegate to restrict in the query.
>
> For the latter here is an example from one our our apps.
>
> 100 : (entity.name = 'Song' and session.currentUser.isAdmin = 0) =>
> queryDataSourceDelegate =
> "com.alignsoft.rdr.admin.datasource.SongsForCurrentBandQueryDataSource"
> [ERDDelayedObjectCreationAssignment]
>
> public class SongsForCurrentBandQueryDataSource implements
> ERDQueryDataSourceDelegateInterface {
>
> public EODataSource queryDataSource(ERD2WQueryPage sender) {
>
> EODataSource ds = sender.dataSource();
>
> if (ds == null || !(ds instanceof EODatabaseDataSource)) {
> ds = new
> EODatabaseDataSource(sender.session().defaultEditingContext(),
> sender.entity().name());
> sender.setDataSource(ds);
> }
>
> EOFetchSpecification fs = ((EODatabaseDataSource)
> ds).fetchSpecification();
> fs.setQualifier(qualifierFromSender(sender));
> fs.setIsDeep(sender.isDeep());
> fs.setUsesDistinct(sender.usesDistinct());
>
> fs.setRefreshesRefetchedObjects(sender.refreshRefetchedObjects());
>
> int limit = sender.fetchLimit();
> if (limit != 0) {
> fs.setFetchLimit(limit);
> }
>
> NSArray prefetchingRelationshipKeyPaths =
> sender.prefetchingRelationshipKeyPaths();
> if (prefetchingRelationshipKeyPaths != null &&
> prefetchingRelationshipKeyPaths.count() > 0) {
>
> fs.setPrefetchingRelationshipKeyPaths(prefetchingRelationshipKeyPaths);
> }
> return ds;
> }
>
> private EOQualifier qualifierFromSender(ERD2WQueryPage sender) {
> EOQualifier q = sender.qualifier();
> Band b = ((Session)sender.session()).currentUser().band();
> q = ERXQ.and(ERXQ.equals("album.band", b), q);
> return q;
> }
> }
>
> --
> David LeBer
> Codeferous Software
>
> On 2012-04-13, at 7:34 AM, Theodore Petrosky wrote:
>
>> I don't even know where to begin. I have a D2W app that manages Briefs. A
>> Brief is created by a User. (one to one relation)
>>
>> I can easily create a tab that calls a method to limit the resultant list to
>> only those Briefs created by the current User. However, where do I 'fix' the
>> search area.
>>
>> I mean if the current User is Sally, she will search for Brief(s) that the
>> Objective attribute contains the word 'Iceman'. But I want all queries to
>> include 'and user = 'Sally'.
>>
>> Sally should not see Bob's Briefs. I am trying to embrace D2W, and (for me)
>> this would be trivial in a Wonder app.
>>
>> Is there a property for this?
>>
>> Ted
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/dleber_wodev%40codeferous.com
>>
>> This email sent to [email protected]
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/anjo%40krank.net
>
> This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]