On 2010-05-04, at 12:34 PM, Theodore Petrosky wrote:

> David, 
> 
> This is fantastic... 
> 
> EOQualifier openVersionsQualifier = 
> Job.VERSIONS.dot(Version.VERSION_STATUS).dot(VersionStatus.VERSION_STATUS_TITLE).eq("Released").and(Job.CLIENT.eq(currentClient));
>         
> readyToBillJobList = Job.fetchDistinctJobs(jobListEC, openVersionsQualifier, 
> null);
> 
> fantastic....

Yes it is, isn't it.

> 
> BTW,
> 
> I copied the fetchJobs(EC, qual, sort) from the _Job.java and pasted into 
> Job.java with the change "fetchSpec.setUsesDistinct(true);".
> Is this the recommended way to handle this?
> 
> 
> public static NSArray<Job> fetchDistinctJobs(EOEditingContext editingContext, 
> EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) {
>    EOFetchSpecification fetchSpec = new 
> EOFetchSpecification(_Job.ENTITY_NAME, qualifier, sortOrderings);
>    fetchSpec.setUsesDistinct(true);
>    fetchSpec.setIsDeep(true);
>    NSArray<Job> eoObjects = 
> (NSArray<Job>)editingContext.objectsWithFetchSpecification(fetchSpec);
>    return eoObjects;
>  }

That would be my first choice, or modify your EO generation templates to take a 
'useDistinct' parameter on the fetchEntityName methods.

Something like:

public static NSArray<Job>fetchJobs(EOEditingContext editingContext, 
EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) {
        return fetchJobs(editingContext, qualifier, sortOrderings, false, true);
}

public static NSArray<Job> fetchJobs(EOEditingContext editingContext, 
EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings, boolean 
useDistinct, boolean isDeep) {
   EOFetchSpecification fetchSpec = new EOFetchSpecification(_Job.ENTITY_NAME, 
qualifier, sortOrderings);
   fetchSpec.setUsesDistinct(useDistinct);
   fetchSpec.setIsDeep(isDeep);
   NSArray<Job> eoObjects = 
(NSArray<Job>)editingContext.objectsWithFetchSpecification(fetchSpec);
   return eoObjects;
 }


> 
> Thanks,
> 
> Ted
> 
> 
> --- On Tue, 5/4/10, David LeBer <[email protected]> wrote:
> 
>>> NSMutableArray<Client>  args = new
>> NSMutableArray<Client>();
>>> args.addObject(currentClient);
>>>         
>>> openVersionsQualifier =
>> EOQualifier.qualifierWithQualifierFormat("versions.versionStatus.versionStatusTitle
>> = 'Released' and client = %@)", args);
>>>          
>>> readyToBillJobList = Job.fetchDistinctJobs(jobListEC,
>> openVersionsQualifier, null);
>>> 
>>> I wanted to put two objects into the args array.
>>> object 1:  String
>>> object 2:  currentClient
>>> 
>>> but of course args is of type Client so I can not do
>> that... I did try to use the primaryKey of currentClient,
>> but then the qualifier is expecting an integer... so I
>> casted the string to an int and it worked. but then args is
>> of type Integer... still no joy.
>>> 
>>> so I tried to let the primaryKey be a string but then
>> the qualifier barked it needed an integer.
>>> 
>>> Either I just don't get it or there is an easier way
>> that I just don't see.. If I could cast to integer in the
>> qualifier like   " clientid = %@::int",
>> args   would fix my problem. then I could
>> save all strings in 'args'.
>>> 
>>> Ted
>> 
>> 
>> Couldn't you use NSMutableArray<Object>?
>> 
>> But really, I'd avoid using qualifierWithQualifierFormat
>> (Icky, icky, 'magic' strings).
>> 
>> If you are using Wonder then this is easy to do using the
>> ERXKey support:
>> 
>> EOQualifier qual =
>> UndocumentedRootObject.VERSIONS.dot(Version.VERSION_STATUS).dot(VersionStatus.VERSION_STATUS_TITLE).eq("Released").and(UndocumentedRootObject.CLIENT.eq(myClient));
>> 
>> ;david
>> 
>> --
>> David LeBer
>> Codeferous Software
>> 'co-def-er-ous' adj. Literally 'code-bearing'
>> site:     http://codeferous.com
>> blog:     http://davidleber.net
>> profile:    http://www.linkedin.com/in/davidleber
>> twitter:    http://twitter.com/rebeld
>> --
>> Toronto Area Cocoa / WebObjects developers group:
>> http://tacow.org
>> 
>> 
>> 
>> 
>> 
> 
> 
> 

;david

--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site:   http://codeferous.com
blog:   http://davidleber.net
profile:        http://www.linkedin.com/in/davidleber
twitter:        http://twitter.com/rebeld
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org




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

This email sent to [email protected]

Reply via email to