Using Groovy Aggregate Functions in ADF BC
Posted
by Sireesha Pinninti
on Oracle Blogs
See other posts from Oracle Blogs
or by Sireesha Pinninti
Published on Wed, 29 Jun 2011 22:55:08 -0700
Indexed on
2011/06/30
8:27 UTC
Read the original article
Hit count: 326
/Oracle/ADF/BC4J
This article explains how groovy aggregate functions(sum, count, min, max and avg) can be used in ADF Business components and demonstrates how these can be used at entity and view level
Let's consider EMP and DEPT tables and an usecase to track number of employees in each department
Entity-Level
To use aggregate functions at entity level, we need to have association between entities representing master and child relationship and the destination accessor name is what we are going to use in our groovySyntax: <Accessor>.count(Groovyexpression)
- Note down the destination accessor name(EMP) in the association or AccessorAttribute name in source entity
- Add a transient attribute in source entity with persistent property set to false and provide the groovy expression in the syntax provided above
- Finally, Add newly added attribute to view object
View-Level
To use aggregate functions at view level, we need to have a view link between viewobjects representing master and child relationship and the destination accessor name is what we are going to use in our groovy
Syntax: <ViewLinkAccessor>.count(Groovyexpression)
- Note down the destination accessor name(EmpView) in the view link or viewLinkAccessor name in source view
Now, If you run application module tester and execute DeptView / ViewLink, you should see employee count in EmpCount field
In similar way, one can use other groovy aggregate functions sum, avg, min and max.
© Oracle Blogs or respective owner