With Oracle BPM 12.1.3 becoming GA, I wanted to try out some of the new features that got added to this release. There are 2 features that are very helpful to the BPM developers:
- Groovy Scripting support
- BPM Data Object Methods
These are very good additions to the product as it provides a lot of flexibility to the developer ( For developers who come from ALBPM or OBPM this is priceless....).
In this blog post, I wanted to explore the following:
- Create a BPM Data Object with attributes and Methods
- Use the Data Object Method from a Script task
For this simple scenario, I created a process that accepts 2 Integers as Input and returns back the result of Adding the 2 Integers.
The following are the High Level Steps to implement the process:
- Create the BPM process (Synchronous BPM Process Type).
- Implement the Start Event and define the interface which accepts 2 input arguments (input1Arg and input2Arg of Type Int)
- Implement the End Event and define the Interface which returns 1 output argument (outputArg of Type Int)
- Add a Script task to the Process CalculateTotal
- In the Business Catalog add a new Module MyModule
- Add a new BPM Data Object ArithmeticHelper to the module. Define ArithmeticHelper by adding the following:
- Attribute: input1 Type: Int
- Attribute: input2 Type: Int
- Method: calculateSum Parameters: none Return: Integer
- Implement the calculateSum method with the following Groovy script code:
def result=0;
result=input1+input2;
return result;
- In the BPM Process, create 2 Process Data Objects:
- v_arithmeticHelper Type: ArithmeticHelper
- v_output Type: Integer
- Map the Start input arguments to the attributes in the process data object v_arithmeticHelper
- Map the Endoutput arguments to the process data object v_output
- Implement the Script task CalculateTotal. To implement Groovy scripting on a BPM Script task, we can navigate to the script editor by right-clicking the Script task and selecting the option Go To Script. In the script editor, add the following groovy script:
v_output=v_arthmeticHelper.calculateSum();
Once the Project is compiled and deployed, we can test the composite from EM. The result of the testing should show the Total for the 2 input integers that were entered.
You can find the complete BPM project here to run the sample on your environment.
Hope this blog helps in demonstrating Simple Scripting example in Oracle BPM 12.1.3 which can be used to implement your own requirements!