So I think you have to use this construction:
rule "interest calculation"
no-loop
when
$account : Account( )
then
modify($account) {
setBalance((long)($account.getBalance() * 1.03) )
};
End
Mila
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Yaniv Itzhaki
Sent: Thursday, September 16, 2010 10:25 AM
To: Rules Users List
Subject: Re: [rules-users] URGENT - using lock-on-active or not
Thanks
I have number of rules between the 2 rules, I just sent, that can get other inputs that
affect my decision to fire the second rule and update again the case.
for example:
- at the beginning the case value is 80
- according to the first rule I update the case value to 40
- ....other rules...
- according to the previous rules I need to update again the case value - add 5 to the
last value (40 + 5), but I get 80 + 5, because to working memory was not updated with my
updates (change to 40).
Yaniv
2010/9/16 Michael Anstis <michael.anstis(a)gmail.com>
This is by design
http://lists.jboss.org/pipermail/rules-users/2009-March/008299.html
What are you trying to accomplish? There is no difference in the patterns you are matching
in both rules however you expect different consequences to occur based upon salience.
Based upon the foregoing link you could try changing one rule to be in a different
ruleflow-group however that could have other consequences.
2010/9/16 Yaniv Itzhaki <iyaniv(a)gmail.com>
Hi All,
I have an urgent problem which I hope someone can explain it to me and how it can be
solved.
I created 2 rules "Update 1" and "Update 2", basically the rules are
the same, get all the CaseLog objects according to "Category" and
"Value" and update the Case, which holds a list of CaseLogs, with a new object.
Note that in the update method I am updating the working memory by retracting the old log
and inserting the new one.
Now for the problem:
The problem is that on one hand, when I insert a new log line all rules without
lock-on-active re-fire. On the other hand, rules with lock-on-active seem to disregard the
addition of the new object and fire only on the lines that were present when their group
was activated.
Please see the rules below
Thanks
Yaniv
rule "Update 1"
salience 4
ruleflow-group "group1"
lock-on-active
when
$case : Case()
$myLog : CaseLog( myClass == "Category",
myValue == "1" )
then
System.out.println("Logic: Update 1");
$case.update($myLog,40.0,null);
end
rule "Update 2"
salience 0
ruleflow-group "group1"
lock-on-active
when
$case : Case()
$myLog : CaseLog( myClass == "Category",
myValue == "1", $score : myScore )
then
System.out.println("Logic: Update 2 " + $score + 5.0);
$case.update($myLog,$score + 5,null);
end
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users