[jboss-jira] [JBoss JIRA] (DROOLS-365) Rule attribute for adding inverse of consequence as rule condition

Adar Dembo (JIRA) jira-events at lists.jboss.org
Thu Dec 5 19:26:05 EST 2013


Adar Dembo created DROOLS-365:
---------------------------------

             Summary: 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


More information about the jboss-jira mailing list