Arjun

    It is a bug since a more friendly message should be raised at compile time stating that your "contact" declaration is not available in one of your logical branches.
    Having said that, what you want to do is make your OR take priority over the implicit AND and as such, you need to add () around the OR:

When
contact:Contact (initialized==true)
exr: ( Relation( contact==cntct,
               active:active==$1,
               relationName=="Old")
or Relation( contact==cntct,
               active:active==$1,
               relationName==null) )
Then
    contact.getStatus().setStatus(true);
    contact.getStatus().addToReasonTrace(drools.getRule().getName());
end

   Having said that, better yet for you would not to use the OR CE, but to use restriction connectives. This would be the most efficient (and clean) way of writing your rule:

When
contact:Contact (initialized==true)
exr: Relation( contact==cntct,
               active:active==$1,
               relationName =="Old" || == null )
Then
    contact.getStatus().setStatus(true);
    contact.getStatus().addToReasonTrace(drools.getRule().getName());
end

   As a syntax sugar, you could also write:

exr: Relation( contact==cntct,
               active:active==$1,
               relationName in ( "Old", null ) )

   Can you please open a JIRA with your test case for the bug?
   Thank you,
        Edson
 
2007/7/30, Arjun Dhar <dhar_ar@yahoo.com >:
When I define a rule:

When
cntct:Contact (initialized==true)
exr:Relation( contact==cntct,
               active:active==$1,
               relationName=="Old")
Then
contact.getStatus().setStatus(true);
contact.getStatus().addToReasonTrace(drools.getRule().getName());
end

..The bove works.

BUT, when I do the following:

When
cntct:Contact (initialized==true)
exr:Relation( contact==cntct,
               active:active==$1,
               relationName=="Old")
|| Relation( contact==cntct,
               active:active==$1,
               relationName==null)
Then
contact.getStatus().setStatus(true);
contact.getStatus().addToReasonTrace(drools.getRule().getName());
end
... The script compiles anda stateless Session is created successfully, but at
runtime/execution it fails with the exception:
java.lang.ClassCastException: com.arjun.brms.businessObjects.Contact
org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:75)
org.drools.reteoo.EvalConditionNode.assertTuple (EvalConditionNode.java:141)
org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple
(SingleTupleSinkAdapter.java:20)
org.drools.reteoo.JoinNode.assertTuple(JoinNode.java:120)
org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple
(SingleTupleSinkAdapter.java:20)
org.drools.reteoo.JoinNode.assertObject(JoinNode.java:162)
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject
(CompositeObjectSinkAdapter.java:317)
org.drools.reteoo.AlphaNode.assertObject (AlphaNode.java:130)
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject
(CompositeObjectSinkAdapter.java:308)
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130)
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject
(CompositeObjectSinkAdapter.java:308)
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:168)
org.drools.reteoo.Rete.assertObject(Rete.java:168)
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java :190)
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:70)
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:848)
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java :822)
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:623)

Class diagram:
~~~~~~~~~~~~~~~~
Contact<-- bi-directional association -->List<Relation>

Please advise! is this a bug?

thanks,
Arjun

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com