OK: If your rules are looping, it suggests that you may have written them
badly. (EG:
rule rule1
when
ObjectA ( $property : property==null )
then
$property = 12;
update (ObjectA);
end
rule rule2
when
ObjectA ( $property : property!=null )
then
$property = null;
update (ObjectA);
end
Try breaking things down into Ruleflow Groups so that each logically
separated section leads into the next.
Another way of handling this is do not have Update calls in your rules.
Instead I attach listeners to each part of the fact model - the listeners
call Update for me.
If I want to prevent loops? I simply disable the listeners.
On the current project I'm doing I've done a combination of both of these,
and it works well.
I hope this helps,
-Trav
Travis Smith
Analyst Programmer
Development Centre
BNZ
DDI: +644 4746356 (Or Ext 76356)
dbfree75 <wbismuth(a)yahoo.fr>
Sent by: rules-users-bounces(a)lists.jboss.org
25/05/2011 11:55 a.m.
Please respond to
Rules Users List <rules-users(a)lists.jboss.org>
To
rules-users(a)lists.jboss.org
cc
Subject
Re: [rules-users] Update function usage for java objects to be retrieved
for database update
I'm still using such solution .
Here an example of rule where I nees to set the
originalPropertyValuationLoan :
rule "OriginalPropertyValuationLoan - NbSecuredGaranteeUnderLoan >= 1 -
garantee H - postCode equivalent - initialValue equivalent"
no-loop
salience 970
dialect "mvel"
when
$controlFact : ControlFact(phase ==
"INITIAL")
$loanEvaluated :
loanEvaluated(nbSecuredGaranteeUnderLoan >= 1,
originalPropertyValuationLoan == null)
$loan : loan() from $loanEvaluated.loan
$garantee : garantee(typegarantee.code ==
"H" , initialValue != null) from
$loan.garantees
$postCodes : Set(size == 1)
from accumulate(
garantee(typegarantee.code == "H", $n
:
postCodeInGarantee) from $loan.garantees,
collectSet($n)
)
$garantees : Set(size == 1)
from accumulate(
garantee(typegarantee.code == "H" ||
typegarantee.code == "O", $n : typegarantee.code) from $loan.garantees,
collectSet($n)
)
$initialValue : Set(size == 1)
from accumulate(
garantee(typegarantee.code == "H", $n : initialValue ) from
$loan.garantees,
collectSet($n)
)
then
$loanEvaluated.originalPropertyValuationLoan =
$garantee.initialValue
update($loanEvaluated)
#System.out.println("OriginalPropertyValuationLoan -
NbSecuredGaranteeUnderLoan > 1 : " +
$loan.loanEvaluated.originalPropertyValuationLoan);
end
In case this rule isn't fired because any of these conditions isn't set,
on
update after any other property has been set this rule will be fired
again
--
View this message in context:
http://drools.46999.n3.nabble.com/Update-function-usage-for-java-objects-...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
CAUTION - This message may contain privileged and confidential information
intended only for the use of the addressee named above. If you are not the
intended recipient of this message you are hereby notified that any use,
dissemination, distribution or reproduction of this message is prohibited.
This email was sent by the Bank of New Zealand. You can contact us on
0800 ASK BNZ (0800 275 269). Any views expressed in this message are those
of the individual sender and may not necessarily reflect the views of Bank
of New Zealand.