Scripting of Decisions Mgr. Ivo Bek, Product Manager Mgr. Marian Macik, Quality Engineer April 2019 2 AGENDA ❏ Motivation ❏ Types of decisions ❏ DRL native rules versus DMN ❏ Uses of DMN ❏ DMN specification from OMG ❏ Demo 3 TYPES OF DECISIONS ❏ Selection (Routing) ❏ Scoring ❏ Categorizing ❏ The decision doesn't take an action (no side effect), just determines a data value 4 DRL NATIVE RULES VERSUS DMN ❏ Rule scripting languages ❏ Generate rules ❏ Spreadsheets ❏ Decisions are tangible and more stable than individual rules rule "Mortgage" when $price : Price(value < 10000) $person: Person(age > 25) then kcontext.setVariable(“mortgageApproved”, true); end 5 USES OF DMN ❏ Modeling human decision making ❏ Modeling requirements for decision making ❏ Executing decision logic 6 DECIDING AS AN ACTIVITY 7 FROM DECISION REQUIREMENT TO LOGIC 8 DECISION TABLE ❏ Rows = rules (most common) ❏ Hit policy determines what to do with rules that matches ❏ Unique, First... Decision logic 9 LITERAL EXPRESSION ❏ FEEL ❏ DMN FEEL Cheat Sheet Decision logic DEMO Decision-driven Business Process plus.google.com/+RedHat linkedin.com/company/red-hat youtube.com/user/RedHatVideos facebook.com/redhatinc twitter.com/RedHatNews THANK YOU LABS DMN inside Business Process Forms The Process ❏ In a new project, design the following process: Data Object Person ❏ Create this type using Data Object asset. ❏ Add field age of type Integer to it. Process variables ❏ Create 3 process variables: ❏ price of type Integer ❏ approved of type Boolean ❏ person of type Person DMN ❏ Create a DMN asset. ❏ Add 2 DMN Input Data nodes: ❏ price of type number ❏ age of type number ❏ Add mortgageApproved DMN Decision node of type boolean and click on a small edit icon near the node. ❏ Click on Select expression and choose Decision Table. Configure it like on the picture. ❏ Save your DMN. Mortgage Approval Business Rule Task ❏ Select DMN as Rule Language. ❏ Fill in the namespace, it can be found when clicking on DMN canvas and then on Diagram properties. ❏ Decision Name is mortgageApproved. ❏ DMN Model Name is the name of your DMN file (without .dmn extension). ❏ Configure data assignments: ❏ Inputs: ❏ price of type Integer from source price. ❏ age of type Integer from source #{person.age}. ❏ Outputs: ❏ mortgageApproved of type Boolean with target approved. ❏ Configure the gateways as on the picture: approved is true approved is true default default approved is true can be set on sequence flow (“arrow”) itself default is set on the gateways Gateways ❏ Configure data assignments: ❏ Inputs: ❏ price of type Integer from source price. ❏ person of type Person from source person. ❏ Outputs: ❏ approved of type Boolean with target approved. ❏ Assign the task to the actor wbadmin. Manager Approval Human Task ❏ Congratulations! You can now run your process and verify that it works. ❏ If you have spare time, you can try to fine-tune the forms: ❏ Process form shouldn’t have approved field visible. ❏ price and age should be required fields. ❏ Manager Approval task can have price and age as input (data assignment) which would mean they will be available for manager to review when completing the task. After you changed the assignment, regenerate forms to propagate all changes you made. Be sure that these two fields are read-only as a manager can only change the approved field. Run the Process ❏ If you want, you can try creating Test Scenario asset. ❏ Add Asset of type Test Scenario. ❏ Select Source type of DMN. ❏ Choose your DMN asset. ❏ Fill your test data and expected results. ❏ Run your test scenario using the play button. Test Scenario