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:

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:

  1. Create a DMN model containing the rules for possible money laundering.
  2. Adapt the BPMN process Pizza Service to accommodate a Business Rule Task.
  3. 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

  1. Open the Camunda modeler and create new file, DMN Diagram (Camunda Platform)
  2. Create a Decision "Payment Scoring" (DRD level) and select "Decision Table" from it.
  3. Click on the top-left blue square of the Decision to enter in the editing mode for the Decision Table.
  4. 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.

  1. 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/
  2. 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

  1. Download the basic BPMN process Pizza Service from https://moodle.fhnw.ch/mod/resource/view.php?id=1587752
  2. Add a Business Rule Task "Score payment" between User Task "Take pizza order" and "Bake pizza".
  3. Add a Lane "DMN Engine" and place "Score payment" on it.
  4. 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.
  1. 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

  1. 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}
  1. Compare your BPMN model with the possible solution, which you find at: https://moodle.fhnw.ch/mod/resource/view.php?id=1595300

b. Deployment

  1. Deploy DMN Decision Model in the DigiBP Classroom Instance. Deployment URL: https://digibp.herokuapp.com/engine-rest
  2. Deploy Business Process Model in the DigiBP Classroom Instance using your tenant Id. Deployment URL: https://digibp.herokuapp.com/engine-rest
  3. Run the process. Link: digibp.herokuapp.com

If you have questions, please feel free to contact me any time: [email protected]