Hi all,
It seems to me that the no-loop only prevents a rule from triggering
itself - and doesn't make the rule only fire once (which is what I'm
after)
e.g. consider the following two contrived simple rules:
rule "addPriorityPrefix"
dialect "java"
no-loop true
when
$work : Work (priority >= 200)
then
modify($work) {
setTitle("!!! " + getTitle());
};
end
rule "re-assign low priority tasks"
dialect "java"
no-loop true
when
$work : Work (priority < -200)
then
modify($work) {
setOwner("nobody");
};
end
What I end up with is an infinte loop.
Whilst for the simple case I can re-write them like
$work : Work (priority >= 200, !title.startWith("!!!"))
however with the more complex rules this makes the rules get very
complex quickly and less easy to write. Is there a way to prevent these
loops - have I misunderstood or do you really need to check everything
in the rule that you may set?
How would you do the banking interest example?
rule "interest calculation"
no-loop
when
$account : Account( )
then
modify($account) {
setBalance((long)($account.getBalance() * 1.01) )
};
end
if there was another rule that if you where a gold customer and payed in
$500 the previous month then you get $4 bonus?
rule "gold bonus"
no-loop
when
$account : Account(type="gold", previousMonthDeposit > 500 )
then
modify($account) {
setBalance((long)($account.getBalance() + 4) )
};
end
Regards,
/James
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received
this message in error, please immediately notify the postmaster(a)nds.com and delete it from
your system as well as any copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes. To protect the environment please
do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United
Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603
8808 40-00
**************************************************************************************