Tuesday, April 15, 2014

Using ADF BC Declarative Built-in Rules: Unique Key Validator

Following my previous post Using ADF BC Declarative Built-in Rules: Collection Validator I would like to cover another declarative build-in rule, the "Unique Key Validator".

The "Unique Key Validator" is an entity level validator that ensures that primary key values for an entity object are always unique. For example, in the Employees table in the HR schema you can create a "Unique Key Validator" on the "EMPLOYEE_ID" (since this is the primary key) to ensure that an employee should have a unique employee id. If a key (in this example an employee id) is found in either the entity's cache or the database a "TooManyObjectsException" is thrown. Let's see how you can define a "Unique Key Validator" on the EMPLOYEE_ID column of the EMPLOYEES HR table.

I've created a new ADF Application "UniqueKeyValidatorDemo" using the "Fusion Web Application (ADF)" template and using the "Business Components from Tables" wizard I've created an Entity "EmployeesEO" based on the EMPLOYEES table, a view "EmployeesVO" based on the "EmployeesEO" entity and an Application Module "UniqueKeyValidatorAM".

Business rules are defined on the entity object so to create a 'Unique Key Validator" open the "EmployeesEO" and in the "Business Rules" tab click the green plus icon "Create new validator".

From the "Add Validation Rule" window select "UniqueKey" in the "Type" drop down and select the "EmpEmpIdPk(Employee_ID)" key.

In the "Failure Handling" tab define a failure message and click "OK". In my example I have used three message token expressions to construct a dynamic error message, passing to the failure message the "Employee Id" (using the newValue expression to get the value being validated), "First Name" and "Last Name".

To test your newly defined "Unique Key Validator" run the Application module and and try to update one of the employees using an existing employee id. For example, try to update Steven King's employee id to 101. You should get your custom dynamic error message displayed.

What if you wanted to enforce a "Unique Key Validator" on a non-primary key attribute? For example, what if you wanted to ensure that every employee should have a unique email address. The The "Unique Key Validator" can be applied on non-primary key attributes known as "alternate keys".

You can create an alternate key using the entity's "General" tab. So in our case, let's create an alternate key for the "Email" attribute of the "EmployeesEO" entity object.  Under the "Alternate Keys" section click on the green plus icon "Add Alternate Key".

 In the "Define Alternate Key" window specify a name in the "Alternate key Name" field (in my case it's "EmailAltKey") and shuffle the "Email" attribute from the "Available" list to the "Selected" list and click "OK".

To define a "Unique Key Validator" based on the newly created email alternate key go to the "Business Rules" tab and click on the green plus button "Create new validator" (just as you did above with the "Unique Key Validator" defined on the Employee Id primary key). In the "Add Validation Rule" window select "UniqueKey" in the "Rule" drop down and select alternate key that you have created above.

Define a failure message using the "Failure Handling" tab and click "OK".
Run your application module and update an employee's email  with an existing email. For example, update Steven King's email to "NKOCHHAR". You should get an error message saying that the email is already in use.

Download sample application: Unique Key Validator

Wednesday, April 9, 2014

How a better Customer Experience can improve your business

Today, customers are surrounded by opportunities. It is therefore critical to make their experiences as enjoyable, simple, consistent, and relevant as possible as they move throughout the sales lifecycle, from buying to owning, and back again. By delivering exceptional customer experiences, businesses can acquire new customers, retain more customers, and improve efficiency.

Building the ultimate Customer Experience with eProseed and Oracle
Oracle, backed by eProseed's mastery of process and system integration - eProseed was elected Oracle Partner of the Year for four consecutive years -, provides the most complete, cloud-enabled customer experience solution in the industry, creating an environment where companies can differentiate themselves across all channels, touch points, and interactions.

eProseed and Oracle have the pleasure to invite you to the Workshop on How a better Customer Experience can improve your business, at Windsor restaurant, on 13th May 2014 from 10:00 to 14:00.

10h00 – 10h30       Welcome & coffee
10h30 – 11h00       Introduction: eProseed
11h00 – 11h10       Oracle’s Customer Experience Concept
11h10 – 11h40       Social
11h40 – 12h10       Marketing
12h10 – 12h40       Customer Service
12h40 – 13h00       Q&A
13h00 – 14h00       Lunch

Bernard Hermant (eProseed),
Roel Van den Bergh, Petra Bikkenbergs, Ward Schoonjans (Oracle)


Tuesday, March 25, 2014

Oracle Java 8 is Out!

Oracle officially launched the release of Java 8 with some really nice features that includes lambda expressions and streams, compact profiles to deploy applications with only the components required by your application, Java FX becoming full open source, some really cool date and time APIs to support business calendars, Japanese, Buda and Islamic calendars, a flight recorder to monitor performance, Nashorn which is a light-weight yet high performance Javascript runtime built on top of the actual JVM operating with the garbage collector and other JVM components and being able to call Java from Javascript, Java ME embedded to grow the capabilities for IoT (Internet of Things) and the most cool performance feature of them all is eliminating PermGen by having the JVM automatically adjusting the PermSize.

An on-demand replay of the launch will be soon provided along with many video sessions of the new features (http://www.oracle.com/java8launch).
Download Java SE 8 and happy hacking!

Sunday, March 16, 2014

Using ADF BC Declarative Built-in Rules: Collection Validator

I recently gave an ADF training and realized that many people where having difficulties using the predefined validation rules in ADF Business Components so i decided to write a series of blog posts describing the types of validation available to ADF BC applications.

There are various options for handling validation in ADF applications. You can either define validations on your business service layer or directly on your user interface.

Validations options on your business service layer consist of declarative and programmatic ADF BC validations and validations defined on your database.

Validation options on your user interface consist of built-in validation capabilities on components such as input components and select components. Please make sure though that validations defined on the user interface are also defined on your business service layer to leverage the validations defined on your business service layer when you choose to expose your model in other ways.

Validations can be defined at either the entity level or on a specific attribute. I will be covering in posts that will follow all validation rules. In this post i will explain how you can use the collection validator.

The collection validator is an entity level validator used to compute an aggregate value on an attribute in a child of the current entity object using an aggregate function such as Sum, Count, Average, Min and Max.

I will be using the HR schema to demo the Collection Validator and let's assume the following requirement. A department has a specific budget (let's say 20,000 Euros) comprised of the sum of its employees' salary.

I've created an application, "Collection Validator" using the "Fusion Web Applications (ADF)" template and accepting all the default settings (i just provided my own package name).

I then created the business component objects to use in the collection validator demo which includes two entity objects, one on the "Employees" table and one on the "Departments" table, their respective updatable view objects and an application module. I did all these using the "Business Components from Tables" wizard. And just to tidy up things i refactored all associations into the "associations" package under the "entities" package and refactored all view links into the "links" package under the "views" package.

A collection validator requires an accessor, an association that has been defined for the entity. The "Business Components from Tables" wizard automatically detected the foreign keys defined in the database and created an association for each foreign key, thus all accessor have been created for you automatically. We have two types of associations. The default association type that defines a "soft-type" relationship where entities are related but are not completely dependent and a composition association type that defines a more strict type of association where, in brief, a destination entity is completely dependent on the source.

The collection validator requires a "composition association". I will be using the default association created by the "Business Components from Tables" named "EmpDeptFkAssoc" to mark it as a composite association.

So open the "EmpDeptFkAssoc" association, select the "Relationship" tab and in the "Behavior" section select the check box "Composition Association".

The collection validator will be defined on the "Departments" entity. So open the "Departments" enity and on the "Business Rules" tab, select the "Entity Validators" folder and click on the green plus icon. This will open the "Add Validation" window.

 In the "Type" drop down select the "Collection" validator, in the operation select "Sum" and in the "Accessor" drop down, if you have accepted the default, you should have "Employees1". This is the accessor that got generated from the "EmpDeptFkAssoc" association. In the "Operator" selection i will choose "LessThan" and in the "Compare With" selection i will leave the default which is "Literal Value". In the "Enter Literal Value" box type i will type 20000.

In the "Validation Execution" tab you can control when the validation should be execute (using Groovy expressions which i will cover in another post) and the triggering attributes (to execute the validation only when the selected attribute(s) have been changed).

In the "Failure Handling" tab you can define the severity, either "Error" or "Informational Warning" and the actual failure message. A very cool feature here is tokens. Tokens which are defined in a failure message using the angle brackets {} are placeholders for passing either parameter values or parameter control hints (labels). I've defined the following failure message:

Department {DeptName} has reached it's allowed budget.

JDeveloper automatically detected the "DeptName" token and created it in the "Token Message Expressions" section. In the expression input field just type the name of the department name attribute, "DepartmentName". At runtime this will translate to the actual department name.

Click "OK" to define the business rule and run your Application Module to test the collection validator rule. In the "Business Composer Browser" select the "EmpDeptFkLink1" view link to present the Department record in a form with its Employee records displayed in a detailed table.

Add a new employee in a department and make sure you set the employee's salary to a value that when you sum the salaries of all employees in that department will be greater or equal to 20,000. In my case, i will add a new employee in the "Administration" department with a salary set to 15,600. Click the commit button in the employees detail section and you should get an error with your custom message displayed.

Download sample application: Collection Validator

Tuesday, February 11, 2014

LOV (List of Values) using EJBs

Following a request, I would like in this post to demonstrate how to use EJBs to build your business services and how to build a simple form with a list-of-value component (using the selectOneChoice component).

 I created an application using the "Fusion Web Application (ADF)" template, i initialized my model project by creating a database connection to the HR schema and created two EJB entities, one for the Employees table and one for the Departments table.

I created a session bean using the default settings (with all methods from both entities being selected) and generated a data control from the session bean by just right-clicking on the session bean and selecting from the context menu "Create Data Control".

I created a page (employees.jspx) and dropped the employeesFindAll collection on the page as a form (for demo purposes i am just using three attributes: EmployeeId, FirstName and LastName). The initial requirement was instead of displaying the department id to have a drop down displaying the department name.

When you created the EJB entities from table, ADF interrogated the database catalog and identified the relationship between the two tables, thus injecting it into the Employees EJB.

To add the department name as a list-of-value just drag and drop onto your page the nested departments collection as an ADF Select One Choice component.

Run the employees page and you will see that ADF will synchronize the department list as you navigate between different employees.

Download sample application: LOVsUsingEJBs

Wednesday, February 5, 2014

Working with the selectManyCheckbox component

I recently came across a simple, yet not so straightforward use case as it seems for many ADF developers on the JDeveloper & ADF forum so I decided to blog about it.

The requirement was to use the selectManyCheckbox component and to save the selection in the database in a varchar2 column of type.

So I created a custom table in the HR schema, MY_EMPLOYEES with 3 columns; ID (number), NAME (varchar2) and  DEPARTMENTS (varchar2).

I then created the basic ADFBC objects (an entity MyEmployees based on the MY_EMPLOYEES table, a view MyEmployeesView based on the MyEmployees entity and an application module AppModule that has the MyEmployeesView selected in the data model).

Moving on the ViewController project, i created a page (employees) where i dragged the MyEmployeesView view object as an ADF Form (JDeveloper created automatically for me the 3 attributes Id, Name and Departments).

From the component pallet i added  a selectManyCheckbox component, accepting the default settings (just changed the label to Departments) and a button component (which i called Save).

In the page bindings I just added the Commit operation as an action (so that i can invoke it from the Save button).

All the logic is implemented in a managed bean with scope set to pageFlowScope. Both the selectManyCheckbox and selectItems values are set from the bean. 

Same goes with committing the data (selected departments). This is handled via a bean method.

You can test the application by running the employees.jspx page. Select one or more departments and click save. The selection array is stored in the varchar database column.

On loading the page the bean will convert the string back into an array and assign it to the selectManyCheckbox component.

Download Sample Application - WorkingWithTheSelectManyCheckboxComponent

Tuesday, February 4, 2014

Oracle Fusion Middleware Partner Community Forum 2014

Hi everyone,

This year Oracle is organizing its Oracle Fusion Middleware Partner Community Forum in Malta. The event is going to be held on February 18th and 19th 2014 with hands-on training on February 20th & 21st 2014.

The event is a great opportunity to learn about:
  • SOA Suite 12c & Cloud integration
  • BPM Suite 12c & Adaptive Case Management 12c
  • Internet of Things & mobile strategy & fast data
  • WebLogic 12c the foundation of Oracle Fusion Middleware
Oracle will be running the following hands-on bootcamps:
  • Internet of Things (IoT) hands-on Bootcamp
    • Trainer: Harish Gaur, Director Product Management at Oracle
  • Coherence 12c hands-on Bootcamp
    • Trainer: Maciej Gruszka, Senior Principal Product Manager at Oracle
  •     Mobile Platform Cookbook Concepts and Practices Workshop
    • Trainer: Frank Nimphius, Principal Product Manager at Oracle
  • Adaptive Case Management hands-on Bootcamp
    • Trainer: Niall Commiskey, Technology Architect
Don't miss this unique experience.

See you all in Malta!