Hi,
I have a event processing rule as follows
declare Sale
@role(event)
end
rule "StoreABC"
when
#conditions
Number(
$TotalSalesAmount : intValue, intValue > 100)
from
accumulate ( Sale($amount : amount, $quantity : quantity)
from
entry-point StoreABC,sum($amount * $quantity))
then
System.out.println("StoreABC
sale exceeds 100…");
End
The POJO Sale has a attribute “String type;”. The
above rule actually ignores the type, and does the accumulation for all types
put together. Now I want the rule to fire successfully only when the TotalSalesAmount
for _any_ given type exceeds 100.
And is it possible to access the “type” of Sale whose
sales exceeded 100, in the “Then” clause ?
Example:
Lets say the input events are as below (Triplets –
Type, Quantity and Amount)
1.
Apple , 10, 5
2.
Orange, 10, 6
3.
Banana, 20, 4
4.
Orange, 10, 5
5.
Apple, 2, 5
Now in the above rule, the event fires after Event 2 since
the total sales is > 100. However I want the rule to fire after Event 4
since at that point the sale of one particular item, viz. “Orange”
exceeds 100 in this store. In the “THEN” clause of the rules, I
also want access to a variable that indicates that it was “Orange”
whose sale exceeded 100 in this store.
Is this possible in Drools Fusion ? If yes, can you please
let me know the changes to be made to the above rule ?
Thanks
Kiran