I have a situation where I need to check for overlapping dates in a collection
of previous addresses. I am only performing this check after checking that
the beginDate and endDate are not null.
Currently I am using an eval to perform an outside method. Does anyone know
if and how I could perform this same check using Drools.
Curently my rules look something like this
gloabl java.lang.Boolean dateErrorExists; // starts off as false
global ValidationUtils utils;
rule "beginDate must exist"
when
Address ( beginDate != null )
then
dateMissing = true;
<display error>
end
rule "endDate must exist"
when
Address ( endDate != null )
then
dateMissing = true;
<display error>
end
rule "Previous Address dates cannot overlap"
salience -10
when
eval (dateMissing)
eval (utils.doAddressDatesOverlap())
then
<display error>
end
Our system simply runs thru the data checking the rules (no facts are changed)
so the dateMissing global is reset to false everytime we perform our
validation.
The downside to this is I am having to re-get the data from the DB within the
doAddressDatesOverlap() function. This function orders the Address objects by
their startDates and then compares the endDate of one with the startDate of
the next and returns false if they overlap.
If anyone knows of a cleaner, simpler or better way to perform this check
within Drools I would appreciate the input.
Thanks in advance,
Brian Enderle