Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364229 - Aggregate Functions
Summary: Aggregate Functions
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Sapphire (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Konstantin Komissarchik CLA
QA Contact:
URL:
Whiteboard:
Keywords: plan
Depends on:
Blocks:
 
Reported: 2011-11-19 17:13 EST by Konstantin Komissarchik CLA
Modified: 2021-11-19 09:22 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Komissarchik CLA 2011-11-19 17:13:43 EST
Collections come up frequently in Sapphire EL use cases. When dealing with collections, it is often necessary to aggregate the contained data. We should implement at least these four most common aggregate functions:

Sum, Avg, Min, Max

The functions should take either one or two arguments. The first argument is always the collection. If the collection is a simple array or a java.util.Collection, the second parameter is not needed. If the collection is a ModelElementList, then the second parameter would be used to specify the name of the list entry's value property to aggregate on (in a form of a string type parameter). If the collection is a ModelElementList and second parameter is omitted, the function should use the first value property found in the list entry type.

Example: 

${ Sum( Items, "Total" ) }

Where Items is a list property containing Item elements that have a value property named Total.
Comment 1 Konstantin Komissarchik CLA 2011-11-20 22:50:44 EST
Implemented. Unit tests in TestExpr0010 - TestExpr0013.
Comment 2 Shenxue Zhou CLA 2011-11-28 17:10:55 EST
Verified the fix with purchase order sample. Locally changed the functions on the Subtotal property to verify the Avg, Min, and Max.