Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 364229

Summary: Aggregate Functions
Product: z_Archived Reporter: Konstantin Komissarchik <konstantin>
Component: SapphireAssignee: Konstantin Komissarchik <konstantin>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: shenxue.zhou
Version: unspecifiedKeywords: plan
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

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.