<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
First, thank you for yours answers which are very clear. Your solution will probably work. I'm just desapointed that there is no way to synchronized the shadow with the object. That would be great for my work.<br><br><blockquote><hr>Subject: RE: [rules-users] Synch Business Object / Working Memory<br>Date: Fri, 11 Apr 2008 14:57:52 +0100<br>From: manstis1@ford.com<br>To: rules-users@lists.jboss.org<br><br>
<meta http-equiv="Content-Type" content="text/html; charset=unicode">
<meta name="Generator" content="Microsoft SafeHTML">
<style>
.ExternalClass .EC_hmmessage P
{padding-right:0px;padding-left:0px;padding-bottom:0px;padding-top:0px;}
.ExternalClass BODY.EC_hmmessage
{font-size:10pt;font-family:Tahoma;}
</style>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span class="EC_008434813-11042008">Do you need ruleflow? Perhaps this is too simple and I
misunderstood.</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span class="EC_008434813-11042008"></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span class="EC_008434813-11042008">package com.sample;</span></font></div>
<div><font face="Courier New"></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span class="EC_008434813-11042008">public class Test {</span></font></div>
<div><font face="Courier New"></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span class="EC_008434813-11042008"> private Integer
a;<br> private Integer b;<br> private
Integer c;</span></font></div>
<div><font face="Courier New"></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span class="EC_008434813-11042008"> public Integer getA()
{<br> return a;<br>
}</span></font></div>
<div><font face="Courier New"></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span class="EC_008434813-11042008"> public Integer getB()
{<br> return b;<br>
}</span></font></div>
<div><font face="Courier New"></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span class="EC_008434813-11042008"> public Integer getC()
{<br> return c;<br>
}</span></font></div>
<div><font face="Courier New"></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span class="EC_008434813-11042008"> public void setA(Integer a)
{<br> this.a =
a;<br> }</span></font></div>
<div><font face="Courier New"></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span class="EC_008434813-11042008"> public void setB(Integer b)
{<br> this.b =
b;<br> }</span></font></div>
<div><font face="Courier New"></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span class="EC_008434813-11042008"> public void setC(Integer c)
{<br> this.c =
c;<br> }</span></font></div>
<div><font face="Courier New"></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Courier New"><span class="EC_008434813-11042008">}</span></font></div>
<div> </div>
<div><font color="#0000ff" face="Courier New">package com.sample</font></div>
<div> </div>
<div><font color="#0000ff" face="Courier New">import
com.sample.Test<br> <br>rule "rule 1"<br> salience
90<br> when<br> a :
Test( a != null, b == null )<br> then<br>
System.out.println("setting b to
10");<br>
a.setB(10);<br>
update(a);<br>end</font></div>
<div> </div>
<div><font color="#0000ff" face="Courier New">rule "rule 2"<br>
salience 80<br>
when<br> a : Test( b : b != null, c ==
null )<br> then<br>
System.out.println("setting c to b x
5");<br> a.setC(b *
5);<br> update(a);<br>end</font></div>
<div> </div>
<div><font color="#0000ff" face="Courier New">rule "rule 3"<br>
salience 70<br>
when<br> a : Test( c != null
)<br> then<br> System.out.println("c =
" + a.getC());<br>end<br></font></div>
<div><font color="#0000ff" face="Courier New"></font> </div>
<div><br></div>
<blockquote style="margin-right: 0px;">
<div class="EC_OutlookMessageHeader" dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma"><b>From:</b> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b>On Behalf Of </b>Jonathan
Guéhenneux<br><b>Sent:</b> 11 April 2008 13:23<br><b>To:</b> Rules Users
List<br><b>Subject:</b> RE: [rules-users] Synch Business Object / Working
Memory<br></font><br></div>
<div></div>Indeed, it works but I will have to use such booleans for a lot of
rules.<br><br>Cause my rule flow is <span class="EC_def-example">schematically</span> :<br><br>compute A<br>compute
B(A)<br>compute C(B)<br>...<br><br>Perhaps I may create several ruleflows, one
per independant computing?<br><br>
<blockquote>
<hr>
Subject: RE: [rules-users] Synch Business Object / Working Memory<br>Date:
Fri, 11 Apr 2008 12:11:32 +0100<br>From: manstis1@ford.com<br>To:
rules-users@lists.jboss.org<br><br>
<style>
.ExternalClass .EC_hmmessage P
{padding-right:0px;padding-left:0px;padding-bottom:0px;padding-top:0px;}
.ExternalClass BODY.EC_hmmessage
{font-size:10pt;font-family:Tahoma;}
</style>
<div dir="ltr" align="left"><span class="EC_EC_694480211-11042008"><font color="#0000ff" face="Arial">I was thinking something more like this:-</font></span></div>
<div dir="ltr" align="left"><span class="EC_EC_694480211-11042008"><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span class="EC_EC_694480211-11042008"><font color="#960000"><font color="#960000"></font>
<p align="left"><font color="#960000"><font color="#0000ff" face="Courier New">package com.sample</font></font></p>
<p align="left"><font color="#960000"><font color="#0000ff" face="Courier New">import com.sample.Test<br> <br>rule "rule 1 -
1"<br> salience 90<br>
when<br> a :
Test(<br> computed ==
"false",<br>
c <
15,<br> d
>= 75) <br>
then<br> System.out.println("setting e to
0");<br>
a.setE(0);<br>
update(a);<br>end</font></font></p>
<p align="left"><font color="#960000"><font color="#0000ff" face="Courier New"></font></font> </p>
<p align="left"><font color="#960000"><font color="#0000ff" face="Courier New">rule "rule 1 - 2"<br> salience
10<br> when<br>
a :
Test(<br>
computed ==
"false",<br>
c <
15,<br> d
>= 75) <br>
then<br> System.out.println("setting e to
1");<br>
a.setE(1);<br>end<br></font></font></p></font><font color="#960000">
<p align="left"><font color="#0000ff" face="Arial"><span class="EC_EC_694480211-11042008">Note rule "rule 1 - 2" deliberately uses the
same patterns as rule "rule 1 - 1".</span></font></p></font></span></div>
<div> </div>
<div><font color="#0000ff" face="Courier New">package com.sample;</font></div>
<div><font face="Courier New"></font> </div>
<div><font color="#0000ff" face="Courier New">public class <span class="EC_EC_694480211-11042008">Test</span> {<br>
<br> private boolean computed
=false;<br> private int c=0;<br> private
int d=80;<br> private int e;</font></div>
<div><font face="Courier New"></font> </div>
<div><font color="#0000ff" face="Courier New"> public String
getComputed(){<br>
if(computed)<br>
return "true";<br>
else<br> return
"false";<br> }</font></div>
<div><font face="Courier New"></font> </div>
<div><font color="#0000ff" face="Courier New"> public int
getC() {<br> return
c;<br> }</font></div>
<div><font face="Courier New"></font> </div>
<div><font color="#0000ff" face="Courier New"> public int
getD() {<br> return
d;<br> }</font></div>
<div><font face="Courier New"></font> </div>
<div><font color="#0000ff" face="Courier New"> public void
setE(int e){<br> this.e =
e;<br> computed =
true;<br> }</font></div>
<div><font face="Courier New"></font> </div>
<div><font color="#0000ff" face="Courier New">}<br></font></div>
<div><span class="EC_EC_694480211-11042008"><font color="#0000ff" face="Arial">Rule
"rule 1 - 1" is the only rule to run (and runs once); the second activatino
being cancelled due to the update to "computed". Here's the audit
view:-</font></span></div>
<div><span class="EC_EC_694480211-11042008"><font color="#0000ff" face="Arial"></font></span> </div><font color="#0000ff" face="Courier New"><object-stream><br>
<list><br>
<org.drools.audit.event.ActivationLogEvent><br>
<activationId>rule 1 - 1
[1]</activationId><br> <rule>rule
1 - 1</rule><br>
<declarations>a=com.sample.Test@67126712(1)</declarations><br>
<type>4</type><br>
</org.drools.audit.event.ActivationLogEvent><br>
<org.drools.audit.event.ActivationLogEvent><br>
<activationId>rule 1 - 2
[1]</activationId><br> <rule>rule
1 - 2</rule><br>
<declarations>a=com.sample.Test@67126712(1)</declarations><br>
<type>4</type><br>
</org.drools.audit.event.ActivationLogEvent><br>
<org.drools.audit.event.ObjectLogEvent><br>
<factId>1</factId><br>
<objectToString>com.sample.Test@67126712</objectToString><br>
<type>1</type><br>
</org.drools.audit.event.ObjectLogEvent><br>
<org.drools.audit.event.ActivationLogEvent><br>
<activationId>rule 1 - 1
[1]</activationId><br> <rule>rule
1 - 1</rule><br>
<declarations>a=com.sample.Test@67126712(1)</declarations><br>
<type>6</type><br>
</org.drools.audit.event.ActivationLogEvent><br>
<org.drools.audit.event.ActivationLogEvent><br>
<activationId>rule 1 - 2
[1]</activationId><br> <rule>rule
1 - 2</rule><br>
<declarations>a=com.sample.Test@67126712(1)</declarations><br>
<type>5</type><br>
</org.drools.audit.event.ActivationLogEvent><br>
<org.drools.audit.event.ObjectLogEvent><br>
<factId>1</factId><br>
<objectToString>com.sample.Test@67126712</objectToString><br>
<type>2</type><br>
</org.drools.audit.event.ObjectLogEvent><br>
<org.drools.audit.event.ActivationLogEvent><br>
<activationId>rule 1 - 1
[1]</activationId><br> <rule>rule
1 - 1</rule><br>
<declarations>a=com.sample.Test@67126712(1)</declarations><br>
<type>7</type><br>
</org.drools.audit.event.ActivationLogEvent><br>
</list><br></object-stream></font>
<div><span class="EC_EC_694480211-11042008"></span> </div>
<div><br></div>
<blockquote style="margin-right: 0px;">
<div class="EC_EC_OutlookMessageHeader" dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma"><b>From:</b> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b>On Behalf Of </b>Jonathan
Guéhenneux<br><b>Sent:</b> 11 April 2008 11:33<br><b>To:</b> Rules Users
List<br><b>Subject:</b> RE: [rules-users] Synch Business Object / Working
Memory<br></font><br></div>
<div></div>Ok, I think I understood well. I modified my business code, now
I call if<br><br>(wm != null)<br>
wm.update(wm.getFactHandle(this), this);<br><br>each
time a properties is modified.<br><br>But it is worse. Rules that sould be
activated only once actually loop, even if I add the no-loop
clause.<br><br>I understand why they loop, assuming update = (rectact +
insert), but I dont get a solution to my problem. I just want to notify an
object changement in order to read again the properties, but I dont want
to restart the ruleflow.<br><br>Sorry, but I find hard to say it in
english because even in french, it's not very clear ;)<br>
<blockquote>
<hr>
Subject: RE: [rules-users] Synch Business Object / Working
Memory<br>Date: Fri, 11 Apr 2008 10:39:41 +0100<br>From:
manstis1@ford.com<br>To: rules-users@lists.jboss.org<br><br>
<style>
.ExternalClass .EC_hmmessage P
{padding-right:0px;padding-left:0px;padding-bottom:0px;padding-top:0px;}
.ExternalClass BODY.EC_hmmessage
{font-size:10pt;font-family:Tahoma;}
</style>
<div dir="ltr" align="left"><span class="EC_EC_EC_208223809-11042008"><font color="#0000ff" face="Arial">In essence, yes. Have a look at "update" in the
manual (and a read on Shadow Facts will probably be useful
too).</font></span></div><br>
<blockquote style="margin-right: 0px;">
<div class="EC_EC_EC_OutlookMessageHeader" dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma"><b>From:</b> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b>On Behalf Of
</b>Jonathan Guéhenneux<br><b>Sent:</b> 11 April 2008
10:24<br><b>To:</b> Rules Users List<br><b>Subject:</b> RE:
[rules-users] Synch Business Object / Working
Memory<br></font><br></div>
<div></div>yes, i made a mistake. its a.setE(...) and not
c.setE(...).<br><br>I don't call update. If I dont call update,
properties of an object are just read one time for all
rules?<br><br><br>
<blockquote>
<hr>
Subject: RE: [rules-users] Synch Business Object / Working
Memory<br>Date: Fri, 11 Apr 2008 09:47:43 +0100<br>From:
manstis1@ford.com<br>To: rules-users@lists.jboss.org<br><br>
<style>
.ExternalClass .EC_hmmessage P
{padding-right:0px;padding-left:0px;padding-bottom:0px;padding-top:0px;}
.ExternalClass BODY.EC_hmmessage
{font-size:10pt;font-family:Tahoma;}
</style>
<div dir="ltr" align="left"><span class="EC_EC_EC_EC_287464408-11042008"><font color="#0000ff" face="Arial">I
guess the example is a simplification as "c" (in RHS) has not been
bound to a fact.</font></span></div>
<div dir="ltr" align="left"><span class="EC_EC_EC_EC_287464408-11042008"><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span class="EC_EC_EC_EC_287464408-11042008"><font color="#0000ff" face="Arial">Anyway, that aside, do you call "update" to ensure WM
knows of changes to facts otherwise properties need to be
"time-constant" which in your example they are
not.</font></span></div><br>
<blockquote style="margin-right: 0px;">
<div class="EC_EC_EC_EC_OutlookMessageHeader" dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma"><b>From:</b> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b>On Behalf Of
</b>Jonathan Guéhenneux<br><b>Sent:</b> 11 April 2008
09:34<br><b>To:</b> Rules Users List<br><b>Subject:</b>
[rules-users] Synch Business Object / Working
Memory<br></font><br></div>
<div></div>Hi,<br><br>I have two rules :<br><br>rule "rule 1 -
1"<br> <br> salience
90<br> ruleflow-group
"rfg1"<br> when<br>
a : A(<br>
eComputed == "false",<br>
c <
15,<br> d
>= 75)
<br> then<br>
c.setE(0);<br>end<br><br><br><br>rule "rule 1 -
2"<br><br> salience 10<br>
ruleflow-group "rfg1"<br>
when<br> a :
A(<br>
eComputed == "false",<br>
c >= 15,<br>
d >=
75) <br>
then<br>
c.setE(1);<br>end<br><br><br><br>and part of the corresponding
business code :<br><br>public class A {<br><br>
...<br><br> public String
getEComputed(){<br>
if(eComputed)<br>
return "true";<br>
else<br> return
"false";<br> }<br><br>
...<br><br> public void setE(int
e){<br> this.e =
e;<br> eComputed =
true;<br> }<br><br>
...<br><br>}<br><br><br><br>so, I expected that if the first rule
is activated, the second won't be. But according to my tests, the
two rule can be fired on the same object A.<br>While debugging, I
noticed the getEComputed method was only called once. I suppose
that I should write this :<br><br><br>rule "rule 1 -
1"<br> <br> salience
90<br> ruleflow-group
"rfg1"<br> when<br>
a : A(<br>
eComputed == "false",<br>
c <
15,<br> d
>= 75)
<br> then<br>
c.setE(0);<br>
c.setEComputed("true);<br>end<br><br><br><br>rule "rule 1 -
2"<br><br> salience 10<br>
ruleflow-group "rfg1"<br>
when<br> a :
A(<br>
eComputed == "false",<br>
c >= 15,<br>
d >=
75) <br>
then<br>
c.setE(1);<br>
c.setEComputed("true);<br>end<br><br>But I would prefer another
solution. Thanks for help.<br><br>
<hr>
Plus de 15 millions de français utilisent Windows Live Messenger !
<a href="http://www.windowslive.fr/messenger/" target="_blank">Téléchargez Messenger, c'est gratuit !</a>
</blockquote></blockquote><br>
<hr>
Plus de 15 millions de français utilisent Windows Live Messenger ! <a href="http://www.windowslive.fr/messenger/" target="_blank">Téléchargez
Messenger, c'est gratuit !</a> </blockquote></blockquote><br>
<hr>
Tous vos amis discutent sur Messenger, et vous ? <a href="http://www.windowslive.fr/messenger/" target="_blank">Téléchargez
Messenger, c'est gratuit !</a> </blockquote></blockquote><br>
<hr>
Tous vos amis discutent sur Messenger, et vous ? <a href="http://www.windowslive.fr/messenger/" target="_blank">Téléchargez Messenger,
c'est gratuit !</a> </blockquote>
</blockquote><br /><hr />Discutez gratuitement avec vos amis en vidéo ! <a href='http://www.windowslive.fr/messenger/' target='_new'>Téléchargez Messenger, c'est gratuit !</a></body>
</html>