Doesn't sound right - which version of drools you using? 

Pretty much none of the tests would pass if condiditions weren't anded
together properly, so my guess is there is something odd going on with the
rule. 

-----Original Message-----
From: Kihm, Christian [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 23 November 2005 7:20 PM
To: [email protected]
Subject: [drools-dev] Multiple conditions vs. single condition - not the
same behaviour

Hi folks,

I encountered a problem using rules with more than one condition. One
condition evaluates to false, but the consequence is executed. After
refactoring the condition, concatenate the 3 within one, the consequence
doesn't execute as expected. I have attached the 2 variants below.

I have tried to isolate this in an example code, but I failed. So please can
you give me a hint where I can start to debug? 

Regards
Christian 

Variant one)
-----------------

<rule name="object_readonly_testcase_closed" salience="3400">
      <parameter identifier="obj">
            <class>IApplicationObject</class>
      </parameter>
      <parameter identifier="objStates">
            <class>IStateDecorator</class>
      </parameter>
      <parameter identifier="objMessages">
            <class>IMessageDecorator</class>
      </parameter>

      
      <java:condition><![CDATA[ (
      hasRight(obj, userSession, FormFieldRight.TESTACTION_BASE, true)
      && objStates._containsStateBits("state",
IStateDecorator.STATE_PERSISTENT)
      && hasSameValue(obj, "state", new String[] {"3", "4", "5", "6"})
      )
      ]]></java:condition>

      <java:consequence><![CDATA[
            System.out.println("object_readonly_testcase_closed -> " +
objStates._containsStateBits("state", IStateDecorator.STATE_PERSISTENT));
       ]]></java:consequence>
</rule>


Variant two)
-----------------

<rule name="object_readonly_testcase_closed" salience="3400">
      <parameter identifier="obj">
            <class>IApplicationObject</class>
      </parameter>
      <parameter identifier="objStates">
            <class>IStateDecorator</class>
      </parameter>
      <parameter identifier="objMessages">
            <class>IMessageDecorator</class>
      </parameter>


      <java:condition><![CDATA[ hasRight(obj, userSession,
FormFieldRight.TESTACTION_BASE, true) ]]></java:condition>
      <java:condition><![CDATA[ objStates._containsStateBits("state",
IStateDecorator.STATE_PERSISTENT) ]]></java:condition>
      <java:condition><![CDATA[ hasSameValue(obj, "state", new String[]
{"3", "4", "5", "6"}) ]]></java:condition>

      <java:consequence><![CDATA[ 
            System.out.println("object_readonly_testcase_closed -> " +
objStates._containsStateBits("state", IStateDecorator.STATE_PERSISTENT));
       ]]></java:consequence>
</rule>

Reply via email to