Lab 06 - Create Technical Rules (DRL)

Lab Goal

To create a technical rule (DRL) to total up the shopping cart items for online retail web shop

Technical rules

  • Are generally not created in this web UI:
    • Developer teams author technical rules
    • Then uploaded to the repository
    • Appear here in a free form editor
    • No syntax help in editor (caution...)
    • Business users advised to stick with guided rule editors
    • For completeness we create one technical rule here...

Create new technical rule

  • Now let's create a new technical rule
  • To add a technical rule, first have to return to Asset view
  • Click on retail-webshop project in bread crumb menu at top

Create new technical rule

  • Click on ADD ASSET -> DRL FILE to open pop-up and create 'Total Shopping Cart Items' rule as shown:
  • Click on +OK to create rule

Create technical rule

  • Presented with the free text editor for our rule (DRL)
  • Add package line shown here to provide all domain model objects

Create technical rule

  • Add basic rule outline, noting indentation:
    • rule "Total Shopping Cart Items"
    • ruleflow-group "pricing-rules"
    • no-loop true, when, then, end

Create technical rule

  • Now lets look at the condition (WHEN) of this rule:
    • There is a ShoppingCart assigned variable: $sc
    • There is a ShoppingCartItem assigned variable: $sci
    • The ShoppingCartItem is in the shopping cart: $sci
  • Can use Fact Types in right column, just remove package names

Create technical rule

  • The rule applies four actions (THEN) if fired:
    • Modify value of shopping cart cartItemTotal
    • $sc.setCartItemTotal( $sc.getCartItemTotal() + ($sci.getPrice() * $sci.getQuantity()));
    • Modify value of cartItemPromoSavings
    • $sc.setCartItemPromoSavings($sc.getCartItemPromoSavings() + ($sci.getPromoSavings() * $sci.getQuantity()));
    • update ShoppingCart: update( $sc );
    • retract ShoppingCartItem: retract( $sci );

Create technical rule

  • This is the finished technical rule:

Don't forget to save

  • Click SAVE and again on confirm pop-up SAVE:

Lab Completed

What you should see...

  • Click on retail-web shop project (use bread crumb menu at the top) for assets view, this ends lab 6:
Eric D. Schabell
Global Technology Evangelist and Portfolio Architect Director
More Red Hat Decision Manager Workshops

Red Hat Decision Manager Articles

Red Hat Decision Manager Demos

Decision Manager Workshop

Up next...

Lab 7 - Create Guided Decision Table