• 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
Filtering an array and computed values.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Filtering an array and computed values.


  • Subject: Filtering an array and computed values.
  • From: Louis Demers <email@hidden>
  • Date: Thu, 05 Jun 2008 23:35:04 -0400

Hi,
Context: I want to display all parts whose inventory is not empty. I have a page that use a WODisplayGroup and a fetchspec built into EntityModeler to extract from the database some subcategories.


Schema: My Part class has a one2many relationship to a Transaction class. Each transaction has a quantity field , positive when things are put in inventory and negative when taken out. Each Transaction also has a date field.

In my lists, to display current inventory, I use a method on my Part class like

// __________________________________________________________________________________________________________________
public Number partCount() {
return (Number) transactions().valueForKey("@sum.quantity");
}
// __________________________________________________________________________________________________________________



Question 1: I would like to display parts with the sum of transactions quantities is greater than 0


question 2: Eventually , I would like to further filter the transactions so that only those before a certain date are considered into the sum.


My current guess would be to manually remove parts by looping through the WODisplaygroup.allObjects() array and removing parts that do not qualify.


Question 1.1: where would I filter this, in appendToResponse where I currently call dg.fetch ?

As for the second question, I could write a new partCount that would take a date as a parameter and loop through hall transactions into the arrays and only add quantities that qualify.


Would those approach make sense and qualify as the WOWay of doing things ?




Louis Demers eng.
www.obzerv.com


_______________________________________________ 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: Filtering an array and computed values.
      • From: "Daniele Corti" <email@hidden>
  • Prev by Date: Re: ALCATRAZ! (Was: [OT] WOWODC Outing)
  • Next by Date: Re: ALCATRAZ! (Was: [OT] WOWODC Outing)
  • Previous by thread: Re: ALCATRAZ! (Was: [OT] WOWODC Outing)
  • Next by thread: Re: Filtering an array and computed values.
  • Index(es):
    • Date
    • Thread