• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: limiting All Queries in D2W
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: limiting All Queries in D2W


  • Subject: Re: limiting All Queries in D2W
  • From: Anjo Krank <email@hidden>
  • Date: Fri, 13 Apr 2012 16:09:05 +0200

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@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


 _______________________________________________
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

References: 
 >limiting All Queries in D2W (From: Theodore Petrosky <email@hidden>)
 >Re: limiting All Queries in D2W (From: David LeBer <email@hidden>)

  • Prev by Date: Re: WO 2012 by Apple?
  • Next by Date: Re: [ANN] WOInject 1.0
  • Previous by thread: Re: limiting All Queries in D2W
  • Next by thread: Foreign Keys
  • Index(es):
    • Date
    • Thread