On 25/09/2013, at 2:32 PM, Paul Hoadley < email@hidden> wrote: To be more specific, then, I'm implementing a new background task for the ERJasperReports.framework which I'm calling ERJRDataSourceReportTask. It's analogous to the existing ERJRFetchSpecificationReportTask, but takes an ERJRFoundationDataSource instead of a fetch specification. For our purposes here, we probably only need to know that the latter just takes an NSArray<? extends NSKeyValueCodingAdditions>. So here's part of the new class:
public class ERJRDataSourceReportTask implements Callable<File>, IERXPercentComplete { public ERJRDataSourceReportTask(ERJRFoundationDataSource dataSource, String reportName) { // ... }
Ideally I'd like to keep it general like this (that is, accepting ERJRFoundationDataSource in the constructor), but what happens in the specific case where the NSArray<? extends NSKeyValueCodingAdditions> backing that is actually an NSArray<EOEnterpriseObject>? Should I look for that specific case (in the task's constructor above), then pull out all the EOGlobalIDs, and then re-create all the EOs via those EOGlobalIDs right there on the spot? I mean, presumably this is equivalent to having the caller supply an array of EOGlobalIDs (because the _constructor_ is running in the same original thread), but what I've just described sounds ridiculous, doesn't it?
What I would like to avoid is a special-case constructor accepting NSArray<EOGlobalID>, but I could do that if I had to. Any thoughts?
Actually, there's another complication for my use case. In preparation for the reporting task, I'm actually modifying all the EOs in the array slightly in preparation for the report—they have a non-persistent "user info" NSMutableDictionary which I'm using to do a bit of the heavy lifting for the report. So I'm stashing, say, a running balance for a list of transactions—whatever it is, assume it can't be done by the reporting engine.
This might help to make my query a bit more general, at least: is there any way I can safely get these "prepared" EOs from the main thread into the background thread? (Given that passing them as EOGlobalIDs is going to get me fresh copies without the preparation.)
If the answer is no, I guess I'll have to do something less general than what I started above—pass the array of EOs in as EOGlobalIDs, and do the preparatory steps in the background as well.
|