Hey,
We have the following situation: Fact1 and Fact2 both have a 'score'
property. They also both have a 'month' property. When a Fact1 and a
Fact2 have the same month (at most there will only be one such pairing
for each month), a Fact3 is created with a score made from adding the
two base Facts scores:
rule "ExampleRule"
dialect "mvel"
when
Fact1( fact1Month : month, fact1Score : score > 0)
Fact2( month == fact1Month, fact2Score : score > 0)
then
Fact3 fact3 = new Fact3();
fact3.setScore( fact1Score + fact2Score);
insertLogical(fact3);
end
Our problem is that if fact1Score or fact2Score is now changed, a new
Fact3 with a new score is created, *but* the old Fact3 is of course
not removed - the conditions in its when still hold true as well (the
new score is still above 0).
Can anyone think of a way to make sure that if either fact1Score or
fact2Score is changed, then the old fact3 is removed from memory?
The only way we could at all think to do this is to add a timestamp to
fact3, and to have another rule that retracts old fact3s if there is
one with a newer timestamp and the same month... but it seems horribly
messy.
Thanks,
Stephen
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.