• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: summing a column and other math...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: summing a column and other math...


  • Subject: Re: summing a column and other math...
  • From: Johann Werner <email@hidden>
  • Date: Thu, 10 Jun 2010 17:28:49 +0200

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      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: summing a column and other math...
      • From: Theodore Petrosky <email@hidden>
References: 
 >summing a column and other math... (From: Theodore Petrosky <email@hidden>)

  • Prev by Date: RE: wonder maven problem
  • Next by Date: [OT] Room reservation at the Gouverneur
  • Previous by thread: summing a column and other math...
  • Next by thread: Re: summing a column and other math...
  • Index(es):
    • Date
    • Thread