<br>   Don&#39;t tell anyone, but I was a naughty boy yesterday... I was in the middle of a huge change and could not commit stuff because I was waiting for a fix from someone else, and then I decided to use the time and sneaked in the fix for this problem with the code I was committing. I will still create the JIRA for documentation purposes, but the fix is in there... in case you want to give a try.<br>
<br>   Regarding agenda-groups, you should not do that. I know the legacy API does not prevent you from doing it, but the results are unpredictable. The compiled model is supposed to be immutable. As we move away from the legacy API, this will not be allowed anymore.<br>
<br>   []s<br>   Edson<br><br><div class="gmail_quote">2009/2/25 Guy <span dir="ltr">&lt;<a href="mailto:guyt1122@aim.com">guyt1122@aim.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">Edson Tirelli &lt;tirelli &lt;at&gt; <a href="http://post.com" target="_blank">post.com</a>&gt; writes:<br>
<br>
&gt;<br>
&gt;<br>
&gt;    Well found! Thanks for reporting. I will fix and let you know.  <br>
</div>Edson2009/2/23  &lt;guyt1122 &lt;at&gt; <a href="http://aim.com" target="_blank">aim.com</a>&gt;<br>
<div><div></div><div class="Wj3C7c">&gt; Hi,<br>
&gt;<br>
&gt;<br>
&gt; I&#39;m using Drools 5.0M5 and Web Guided decision tables. What I want to be able<br>
to do is to create several decision tables under one package and then using an<br>
Agenda filter and firelimit option to fire one rule from a single decision table<br>
that I&#39;m filtering.<br>
&gt; What I did to try and accomplish this is the following.  I notice that each<br>
row in the decision table has a rule name that matches the following format:<br>
&quot;Row 1 DecisionTableName&quot;, &quot;Row 2 DecisionTableName&quot; ... &quot;Row N<br>
DecisionTableName&quot;, so I create a RuleNameEndsWithAgendaFilter agenda filter to<br>
only accept rules that ends with &quot;DecisionTableName&quot;. Then I call on the<br>
StatefulSession.fireAllRules(AgendaFilter, fireLimit) with my agenda filter and<br>
a firelimit of 1.<br>
&gt; What I&#39;m noticing is some inconsistent behavior were the logic would work<br>
sometimes and not other times.  It seems to always works if there is a single<br>
decision table under the package.  After debuging the<br>
StatefuleSession.fireAllRules(AgendaFilter, firelimit), I tracked down the issue<br>
to the way the firelimit count updated in the<br>
&quot;DefaultAgenda.fireAllRules(AgendaFilter, fireLimit)&quot; and with the<br>
&quot;DefaultAgenda.fireNextItem(AgendaFilter)&quot;.<br>
&gt; I may have misunderstood what the firelimit meant but it seems like the while<br>
loop in the fireAllRules always decrements the firelimit count regardless if the<br>
DefaultAgenda.fireNextItem(AgendaFilter) calls the fireActivation method or the<br>
fireActivationCancelled method.  I would perfer the firelimit count to only get<br>
decremented if the fireNextItem results in a fireActivation method call and I<br>
think the logic will work for my scenario.  Looking at the documenation, it look<br>
like the logic is geared towards focusing agenda groups, but I do not want to<br>
have maintain a agenda group column on my decision tables.  I want each decision<br>
table to be an agenda group automagically.<br>
&gt; I have included the following code showing the firelimit is always updated in<br>
the while loop below:<br>
&gt;     public int fireAllRules(AgendaFilter agendaFilter,<br>
&gt;                             int fireLimit) {<br>
&gt;         this.halt.set( false );<br>
&gt;         int fireCount = 0;<br>
&gt;         while ( continueFiring( fireLimit ) &amp;&amp; fireNextItem( agendaFilter ) ) {<br>
&gt;             fireCount++;<br>
&gt;             fireLimit = updateFireLimit( fireLimit );<br>
&gt;             this.workingMemory.executeQueuedActions();<br>
&gt;         }<br>
&gt;         if ( this.focusStack.size() == 1 &amp;&amp; getMainAgendaGroup().isEmpty() ) {<br>
&gt;             // the root MAIN agenda group is empty, reset active to false, so<br>
it can receive more activations.<br>
&gt;             getMainAgendaGroup().setActive( false );<br>
&gt;         }<br>
&gt;         return fireCount;<br>
&gt;     }<br>
&gt;<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt;<br>
&gt; Guy<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; rules-users mailing listrules-users &lt;at&gt;<br>
lists.jboss.orghttps://<a href="http://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">lists.jboss.org/mailman/listinfo/rules-users</a><br>
<div class="Ih2E3d">&gt;<br>
&gt;<br>
&gt; --   Edson Tirelli  JBoss Drools Core Development  JBoss, a division of Red<br>
</div>Hat  &lt;at&gt;  <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; rules-users &lt;at&gt; <a href="http://lists.jboss.org" target="_blank">lists.jboss.org</a><br>
<div class="Ih2E3d">&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
<br>
</div>Hi Edson,<br>
<br>
Thanks for your reply.  Will you create a Jira ticket for this issue?<br>
<br>
Also, I found a work around for my scenario let me know if it is advisable to<br>
update Rule at runtime. I&#39;m iterating overall of the rules in the packages and<br>
setting the agenda group name to the rule name, sans the &quot;Row N&quot;.  Then before<br>
firingAllRules, focus the agenda group that matches the decision table I want to<br>
evaluate.<br>
<br>
Code:<br>
<br>
// Get the rulebase<br>
RuleBase ruleBase = ruleAgent.getRuleBase();<br>
<br>
// Iterate over package and rules to update the agenda group name<br>
for(Package package : ruleBase.getPackages()) {<br>
   int total = package.getRules().length();<br>
   for (Rule rule : package.getRules()) {<br>
      rule.setAgendaGroup(parseRuleName(rule.getName()));<br>
      rule.setSalience(new SalienceInteger((int) ((total - rule.getLoadOrder())<br>
+ 1));<br>
   }<br>
}<br>
<br>
// Create the new stateful session<br>
StatefulSession statefulSession = ruleBase.newStatefulSession();<br>
try {<br>
  // Insert the facts.<br>
  statefulSession.insert(fact);<br>
  // Focus the appropriate agenda group...<br>
  statefulSession.focus(theDecisionTableName);<br>
  // Fire the rules with agenda filter and firelimit.<br>
  statefulSession.fireAllRules(new<br>
RuleNameEndsWithAgendaFilter(theDecisionTableName, true), 1);<br>
} finally {<br>
  // Dispose of the session when done.<br>
  statefulSession.dispose();<br>
}<br>
<br>
Thanks,<br>
Guy<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
<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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>