<br> Joshua,<br><br> The limitation is on binding variables on different fact types on different logical branches and using them in the consequence. If you don't use the bindings in the consequence, you are fine.<br>
<br> This is a temporary limitation.<br><br> []s<br> Edson<br><br><div><span class="gmail_quote">2008/3/7, Joshua Undesser <<a href="mailto:jundesse@cdmtech.com">jundesse@cdmtech.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br> Thank you Mark for the quick reply. I am curious if this is only temporary<br> or if this is the protocol that Drools is going to use for "or" statements?<br> The reason I ask is that i come from a jess/clips background, where "or" can<br>
be used across multiple classes as shown in my example and it is very useful<br> when you have two huge rules that are identical except for one LHS class<br> pattern difference.<br> <br> Obviously the fix for now is to break up the rule into two rules, but I was<br>
curious if this was only a temporary restriction or if this is going to be<br> the standing protocol?<br> <br> I'll also grab the new 4.0.5 branch as you mentioned and give that a whirl.<br> <br> Thanks again Mark!<br>
<br> Joshua<br> <br><br> <br> <br> <br> <br> Mark Proctor wrote:<br> ><br> > The 'or' must be used for classes of the same type.<br> ><br> > Mark<br> > Joshua Undesser wrote:<br> >> I am curious if anyone else has run into this problem.....It seems like<br>
>> there<br> >> is something wrong in the Drools Logic....My issue can be very easily be<br> >> recreated in about 5 minutes....<br> >><br> >> >From eclipse I set up a new drools project. Where DroolTest.java is<br>
>> defined I create 4 new classes, ClassA, ClassB extends ClassA, ClassC<br> >> extends ClassA, and ClassD.<br> >><br> >> Each of these classes has a default constructor that does nothing, there<br>
>> are<br> >> no attributes or anything in these classes just to make the example<br> >> simple<br> >> to reproduce. Ie ClassA looks like this....<br> >><br> >><br> >><br> >> package com.sample;<br>
>><br> >> public class ClassA {<br> >><br> >> public ClassA() {<br> >> }<br> >> }<br> >><br> >><br> >><br> >> Now within the DroolsTest.java source code at line 29 (ie right after the<br>
>> workingMemory.insert( message ) method call I added 4 more lines which<br> >> creates and inserts two objects...<br> >><br> >> ClassB classB = new ClassB();<br> >> ClassD classD = new ClassD();<br>
>> workingMemory.insert( classB );<br> >> workingMemory.insert( classD );<br> >><br> >> and then the next line would be the<br> >> workingMemory.fireAllRules();<br> >> as normal.<br> >><br>
>><br> >> Then in the sample.drl file I add the following rule and functions<br> >><br> >> 1 rule "Test"<br> >> 2 when<br> >> 3<br> >> 4 $classA : ClassA()<br>
>> 5 $classD : ClassD()<br> >> 6<br> >> 7 (or<br> >> 8 $classB : ClassB(eval($classB == $classA))<br> >> 9 $classC : ClassC(eval($classC == $classA))<br>
>> 10 )<br> >> 11<br> >> 12 eval(retB($classA, $classD))<br> >> 13<br> >> 14 then<br> >> 15 System.out.println("\n\n<<FIRE RULE>>TEST");<br>
>> 16 end<br> >> 17<br> >> 18 function boolean retA(Object obj) {<br> >> 19 System.out.println("Ret Val = " + obj);<br> >> 20 return true;<br> >> 21 }<br> >> 22<br>
>> 23 function boolean retB(Object obj1, Object obj2) {<br> >> 24 System.out.println("Ret Val 1 = " + obj1);<br> >> 25 System.out.println("Ret Val 2 = " + obj2);<br> >> 26 return true;<br>
>> 27 }<br> >><br> >><br> >><br> >> So what I am doing is very quick and very simple to reproduce. What is<br> >> happening is that when i run the program I am getting a class cast<br>
>> exception<br> >> which is very very strange.<br> >><br> >><br> >> At first I thought it was tied only to the OR statement because if I<br> >> break<br> >> the rule into two rules (one for each of the or conditions) it works<br>
>> fine.<br> >><br> >> But after playing with it a little further I get a lot of other strange<br> >> class cast exceptions.<br> >><br> >> For instance if I replace line 12 (eval(retB($classA, $classD))) with<br>
>> eval(retA($classA)) it works fine, but if I replace it with<br> >> eval(retA($classD)) I get another class cast exception. Another<br> >> strainge<br> >> issue....if switch lines 4 and 5 and keep line 12 as eval(retA($classD))<br>
>> that previously failed, it now passes, but if I change line 12 back to<br> >> eval(retA($classA)) which previously passed it now fails.....<br> >><br> >> There are a few other combinations that produce errors as well. Just<br>
>> seems<br> >> to be a fundamental flaw in the logic and I'm curious if anyone else has<br> >> seen this?<br> >><br> >> Thanks!<br> >><br> >> Joshua<br> >><br> >> P.S.<br>
>><br> >> Also I've noticed an issue with the manual example 6.36<br> >><br> >><br> >> This does not seem to work for me<br> >> pensioner : (or Person( sex == "f", age > 60 )<br>
>> Person( sex == "m", age > 65 ) )<br> >><br> >><br> >> But this does<br> >> (or pensioner : Person( sex == "f", age > 60 )<br> >> pensioner : Person( sex == "m", age > 65 ) )<br>
>><br> >><br> >><br> >><br> >> Although both formats are stated as working in the manual.<br> >><br> >><br> >><br> >><br> >><br> >><br> >><br> ><br>
> _______________________________________________<br> > rules-users mailing list<br> > <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br> > <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br> ><br> <br> <br>--<br> View this message in context: <a href="http://www.nabble.com/Problem-passing-objects-to-a-method-via-the-eval-statement-tp15885523p15898856.html">http://www.nabble.com/Problem-passing-objects-to-a-method-via-the-eval-statement-tp15885523p15898856.html</a><br>
<br>Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br> <br> _______________________________________________<br> <br>rules-users mailing list<br> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br> </blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br>
Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>