Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Scripting    What's wrong with this f-script please?
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Journeyman
Posted
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
 
Posts: 84 | Location: Calgary, Canada | Registered: December 15, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
Ok, I found my mistake. tasks.status should be tasks.statusCode. That fixed it.
 
Posts: 84 | Location: Calgary, Canada | Registered: December 15, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
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
 
Posts: 84 | Location: Calgary, Canada | Registered: December 15, 2006Reply With QuoteEdit or Delete MessageReport This Post
Apprentice
Posted Hide Post
quote:
Originally posted by Brendan:
...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}


 {{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
 
Posts: 5 | Registered: July 01, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
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
 
Posts: 84 | Location: Calgary, Canada | Registered: December 15, 2006Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Scripting    What's wrong with this f-script please?

© Copyright 2006 Marketcircle Inc. All rights reserved.