I would suggest that you assert all of your objects into working memory. For example, if you have the object A with an embedded B and C, you need to do the following<br><br>insert(A);<br>insert(A.B);<br>insert(A.C);<br><br>
than within your rules, join the objects where needed<br><br>rule<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; A(b$ : b != null)<br>&nbsp; &nbsp; B(this == b$)<br><br>etc. &nbsp;&nbsp; <br><br><div class="gmail_quote">On Mon, Feb 23, 2009 at 10:39 AM, Corneil du Plessis <span dir="ltr">&lt;<a href="mailto:corneil@tsctech.com">corneil@tsctech.com</a>&gt;</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;">


  
  

<div>
You should initialise your globals and then pass them into the session.<br>
Your rule file will have:
<pre>global java.lang.String recipients
global java.lang.String to
global java.lang.String cc

</pre><div><div></div><div class="Wj3C7c">
On Mon, 2009-02-23 at 06:23 -0800, D1vy@@Ind1@ wrote:
<blockquote type="CITE">
<pre>Thanks for your help , Sudhir, 

I used 

rule
when $a:A(b.z.s==&quot;test&quot;);
then
end

And that solved my problem.

But I would like to know one more information about global variables.

package...
dialect java
import ..,

global java.lang.String recipients=&quot;<a href="mailto:divya@gmail.com" target="_blank">divya@gmail.com</a>&quot;
global java.lang.String to=&quot;<a href="mailto:xyz@yahoo.com" target="_blank">xyz@yahoo.com</a>&quot;
global java.lang.String cc=&quot;<a href="mailto:abc@gmail.com" target="_blank">abc@gmail.com</a>&quot;

rule
when when $a:A(b.z.s==&quot;divya&quot;);
then
$a.setRecipients(recipients);
$a.setTo(to);
$a.setCC(cc);
update($a)
end

Is this feasible with Drools. I get 

unable to comile myfile.drl file
[9,40]: unknown:9:40 mismatched token: [@49,201:201=&#39;=&#39;,&lt;71&gt;,9:40];
E

exception. Could you please help me with this too.


Thanks
-D








Sudhir M-2 wrote:
&gt; 
&gt; Hi D,
&gt; I don&#39;t know which version of drools are you using. If u are using drools
&gt; 4
&gt; or higher you can use &#39;from&#39;  to write rules on nested objects. All u need
&gt; to do is insert the root pbject in the working memory
&gt; 
&gt; Regards,
&gt; sudhir.
&gt; 
&gt; On Mon, Feb 23, 2009 at 2:56 PM, Divya Rajendranath &lt;
&gt; <a href="mailto:divya.rajendranath@gmail.com" target="_blank">divya.rajendranath@gmail.com</a>&gt; wrote:
&gt; 
&gt;&gt; Hi,
&gt;&gt;
&gt;&gt; I am planning to use Drools - JBoss Rules Engine. My requirement is to
&gt;&gt; disburse mails from my application to different groups based on various
&gt;&gt; criteria. I want to use Drools here.
&gt;&gt;
&gt;&gt; My object structure is as follows:
&gt;&gt;
&gt;&gt; class A{
&gt;&gt;
&gt;&gt; String B = &quot;&quot;;
&gt;&gt;
&gt;&gt; B b;
&gt;&gt;
&gt;&gt; C c;
&gt;&gt; }
&gt;&gt;
&gt;&gt; Hence Obj A has embedded objects within it, and obj B and C further has
&gt;&gt; embedded objects.
&gt;&gt;
&gt;&gt; class B {
&gt;&gt;
&gt;&gt; String X;
&gt;&gt;
&gt;&gt; Z z;
&gt;&gt;
&gt;&gt; }
&gt;&gt;
&gt;&gt; class Z{
&gt;&gt;
&gt;&gt; String t;
&gt;&gt;
&gt;&gt; String s;
&gt;&gt;
&gt;&gt; }
&gt;&gt;
&gt;&gt; The decision on sending the mails based on the fields in embedded objects
&gt;&gt; of A. I pass instance of A to Drools
&gt;&gt;
&gt;&gt; Format of drl file:
&gt;&gt;
&gt;&gt; package...;
&gt;&gt;
&gt;&gt; import ..;
&gt;&gt;
&gt;&gt; rule &quot;Test&quot;
&gt;&gt;
&gt;&gt; when $a:A(B(Z(s == &quot;testvalue&quot;)))
&gt;&gt;
&gt;&gt; then
&gt;&gt;
&gt;&gt; $a.setSomething();
&gt;&gt;
&gt;&gt; update($a);
&gt;&gt;
&gt;&gt; end
&gt;&gt;
&gt;&gt; I wanted to know if this (accessing fields in embedded/child object) is
&gt;&gt; feasible with Drools.
&gt;&gt;
&gt;&gt; I get an error saying &quot;UNable to compile myfile.drl when i try to fo
&gt;&gt; this.
&gt;&gt;
&gt;&gt; Could some one look into this issue and let me know the reason for this ?
&gt;&gt;
&gt;&gt;
&gt;&gt;
&gt;&gt; Thanks
&gt;&gt;
&gt;&gt; -D
&gt;&gt;
&gt;&gt; _______________________________________________
&gt;&gt; rules-users mailing list
&gt;&gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
&gt;&gt;
&gt;&gt;
&gt; 
&gt; _______________________________________________
&gt; rules-users mailing list
&gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
&gt; 
&gt; 

</pre>
</blockquote>
</div></div></div>

<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></blockquote></div><br>