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

Filed under:

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

 

AGGREGATE_COUNT_FN_RT_NEW.png

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 groovy

Syntax: <Accessor>.count(Groovyexpression)

- Note down the destination accessor name(EMP) in the association or AccessorAttribute name in source entity

DEPT_EMP_ASSOC_NEW.PNG

- Add a transient attribute in source entity with persistent property set to false and provide the groovy expression in the syntax provided above

ENTITY_TRANS_ATTR.PNG

- 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

DEPT_EMP_VIEW_LINK.png
- Add a transient attribute in view object and provide a groovy aggregate function count as a value to it in the syntax provided above

VIEW_TRANS_ATTR_NEW.png

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

Related posts about /Oracle/ADF/BC4J