Is there any reason that you can not add a view on the backend. get halfway 
there with a view then your d2w query will not be so involved.




On Jul 9, 2013, at 2:30 AM, Markus Ruggiero <mailingli...@kataputt.com> wrote:

> Thanks Ramsey, but...
> 
> On 08.07.2013, at 19:49, Ramsey Gurley <rgur...@smarthealth.com> wrote:
> 
>> It seems like the approach is backwards.
>> 
>> The problem with querying on Edoc is you need multiple qualifiers (status 
>> equals and comment equals and statement equals) to apply to the same related 
>> Refs. For a to-one, that's no problem, but Refs is a to-many. I think if you 
>> try to fetch against the to many, you just get all the edocs with refs that 
>> match any of the qualifiers (status equals or comment equals or statement 
>> equals).
> 
> Right, that's what's happening (I DO query on Refs)
>> 
>> Given that is the case, I would fetch Refs instead, prefetching the Edocs 
>> and then finding the overlap between them in memory.
>> 
> 
> That's clear and I know how to do this
> 
>> EOQualifer q1, q2; //more as needed
>> q1 = Ref.COMMENT.eq('"foo").and(Ref.STATEMENT.eq(s3));
>> q2 = 
>> Ref.COMMENT.eq("bar").and(Ref.STATUS.eq("baz")).and(Ref.STATEMENT.eq(s10));
>> EOQualifier q = ERXQ.or(q1, q2);
>> 
>> NSArray<Ref> refs = //fetch Refs matching q, prefetch related edocs
>> 
>> refs1 = //refs matching q1
>> refs2 = //refs matching q2
>> 
>> //If edoc allows null, you'll need to remove null values too
>> edocs1 = Ref.EDOC.atUnique().arrayValueInObject(refs1);
>> edocs2 = Ref.EDOC.atUnique().arrayValueInObject(refs2);
>> 
>> minus = ERXArrayUtilities.arrayMinusArray(edocs1, edocs2);
>> union = ERXArrayUtilities.arrayMinusArray(edocs1, minus);
>> 
> 
> Now what? I want to use as much "plain" D2W as possible. So I am looking to 
> build a qualifier that I can stuff back into the display group (standard WO 
> practice for a property level custom query component). My understanding is 
> that for this to work I need one final big complicated EOQualifier.
> 
> Another idea was to have a next page delegate that does all the fetching and 
> merging etc and then return a standard D2WListPage. But what would I feed to 
> the display group? I think the only thing I have at that moment is an NSArray 
> of EOs. Does an ArrayDataSource make sense here? Would it work when the user 
> wants to edit a record from the displayed list?
> 
>> If these are really large arrays of EOs then doing it in memory might not be 
>> an option. If that's the case, just give up and become a goat herder on Niue.
>> 
> What if I don't like goats?
> 
>> BTW, never make side effects in your EO's accessor methods. You will regret 
>> it.
>> 
> Yes, I know - and I don't do that. In my case I simply let the WORep do its 
> magic and in the setter on the loopvar I register what has been set.
> 
>> Ramsey
>> 
>> <376.jpg>
>> 
> Nice, I like that one (Tiger on a surfboard in a pool)
> 
>> 
>> On Jul 8, 2013, at 4:03 AM, Markus Ruggiero wrote:
>> 
>>> I am not even able to really figure the plain SQL statement :-((
>>> 
>>> Model:
>>> 
>>> product <-->> edoc <-->> refs <<-> statement
>>> 
>>> refs has a comments and a status attribute
>>> 
>>> An edoc is defined by its assigned statements. Each single assignment can 
>>> have a specific status and comment. Which statements out of a pool are 
>>> assigned is determined by the type of edoc. Each edoc is product specific 
>>> with possibly specific comments and status. Thus the same statement can be 
>>> assigned to many edocs (one edoc of a given type per product).
>>> 
>>> User wants to find edocs of a specific type, thus the list of assigned 
>>> statements is already given.
>>> 
>>> The list of statements for the given edoc type is shown inside a repetition 
>>> where the user can specify for each possible ref a comment and a status as 
>>> search criteria. I need to build a qualifier to retrieve edocs that have 
>>> references to statements and the reference is qualified by status and 
>>> comment.
>>> The whole thing lives inside D2W. The list is shown with a custom property 
>>> level query component in a standard D2WQuery page, the result is then shown 
>>> in a standard D2WList page. My intention is to build the display group 
>>> qualifier incrementally inside the setComment() and setStatus() accessor 
>>> methods in each pass through the WORepetition. D2W will then take care of 
>>> any other property level query value on the rest of the query page. This 
>>> all works, it's just that I have not yet succeeded in building that 
>>> particular qualifier. Either I find too much data or I do not find anything 
>>> at all.
>>> 
>>> Example:
>>> 
>>> Assume the list of assignable statements is S1... S10
>>> I show a repetition with 10 items (one item per statement)
>>> The users enters "foo" for the comment on line 3 (corresponding to 
>>> statement S3) and "bar" on line 10 (corresponding to statement S10)
>>> The selection should now return all edocs where the reference to statement 
>>> S3 has the comment "foo" AND the reference to statement S10 has the comment 
>>> "bar", it must not return edocs where only one condition is met. To make 
>>> things even more interesting the user might also throw in some selection on 
>>> status, either in combination with a comment or individually. I need all 
>>> the edocs that fulfill ALL criteria.
>>> 
>>> It looks so innocuous but when I try to come up with something it becomes 
>>> more and more complicated. Can anyone help?? The 
>>> 
>>> Thanks a lot
>>> ---markus---
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/webobjects-dev/rgurley%40smarthealth.com
>>> 
>>> This email sent to rgur...@smarthealth.com
>> 
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/tedpet5%40yahoo.com
> 
> This email sent to tedp...@yahoo.com

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to