[rules-dev] Rule syntax to accumulate time segments over a limited set of date ranges

billhainaut at gmail.com billhainaut at gmail.com
Thu May 6 16:24:23 EDT 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20100506/e63b6fa2/attachment-0001.html 


More information about the rules-dev mailing list