<div>&nbsp;</div>
<div>Thank You guys.</div>
<div>&nbsp;</div>
<div>I worked it out. I have the contracts (main and related)&nbsp;encapsulated within a parent object.</div>
<div>So, once I did the assertion I checked the &quot;pattern matched&quot; fact agains the parent object.</div>
<div>&nbsp;</div>
<div>Thank You again.</div>
<div>&nbsp;</div>
<div>This ML is always usefull as usual!</div>
<div>&nbsp;</div>
<div>I really hope to be usefull as well to the few I can answer back.</div>
<div>&nbsp;</div>
<div>Bye</div>
<div>&nbsp;</div>
<div>Massi</div>
<div><br><br>&nbsp;</div>
<div class="gmail_quote">On Jan 7, 2008 9:27 PM, Mark Proctor &lt;<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div text="#000000" bgcolor="#ffffff">rules are just querries over data, like a database view.<br>Ask yourself this. If you asserted those two objects, A1 and A2, into a database and you had two views V1 and V2. How would you make V1 select A1 and V2 select A2?
<br><br>When you have the&nbsp; answer for&nbsp; that, it&#39;ll apply to Drools too.<br><br>Mark<br>Massi Gmail wrote: 
<blockquote type="cite">
<div>
<div></div>
<div class="Wj3C7c">
<div><font face="Arial" size="2">ok</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">But i think I do not need to differentiate them.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I try to explain it better.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I have got a set of &quot;Contract&quot; class Facts. All of them inserted into the working memory.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">But Just one of them is the &quot;main contract&quot;, all the others all &quot;related contracts&quot;.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">So , when i write a rule I need to distinguish between a &quot;main contract&quot; (which is unique along the session) </font></div>
<div><font face="Arial" size="2">and a &quot;related contract&quot;.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I should write rules like the followings:</font></div>
<div>&nbsp;</div>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<div><font face="Arial" size="2"><em>when</em></font></div>
<div><font face="Arial" size="2"><em>&nbsp;&nbsp;&nbsp; $mc: Contract() from maincontract</em></font></div>
<div><font face="Arial" size="2"><em>then</em></font></div>
<div><font face="Arial" size="2"><em>&nbsp;&nbsp;&nbsp; #rule fired over &quot;the&quot; main contract</em></font></div>
<div><font face="Arial" size="2"><em>end</em></font></div>
<div><font face="Arial" size="2"><em></em></font>&nbsp;</div>
<div><font face="Arial" size="2"><em>when</em></font></div>
<div><font face="Arial" size="2"><em>&nbsp;&nbsp; $rc: Contract() from relatedcontract</em></font></div>
<div><font face="Arial" size="2"><em>then</em></font></div>
<div><font face="Arial" size="2"><em>&nbsp;&nbsp; #rule fired over &quot;a&quot; related contract</em></font></div>
<div><font face="Arial" size="2"><em>end</em></font></div></blockquote>
<div><font face="Arial" size="2">I think the only solution to do that is to make &quot;maincontract&quot; and &quot;relatedcontracr&quot; globals.</font></div>
<div><font face="Arial" size="2">But, if I make them globals, then the&nbsp;rule engine will not be notified about their changes and</font></div>
<div><font face="Arial" size="2">I do want it to be notified about it. </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Should I make them &quot;globals&quot; and&nbsp;&quot;facts&quot; as well?</font></div>
<div><font face="Arial" size="2">Can globals be inserted into the WM as well? Is it too horrible? :D</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thank u anyway.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Massi</font></div>
<div>&nbsp;</div>
<blockquote style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<div style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal">----- Original Message ----- </div>
<div style="BACKGROUND: rgb(228,228,228) 0% 50%; FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><b>From:</b> <a title="tirelli@post.com" href="mailto:tirelli@post.com" target="_blank">Edson Tirelli</a> </div>

<div style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><b>To:</b> <a title="rules-users@lists.jboss.org" href="mailto:rules-users@lists.jboss.org" target="_blank">Rules Users List</a> </div>
<div style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><b>Sent:</b> Saturday, January 05, 2008 12:00 PM</div>
<div style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><b>Subject:</b> Re: [rules-users] Checking fact &quot;id&quot;</div>
<div><br></div><br>&nbsp;&nbsp; What attribute differentiates A1 from A2? <br>&nbsp;&nbsp; Such scenarios usually are solved by an additional constraint...<br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br>
<div><span class="gmail_quote">2008/1/4, Massi Gmail &lt;<a href="mailto:mmquelo@gmail.com" target="_blank"> mmquelo@gmail.com</a>&gt;:</span> 
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<div bgcolor="#ffffff">
<div>&nbsp;</div>
<div><font face="Arial" size="2">Hi guys,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Now I am strugglin&#39; with &quot;fact id checking&quot;&nbsp; or whatever we can call it.... :D</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Let&#39;s take into account the followong scenario:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I have class A (it&#39;s just a name) javabeans to be inserted into the WM.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I define two objects of class A: A1 and A2.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Somewhere I do &quot;insert(A1)&quot; and &quot;insert(A2)&quot; ( let&#39;s say I do it in the same package of R1 and R2..see below...) </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Then I define two different rules R1 and R2 that reason over class &quot;A&quot; facts&nbsp; (let&#39;s say R1 and R2 are in the same package) .</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">The point is....&nbsp; I want R1 to fire only on A1 and R2 only on A2.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Is that possible in drools? Is there a sort of &quot;fact id&quot; I can reason over?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I do not think globals will be of any help, cause in the guide i have read that globals should never be used within LHS.</font></div>
<div><font face="Arial" size="2">We should never reason over globals. </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Let me know.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Massi</font></div>
<div>&nbsp;</div>
<div>&nbsp;</div></div><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank">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><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;JBoss Drools Core Development<br>&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646 
<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com/" target="_blank">www.jboss.com</a> 
<p></p>
<hr>
_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank">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></blockquote></div></div><pre><hr width="90%" size="4"><div class="Ih2E3d">
_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
  </div></pre></blockquote><br></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>