Showing posts with label Oracle BPM 11g. Show all posts
Showing posts with label Oracle BPM 11g. Show all posts

Saturday, September 6, 2014

Business Exceptions in Oracle BPM

Handling Business Exceptions in Oracle BPM

I will go over a simple example where you handle Business Exceptions that are propagated to different composite.
Handling in the same composite is pretty straight forward. Use the same

I have 2 composites here. BizExceptionB & BizExceptionA.
Both the exceptions are created in BusinessCatalog of BizExceptionB process.

Snapshot of BizExceptionB Process.



The process takes a string Argument if the value is "One" it goes thru Biz Exception One case and if its "two" it goes thru Biz Exception Two case and throws the corresponding exception.

Export the Business Exceptions into a ".bob" file as shown in the screenshot.




Coming to BizExceptionA process.

It's a simple process which calls BizExceptionB process and have handlers to catch different Business Exceptions. I'm using boundary catch event for this example. You can use regular Event Sub-Process too to catch the exceptions. Screenshot below.



In this process, import the previously saved ".bob" file into BizExceptionA process, This will automatically show the Business Exceptions which were created in BizExceptionB Process under Business Catalog. Use the same ones to catch the errors in the screenshot shown above.


Note: When you import the ".bob" file into BizExceptionA process, it would show 2 Business Exceptions for each one you have. Use the one with "locked" symbol on it when in your catch branch/event. Ignore the one without lock symbol.

Shoot me in the comments, if you need any further help.

Sample project can be downloaded from here
 

Wednesday, June 18, 2014

IF Else in Assign/Script Activity in SOA/BPM

If else conditional assign in Assign or Script Activity of SOA or BPM

Note: It's not a complete solution. however, you can use this method in most of the cases.


Use Case:

Assume an input string which can have value "Submit" or "Cancel" and based on this you want to output string to be either "APP" or "REJ"

if  input_arg = "Submit"
Then
output_arg = "APP"
Else
output_arg = "REJ"


General way of giving a solution for this to write an XSLT or use switch/exclusive gateway and have 2 Assign/Script tasks to assign the appropriate value to the output element.

Here in this example, I will use "translate" function to achieve the same without gateways and in a single Assign/Script Task.



The xpath expression used here is:

translate(string(contains(bpmn:getDataObject('projectDataObject1'),"Submit")),"trufalse","APPREJ")

Lemme split the function and explain it in detail.

1. contains(bpmn:getDataObject('projectDataObject1'),"Submit")  :  This is obvious, checking whether the input argument has the string "Submit". If yes, the function returns "true" else it returns "false"

2. string(contains(bpmn:getDataObject('projectDataObject1'),"Submit")) : Converting the above returned Boolean "true or false" into a string.

3. translate(string(contains(bpmn:getDataObject('projectDataObject1'),"Submit")),"trufalse","APPREJ") : This is the important part, translate function does replacement each character by character.
So, in this above statement  
string(contains(bpmn:getDataObject('projectDataObject1'),"Submit"))  is the input argument to "translate" function

"trufalse"  Indicates what characters to be replaced. This is the 2nd argument.
 "APPREJ"  Indicates with which characters they need to be replaced. This is the 3rd argument to the function.
 "t" would be replaced with "A"
 "r" would be replaced with "P"
"u" would be replaced with "P"
 "f" would be replaced with "R"
so... on

The last letter "e" doesn't have the corresponding replacement element. So, that will be ignored. 
Even "true" has "e" in it, but I didn't mention it explicitly, since we need to mention each character only once. 


So, finally summing up, based on the input argument containing "Submit" or not, the output argument will be updated to "APP" or "REJ".


This might be little confusing :-)

To help you understand more, here are few examples on how the translate function works:

translate("AABBCDBA","ABCD","XYZW") AABBCD is the input and output would be XXYYZWYX
Each character is replaced appropriately.

translate("ABC123DDC","ABCD32154","abcd00000") :   ABC123DDC is the input here and output would be abc000ddc


You can have pretty complicated xpath's to achieve nested if's too. Example here:

translate(string(not(
contains(bpmn:getDataObject('applicationDataDO')/ns:ApplicationStatus,'REJ'))),
 'trufalse',
concat(translate(string(
contains(bpmn:getDataOutput('outcome'),'REJECT')),'trufalse','REJSUB'),'REJ'))
  

You can literally replace any character with any character. Just make sure what you are doing. :-)


Oracle BPM 12c supported much easier way of nested if's in Script tasks, I will post on a blog in it soon. Keep watching !


Shoot me in the comments, if you need any further help.