<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV dir=ltr align=left><SPAN class=458050709-07012008><FONT face=Arial
color=#0000ff size=2>Forgetting the use of Drools how do you determine
(programmatically) which is the main contract and which are
related?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=458050709-07012008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=458050709-07012008><FONT face=Arial
color=#0000ff size=2>Once you can answer this your Drools solution should
become self evident.</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV dir=ltr align=left><SPAN class=458050709-07012008><FONT face=Arial
color=#0000ff size=2><STRONG><EM>An attribute
</EM></STRONG></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=458050709-07012008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=458050709-07012008>
<DIV><FONT face=Arial color=#0000ff size=2><EM>when</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM> $mc:
Contract(<SPAN class=458050709-07012008>type == "main" </SPAN>)
</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM>then</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM> #rule fired
over "the" main contract</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM>end</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM></EM></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM>when</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM> $rc:
Contract(<SPAN class=458050709-07012008>type == "related"
</SPAN>)</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM>then</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM> #rule fired over
"a" related contract</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff
size=2><EM>end</EM></FONT></DIV></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT><FONT face=Arial
color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=458050709-07012008><FONT face=Arial color=#0000ff
size=2><STRONG><EM>A relationship</EM></STRONG></FONT></SPAN></DIV>
<DIV><SPAN class=458050709-07012008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV>
<DIV dir=ltr align=left><SPAN class=458050709-07012008>
<DIV><FONT face=Arial color=#0000ff size=2><EM>when</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM> $mc:
Contract(<SPAN class=458050709-07012008> </SPAN>) </EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM>then</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM> #rule fired
over "the" main contract</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM>end</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM></EM></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM>when</EM></FONT></DIV>
<DIV><EM><FONT face=Arial color=#0000ff size=2>
<DIV><FONT face=Arial color=#0000ff size=2><EM> $mc:
Contract(<SPAN class=458050709-07012008> </SPAN>)
</EM></FONT></DIV></FONT></EM></DIV>
<DIV><EM><FONT face=Arial><FONT color=#0000ff><FONT size=2>
$rc: Contract(<SPAN class=458050709-07012008> </SPAN>)<SPAN
class=458050709-07012008> from
$mc.contracts</SPAN></FONT></FONT></FONT></EM></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM>then</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><EM> #rule fired over
"a" related contract</EM></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff
size=2><EM>end</EM></FONT></DIV></SPAN></DIV></DIV></BLOCKQUOTE><FONT face=Arial
color=#0000ff size=2></FONT><FONT face=Arial color=#0000ff size=2></FONT>
<DIV><BR></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>Massi
Gmail<BR><B>Sent:</B> 05 January 2008 11:33<BR><B>To:</B> Rules Users
List<BR><B>Subject:</B> Re: [rules-users] Checking fact
"id"<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2>ok</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>But i think I do not need to differentiate
them.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I try to explain it better.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I have got a set of "Contract" class Facts. All
of them inserted into the working memory.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>But Just one of them is the "main contract", all
the others all "related contracts".</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>So , when i write a rule I need to distinguish
between a "main contract" (which is unique along the session) </FONT></DIV>
<DIV><FONT face=Arial size=2>and a "related contract".</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I should write rules like the
followings:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </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> $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> #rule fired over "the"
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> </DIV>
<DIV><FONT face=Arial size=2><EM>when</EM></FONT></DIV>
<DIV><FONT face=Arial size=2><EM> $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> #rule fired over "a" 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
"maincontract" and "relatedcontracr" globals.</FONT></DIV>
<DIV><FONT face=Arial size=2>But, if I make them globals, then the 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><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Should I make them "globals" and "facts" 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><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thank u anyway.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Massi</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=tirelli@post.com href="mailto:tirelli@post.com">Edson Tirelli</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=rules-users@lists.jboss.org
href="mailto:rules-users@lists.jboss.org">Rules Users List</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Saturday, January 05, 2008 12:00
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [rules-users] Checking
fact "id"</DIV>
<DIV><BR></DIV><BR> What attribute differentiates A1 from A2?
<BR> Such scenarios usually are solved by an additional
constraint...<BR><BR> []s<BR> Edson<BR><BR>
<DIV><SPAN class=gmail_quote>2008/1/4, Massi Gmail <<A
href="mailto:mmquelo@gmail.com"> mmquelo@gmail.com</A>>:</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><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Hi guys,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Now I am strugglin' with "fact id
checking" or whatever we can call it.... :D</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Let's take into account the followong
scenario:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I have class A (it's just a name) javabeans
to be inserted into the WM.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I define two objects of class A: A1 and
A2.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Somewhere I do "insert(A1)" and "insert(A2)"
( let's say I do it in the same package of R1 and R2..see below...)
</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Then I define two different rules R1 and R2
that reason over class "A" facts (let's say R1 and R2 are in the
same package) .</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>The point is.... I want R1 to fire only
on A1 and R2 only on A2.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Is that possible in drools? Is there a sort
of "fact id" I can reason over?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </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><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Let me know.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Massi</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2></FONT> </DIV></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></BLOCKQUOTE></DIV><BR><BR
clear=all><BR>-- <BR> Edson Tirelli<BR> JBoss Drools
Core Development<BR> Office: +55 11
3529-6000<BR> Mobile: +55 11 9287-5646 <BR> JBoss, a
division of Red Hat @ <A href="http://www.jboss.com">www.jboss.com</A>
<P>
<HR>
<P></P>_______________________________________________<BR>rules-users
mailing
list<BR>rules-users@lists.jboss.org<BR>https://lists.jboss.org/mailman/listinfo/rules-users<BR></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>