Globals are intended to provide a way to pass values in and out of the
engine. Not for reasoning and exchange of values between rules.
Values that are changed by rules and are reasoned over are clearly facts
of your domain and should be modeled as such.
[]s
Edson
2007/6/14, Alexander Komissarov <aleks.komissarov(a)gmail.com>:
Hello,
Please give me advice for best way storing global variables.
global java.lang.Integer res;
global java.lang.Integer res2;
...
I've several number of rules. One rule has variable initialization e.g.:
...
rule "AmountsAreNotNull" salience 20
when
< conditions >
then
...
res = new Integer(a.compareTo(new BigDecimal(25)));
res = (res == -1)?0:res;
res = (res == -1)?0:res;
res2 = new Integer(a.compareTo(b));
res2 = (res2 == -1)?0:res2;
...
end
The values of these variables are proper and equal 1
Then next rule has comparing for res|res2 values, but they have lost their
values (res == null and res2 == null)
rule "CompareValues" salience 10
when
res:Integer(intValue == 0)
res2:Integer(intValue == 0)
result:List()
then
result.add(Boolean.TRUE);
end
What decision you can advise me to save variables value between rules?
Thanks.
____________________
Regards,
Komissarov Alexander
mail: aleks.komissarov(a)gmail.com
icq: 239128267
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @
www.jboss.com