<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1">
<TITLE>Rules to detect states in an object graph?!?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Arial">Sorry, me again,</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">I'm putting together some prototype rules that operate on related objects in a graph of objects.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">I'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 SIZE=2 FACE="Courier New">//Java code</FONT>

<BR><FONT SIZE=2 FACE="Courier New">parent.addChild(child)</FONT>

<BR><FONT SIZE=2 FACE="Courier New">wm.assertObject(parent);</FONT>

<BR><FONT SIZE=2 FACE="Courier New">wm.assertObject(child);</FONT>
</P>

<P><FONT SIZE=2 FACE="Courier New">//Rule</FONT>

<BR><FONT SIZE=2 FACE="Courier New">rule &quot;</FONT><FONT SIZE=2 FACE="Courier New">Adult smurfs</FONT><FONT SIZE=2 FACE="Courier New">&quot;</FONT>

<BR><FONT SIZE=2 FACE="Courier New">when</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">c</FONT><FONT SIZE=2 FACE="Courier New"> :</FONT> <FONT SIZE=2 FACE="Courier New">Child</FONT> <FONT SIZE=2 FACE="Courier New">(</FONT> <FONT SIZE=2 FACE="Courier New">age &gt; 18, p : parent</FONT> <FONT SIZE=2 FACE="Courier New">)</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">Parent</FONT> <FONT SIZE=2 FACE="Courier New">(</FONT> <FONT SIZE=2 FACE="Courier New">parentId == ( p.parentId</FONT><FONT SIZE=2 FACE="Courier New"> )</FONT><FONT SIZE=2 FACE="Courier New">, type == &quot;SMURF&quot; )</FONT>

<BR><FONT SIZE=2 FACE="Courier New">then</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">System.out.println(&quot;Smurf &quot; + p.getName() + &quot; is &quot; + c.getAge() + &quot; years old.&quot;</FONT>

<BR><FONT SIZE=2 FACE="Courier New">end</FONT>
</P>

<P><FONT SIZE=2 FACE="Courier New">rule &quot;</FONT><FONT SIZE=2 FACE="Courier New">Adult clangers</FONT><FONT SIZE=2 FACE="Courier New">&quot;</FONT>

<BR><FONT SIZE=2 FACE="Courier New">when</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">c</FONT><FONT SIZE=2 FACE="Courier New"> :</FONT> <FONT SIZE=2 FACE="Courier New">Child</FONT> <FONT SIZE=2 FACE="Courier New">(</FONT> <FONT SIZE=2 FACE="Courier New">age &gt; 18, p : parent</FONT> <FONT SIZE=2 FACE="Courier New">)</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">Parent</FONT> <FONT SIZE=2 FACE="Courier New">(</FONT> <FONT SIZE=2 FACE="Courier New">parentId == ( p.parentId</FONT><FONT SIZE=2 FACE="Courier New"> )</FONT><FONT SIZE=2 FACE="Courier New">, type == &quot;CLANGER&quot; )</FONT>

<BR><FONT SIZE=2 FACE="Courier New">then</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">System.out.println(&quot;Clanger &quot; + p.getName() + &quot; is &quot; + c.getAge() + &quot; years old.&quot;</FONT>

<BR><FONT SIZE=2 FACE="Courier New">end</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">This requires that the parent-child relationship is navigable from the child end of the relationship --</FONT> <FONT SIZE=2 FACE="Courier New">child.getParent()</FONT><FONT SIZE=2 FACE="Arial">.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">What other approaches does anyone else use to implement rules that span related objects?</FONT>
</P>

<P><FONT COLOR="#000000" SIZE=2 FACE="Arial">With kind regards,</FONT>
</P>

<P><FONT COLOR="#808080" SIZE=4 FACE="Goudy Old Style">Michael Anstis</FONT><BR>
<FONT COLOR="#808080" SIZE=2 FACE="Arial">-------------------------------------------</FONT><BR>
<B></B><B><FONT COLOR="#000080" FACE="Arial">Next Generation Estimating System</FONT></B>

<BR><FONT COLOR="#808080" SIZE=2 FACE="Wingdings">(</FONT><FONT COLOR="#808080" SIZE=2 FACE="Arial"> Trafford House (Int) 8 718 2239 </FONT>

<BR><FONT COLOR="#808080" SIZE=2 FACE="Wingdings">(</FONT><FONT COLOR="#808080" SIZE=2 FACE="Arial"> Trafford House (Ext) +44 (0)1268 702239</FONT>

<BR><FONT COLOR="#808080" SIZE=2 FACE="Wingdings">*</FONT><FONT COLOR="#808080" SIZE=2 FACE="Arial"></FONT> <FONT COLOR="#808080" SIZE=2 FACE="Tahoma">&lt;</FONT><A HREF="mailto:manstis1@ford.com"><U></U><U><FONT COLOR="#0000FF" SIZE=2 FACE="Tahoma">mailto:manstis1@ford.com</FONT></U></A><FONT COLOR="#808080" SIZE=2 FACE="Tahoma">&gt;</FONT>
</P>

</BODY>
</HTML>