I need to write a rule in Drools 6.5 that checks for the existence of an event of type A. There is a second class named B which has a field date
.
While checking for existence of an event A
, if at least one event of type B
exists, A
must happen after the latest B.date
in order for the rule to fire; otherwise the rule should fire regardless of any B
events.
Both event types of A
and B
have their own explicit timestamp field.
when
// TODO if at least one event of type B exists, A must happen after max(b.date). Otherwise, the rule must fire regardless of any B
$a : A( ... )
then
...
How do I perform this check?
EDIT: If no B
is present in the working memory, and A
meets the requirements, the rule must fire regardless.