Wednesday, December 17, 2014

Oracle BPM 12c Gateways (Part 3 of 5): Parallel Gateway

The parallel gateway enables you to perform multiple tasks simultaneously, allowing your process to follow several unconditional paths in parallel. When your process token reaches a parallel gateway activity, the parallel gateway will create a token for each outgoing parallel sequence flow. Your process will wait until all tokens have arrived at the parallel gateway merge activity before resuming with the rest of the activities.

You should be very careful with the parallel gateway activity because if one of the tokens that have been created by the parallel gateway doesn't arrive at the parallel gateway merge activity, then your process will freeze.

So let's see how you can use the parallel gateway in a process. Let's assume that you are implementing an order process and that at some point in your process you want to request for quotations from two different suppliers. Once you have received both quotations your process should resume (ideally pick the lowest quotation but I will not be implementing this part).

I created a BPM application with a default BPM project (named both application and project "ParallelGatewayDemo") having an empty composite.

Next I created an asynchronous BPMN process and named it OrderProcess without any arguments.

As already stated above in this demo I will be simulating an order process where I need to send two supplier quotation. So I will use the parallel gateway. Please note how JDeveloper automatically adds a parallel gateway merge activity when you drop a parallel activity on your process.

To simulate a supplier's request for quotation I used a human task component. I created a single human task for both suppliers accepting all the defaults and just changing the human task title for each case.

For simplicity reasons I changed the human task assignment type from "Lane Participants" to "Names and expressions" and assigned the "weblogic" user as a new user participant.

So let's test our process. Since we didn't specify any arguments you can directly invoke your process. If you open the flaw trace you will see that two human tasks have been created and are pending.


Go to the BPM workspace, login using the weblogic user and if you followed my exact steps and you should see two tasks. Approve one of them.
If you go back to the flow trace you should see that there process is waiting for the second human task.

Approve the second human task (from the BPM workspace) and go back to the flow trace; you process should be completed.

Both tokens from both outgoing parallel sequence flow have reached the parallel gateway merge activity which signaled to the process that all parallel activities have been completed.

Download sample application: Parallel Gateway

Monday, November 10, 2014

Using ADF BC Declarative Built-in Rules (Part 7 of 10): Range validator

The "Range Validator" is another entity attribute validator which can be be defined at either the entity or attribute level but pertains to an entity attribute just like the "Compare", "Key Exists", "Length" and "List" validators.

As it's name suggests you can use the "Range" validator to ensure that an attribute value falls either within or outside some specified minimum and maximum values. For example, ensure that an employee's salary is between $10,000 and $20,000.

For the purpose of demoing the "Range" validator I have created an 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 default view object based on the Employees entity object and a default application module.

Next let’s define a "Range" validator on the Employees entity object to ensure that an employee's salary is within a specified minimum and maximum values. So on the  “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 “Range”, select the attribute that you want to define the validator, in my demo it's the "Salary" attribute and then select an operator, either Between or NotBetween. In my demo I have selected the "Between" operator.

Under the range section define a minimum and a maximum 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 new salary value using the newValue keyword.


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

Run the Application module to test your "Range" validator and try to update an employee's salary to a value greater than 20,000. The "Range" validator should have fired displaying your error message.

Download sample application: Range Validator

Monday, September 22, 2014

Oracle BPM 12c Gateways (Part 2 of 5): Inclusive Gateway


The inclusive gateway, just like the exclusive gateway, enables you to split your process into two or more paths. The intrinsic difference between an exclusive gateway and an inclusive gateway is that in an exclusive gateway, the process only continues down one of several paths (if multiple outgoing sequence flows are present) while in an inclusive gateway a process will follow all conditional paths whose expressions are evaluated to true.

Furthermore, in an inclusive gateway a process will only follow the default path only if no conditional expressions evaluate to true. Because of this particular characteristic the notation of an inclusive gateway consist of a split and a merge inclusive gateway.


An inclusive gateway can consist multiple outgoing conditional sequence flows for an inclusive gateway split. However, an inclusive gateway must define a default sequence flow. All conditional expressions that evaluate to true are executed; otherwise the default sequence flow is executed.

At run time, the BPM engine generates a token for each conditional sequence that evaluates to true. If none of the conditional sequence flows evaluate to true then a token gets generated for the default sequence flow. The process will pause and will resume only when all tokens have reached the merge

So let's see how you can use an inclusive gateway in 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 this demo I will be simulating a Banking Supervision process where a specific department of a Central Bank is responsible for over-sighting it's financial institutions and based on certain decision points various documents are required to be generated.

Therefore I will create two input arguments, NonComplianceLetter and LetterToCentralBank, both of type boolean to denote whether these two type of documents are required to be generated and an output string argument, DocumentsGenerated, to act as a confirmation of which documents where generated.

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 (nonComplianceLetter and letterToCentralBank both of type boolean and documentsGenerated of type string).

Next I assigned the two input arguments (NonComplianceLetter and LetterToCentralBank) to the process data objects (nonComplianceLetter, letterToCentralBank) 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 documentsGenerated process data object to the DocumentsGenerated output argument.

As already mentioned I will be simulating a Banking Supervision process where based on the two boolean input arguments I will generate either both documents (Non-Compliance Letter and Letter to Central Bank), one of the documents (Non-Compliance Letter or Letter to Central Bank) or will not generated any documents at all. And to implement such a scenario I will use an inclusive gateway. Please pay attention how JDeveloper automatically adds an inclusive merge gateway with every inclusive split gateway.

Furthermore I dropped three script tasks, one between the inclusive split and merge gateway, one above the inclusive gateway and one below the inclusive gateway.

On each script task, using the "Data Associations" provided some static text to the documentsGenerated process data object to display whether a document is generated (please note that in the second script task I used the concat function to concatenate the string value from the first script task).

Because I want to have the third script task (Do not Generate Any Letters) marked as the default sequence flow I will delete the default sequence flow from the second script task (Generate Letter to Central Bank) and redefine the sequence flows.

For the first two conditional outbound sequence flows I have defined an XPath expression to check whether its marching document is selected. For the "Generate Non-Compliance Letter" conditional flow you should have an XPath condition similar to "xp20:matches(string(bpmn:getDataObject('nonComplianceLetter')), '\s*(?i:true|1)\s*')". For the "Generate Letter to Central Bank" conditional outbound sequence flow your XPath should be similar to "xp20:matches(string(bpmn:getDataObject('letterToCentralBank')), '\s*(?i:true|1)\s*')".

Deploy your process on the integrated Weblogic server and run a test with just one of the documents selected (let's say LetterToCentralBank set to true). The second conditional sequence flow is evaluated to true and if you inspect the "End" message DocumentsGenerated output element you should see that the Letter to Central Bank document has been generated.

Switch to graphical view to see the execution path highlighted.

 
Now test your process without selecting any of the two documents. The process should have followed the default sequence flow. You can confirm this by inspecting the "End" message DocumentsGenerated output element; it should read "No documents generated".

If you switch to graphical view you will see that the process followed the default outbound sequence flow.



Download sample application: Inclusive Gateway

Wednesday, September 17, 2014

Using ADF BC Declarative Built-in Rules (Part 6 of 10): List validator

The "List Validator" is yet another validator that can be defined at either the entity level or the attribute level but pertains to an entity object attribute to ensure that a value is either in a list or not.

So the "List Validator" compares an attribute against a list of

a) literal values ensuring that the value is in or not in the list of literal values that you define,
b) against an SQL query ensuring that the value is in or not in the first column of the query's result set,
c) against a view attribute ensuring that the value is in or not in the attribute of the specified view object or
d) against a view accessor ensuring that the value is in or not in the specified attribute in all rows of the view object retrieved by the view accessor.

Let's see a demo of the "List Validator". 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 Departments HR table, a view object based on the Departments entity object and a default application module.

Next let’s define a "List" validator on the Departments entity object to ensure that a department is in the list of literal values that we will define. So on “Business Rules” tab of the Departments 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 “List” and select the attribute on which you want to define the list validator. In my demo I have selected “DepartmentName”. Select the operator (In or NotIn) and the List Type (Literal Values, Query Result, View Object Attribute or View Accessor Attribute). In my demo i have selected the "In" operator and "Literal Values" as the List Type.

In the "Enter List of Values" text box enter the possible values a department can have (enter each values without quotes on a new line).
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 department name.

If you inspect the Department’s entity source code you will see that JDeveloper added a ListValidationBean tag to the XML entity definition file.
Before testing our validator please ensure that your application module has the Departments view selected under the “Data Model”.

To test your validator, run the Application module and try to update a department's name to "Sales" (if you recall i did not include sales in my list of allowed literal values). You should get your custom dynamic error message displayed.

Please note that list validators based on SQL queries or View Object attributes retrieve all rows of a query each time a validation is perform, therefore you should be very careful when you choose to use these list types. It it recommended that you use these list types only for relatively small value sets.

Download sample application: List Validator

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