<br><br><div>Is B name of the class? If so it should be name of the variable not the class name.<div>As you are using 4.0.7 the above rule can be written as:</div><div><br></div><div><span class="Apple-style-span" style="border-collapse: collapse; ">rule "test"<br>
salience 20<br> no-loop true<br> when<br> $a:A( $b : b);</span></div><div><span class="Apple-style-span" style="border-collapse: collapse; "> B(X=="testValue") from $b</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; "> // eval (b.X == "testValue"); using eval is not a good idea. There might be a performance hit.<br> <br><div class="Ih2E3d" style="color: rgb(80, 0, 80); ">
then<br> $a.setSomething();<br> update($a);<br> end<br></div></span></div><div><br></div><div>Regards,</div><div>sudhir</div><div><br><div class="gmail_quote">On Mon, Feb 23, 2009 at 5:59 PM, D1vy@@Ind1@ <span dir="ltr"><<a href="mailto:divya.rajendranath@gmail.com">divya.rajendranath@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
Sudhir,<br>
Thanks for the information ...<br>
<br>
To give more data..<br>
I am using drools 4.0.7 version.<br>
<br>
I have appropriate setters and getters in all my classes A, B, Z.<br>
<br>
My drools file look like this:<br>
<br>
rule "test"<br>
salience 20<br>
no-loop true<br>
when<br>
$a:A( b : B);<br>
eval (b.X == "testValue");<br>
<div class="Ih2E3d"> then<br>
$a.setSomething();<br>
update($a);<br>
end<br>
<br>
</div>When I run this rule, it says<br>
<br>
Unable to create Field Extractor for 'B' : [Rule name=test,<br>
agendaGroup=MAIN, salience=20, no-loop=true]<br>
org.drools.RuntimeDroolsException: org.drools.RuntimeDroolsException:<br>
Field/method 'B' not found for class 'com.test.java.A'<br>
Rule Compilation error : [Rule name=test, agendaGroup=MAIN, salience=20,<br>
no-loop=true]<br>
Rule_test_0.java (8:323) : b.X cannot be resolved to a type<br>
E<br>
<br>
I have double checked if there was any typos in defining my fields, and<br>
there exists no problem due to typos.<br>
<br>
Could you please throw light on this exception ?<br>
<br>
<br>
Thanks<br>
-D<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
<br>
D1vy@@Ind1@ wrote:<br>
><br>
> Hi,<br>
><br>
> I am planning to use Drools - JBoss Rules Engine. My requirement is to<br>
> disburse mails from my application to different groups based on various<br>
> criteria. I want to use Drools here.<br>
><br>
> My object structure is as follows:<br>
><br>
> class A{<br>
><br>
> String B = "";<br>
><br>
> B b;<br>
><br>
> C c;<br>
> }<br>
><br>
> Hence Obj A has embedded objects within it, and obj B and C further has<br>
> embedded objects.<br>
><br>
> class B {<br>
><br>
> String X;<br>
><br>
> Z z;<br>
><br>
> }<br>
><br>
> class Z{<br>
><br>
> String t;<br>
><br>
> String s;<br>
><br>
> }<br>
><br>
> The decision on sending the mails based on the fields in embedded objects<br>
> of<br>
> A. I pass instance of A to Drools<br>
><br>
> Format of drl file:<br>
><br>
> package...;<br>
><br>
> import ..;<br>
><br>
> rule "Test"<br>
><br>
> when $a:A(B(Z(s == "testvalue")))<br>
><br>
> then<br>
><br>
> $a.setSomething();<br>
><br>
> update($a);<br>
><br>
> end<br>
><br>
> I wanted to know if this (accessing fields in embedded/child object) is<br>
> feasible with Drools.<br>
><br>
> I get an error saying "UNable to compile myfile.drl when i try to fo this.<br>
><br>
> Could some one look into this issue and let me know the reason for this ?<br>
><br>
><br>
><br>
> Thanks<br>
><br>
> -D<br>
><br>
</div></div>> _______________________________________________<br>
> rules-users mailing list<br>
<div class="Ih2E3d">> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
</div><div class="Ih2E3d">> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>
><br>
<br>
</div><font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/Help-on-using-Drools-with-embedded-objects-tp22158087p22160635.html" target="_blank">http://www.nabble.com/Help-on-using-Drools-with-embedded-objects-tp22158087p22160635.html</a><br>
Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
</font><div class="Ih2E3d"><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
</div><div><div></div><div class="Wj3C7c"><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br></div></div>