|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
|
Journeyman |
Hi,
I am trying to write an f-script that fetches all organizations that have projects that have a specific keyword defined and that has tasks that are done with a completeDate within a user defined range. Here is my script: ------------------------------------------------ "projects with tasks with status Done" doneTasksQual := BDQualifier qualifierWhereValueOfKey:'tasks.status' isEqualTo:7. startDate := (element valueForKeyPath:'userInput.startDate') dateAsBeginningOfDay. endDate := (element valueForKeyPath:'userInput.endDate') dateAsEndOfDay. "projects with tasks completed between start and end date" startQual := BDKeyValueQualifier keyValueQualifierWithKey:'tasks.completeDate' operatorSelector:#isGreaterThan: value:startDate. endQual := BDKeyValueQualifier keyValueQualifierWithKey:'tasks.completeDate' operatorSelector:#isLessThan: value:endDate. "projects with keyword Billing Hourly" keywordQual := BDQualifier qualifierWhereValueOfKey:'keywords.name' isEqualTo:'Billing Hourly'. quals := {doneTasksQual, startQual, endQual, keywordQual}. andQualifier := (((BDAndQualifier alloc) initWithQualifierArray:quals) autorelease). sys log:andQualifier. "at this point, the system is currently outputting the following qualifier to the console:" "(tasks.status = 7) and (tasks.completeDate > 2007-01-01 00:00:00 -0700) and (tasks.completeDate < 2007-02-08 23:59:59 -0700) and (keywords.name = 'Billing Hourly')" "fetch qualifying projects" projects := objectContext objectsForEntityNamed:'Project' matchingQualifier:andQualifier. sys log: projects. "when I log the projects, it displays nil. Do you see anything wrong?" organizations := projects valueForKeyPath:'organizations'. organizations. ------------------------------------------------ If you read my comments in the code I tell you what's happening at various stages. But basically, I'm not sure if Daylite is following my keypaths through the flattened tasks and keywords relationships in the EOModel. I am assuming this would work the same way it does in WebObjects' EOF persistence framework. Thanks, Brendan |
||
|
|
Journeyman |
Ok, I found my mistake. tasks.status should be tasks.statusCode. That fixed it.
|
|||
|
|
Journeyman |
As a follow up question, how can you easily turn an array of arrays into a single dimensional array in f-script?
E.g. I have {{org1, org2}, {org3}, {org4, org5}} and I would like to get {org1, org2, org3, org4, org5} Thanks, Brendan |
|||
|
|
Apprentice |
{{org1, org2}, {org3}, {org4, org5}} \ #++ will do it. "\" is the reduction method, and "++" the concatenation method. Reduction lets you cumulatively evaluate a block (here #++) on the elements of an array. Have a look at chapter 17 of the F-Script doc for more. Philippe |
|||
|
|
Journeyman |
Cool. Thanks for the tip. I forgot that I posted this question actually. I eventually found a method called flattenArrayOfArrays which also did the trick.
Thanks, Brendan |
|||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|

