I'm currently doing some fix on a java batch which run a set of Drools (yeuch!) rules.
The rule I have to fix is this:
rule "Insert a too old condition"
salience -1
when
$person : Person()
$tooOldInstant : DateTime() from now.minusDays(10)
DateTime( this < $tooOldInstant ) from accumulate (
LastData( $date : lastDate ) from $person.personLastDatas,
maxValue($date)
)
then
insert(new Condition("submitTooOldCondition"));
end
where for simplification Person is a simple bean with a personLastDatas Set<LastData> AND LastData has a org.joda.time.DateTime lastDate property.
Question: How do I insert a new condition where if $person.personLastDatas is null the rule apply?
Something like:
rule "Insert a too old condition modified"
salience -1
when
$person : Person()
$tooOldInstant : DateTime() from now.minusDays(10)
$maxLastDate : DateTime() from accumulate (
LastData( $date : lastDate ) from $person.personLastDatas,
maxValue($date)
)
($maxLastDate == null || $maxLastDate < $tooOldInstant)
then
insert(new Condition("submitTooOldCondition"));
end