• 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: Need help in building a pretty complex EOQualifier
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help in building a pretty complex EOQualifier


  • Subject: Re: Need help in building a pretty complex EOQualifier
  • From: David Avendasora <email@hidden>
  • Date: Thu, 12 Dec 2013 11:15:32 -0500

Hi Markus,

The problem is that you can’t do what you are trying to in one step because there are likely several DocumentText objects that match each of your criteria which is going to cause the problems you are seeing. 

You will have to evaluate the criteria one at a time, but first you have to figure out which criteria can combine into single Qualifiers/Clauses, and which have to be evaluated independently.

I find it much easier to create each qualifier individually, using descriptive of names as possible, then combine them together so it all reads as a sentence. It helps make complicated qualifiers like this more obvious to write, and later come back and read.

 all Documents where the assignment to Text "A" has comment "x” 
seems like criteria that can be combined like so:

 assignment to Text "A"  
ERXKeyValueQualifier thatAreForTextA = DocumentText.TEXT.eq(“A”)
has comment "x” 
ERXKeyValueQualifier thatAreForCommentContainsX = DocumentText.COMMENT.contains(“x”);
assignment to Text "A" has comment "x” 
ERXAndQualifier thatAreForTextAandCommentContainsX = thatAreForTextA.and(thatAreForCommentContainsX);

Now we will create a qualifier for Document objects that are related to **at least one** DocumentText that match this set of criteria:
ERXExistsQualifier thatMatchTheFirstSetOfCriteria = new ERXExistsQualifier(DOCUMENT_TEXTS, thatAreForTextAandCommentContainsX);


 AND the assignment to Text "B" has status "y”.
This also seems like criteria that can be combined.

 assignment to Text "B" 
ERXKeyValueQualifier thatAreForTextB = DocumentText.TEXT.eq(“B”)
 has status "y”.
ERXKeyValueQualifier thatAreForStatusY = DocumentText.STATUS.eq(“y”);
 assignment to Text "B" has status "y”.
ERXAndQualifier thatAreForTextBandStatusY = thatAreForTextB.and(thatAreForStatusY);

Now we will create another qualifier for Document objects. This one will find instances that are related to **at least one** DocumentText that match the this second set of criteria:
ERXExistsQualifier thatMatchTheSecondSetOfCriteria = new ERXExistsQualifier(DOCUMENT_TEXTS, thatAreForTextBandStatusY);


Now comes the two-step part:

First, fetch the Document objects that are related to **at least one** DocumentText that match the *first* set of criteria:
NSArray<Document> documentsForTheFirstSetOfCriteria = Document.fetch(thatMatchTheFirstSetOfCriteria);

Now, filter the that array for ones that are also related to **at least one** DocumentText that match the *second* set of criteria
NSArray<Document> documentsForTheFirstAndSecondSetsOfCriteria = ERXQ.filtered(documentsForTheFirstSetOfCriteria, thatMatchTheSecondSetOfCriteria);

Done. “documentsForTheFirstAndSecondSetsOfCriteria" will have … wait for it … Document objects that match both sets of criteria!

Another way to write (in English) what this does is:

"The user wants to see all Documents that are related to at least one DocumentText that has a Text of “A” and a comment of “x” and the Documents must also be related to at least one DocumentText that has a Text of “B” and a status of “y”."

Dave Avendasora

On Dec 12, 2013, at 8:56 AM, Markus Ruggiero <email@hidden> wrote:

Now comes the qualifier to retrieve Documents: The user sees a D2WQueryPage for the document properties with an embedded property level query component that presents the full list of possible DocumentText objects with their status and comment fields. A typical scenario could be: the user wants to enter a comment query for the second assigned text (that's Text "A") and/or picks a query value for the status of the 7th assigned text (this could be Text "B"). Upon executing the query the user expects to retrieve a list of Documents that fulfill all given criteria. In this example the user wants to see all Documents where the assignment to Text "A" has comment "x" AND the assignment to Text "B" has status "y".


—————————————————————————————
WebObjects - so easy that even Dave Avendasora can do it!™
—————————————————————————————
David Avendasora
Senior Software Abuser
Nekesto, Inc.





 _______________________________________________
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

  • Follow-Ups:
    • Re: Need help in building a pretty complex EOQualifier
      • From: Markus Ruggiero <email@hidden>
References: 
 >Need help in building a pretty complex EOQualifier (From: Markus Ruggiero <email@hidden>)

  • Prev by Date: Re: Need help in building a pretty complex EOQualifier
  • Next by Date: Re: Need help in building a pretty complex EOQualifier
  • Previous by thread: Re: Need help in building a pretty complex EOQualifier
  • Next by thread: Re: Need help in building a pretty complex EOQualifier
  • Index(es):
    • Date
    • Thread