There are many options you could use. Here are a couple<br><ul><li>Insert the service object into WM, than match on it and use it on the RHS to call methods on it</li><li>Have the service object as a global and call methods on it</li>
<li>Make the service helper methods static and call them directly<br></li></ul><br><div class="gmail_quote">On Wed, Feb 25, 2009 at 10:52 AM, 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="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
A couple of more questions,<br>
<br>
I am calling my rules engine from a service and into the session i am<br>
inserting the business object.<br>
<br>
In my service class, I have a few helper functions, which I need to call<br>
from my drl file.<br>
<br>
How can I do that ?<br>
<br>
Thanks<br>
-D<br>
<br>
<br>
<br>
Corneil du Plessis wrote:<br>
><br>
> You should initialise your globals and then pass them into the session.<br>
> Your rule file will have:<br>
><br>
> global java.lang.String recipients<br>
> global java.lang.String to<br>
> global java.lang.String cc<br>
><br>
><br>
> On Mon, 2009-02-23 at 06:23 -0800, D1vy@@Ind1@ wrote:<br>
><br>
>> Thanks for your help , Sudhir,<br>
>><br>
>> I used<br>
>><br>
>> rule<br>
>> when $a:A(b.z.s=="test");<br>
>> then<br>
>> end<br>
>><br>
>> And that solved my problem.<br>
>><br>
>> But I would like to know one more information about global variables.<br>
>><br>
>> package...<br>
>> dialect java<br>
>> import ..,<br>
>><br>
>> global java.lang.String recipients="<a href="mailto:divya@gmail.com">divya@gmail.com</a>"<br>
>> global java.lang.String to="<a href="mailto:xyz@yahoo.com">xyz@yahoo.com</a>"<br>
>> global java.lang.String cc="<a href="mailto:abc@gmail.com">abc@gmail.com</a>"<br>
>><br>
>> rule<br>
>> when when $a:A(b.z.s=="divya");<br>
>> then<br>
>> $a.setRecipients(recipients);<br>
>> $a.setTo(to);<br>
>> $a.setCC(cc);<br>
>> update($a)<br>
>> end<br>
>><br>
>> Is this feasible with Drools. I get<br>
>><br>
>> unable to comile myfile.drl file<br>
>> [9,40]: unknown:9:40 mismatched token: [@49,201:201='=',<71>,9:40];<br>
>> E<br>
>><br>
>> exception. Could you please help me with this too.<br>
>><br>
>><br>
>> Thanks<br>
>> -D<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> Sudhir M-2 wrote:<br>
>> ><br>
>> > Hi D,<br>
>> > I don't know which version of drools are you using. If u are using<br>
>> drools<br>
>> > 4<br>
>> > or higher you can use 'from' to write rules on nested objects. All u<br>
>> need<br>
>> > to do is insert the root pbject in the working memory<br>
>> ><br>
>> > Regards,<br>
>> > sudhir.<br>
>> ><br>
>> > On Mon, Feb 23, 2009 at 2:56 PM, Divya Rajendranath <<br>
>> > <a href="mailto:divya.rajendranath@gmail.com">divya.rajendranath@gmail.com</a>> 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<br>
>> 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<br>
>> 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<br>
>> objects<br>
>> >> of 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)<br>
>> is<br>
>> >> feasible with Drools.<br>
>> >><br>
>> >> I get an error saying "UNable to compile myfile.drl when i try to fo<br>
>> >> this.<br>
>> >><br>
>> >> Could some one look into this issue and let me know the reason for<br>
>> this ?<br>
>> >><br>
>> >><br>
>> >><br>
>> >> Thanks<br>
>> >><br>
>> >> -D<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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>
><br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://www.nabble.com/Help-on-using-Drools-with-embedded-objects-tp22158087p22205576.html" target="_blank">http://www.nabble.com/Help-on-using-Drools-with-embedded-objects-tp22158087p22205576.html</a><br>
Sent from the drools - user mailing list archive at Nabble.com.<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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>