<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
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="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>
<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"><span class="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_694480211-11042008"><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span class="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_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_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_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_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_694480211-11042008"></span> </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 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_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_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_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_287464408-11042008"><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span class="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_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='_new'>Téléchargez Messenger, c'est gratuit !</a></body>
</html>