Hi,

I have some trouble to figure out how to stop / start the propagation of updates within a Then block.
Here is a snippet to represent the problem I have.

rule "my-rule"
    when
        $objects : List()
                from accumulate( $entity : Entity(closed==false), collectList($entity) )
    then
        for(Object obj : $objects) {
            ((Entity) obj).setClosed(true);
            update(obj);
        }
end

When this rule's consequence is called first, the first enity in the list is 'update', but then update if propagated to immediately causing the rule to be evaluated with all the entities minus the updated one. So I'm wondering if there is a transaction like operation allowing me to update all the entities in the list and then fire the rules.

According to the documentation no-loop should have help me for this.

Here is the original rules
rule "close-shift"
salience -1
when
$shift : Shift( )
$assignments : List( size > 0 )
from accumulate (
$assignment : PlanifEventAssignment( 
close == false, 
shift == $shift ),
collectList($assignment) )
$availables : List( size >= $assignments.size )
from accumulate ( ( and
ShiftAssignment(
shift == $shift,
$employee : employee)
$available : EmployeeAvailable (
employee == $employee,
assignment.shift == $shift) ),
collectList($available) )
eval( Dfs.search($assignments, $availables) != null )
then
// Recalculate the result.
Map table = Dfs.search($assignments, $availables);
for(Object entry : table.entrySet()) {
PlanifEventAssignment assignment = (PlanifEventAssignment)((Entry)entry).getKey();
EmployeeValue employee = (EmployeeValue)((Entry)entry).getValue();
assignment.setClose(true);
assignment.setEmployee(employee);
update(assignment);
}
end


Patrik Dufresne