[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gdl2, filtering objects for display group
From: |
David Ayers |
Subject: |
Re: gdl2, filtering objects for display group |
Date: |
Fri, 21 Jan 2005 10:28:10 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 |
Dirk Lattermann wrote:
I have set up a EODatabaseDataSource for A and a EODetailDataSource
for B with corresponding EODisplayGroups and an
EOMasterDetailAssociation between the two. Displaying data from
these instances works ok, and I get to see the values of B that are
in relation to the selected value of A.
Now, I want to restrict the values of B to those that don't have
any related records in C.
1. Should I do this in restricting the EODetailDataSource or the
EODisplayGroup for B? (Are both possible?)
Acutally I can't give you an answer off the top of my head right now
about whether there is a "true and correct" way, but restricting the
EODisplayGroup should work.
I tried restricting the EODisplayGroup for B in the following way:
I created a subclass of EOGenericRecord adding a method
-(int) numC
that returns the number of objects in the array containing the related
objects of C. I tested [[dgB selectedObject] valueForKey: @"numC"] and
it worked.
I then created an EOQualifier and qualified the display group:
qual = [EOQualifier qualifierWithQualifierFormat: @"numC > 0"];
[dgB setQualifier: qual];
When fetching data, I got
NSUnknownKeyException: Unable to find value for key
hmm...
I looked in EODisplayGroup which seems to use (unfortunately, I
cannot debug) filteredArrayUsingQualifier: on the allObjects array.
I now tried manually:
[[dgB allObjects] filteredArrayUsingQualifier: qual] and got
NSInvalidArgumentException: EOEntity(instance) does not recognize isEnabled
on stderr, the message
Exception occured while loading model: Unable to find value for key
appears some lines before.
Hmm this seems strange also, maybe you could send the EOModel (if you
want privatly).
2. Is it ok that the NSArray addition filteredArrayUsingQualifier:
needs an entity (which it apparently does)?
GDL2 does a lot of lazy resoltion of EOModel information. It seems this
is an issue with EOAccess that just heppens to get triggered here.
3. Can/should I add an object property numC to the entity so that it
can be properly queried? I failed because there is no corresponding
attribute/column in this entity resp. table.
Even if you make it read-only
4. How can I "qualify" the detail data source so that only the right
objects are fetched in the first place, without them needing to be
filtered later?
5. Is this the right approach to model such situations (those that
originate from queries "where not exists + subselect")?
Maybe you can send me example code to debug. I don't have much time but
hopefully I can find the issue more quickly that way.
Cheers,
David