[rules-users] how to find which condition evaluated to TRUE?

Marina ppine7 at yahoo.com
Tue Jun 17 13:08:35 EDT 2008


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080617/a78fb90f/attachment.html 


More information about the rules-users mailing list