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

1 comment:

  1. really helpful and informative article, please keep this good work up!

    ReplyDelete