Hi Ted,

you are right, there is a WO way of doing this. Using KVC this should be doing 
what you want:

Integer result = 1500 - (Integer) 
timeListDG.displayedObjects.valueForKeyPath("@sum.amountOfTime");


jw


Am 10.06.2010 um 17:16 schrieb Theodore Petrosky:

> I need some help doing 'simple' math with my objects...
> 
> relationships:
> 
> client =>> contract and =>> project 
> project <=>> contract
> project <=>> job
> job <=>> etime
> 
> a contract has assignedHours
> eTime has usedHours
> 
> I am using a displayGroup to show my eTime entries...
> 
>         <webobject name = "TimeListRep">
>            <webobject name = "RowColorGenericContainer">
>              <td><wo:WOString value = "$theTimeListItem.user.fullNameString" 
> /></td>
>              <td><wo:WOString value = "$theTimeListItem.amountOfTime" 
> numberformat = "##.##" /></td>
>              <td><wo:WOString value = 
> "$theTimeListItem.workTask.workTaskTitle" /></td>
>              <td><wo:WOString value = "$theTimeListItem.timeDate" dateformat 
> = "%m.%d.%Y" /></td>
>            </webobject>
>          </webobject>
> 
> TimeListRep : WORepetition {
>       list = timeListDG.displayedObjects;
>       item = theTimeListItem;
>       index = session.index;
> }
> 
> I need to sum the second column   value = "$theTimeListItem.amountOfTime"
> 
> and subtract it from the assignedHours in the contract....
> 
> I can pull the contract from:    theContract = 
> timeList.objectAtIndex(0).job().project().contract();
> and then get   theContract.assignedHours 
> 
> (timeList is the array that feeds the displayGroup)
> 
> In SQL I would:
> 
> select 1500 - sum(c_amount_of_time) from t_e_time where c_job_id IN (SELECT 
> id FROM t_job WHERE c_project_id = 16);
> 
> where 1500 represents the assignedHours from the contract entity..
> 
> I know there is a webobjects way... I just can't find it without help.
> 
> I could:
> 
> int theAssignedHours = 
> timeList.objectAtIndex(0).job().project().contract().assignedHours();
> 
> then the raw SQL to get the sum of eTime used for this contract and 
> subtract....
> 
> I hope I am clear.......
> 
> Ted


Attachment: smime.p7s
Description: S/MIME cryptographic signature

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

This email sent to arch...@mail-archive.com

Reply via email to