Drools Experts:
I have a list of the following fact objects sent to my rules:
CrewSegment
Date startDate
Date endDate
double crewHours
int personId
along with an object to designate seats:
SeatAssignment
int seatId
int personId
Here is the rule I want to enforce in English: No crew member (uniquely identified by personId) can have more than 56 hours of total crewHours in any 7 day period. The rule I've written so far is:
when
$s : SeatAssignment ( )
$total : Number( doubleValue > 56 )
from accumulate( CrewSegment( personId == $s.personId, $crewHours : crewHours ),
sum( $crewHours ) )
This rule nicely catches any instance where more than 56 hours are committed by a person, but does not limit the time period to 7 days.
How do I limit the search to be sure that it is 56 hours WITHIN 7 days, and not just 56 hours total over ANY time period?
Thanks in advance for any help you can provide!!!
Bill