session.getAgenda().getAgendaGroup("Phase1").setFocus();
auto-focus automatically sets the focus when the rule is activated, but
that might not be what you want...
Edson
2009/11/3 Rongala, Kanthi <Kanthi.Rongala(a)mscibarra.com>
Hi,
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)
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.
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
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.
Code is given below:
package com.mscibarra.examples.drools.controllers;
import com.mscibarra.examples.drools.domainentities.*;
rule "Detect and Remove Duplicate Shelves"
agenda-group "Phase1"
//lock-on-active
dialect "mvel"
auto-focus
when
$universe : LibraryUniverse()
$shelf : Shelf() from $universe.shelves
$shelf2 : Shelf(this != $shelf) from $universe.shelves
then
System.out.println("Duplicate Shelves found::"+$shelf);
// without the modify(), drools is not alerted about changes
/*
modify($universe) {
shelves.remove($shelf);
};
*/
end
rule "Singleton Shelf Detector"
agenda-group "Phase2"
//lock-on-active
dialect "mvel"
auto-focus
when
$universe : LibraryUniverse(shelves.size > 1)
then
System.out.println("Multiple Shelves
found::"+$universe.shelves.size);
end
With Regards,
Swaroop
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
Message: 3
Date: Mon, 2 Nov 2009 10:51:32 -0500
From: Edson Tirelli <ed.tirelli(a)gmail.com>
Subject: Re: [rules-users] Agenda Groups basic question
To: Rules Users List <rules-users(a)lists.jboss.org>
Message-ID:
<e6dd5ba30911020751nb973184r73cd6dc46e4e50c0(a)mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"
You need to set the focus for an agenda group to execute.
[]s
Edson
2009/11/2 Rongala, Kanthi <Kanthi.Rongala(a)mscibarra.com>
> Hi,
>
>
>
> I am new to Drools and trying my hands out at Drools 5. I cann?t figure
out
> how to use agenda- groups. I have a small drl file with two agenda groups
> and one rule per agenda-group. This doesn?t seem to work. However if I
> happen to comment out the agenda-group attribute, the results are as
> expected.
>
>
>
> Please let me know what I am missing.
>
>
>
> *package* com.mscibarra.examples.drools.controllers;
>
>
>
> *import* com.mscibarra.examples.drools.domainentities.*;
>
>
>
>
>
> *rule* "Detect and Remove Duplicate Shelves"
>
> *agenda-group* "Phase1"
>
> *lock-on-active*
>
> *dialect* "mvel"
>
> *when*
>
> $universe : LibraryUniverse()
>
> $shelf : Shelf() *from* $universe.shelves
>
> $shelf2 : Shelf(*this* != $shelf) *from*$universe.shelves
>
> *then*
>
> System.out.println("Duplicate Shelves found::"+$shelf);
>
> // without the modify(), drools is not alerted about changes
>
> // $universe.shelves.remove($shelf);
>
> /*
>
> *modify*($universe) {
>
> shelves.remove($shelf);
>
> };
>
> */
>
>
>
> *end*
>
>
>
> *rule* "Singleton Shelf Detector"
>
> *agenda-group* "Phase1"
>
> *lock-on-active*
>
> *dialect* "mvel"
>
> *when*
>
> $universe : LibraryUniverse(shelves.size > 1)
>
> *then*
>
> System.out.println("Multiple Shelves
found::"+$universe.shelves.size);
>
>
> *End*
>
>
>
>
>
>
>
> With Regards,
>
> Kanthi Swaroop Rongala
>
> * *
>
>
>
> ------------------------------
> 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.
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @
www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.jboss.org/pipermail/rules-users/attachments/20091102/e88d48d...
------------------------------
Message: 4
Date: Mon, 2 Nov 2009 16:53:54 +0100
From: "Costigliola Joel \(EXT\)" <joel.costigliola-ext(a)natixis.com>
Subject: Re: [rules-users] Agenda Groups basic question
To: "'Rules Users List'" <rules-users(a)lists.jboss.org>
Message-ID:
<201216F96E6D724F9296BFACF6DB54641E54C88380(a)MSEUMAIL03.cib.net>
Content-Type: text/plain; charset="iso-8859-1"
Hello,
Maybe a typo mistake but both of your rules have the same agenda group
(Phase1)
Regards,
Joel
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.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users