droolsdrools-flow

Drools decision table create object


I want to convert the below rule to decision table,

when
  customer:Customer(purchase > 1000)
  person:Person()
then
  person.markValuableCustomer(customer.id); 
end

I tried to convert this to decision table but I am not sure how to declare the person object. As you can see in the excel I created a new Condition for it.

I tried in a CONDITION column as person:Person but I get some error saying condition has to be entered.

So how to create a object in decision table which has to be used in Action column ?

Please find the excel data just in case if image uploaded is not opening.

    RuleTable HelloWorld1   
    CONDITION                                            CONDITION             ACTION

    customer:CustomerInfo   
    customer.purchase > "$param" && customer.valid        person:Person();  person.markValuableCustomer(customer.id)

    Purchase    
    1000    

enter image description here


Solution

  • You can use this trick:

        RuleTable HelloWorld1   
        CONDITION                      CONDITION        ACTION
    
        customer:CustomerInfo          person:Person()
        customer.purchase > "$param"   /*$param*/       person.mark(customer.id)
        Purchase    
        1000                              x
    

    You can join the cells of the condition column so that a single 'x' is sufficient.