[jboss-jira] [JBoss JIRA] (DROOLS-365) Rule attribute for adding inverse of consequence as rule condition
Jozef Marko (JIRA)
issues at jboss.org
Mon Jul 16 16:51:00 EDT 2018
[ https://issues.jboss.org/browse/DROOLS-365?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jozef Marko resolved DROOLS-365.
--------------------------------
Resolution: Done
> 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
> 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 was sent by Atlassian JIRA
(v7.5.0#75005)
More information about the jboss-jira
mailing list