Thats a clever suggestion,
Another way (more brute force procedural), is to use agenda-groups.
So most of your rules are in an agenda-group called "calculateDate" or
similar.
You then have a group called "deftault" which just has the rule that checks
if the date is still null, and sets it.
You then (from the api) do
workingMemory.setFocus("calculateDate");
workingMemory.setFocus("default");
workingMemory.fireAllRules();
or similar.
In the next release, we are looking at including an "Otherwise()"
functionality for this, so you have a rule that declares that it will fire
only if no other rules did.
I have a prototype implementation of that in trunk.
So lots of options, I think the agenda group may be a little too verbose
though, I liked Michael's suggestion in a previous email.
Michael.
On 1/9/07, Michael Suzio <msuzio(a)gmail.com> wrote:
One way around this is to set the high-salience "default" rule to also
trigger on the non-existence of some "marker" object. Then, in the
consequence, you can always assert a new instance of that object, which then
effectively blocks the rule from triggering again. If you want it to
automatically manage itself, you may be able to do an assertLogical on the
marker object and then it will get removed when the business object gets
retracted.
So, something like this maybe:
rule "Pre"
salience 10
when
$bo: BusinessObject(targetDate != null)
!Marker()
then
assertLogical(new Marker());
Date tmp = null;
$bo.setTargetDate(tmp);
modify($bo);
end
I've had to do that sort of stuff before to handle edge cases like this.
--- Michael
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users