[rules-users] Need help in formulating rule (using list)

psentosa psentosa at yahoo.com
Wed Nov 11 04:46:25 EST 2009


Hi Brody,

I have had similar situation several times, and each time I had to modify my
objects to avoid this, and it was really tedious.
I'd also would like to know whether it is possible to have a "real solution"
in this case without needing to change the base objects, but rather use the
rule language to formulate this kind of business rule

*why didn't I receive this mail through the mailing list? maybe you haven't
subscribed yet?*




Brody bach wrote:
> 
> Hi all,
> 
> I have an object which I use as main fact object, let's say "Schedule",
> which has a list of objects called "TimeEntry"  --->
> 
> class Schedule(){
>      List<TimeEntry> entries;
> }
> 
> class TimeEntry(){
>      String type; 
>      Date start;
>      Date end;
>      Integer length;
> }
> 
> 
> Now, if I insert Schedule into the WM, and would like to iterate over the
> list of TimeEntry, due to the following business rule :
> 
> For all time entries, if it is of type BREAK: 
> check whether a time entry of type WORK exist, 
> before and/or after this BREAK, which has only length of 10 minutes
> 
> The content of the time entry list has been sorted before so they are all
> in correct time order, e.g
> 
> 09:00 - 09:10  WORK (10 min)
> 09:10 - 09:30  BREAK (20 min)
> 09:30 - 10:30  WORK  (60 min)
> --> in this case, the rule should fire 
> 
> How can I define this rule? Some questions which I have:
> - how do I check previous and next element of the current element?
> - the length of the list isn't fix; it may contain 1, 2, or more entries.
> So somehow in an attempt to access next element, it should take care of
> the bound of the list. But should this be really part of the rule
> definition?
> 
> Many thanks in advance!
> 
> Regards
> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Need-help-in-formulating-rule-%28using-list%29-tp26284362p26298480.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list