• 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: Where do I put post query code in ERD2WQueryPage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where do I put post query code in ERD2WQueryPage


  • Subject: Re: Where do I put post query code in ERD2WQueryPage
  • From: David Holt <email@hidden>
  • Date: Tue, 07 Feb 2012 09:18:37 -0800

Hi James,

You do it in the query source delegate.

You get your original query and then add whatever magic you need to do in the delegate.

public class WorkingGroupProjectsQueryDataSourceDelegate 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();
// this is the line where you are getting your combined
// qualifier from the private method below
    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) {
    WorkingGroup wg = WorkingGroup.wg();
    EOQualifier q = Project.WORKING_GROUP.eq(wg).and(sender.qualifier());
    return q;
  }

the .and(sender.qualifier()); in the qualifierFromSender method is whatever your page produces before passing it to the delegate. Here I am just ensuring that the projects listed in a project query page were created by the working group of the logged in user + whatever search criteria were entered on the query page.

David


On 2012-02-07, at 7:44 AM, James Cicenia wrote:

Ok -

As i replaced my custom QueryPage with one out of the wonder box I am a bit confused as usual.

I understand queryDataSourceDelegate.

I needed that for manipulating the qualifiers... ok, so far so good.

In my Query I have a custom component that lists ERTags they can search on. However, that search
can't be combined with the qualifier based search. I retrieve them from the displayGroup's queryMatch
dictionary, and then get the entities associated with the array of tags. I would then Intersect this set
of entities with those retrieved by the qualifier based query.

The question then becomes how can I do this with just pure D2W delegate / rule interfaces?
OR,
Where do I put the code to merge the two results sets?

Thanks

James

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
  • Prev by Date: AjaxObserveField and the Enter key
  • Next by Date: Re: Limit to the number of instances under JavaMonitor
  • Previous by thread: Re: AjaxObserveField and the Enter key
  • Next by thread: Delay with EO deletion?
  • Index(es):
    • Date
    • Thread