Monday, December 30, 2013

ADF Defining Property Sets

ADF property sets are collection of properties and each property is a name value pair.Property set is used in the control hints and messages.Property sets used with entity objects and their attributes , view objects and their attributes and in the application modules
Property set can be create from the new Gallery.Give a property set name and package and click ok.Applying property set to the entity object is as shown below
Apply the property set in the attribute level as below

ADF Creating entity diagrams

From the new gallery create entity diagram
Drag and drop entity objects to it

ADF creating associations

Associations in the entity level can be manually created as below
Shown above are the two tables created to demonstrate association.Create entity objects for both the table using create entity object wizard. Create an association using the wizard
Add the association created as below
Edit association query 


The final screen 


Effective dated entity objects

- Effective dated tables are used to provide a view into the data specific to a time
- Effective dated entity objects can be created as below
From the entitiy object General tab change the Effective Date type to "Effective Dated".
Click on the edit icon
If the effective date sequence and flag is not selected , the effective date is for one day.When we specify the effective dated property for the entity object a transient attribute SysEffectiveDate is created.We need to specify a start date and end date attributes defined in the entity object.Effective date sequence stores the sequence stores the sequence of changes.Effective date sequence flag sets the most recent change in the sequence.

Thursday, December 19, 2013

Setting Default value of VO attribute using Groovy expression


Refer the blog http://suneesh-adf.blogspot.in/2013/12/setting-default-value-of-eo-attribute.html for the db design and BC objects.

Create the UserDetailVOImpl class and add the method :
              public String getHello() {
         return " Hello Suneesh";

    }

Provide the groovy expression to the default value of the transient attribute 
Run the BC tester and add new row.You can see "Hello Suneesh" defaulted.

Setting default value of EO Attribute using Groovy

Create user and user details table as below
Create a BC structure as below 

Generate Impl classes for UserTblEO and add the following method to it 
    public String getName(String name) {
        return "Hello "+name;
    }
Provide the default value of login name expressio as above 
Run the BC tester for LoginAM and create a new row .You can see login name defaulted.



ADF Groovy basic notes

Some of the properties of groovy scripting language

- Groovy is a scripting language having java like syntax
- Groovy is executed at run time
-  Can be used in Entity and View objects in attribute validators(Entity Objects),attribute default values( Entity and View),bind variable default values ( View) place holder for error messages (EO validation rules)
- Define script expression validator or Compare validator 
- Error message tokens can be defined for handling validation failures 
- Conditional execution of validatiors are possible 
- Default value of bind variable in view object can be defined using groovy expression 
- Default value of view criteria 
- Default value and optional re-calculation condition for EO
- Value of transient for EO and VO 


Referencing Buisiness components objects in Groovy expression
Top level object is "adf" . Accessible ADF objects throgh groovy are 
- adf.context - Reference to ADFContext 
- adf.object - Equivalent to this operator in java.
- Entity Objects attributes - Reference methods and attributes of EntityImpl class.
- Entity Objects script validator rules - Attributes and method of ViewImpl class.
- View Object attributes 
- Bind Variable in view Object 
- Bind variable in view accessors 
- Transient attributes 
- adf.error 
- adf.userSession 
- adf.currentDate 
- adf.currentDateTime 
- Referencing custom buisiness components methods and attributes 
eg. Sal*12 - annualsalary .
PromotionDate>HireDate 

Method of entity class in validation rule.For validators use source keyword
eg. source.getDefaultSalaryForGrade()

- newValue - Attribute value being set 
-oldValue - current value of attribute being set 

if(Job=’SALESMAN’)
{
 return newValue<source.getMaxSalaryForGrade(Job)
}

Manipulating business component attribute values in a groovy expression
RowSet Objects
-          rowSetAttr.sum(GroovyExpr)
-          rowSetAttr.count(GroovyExpr)
-          rowSetAttr.avg(GroovyExpr)
-          rowSetAttr.min(GroovyExpr)
-          rowSetAttr.max(GroovyExpr)
EmployeesInDept.sum(“Sal+adf.object.getBenefitsValue(Job)”)