Decision Modelling and Automation - DigiBP/digibp.github.io GitHub Wiki
This hands-on gives you a basic understanding of Decision Modeling and Automation, integration between Business Process models and DMN models, and execution of Decision-Aware Business Process models on the Camunda platform.
Contents:
- 1. Create a DMN model Containing the Rules for Possible Money Laundering
- 2. Extend basic BPMN Pizza Service to Accommodate a Business Rule Task
- 3. Business Process and Decision Model Integration
Scenario:
Mario hails from Naples. He opened a Pizzeria in Muttenz for 2 months. He is married to Nadine from Appenzell. Mario makes great pizza. There is already a very high order volume. But Nadine thinks itโs due to money laundering. She asked us to help her!
Tasks:
- Create a DMN model containing the rules for possible money laundering.
- Adapt the BPMN process Pizza Service to accommodate a Business Rule Task.
- Integrate the DMN model with the BPMN Pizza Service. Deploy and run the process.
1. Create a DMN model Containing the Rules for Possible Money Laundering
- Open the Camunda modeler and create new file, DMN Diagram (Camunda Platform)
- Create a Decision "Payment Scoring" (DRD level) and select "Decision Table" from it.
- Click on the top-left blue square of the Decision to enter in the editing mode for the Decision Table.
- Fill in the Decision Tables with Hit Policy "Unique", input and output variables, and the set of rules. E.g. add rules like the following one:
IF "Payment Method" is "Invoice" AND "Entity Type" is "Legal" AND "Order Volume" is between 300 and 1200, THEN "Scoring" = "Orange" and Explanation = "We need to run a credit check"
Input variables, data types and possible values:
Payment Method: String {Invoice, Cash, Credit Card, Twint, Pre-payment}
Entity Type: String {Private, Legal}
Order Volume: Double [300..1200]
Output variables, data types and possible values:
Scoring: String {Green, Orange, Red}
Explanation: String "We need to run a credit check"
Ensure that the input expressions of each variable do not contain spaces.
- Test your DMN model in the online DMN Simulator (we did it in class) and ensure that it works: https://consulting.camunda.com/dmn-simulator/
- Compare (and if necessary adjust) your DMN model with the possible solution, which you find at: https://moodle.fhnw.ch/mod/resource/view.php?id=1543634
2. Extend basic BPMN Pizza Service to Accommodate a Business Rule Task
- Download the basic BPMN process Pizza Service from https://moodle.fhnw.ch/mod/resource/view.php?id=1587752
- Add a Business Rule Task "Score payment" between User Task "Take pizza order" and "Bake pizza".
- Add a Lane "DMN Engine" and place "Score payment" on it.
- Add a XOR gateway after "Score payment" with three outgoing sequence flows: Green, Orange and Red. Green points to the task "Bake Pizza", Orange points to task "Take pizza order" and Red points to an End Event.
- Extend the Form Fields (attributes) of the User Task "Take pizza order" with two new variables: "scoring" and "explanation" and assign the String data type to both. The two Form Fields will be populated with values after running the Business Rule Task "Score payment"
3. Business Process and Decision Model Integration
a. Integration
- Click on the Business Rule Task "Score Payment" and follow the guide on Moodle: https://moodle.fhnw.ch/mod/resource/view.php?id=1595355
These IDs are case sensitive and should not contain spaces, e.g.:
pizzaPrice
legalEntity
paymentMethod
scoring
explanation
Important:
- Ensure that the variable IDs of the input parameters from the BPMN model are exactly the same as the input expressions from the Decision Table, e.g. see the Order Volume in the image below.
Explanation about "Input Parameters" in the Business Rule Task:
Given the limitation of the data type declaration in the BPMN Diagram, a variable can't hold a decimal value. To overcome this issue, we transform the data type "String" into a "Double" one by using the JavaScript method "Number". This is consistent with the data type of input parameter Order Volume from the Decision Table, which is also double. Hence, the input parameter to add to our Business Rule Task is "orderVolume" (same name as the input expression from the Decision Table) and the script looks as follows:
Number(pizzaPrice)
Explanation about "Output Parameters" in the Business Rule Task:
The results from the DMN model will be mapped to the Result Variable "scoringResult" according to the selected mapper: singleResult (Map<String, Object). Then one should extract the values from the Result Variable "scoringResult" and assign them to the corresponding process variables. This is important for the selection of one of the three outgoing sequence flows (green, orange or red) after the gateway. For this, two new Output parameters "scoring" and "explanation" are declared in the Business Rule Task "Score payment" with the below expressions respectively:
${scoringResult.scoring}
${scoringResult.explanation}
- Compare your BPMN model with the possible solution, which you find at: https://moodle.fhnw.ch/mod/resource/view.php?id=1595300
b. Deployment
- Deploy DMN Decision Model in the DigiBP Classroom Instance. Deployment URL: https://digibp.herokuapp.com/engine-rest
- Deploy Business Process Model in the DigiBP Classroom Instance using your tenant Id. Deployment URL: https://digibp.herokuapp.com/engine-rest
- Run the process. Link: digibp.herokuapp.com
If you have questions, please feel free to contact me any time: [email protected]