Hello,
If I have a complex rule with a few conditions concatenated via AND and OR and NOT, and
the rule evaluated to true during the engine run - is there a way to figure out which of
the conditions caused the rule to evaluate to true?
In a simple example:
rule "test1"
dialect "java"
when
$data : ContractRulesData (region=='NE' && sum > 250)
then
approverList.add("approver1, approver2, Level1");
System.out.println("test1 is TRUE; result: approver1, approver2,
Level1");
end
I tried to add an AgendaListener with the following code to find out which rules have
fired:
public void afterActivationFired(AfterActivationFiredEvent event, WorkingMemory
workingMemory) {
Activation activation = event.getActivation();
Rule rule = activation.getRule();
GroupElement[] leftElements = rule.getTransformedLhs();
System.out.println("afterActivationFired: rule = " + rule.getName());
System.out.println("Conditions: ");
for (GroupElement left_el: leftElements){
System.out.println(left_el.toString());
}
The output is somewhat cryptic :
afterActivationFired: rule = test1
Conditions:
AND[Pattern type='[ClassObjectType
class=com.emptoris.ecm.domain.ContractRulesData]', index='0',
offset='0', identifer='[Declaration: type=ValueType = 'Object'
identifier=$data]']
So, is there a way to get even more information about the conditions and whether they
evaluated to TRUE or FALSE?
Thanks,
Marina