Davide is correct, for our analysis to work, the constraint must not be inside an eval,
and any constraint that does not start with a field name is internally rewritten as an
eval.
Mark
On 11 Jun 2014, at 18:48, Davide Sottara <dsotty(a)gmail.com> wrote:
I think I know what is happening here.
I assume your supportFT class is @propertyReactive.
(btw, you should follow bean conventions and capitalize class names)
Looking at Rule 1, you don't set the value directly, but you do it through
a modify. Your rule 2, which checks for the value, uses the function
"containsAny"
rather than the field direclty as in "value IN (..)".
At the moment, the engine has no way to realize that the function
involves the field "value" - I'm not even sure it is possible in general -
Property reactivity will ignore the update since, from its perspective, none
of the fields relevant to the rule has been affected, hence rule 2 will
not hit.
If you use eval in the constraint, property reactivity is disabled, so
the rule
WILL fire the first time, but now you are vulnerable to infinite loops,
as if
you did not have propertyreactive.
You may have to use the @watch() annotation explicitly to control which
modifies will cause reevaluations and which ones won't (see the manual
for this)
Adding "eval" everywhere is not a good idea.
Best,
Davide
On 06/11/2014 01:53 PM, brachi wrote:
> example of rule that doesn't work without eval:
>
> /* rule "1"
> salience -1
> agenda-group "agenda1"
> when
> $conclusion: supportFT()
> then
> if($conclusion.getValue()==null){
> modify($conclusion) { setValue(new ArrayList())};
> }
> $conclusion.getValue().add("supportedValue");
> modify($conclusion) { setValue($conclusion.getValue()) };
> end
>
>
> rule "2"
> salience -2
> agenda-group "agenda2"
> when
> supportFT(Operators.containsAny(value,new
> String[]{"supportedValue","otherValue"}))
> $conclusion: ConclusionFt()
> then
> modify($conclusion){setValue("success")};
> end*/
>
> rule "2" doesn't hit, works only with eval in rule "2".
> in this example I can add eval, because the Fact Types model is different,
> so the rule doesn't reevaluated.
> because I had this case, I decided to add eval for all constraints, but
> unfortunately I had an infinite loop.
>
>
>
>
> --
> View this message in context:
http://drools.46999.n3.nabble.com/Adding-eval-on-rule-cause-it-to-run-in-...
> 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
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users