Re: limiting All Queries in D2W
Re: limiting All Queries in D2W
- Subject: Re: limiting All Queries in D2W
- From: David LeBer <email@hidden>
- Date: Fri, 13 Apr 2012 10:02:09 -0400
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@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden