when
$lesson : Lesson(allocated ==
false, session.type == Session.DISTINCT)$subjectAllocation : SubjectAllocation( subject == $lesson.subject, $allocatedDays : allocatedDays )
$availableHour : Hour(allocated ==
false, day not memberOf $allocatedDays) then$lesson.setHour($availableHour ) ;
$lesson.setAllocated(
true ) ; update($lesson) ;$availableHour.setSubject($lesson.getSubject() ) ;
$availableHour.setAllocated(
true ) ; update($availableHour) ;$subjectAllocation.addAllocation($availableHour ) ;
update($subjectAllocation) ;rule
when
$lesson : Lesson(allocated == false, session.type == Session.DISTINCT )
$subject : Subject( $allocatedDays :
allocatedDays ) from $lesson.subject
$availableHour : Hour(allocated == false, day not memberOf $allocatedDays)
then
modify( $lesson) {
setHour($availableHour
),
setAllocated(true)
}
modify( $availableHour )
setSubject($lesson.getSubject()),
setAllocated(true )
}
end
Hi all,I am evaluating Drools and am stuck with a simple rule that selects elements which do not correspond to the condition... Since I am updating objects in the RHD, I guess it has to do with my wrong understanding (and the cache...?)I am trying to allocate lessons to periods (hour). My object model can be summarize is as follows :Lessonboolean : allocated // true if the lesson has been allocated to an hourint : session // a session is a bunch of lessonsSubject : subject // an allocated lesson is assigned a subjectSubjectSet<Day> : allocatedDays // days in which this subject is taught - checked before allocation, as a subject can only be taught once a dayHourboolean : allocated // true is this hour has been allocated with a lessonDay : day // the day this hour belongs to - required to check with subject.allocatedDaysI put in the workingMemory a bunch of Lesson objects, which have been set with Subject and Session id. I also put a bunch of Hour object, set with a Day.My rule is as follows:rule
"allocate"when
$lesson : Lesson(allocated == false, session.type == Session.DISTINCT, $allocatedDays : subject.allocatedDays)
$availableHour : Hour(allocated == false, day not memberOf $allocatedDays)
then
$lesson.setHour($availableHour ) ;
$lesson.setAllocated(true) ;
update($lesson);
$availableHour.setSubject($lesson.getSubject()) ;
$availableHour.setAllocated(true );
update($availableHour);
end
When I set a debug on the first line of the THEN section, I can see that sometimes $availableHour.allocated == true ... sometimes $lesson.allocated == true (although it's an implicit And statement ...)Therefore, I can see that the update() works, but it seems that the rule does not use the updated object (due to shallow copy ??)
Any help more than welcome
Regis
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users