Hi Michael,<br><br>To do the opposite approach (where the relationship is navigable from the parent only) you can use the following:<br><br>when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Courier New" size="2">c</font><font face="Courier New" size="2">
 :</font> <font face="Courier New" size="2">Child</font> <font face="Courier New" size="2">(</font> <font face="Courier New" size="2">age &gt; 18</font> <font face="Courier New" size="2">)</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Courier New" size="2">Parent</font> <font face="Courier New" size="2">(</font> children contains c<font face="Courier New" size="2">, type == &quot;SMURF&quot; )</font>

<br><br>Of course this requires either <br><ul><li>the child object in the children collection to be the same as the asserted child object or <br></li><li>the equals/hashcode method to be implemented appropriately in Child
<br></li></ul>cheers<br>Steve<br><br><div><span class="gmail_quote">On 1/24/07, <b class="gmail_sendername">Anstis, Michael (M.)</b> &lt;<a href="mailto:manstis1@ford.com">manstis1@ford.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">







<div>


<p><font face="Arial" size="2">Sorry, me again,</font>
</p>

<p><font face="Arial" size="2">I&#39;m putting together some prototype rules that operate on related objects in a graph of objects.</font>
</p>

<p><font face="Arial" size="2">I&#39;m adding all objects individually to working memory and then checking the objects are related in the rule to ensure only valid combinations are selected; for example:-</font></p>

<p><font face="Courier New" size="2">//Java code</font>

<br><font face="Courier New" size="2">parent.addChild(child)</font>

<br><font face="Courier New" size="2">wm.assertObject(parent);</font>

<br><font face="Courier New" size="2">wm.assertObject(child);</font>
</p>

<p><font face="Courier New" size="2">//Rule</font>

<br><font face="Courier New" size="2">rule &quot;</font><font face="Courier New" size="2">Adult smurfs</font><font face="Courier New" size="2">&quot;</font>

<br><font face="Courier New" size="2">when</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Courier New" size="2">c</font><font face="Courier New" size="2"> :</font> <font face="Courier New" size="2">Child</font> <font face="Courier New" size="2">(</font> <font face="Courier New" size="2">
age &gt; 18, p : parent</font> <font face="Courier New" size="2">)</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Courier New" size="2">Parent</font> <font face="Courier New" size="2">(</font> <font face="Courier New" size="2">parentId == ( p.parentId</font><font face="Courier New" size="2"> )</font><font face="Courier New" size="2">
, type == &quot;SMURF&quot; )</font>

<br><font face="Courier New" size="2">then</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Courier New" size="2">System.out.println(&quot;Smurf &quot; + p.getName() + &quot; is &quot; + c.getAge() + &quot; years old.&quot;</font>

<br><font face="Courier New" size="2">end</font>
</p>

<p><font face="Courier New" size="2">rule &quot;</font><font face="Courier New" size="2">Adult clangers</font><font face="Courier New" size="2">&quot;</font>

<br><font face="Courier New" size="2">when</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Courier New" size="2">c</font><font face="Courier New" size="2"> :</font> <font face="Courier New" size="2">Child</font> <font face="Courier New" size="2">(</font> <font face="Courier New" size="2">
age &gt; 18, p : parent</font> <font face="Courier New" size="2">)</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Courier New" size="2">Parent</font> <font face="Courier New" size="2">(</font> <font face="Courier New" size="2">parentId == ( p.parentId</font><font face="Courier New" size="2"> )</font><font face="Courier New" size="2">
, type == &quot;CLANGER&quot; )</font>

<br><font face="Courier New" size="2">then</font>

<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Courier New" size="2">System.out.println(&quot;Clanger &quot; + p.getName() + &quot; is &quot; + c.getAge() + &quot; years old.&quot;</font>

<br><font face="Courier New" size="2">end</font>
</p>

<p><font face="Arial" size="2">This requires that the parent-child relationship is navigable from the child end of the relationship --</font> <font face="Courier New" size="2">child.getParent()</font><font face="Arial" size="2">
.</font></p>

<p><font face="Arial" size="2">What other approaches does anyone else use to implement rules that span related objects?</font>
</p>

<p><font color="#000000" face="Arial" size="2">With kind regards,</font>
</p>

<p><font color="#808080" face="Goudy Old Style" size="4">Michael Anstis</font><br>
<font color="#808080" face="Arial" size="2">-------------------------------------------</font><br>
<b></b><b><font color="#000080" face="Arial">Next Generation Estimating System</font></b>

<br><font color="#808080" face="Wingdings" size="2">(</font><font color="#808080" face="Arial" size="2"> Trafford House (Int) 8 718 2239 </font>

<br><font color="#808080" face="Wingdings" size="2">(</font><font color="#808080" face="Arial" size="2"> Trafford House (Ext) +44 (0)1268 702239</font>

<br><font color="#808080" face="Wingdings" size="2">*</font><font color="#808080" face="Arial" size="2"></font> <font color="#808080" face="Tahoma" size="2">&lt;</font><a href="mailto:manstis1@ford.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
<u></u><u><font color="#0000ff" face="Tahoma" size="2">mailto:manstis1@ford.com</font></u></a><font color="#808080" face="Tahoma" size="2">&gt;</font>
</p>

</div>

<br>_______________________________________________<br>rules-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br><br></blockquote></div><br><br clear="all"><br>-- <br>Steven Williams<br><br>Supervising Consultant<br><br>Object Consulting<br>Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
<br><a href="mailto:stevenw@objectconsulting.com.au">stevenw@objectconsulting.com.au</a><br><a href="http://www.objectconsulting.com.au">www.objectconsulting.com.au</a><br><br>consulting | development | training | support
<br>our experience makes the difference