<br> session.getAgenda().getAgendaGroup("Phase1").setFocus();<br><br> auto-focus automatically sets the focus when the rule is activated, but that might not be what you want...<br><br> Edson<br><br><div class="gmail_quote">
2009/11/3 Rongala, Kanthi <span dir="ltr"><<a href="mailto:Kanthi.Rongala@mscibarra.com">Kanthi.Rongala@mscibarra.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
As suggested, I made the following changes, to get the desired output. I have some questions regarding the approach to agenda-groups (in drools 5 context)<br>
<br>
1. I had to enable auto-focus once per each agenda-group. I thought agenda-groups were stacked internally by drools engine, and auto-focus might be acting as a directional mechanism (help determine which rule under which agenda is to be triggered). Clearly, I am mistaken and it seems that auto-focus is the way to go.<br>
<br>
I would like to know about other ways to set focus on agenda-groups. I have seem code snippets on google bearing session.setFocus("[agenda-group-name]"). I am currently using statefulsession and cann't figure out this 'setFocus()' method<br>
<br>
2. I was 'compelled' to comment out lock-on-active directive. I understand that lock-on-active is an variant of no-loop causing each fact to be passed to the rule only once in a active agenda (correct me if I am mistaken). With lock-on-active set, I was expecting the messages to be print once atleast, but the current behavior beats me.<br>
<br>
Code is given below:<br>
<div class="im"><br>
package com.mscibarra.examples.drools.controllers;<br>
<br>
import com.mscibarra.examples.drools.domainentities.*;<br>
<br>
rule "Detect and Remove Duplicate Shelves"<br>
agenda-group "Phase1"<br>
//lock-on-active<br>
dialect "mvel"<br>
</div>auto-focus<br>
<div class="im">when<br>
$universe : LibraryUniverse()<br>
$shelf : Shelf() from $universe.shelves<br>
$shelf2 : Shelf(this != $shelf) from $universe.shelves<br>
then<br>
System.out.println("Duplicate Shelves found::"+$shelf);<br>
// without the modify(), drools is not alerted about changes<br>
</div> /*<br>
<div class="im"> modify($universe) {<br>
shelves.remove($shelf);<br>
};<br>
*/<br>
end<br>
<br>
rule "Singleton Shelf Detector"<br>
</div>agenda-group "Phase2"<br>
//lock-on-active<br>
dialect "mvel"<br>
auto-focus<br>
<div class="im">when<br>
$universe : LibraryUniverse(shelves.size > 1)<br>
then<br>
System.out.println("Multiple Shelves found::"+$universe.shelves.size);<br>
</div>end<br>
<br>
<br>
<br>
With Regards,<br>
Swaroop<br>
<br>
---------------------------------------------------------------------------------------------<br>
---------------------------------------------------------------------------------------------<br>
<br>
Message: 3<br>
Date: Mon, 2 Nov 2009 10:51:32 -0500<br>
From: Edson Tirelli <<a href="mailto:ed.tirelli@gmail.com">ed.tirelli@gmail.com</a>><br>
Subject: Re: [rules-users] Agenda Groups basic question<br>
To: Rules Users List <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
Message-ID:<br>
<<a href="mailto:e6dd5ba30911020751nb973184r73cd6dc46e4e50c0@mail.gmail.com">e6dd5ba30911020751nb973184r73cd6dc46e4e50c0@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="windows-1252"<br>
<div class="im"><br>
You need to set the focus for an agenda group to execute.<br>
<br>
[]s<br>
Edson<br>
<br>
2009/11/2 Rongala, Kanthi <<a href="mailto:Kanthi.Rongala@mscibarra.com">Kanthi.Rongala@mscibarra.com</a>><br>
<br>
</div><div><div></div><div class="h5">> Hi,<br>
><br>
><br>
><br>
> I am new to Drools and trying my hands out at Drools 5. I cann?t figure out<br>
> how to use agenda- groups. I have a small drl file with two agenda groups<br>
> and one rule per agenda-group. This doesn?t seem to work. However if I<br>
> happen to comment out the agenda-group attribute, the results are as<br>
> expected.<br>
><br>
><br>
><br>
> Please let me know what I am missing.<br>
><br>
><br>
><br>
> *package* com.mscibarra.examples.drools.controllers;<br>
><br>
><br>
><br>
> *import* com.mscibarra.examples.drools.domainentities.*;<br>
><br>
><br>
><br>
><br>
><br>
> *rule* "Detect and Remove Duplicate Shelves"<br>
><br>
> *agenda-group* "Phase1"<br>
><br>
> *lock-on-active*<br>
><br>
> *dialect* "mvel"<br>
><br>
> *when*<br>
><br>
> $universe : LibraryUniverse()<br>
><br>
> $shelf : Shelf() *from* $universe.shelves<br>
><br>
> $shelf2 : Shelf(*this* != $shelf) *from*$universe.shelves<br>
><br>
> *then*<br>
><br>
> System.out.println("Duplicate Shelves found::"+$shelf);<br>
><br>
> // without the modify(), drools is not alerted about changes<br>
><br>
> // $universe.shelves.remove($shelf);<br>
><br>
> /*<br>
><br>
> *modify*($universe) {<br>
><br>
> shelves.remove($shelf);<br>
><br>
> };<br>
><br>
> */<br>
><br>
><br>
><br>
> *end*<br>
><br>
><br>
><br>
> *rule* "Singleton Shelf Detector"<br>
><br>
> *agenda-group* "Phase1"<br>
><br>
> *lock-on-active*<br>
><br>
> *dialect* "mvel"<br>
><br>
> *when*<br>
><br>
> $universe : LibraryUniverse(shelves.size > 1)<br>
><br>
> *then*<br>
><br>
> System.out.println("Multiple Shelves found::"+$universe.shelves.size);<br>
><br>
><br>
> *End*<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
> With Regards,<br>
><br>
> Kanthi Swaroop Rongala<br>
><br>
> * *<br>
><br>
><br>
><br>
> ------------------------------<br>
> NOTICE: If received in error, please destroy and notify sender. Sender does<br>
> not intend to waive confidentiality or privilege. Use of this email is<br>
> prohibited when received in error.<br>
><br>
</div></div>> _______________________________________________<br>
> rules-users mailing list<br>
<div class="im">> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
</div><div class="im">> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>
><br>
<br>
<br>
--<br>
Edson Tirelli<br>
JBoss Drools Core Development<br>
JBoss by Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>
</div>-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.jboss.org/pipermail/rules-users/attachments/20091102/e88d48d7/attachment-0001.html" target="_blank">http://lists.jboss.org/pipermail/rules-users/attachments/20091102/e88d48d7/attachment-0001.html</a><br>
<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Mon, 2 Nov 2009 16:53:54 +0100<br>
From: "Costigliola Joel \(EXT\)" <<a href="mailto:joel.costigliola-ext@natixis.com">joel.costigliola-ext@natixis.com</a>><br>
Subject: Re: [rules-users] Agenda Groups basic question<br>
To: "'Rules Users List'" <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
Message-ID:<br>
<<a href="mailto:201216F96E6D724F9296BFACF6DB54641E54C88380@MSEUMAIL03.cib.net">201216F96E6D724F9296BFACF6DB54641E54C88380@MSEUMAIL03.cib.net</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<div class="im"><br>
Hello,<br>
<br>
Maybe a typo mistake but both of your rules have the same agenda group (Phase1)<br>
<br>
Regards,<br>
<br>
Joel<br>
<br>
</div><div class="im">NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.<br>
<br>
</div>_______________________________________________<br>
rules-users mailing list<br>
<div class="im"><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
</div><div><div></div><div class="h5"><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 by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>