Let the rule engine do what it does best. You are fighting against the optimizations of the engine by trying to control the flow. You can rewrite your rule as<div><br></div><div>rule &quot;my-rule&quot;</div><div> when</div>
<div>  $entity : Entity( closed == false )</div><div> then</div><div>  modify($entity) { setClosed(true); }</div><div>end</div><div><br></div><div>The rule will fire (once) for each Entity which matches the condition. I haven&#39;t taken the time to apply the same exercise to your more complex rule, but a general rule you should abide by is &quot;No looping in the consequence unless I have a really good reason.&quot;</div>
<div><br></div><div>Mike</div><div><br></div><div><br><div class="gmail_quote">2012/3/13 Patrik Dufresne <span dir="ltr">&lt;<a href="mailto:ikus060@gmail.com">ikus060@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<div><br></div><div>I have some trouble to figure out how to stop / start the propagation of updates within a Then block.</div><div>Here is a snippet to represent the problem I have.</div><div><br></div><div>rule &quot;my-rule&quot;</div>

<div>    when</div><div>        $objects : List()</div><div>                from accumulate( $entity : Entity(closed==false), collectList($entity) )<br></div><div>    then<br></div><div>        for(Object obj : $objects) {</div>

<div>            ((Entity) obj).setClosed(true);<br></div><div>            update(obj);<br></div><div>        }</div><div>end</div><div><br></div><div>When this rule&#39;s consequence is called first, the first enity in the list is &#39;update&#39;, but then update if propagated to immediately causing the rule to be evaluated with all the entities minus the updated one. So I&#39;m wondering if there is a transaction like operation allowing me to update all the entities in the list and then fire the rules.</div>

<div><br></div><div>According to the documentation no-loop should have help me for this.</div><div><br></div><div>Here is the original rules</div><div><div>rule &quot;close-shift&quot;</div><div><span style="white-space:pre-wrap">        </span>salience -1</div>

<div><span style="white-space:pre-wrap">        </span>when</div><div><span style="white-space:pre-wrap">                </span>$shift : Shift( )</div><div><span style="white-space:pre-wrap">                </span>$assignments : List( size &gt; 0 )</div>
<div><span style="white-space:pre-wrap">                                </span>from accumulate (</div><div><span style="white-space:pre-wrap">                                        </span>$assignment : PlanifEventAssignment( </div><div><span style="white-space:pre-wrap">                                                </span>close == false, </div>

<div><span style="white-space:pre-wrap">                                                </span>shift == $shift ),</div><div><span style="white-space:pre-wrap">                                        </span>collectList($assignment) )</div><div><span style="white-space:pre-wrap">                </span>$availables : List( size &gt;= $assignments.size )</div>

<div><span style="white-space:pre-wrap">                                </span>from accumulate ( ( and</div><div><span style="white-space:pre-wrap">                                        </span>ShiftAssignment(</div><div><span style="white-space:pre-wrap">                                                </span>shift == $shift,</div>

<div><span style="white-space:pre-wrap">                                                </span>$employee : employee)</div><div><span style="white-space:pre-wrap">                                        </span>$available : EmployeeAvailable (</div><div><span style="white-space:pre-wrap">                                                </span>employee == $employee,</div>

<div><span style="white-space:pre-wrap">                                                </span>assignment.shift == $shift) ),</div><div><span style="white-space:pre-wrap">                                        </span>collectList($available) )</div><div><span style="white-space:pre-wrap">                </span>eval( Dfs.search($assignments, $availables) != null )</div>

<div><span style="white-space:pre-wrap">        </span>then</div><div><span style="white-space:pre-wrap">                </span>// Recalculate the result.</div><div><span style="white-space:pre-wrap">                </span>Map table = Dfs.search($assignments, $availables);</div>

<div><span style="white-space:pre-wrap">                </span>for(Object entry : table.entrySet()) {</div><div><span style="white-space:pre-wrap">                        </span>PlanifEventAssignment assignment = (PlanifEventAssignment)((Entry)entry).getKey();</div>

<div><span style="white-space:pre-wrap">                        </span>EmployeeValue employee = (EmployeeValue)((Entry)entry).getValue();</div><div><span style="white-space:pre-wrap">                        </span>assignment.setClose(true);</div>
<div><span style="white-space:pre-wrap">                        </span>assignment.setEmployee(employee);</div><div><span style="white-space:pre-wrap">                        </span>update(assignment);</div><div><span style="white-space:pre-wrap">                </span>}</div>

<div>end</div></div><span class="HOEnZb"><font color="#888888"><div><br></div><div><br></div><div>Patrik Dufresne<br>
</div>
</font></span><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br></div>