[
https://issues.jboss.org/browse/DROOLS-365?page=com.atlassian.jira.plugin...
]
Davide Sottara commented on DROOLS-365:
---------------------------------------
I see what you are trying to do, but I am not sure that such an attribute would be
feasible, or even solve your problem.
What happens if a rule inserts (and modifies, and retracts...) more than one object? And
what happens if the same object
is insert by more than one rule?
Have you tried using the EQUALITY assertion behavior and/or the @propertyReactive
annotation? The former considers
equivalent (i.e. equals()) object to be the "same" and thus do not activate
rules multiple times, regardless of the rule
that generated the objects. The latter allows you to control how rules fire in case of
updates.
Best
Davide
Rule attribute for adding inverse of consequence as rule condition
------------------------------------------------------------------
Key: DROOLS-365
URL:
https://issues.jboss.org/browse/DROOLS-365
Project: Drools
Issue Type: Feature Request
Security Level: Public(Everyone can see)
Affects Versions: 5.5.0.Final
Reporter: Adar Dembo
Assignee: Mark Proctor
I have quite a few rules that look like this:
{noformat}
rule "if foo then bar"
when
Foo($a : a, $b : b)
not Bar(a == $a, b == $b)
then
insert(new Bar($a, $b));
end
{noformat}
This is a fairly common pattern for me: a rule should not activate if the facts generated
by its consequence were already asserted. It's a pattern I use extensively to generate
linear (i.e. non-repeating) workflows.
Ideally I'd be able to express it as follows:
{noformat}
rule "if foo then bar"
condition-on-inverse-of-consequence
when
Foo($a : a, $b : b)
then
insert(new Bar($a, $b));
end
{noformat}
And {{condition-on-inverse-of-consequence}} would cause Drools to generate the right kind
of condition, which would be the inverse of the fact changes made by the consequence.
I think {{lock-on-active}} is similar but harsher: it prevents the rule from firing a
second time altogether, regardless of input. At least, that's based on my reading of
the docs. In my example, that would be equivalent to {{not Bar()}} condition in the rule,
which is stricter than {{not Bar(a == $a, b == $b)}}.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira