Wednesday, August 20, 2014

Oracle BPM 12c Gateways (Part 1 of 5): Exclusive Gateway

Oracle BPM provides us with various components to control the flow of a process such as gateways, timer events, errors, message events, send and receive tasks, loop markers and multi-instance markers.

In this five part series part I will be elaborating the gateway control flow components and how we can use them to define the flow of our process.

Gateways are very similar to a flowchart decision element. Using a gateway you can define the control points within your process by splitting and merging paths. At runtime a gateway will determine based on the control points defined at design time the path that a token will take through a process.

There are five gateway types; Exclusive Gateway (XOR), Inclusive Gateway (OR),  Parallel Gateway, Event Based Gateway and Complex Gateway.

Exclusive and Inclusive gateways consist of two outbound sequence flows; a default sequence flow representing the normal path between two objects and a conditional sequence flow to control the process flow based on the evaluation of an expression.

The "Exclusive Gateway" is one of the most commonly used gateways where you can split your process into two or more paths. When a token reaches an exclusive gateway each of the conditional outbound sequence flows is evaluated in the order that you specified during design time when configuring the exclusive gateway and the first conditional flow that is evaluated to true is taken. If none of the conditional outbound sequence flows evaluates to true then then token moves down the default sequence flow. Please note that if you do not specify a default outbound sequence flow on an "Exclusive Gateway" you will get an error at design time and will not be able to compile and deploy your process.

So let's see how you use an "Exclusive Gateway" to control the flow of a process. I have created a new BPM application using the "BPM Application" JDeveloper template and in the "Project SOA Settings" step i have selected "Composite with BPMN Process".
This will bring up the "BPMN 2.0 Process Wizard" where you are prompted to specify a process name and the service type. In this demo I have selected "Asynchronous Service".

In the arguments step I have created two input arguments, OrderId of type int and OrderAmount of type decimal, and an output argument, Status of type string.

When you click finish it will open the process. Using the structure window I have created three process data objects to store the input arguments I have created above and hold the output argument value (orderId of type int, orderTotal of type decimal and status of type string).
Next I assigned the two input arguments (OrderId and OrderTotal) to the process data objects (orderId, orderTotal) by double-clicking on the "Start" activity, going to the "Implementation" tab and selecting "Data Associations".

Please note that i did the same thing for the "End" activity but this time i have mapped the status process data object to the Status output argument.

Just for demo purpose I came up with a very simple scenario where I will use an exclusive gateway to auto approve an order if the order total is less than 100 and to set the status to pending if the order total is greater than 100. I would like to stress that this is just for demo purposes as I would highly recommend that you use a business rules component to store the order total threshold rather than hard-coding it in the process.

Furthermore I dropped two script tasks, one between the exclusive gateway and the end activity and one just above the first script task and mapped the two status values (auto approved and pending) respectively using the "Data Associations" on each of the script tasks.

When you dropped the exclusive gateway between the start and end activity it automatically joined the exclusive gateway with the end activity using a default outbound sequence flow. Next I have created a conditional outbound sequence flow from the exclusive gateway to the "Set Order Status to Pending" script task and defined an XPath expression to check whether the orderTotal is greater than 100.

I finally provided some labels on the two outbound flow to make them better readable and joined the second script task with the end activity as follows.

Deploy your process on the integrated Weblogic server and run a test using a small order (having an order total of less than 100). The process should follow the default outbound flow and the order should be auto-approved.

Now run another test with an order having an order total of greater than 100. The process should follow the conditional outbound flow and the order should be flagged as pending.

An exclusive gateway can also be used to define a loop to check for conditions and re-executing previous steps. So to define a loop using an exclusive gateway just connect a sequence flow to a previous object.
Download sample application: Exclusive Gateway

Monday, August 4, 2014

Using ADF BC Declarative Built-in Rules (Part 5 of 10): Length Validator

The “Length Validator” is another validator that can be defined at either the entity level or the attribute level but pertains to an entity object attribute to compare the number of characters or bytes in an attribute value against a specified length.

For the purpose of this demo I have created a new ADF Fusion Web Application and created the basic business components that I will be using in this demo, an entity object based on the Employees HR table, a view object based on the Employees entity object and a default application module.

Next let’s define a “Length” validator on the Employees entity object to ensure that an employee’s first name is less than 10 characters. So on “Business Rules” tab of the Employees entity object, click on the green plus icon “Create new validator”.  This will open the “Add Validation Rule” editor for defining the validation specifics.

In the “Type” combo select “Length” and select the attribute on which you want to define the length validator. In my demo I have selected “FirstName”. Select the operator (Equals, NotEquals, LessThan, GreaterThan, LessOrEqualTo, GreaterOrEqualTo, Between), the comparison type (either Character or Bytes) and set the length value.

In the "Failure Handling" tab define a failure message and click "OK". In my example I have used a message token expression to construct a dynamic error message, passing to the failure message the employee’s first name.

If you inspect the Employee’s entity source code you will see that JDeveloper added a LengthValidationBean tag to the XML entity definition file.

Before testing our validator please ensure that your application module has the Employees view selected under the “Data Model”.

To test your validator, run the Application module and try to update an employee’s first name, providing a name greater than 10 characters. You should get your custom dynamic error message displayed.

Download sample application: Length Validator

Wednesday, July 16, 2014

Oracle BPM 12c - Process Asset Manager (PAM)

An entirely new feature has been introduced in Oracle BPM 12c called “Process Asset Manager” (PAM) which makes it really simple and reliable to share projects between BPM Studio and BPM Process Composer, providing a unified lifecycle management of BPM projects across BPM Process Composer and BPM Studio tools and offering seamless collaboration across the various personas in a BPM project.

PAM comes with an integrated subversion source control system for version management of BPM assets and can be integrated with OPSS for security and can reference the MDS for run-time artifacts.

So let’s see the lifecycle of PAM from the two different interfaces, starting with the Process Composer.

For the needs of this tutorial I have created a sample Hello BPM project with a synchronous process.

BPM 12c provides us with a a collaborative workspace built on top of Oracle WebCenter Portal that enables more productive BPM by increasing collaboration between the various personas.

The new workspace has been enhanced with the introduction of roles and priviledges assigned at the space level. The 12c version supports three personas, the Owner which maps to the Process Architect, the Viewer which maps to the Process Business Analyst and the Editor which maps to the Process Business Developer.

Furthermore, for each space, you can create multiple projects (BA and BPM projects) which helps in organizing all the processes in business relevant projects.

Start the integrated JDeveloper Weblogic Server instance and if this is the first time you are starting the integrated Weblogic Server you will be asked to provide the admin credentials and listening address for your integrated Weblogic Server.

To share and make a BPM project available in Composer, right click your BPM project and from the context menu select “Save to PAM”.  This will bring up the “Select Connection” window. If this is the first time you are publishing to PAM you will have to create a new PAM connection by clicking on the green “Add” icon (and going through the wizard).
Once you have created (or selected an existing) PAM connection, create a new space to host your BPM project.


Click “OK” and in the “Save Project to PAM” window you can optionally define some comments and click “OK” to publish to PAM.

Go to BPM Process Composer (http://<hostname:<port>/bpm/componser) and login as weblogic to see your published BPM project.

The Composer has been enhanced with some really nice new features, especially around the area of Business Architecture that I will elaborate further in a subsequent post.

When you edit a BPM project in BPM Composer, PAM will lock the BPM project, meaning that other Composer users will not be able to work it but just view the project.

When you do a save in BPM Composer (“Save” button) the changes are saved locally which makes it really fast to work with the Composer.

To publish you changes to PAM and the SCC (Source Code Control) you need to click on the “Publish” button (second button in the screenshot above).

When you click on the “Publish” button you will be prompted with the “Publish Project” window where you have to provide a comment to explain what your changes are about and optionally release the lock and make a snapshot which is nothing more than an SVN tag on your BPM project.

The PAM lifecycle from BPM Studio is a bit different. To work on a project from BPM Studio that has been published to PAM you need to first create an application and then checkout your BPM project into your application.

To do so, open the “Process Asset Manager Navigator”, expand your connection name (in my case it is l”ocal-PAM”), space name (in my case it is “Hello World Space”) and right click on the project name (in my case it is “HelloWorldBPM”) and from the context menu select “Check Out”.

This will open the “Check Out project from PAM” window where you can change the destination for your checked-out project.

Click “OK” to check out the BPM project.

Oracle BPM 12c supports concurrent editing of BPM projects inside BPM Studio. When you do a save, changes are again saved locally. To publish your changes back to the repository you need to right click your project and from the context menu select “Save to PAM”.


To get the latest changes from PAM you can do an “Update” using the project’s context menu.

In case of conflicts there is a visual “Diff-Merge” editor to resolve the conflicts.


Wednesday, July 2, 2014

Using ADF BC Declarative Built-in Rules (Part 4 of 10): Key Exists Validator


The “Key Exists” Validator is validator that can be defined at either the entity level or the attribute level but pertains to an entity object attribute to check whether a key exists based on a primary key, foreign key or an alternate key. The “Key Exists” validator will check first the cache querying rows not committed yet to the database and if the key is not found in the cache will run a check in the database.

So let’s start by creating a new ADF Fusion Web Application and create the basic business components that we will be using in this demo, two entity objects based on the Countries and Regions HR tables, their associated view objects and a default application module.

Next let’s define a “Key Exists” validator on the Countries entity object. So on “Business Rules” tab of the Countries entity object, click on the green plus icon “Create new validator”.  This will open the “Add Validation Rule” editor for defining the validation specifics.

In the “Type” combo select “Key Exists” and you will see that in the “Validation Target Type“ there are three options; to target the validation at the “Entity Object” level meaning that this validation will be used for all view objects that use this entity attribute, “View Object” or “View Accessor”. In my demo I will be targeting my “Key Exists” validator at the entity object.

In the “Association Name“ combo you will get displayed with all the associations pertaining the entity object. In my case I have only one association, the “CountryRegFkAssoc”.

 
In the "Failure Handling" tab define a failure message and click "OK". In my example I have used two message token expressions to construct a dynamic error message, passing to the failure message the country’s name and country’s region id.

Before testing our validator please ensure that your application module has the Countries view and Regions View selected under the “Data Model”.

To test our newly defined "Key Exists Validator" run the Application module and and try to create a country with an invalid region id. You should get your custom dynamic error message displayed.

Now create a new region, do not commit the new region and try to create a new country based on the new region’s id. The “Key Exists” validator will check the cache and will identify that the region id exists (even though it’s not committed in the database).

 Download sample application: Key Exists Validator

Wednesday, June 4, 2014

eProseed awarded Oracle Industry Partner of the Year in Middle-East & North Africa

I’m extremely happy to announce that eProseed was awarded Oracle Industry Partner of the Year in Middle-East & North Africa !

Mabrouk and a big applause to all our colleagues in Beirut office for their outstanding work in the region !


Configuring the SOA Human Task Hostname

When a human task is opened in BPM Workspace, it will try by default to connect to either localhost or the server's alias. So if you try to access the BPM Workspace remotely (from a computer other than where Oracle SOA is running) you will get an http error (unable to connect).
You can fix this issue at run-time using the Enterprise Manager (EM). Login to EM and from the farm navigator select your composite by expanding the "SOA", "soa-infra" and your partition node.

Under "Component Metrics", select the affected human task and go to the "Administration" tab.


Change the hostname to the IP of the server or hostname accessible from the server and click apply Select "OK" when prompted whether you want to save your changes.

If you access now the same human task its details should be loaded and rendered.

This configuration can be defined at design time as well by editing the hwtaskflow.xml configuration file located under the "Application Sources" folder of your human task project.


Open the hwtaskflow.xml file and define your preferred hostname.



Monday, May 19, 2014

Using ADF BC Declarative Built-in Rules (Part 3 of 10): Compare Validator


The my last two posts I’ve demoed how to use the “CollectionValidator” and the “Unique Key Validator”, two declarative validation options that can be defined at the entity level.

In the following six posts I will be going through the declarative validation rules that can be defined either at the entity or attribute level but pertain to an entity object attribute and these are the “Compare Validator”, the “Key Exists Validator”, the “Length Validator”, the “List Validator”, the “Range Validator” and the “Regular Expression Validator”.

So the “Compare Validator” is a validator that can be defined either at the entity or the attribute level but relates to an entity object attribute and it used to perform a logical comparison between an entity attribute and another value. This other value could be a literal value, the result of a query, a view object attribute, a view accessor attribute, an expression or an entity attribute. I will demo all these options.

So let’s start by creating an application, in my case it is called "CompareValidatorDemo" and create the basic ADF BC objects for this tutorial. For creating the ADF BC objects (entities and views) i have used the "Business Components from Tables" wizard and created entities for the Employees, Departments, Regions and Countries table, their corresponding view objects and an application module as depicted in the screenshot below.
Let's define the first "Compare Validator" rule on the Employees entity to ensure that an employee's salary does not exceed a defined amount. On the Employees entity, under the "Business Rules" tab click the green plus button "Create new validator".

From the "Add Validation Rule" window select "Compare" in the "Type" drop down and from the "Rule Definition" tab select "Salary" in the "Attribute" drop down, "LessOrEqualTo" as the "Operator" and in the "Compare With" combo select "Literal Value". Enter a value in the "Enter Literal Value" field.

In the "Failure Handling" tab define a failure message and click "OK". In my example I have used two message token expressions to construct a dynamic error message, passing to the failure message the employee's first name and last name.
To test your newly defined "Compare Validator" run the Application module and and try to update one of the employee's salary to a value greater than 40,000. For example, try to update Steven King's salary to 40,001. You should get your custom dynamic error message displayed.
 
Let's see now how you can compare an Entity attribute against the results of a query. I will define a new "Compare Validator" but this time i will enforce a business rule to make sure a user can't specify a future date as the employee's hire date.
So on the Employees entity, under the "Business Rules" tab click the green plus button "Create new validator" and create a new "Compare Validator" business rule. From the "Add Validation Rule" window select "Compare" in the "Type" drop down and from the "Rule Definition" tab select "HireDate" in the "Attribute" drop down, "LessOrEqualTo" as the "Operator" and in the "Compare With" combo select "Query Result" and enter "select sysdate from dual" as an SQL statement.
In the "Failure Handling" tab define a failure message and test the new business rule you've defined by running the Application module and updating one of the employee's hire date to a past date.You should get your error message displayed.
You can implement the exact same business rule using a Groovy expression. So instead of using the "Query Result" option in the "Compare With" combo, select "Expression" and enter "adf.currentDate" as a Groovy expression to get the current date.
 
Run the Application module and update one of the employee's hire date to a past date.You should get your error message displayed.
You can also compare an Entity's attribute against a view object's attribute using the "View Object Attribute" option in the "Compare With" drop down. This should be used with great caution as it will use the first row's attribute for comparison.
Just for demo purposes i will be comparing the entity's first name against the Employee's view object last name to ensure they are not the same.
Define an error message in the "Failure Handling" tab and run the application module to test this business rule. The first record that you get when accessing the Employees view  is Steven King and the second employee is Neena Kochhar. Go to another employee, for example to employee with id 102 (Lex De Haan). Update Lex's last name to Kochhar and click the "Validate Row" button. The employee's last name is valid. Now update Lex's last name to King and validate the record. You should get your error message displayed.
So a "View Object Attribute" will compare an entity's attribute against the first row's attribute. If you want to compare an entity's attribute against the entire set of view object attribute values you would use the "View Accessor Attribute" option which requires a "View Accessor" to be created. 
For this demo i will be using the "Countries" entity to ensure a country's name is not the same as the region it belongs to. To do so i will have to first create a view criteria on the "Regions" view object as follows.
Then, on the "Countries" entity, under the "View Accessors" tab, create a new accessor by shuffling the "RegionsVO" view object from the "Available View Objects" list to the "View Accessors" list.
Having the "RegionsVO" selected click on the "Edit" button and shuffled the view criteria you've created on the "Regions" view from the available list to the selected list.If you've followed my exact steps you should have a parameter (regionId) that you should bind to the entity's RegionId parameter.
Create a new "Compare" validator and use the newly created accessor to compare the entity's country name to it's corresponding region name.
Define an error message and run the application module to test your business rule. The first country once you access the Countries view is Argentina and has "Americas" defined as it's region name. Update Argentina's country name to Europe and validate the record. Validation is successful. Update Argentina's country name to Americas and validate the record. Validation should fail and you should get your custom error message.
The last feature that i would like to demo on the "Compare Validator" is the ability to compare an entity's attribute against another attribute from the same entity. For example, ensure that an employee can't have themselves defined as their manager. 
For this example i will be using the "Entity Attribute" option from the "Compare With" drop down to define this business rule.
Define an error message and run the application module to test your business rule. Update Steven King's manager to Neena Kochhar (with employee id = 101) and validate the employee record. Validation is successful. Define Steven King as Steven King's manager and validate the record. The validation will fail and you will get your custom error message displayed.
Download sample application: Compare Validator