GuidedEditorImprovements

From michael & jeff & mark discussing:

 

Adding collect support (subset)

Support basic cardinality constructs on the LHS:

 

There are X Red buses --> collect(.... Bus(color == red) etc).

 

This only allows counts - equal, at least, greater than etc... (drop down).

 

Optional binding: if bound to a collection, then on the RHS can only do foreach over the collection (doesn't really make sense though in a GUI, may skip this).

 

Textual: allow people to slip in DRL to do the more complex things.

 

 

Adding accumulate support (very much a subset)

rule "Net Price is the sum of orderLine item quantity times price -  2nd
try"
   when
       $order : OrderHeader()
       $total : Double( )
            from accumulate( OrderItem( orderHeader == $order)
                             sum( quantity * price ) )
   then
         $order.setNetAmount($total);
       System.out.println( "Order total for order: " +
$order.getOrderId() + " is " + $total );
end

 

How might this look in the business rule editor?

 

1) add OrderHeader and set the variable name

2) add a Condition type of accumulate

3) this would pop up a New Result pattern, which would drop down

imported domain objects as well as Java wrapper classes

4) set the variable name on the result pattern

5) add a constraint to the result pattern if required

6) add the source pattern

7) add constraints to the source pattern if required (don't require the

binding of fields for use in functions, etc.)

8) specify a function (allow the selection of fields from the source fact)

9) or specify init, action, reverse, and result (granted this is more

complex than just using a function and could be left out in an initial pass)

 

    • adding "from" support

 


rule "Apply LineItem Discount when quantity is greater than 2"
   dialect "mvel"
   salience 100
   ruleflow-group "calculate single order discounts"
   when
       order : OrderHeader()
       item : OrderItem( quantity > 2 ) from order.items

   then
         order.setOrderDiscount(.05);
       System.out.println( "Order discount for order: " +
order.getOrderId() + " is " + order.getOrderDiscount() );
end

 

In the BRMS:

 

1) Add OrderHeader and set its variable name to order.

2) Add OrderItem and set its variable name to item.

3) Add constraints to OrderItem (quantity > 2).

4) Use the green triangle to bring up the add constraints box. Under

Advanced options choose From . This will create a drop down list of

bound facts. Choose order. Now bring up a list of methods (only ones

that return collections?). Select items.