Taken from the documentation:-
1.6.5.2. Agenda Groups
Agenda groups are a way to partition rules (activations, actually) on the
agenda. At any one time, only one group has "focus" which means that the
activations for rules in that group will only take effect - you can also
have rules "auto focus" which means the focus for its agenda group is taken
when that rules conditions are true.
They are sometimes known as "modules" in CLIPS terminology. Agenda groups
are a handy way to create a "flow" between grouped rules. You can switch the
group which has focus either from within the rule engine, or from the API.
If you rules have a clear need for multiple "phases" or "sequences"
of
processing, consider using agenda-groups for this purpose.
Each time setFocus(...) is called it pushes that Agenda Group onto a stack,
when the focus group is empty it is popped off and the next one of the stack
evaluates. An Agenda Group can appear in multiple locations on the stack.
The default Agenda Group is "MAIN", all rules which do not specify an Agenda
Group are placed there, it is also always the first group on the Stack and
given focus as default.
I would therefore assume that after all activations in the "Check" Agenda
Group executed, the MAIN Agenda Group received focus and remaining
activations processed.
_____
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of
prateek.katiyar(a)wipro.com
Sent: 03 October 2007 09:42
To: rules-users(a)lists.jboss.org
Subject: [rules-users] Help me
Hi
I hava a rule file as:
<?xml version="1.0" encoding="UTF-8"?>
<package name="rules"
xmlns="http://drools.org/drools-4.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
<import name="com.wipro.rfq.report.bean.Validator.RFQBean" />
<global identifier="rfq"
type="com.wipro.rfq.report.bean.Validator.RFQBean"
/>
<import name="com.wipro.loan.validation.bean.Final.LoanApplicationBean"
/>
<global identifier="loanApplication"
type="com.wipro.loan.validation.bean.Final.LoanApplicationBean" />
<rule name="Check_NotNullof_rfqId">
<rule-attribute name="agenda-group" value="Check"/>
<rule-attribute name="auto-focus" value="true"/>
<lhs>
<eval>(rfq.getM_rfqId() ==null) ||
(rfq.getM_rfqId().trim().equals(""))</eval>
</lhs>
<rhs>
System.out.println("The value of m_rfqId is null.");
</rhs>
</rule>
<rule name="Check_NotNullof_partId">
<rule-attribute name="agenda-group" value="Check"/>
<rule-attribute name="auto-focus" value="true"/>
<lhs>
<eval>(rfq.getM_partId() =="null") ||
(rfq.getM_partId().trim().equals(""))</eval>
</lhs>
<rhs>
System.out.println("The value of m_partId is null.");
</rhs>
</rule>
<rule name="validate_FullName">
<rule-attribute name="agenda-group" value="validate-bean"/>
<rule-attribute name="auto-focus" value="true"/>
<lhs>
<eval>true</eval>
</lhs>
<rhs>
System.out.println("full name is null from xml");
</rhs>
</rule>
</package>
As for the first two rules i declared the agenda group as "Check".
Now i want to know that how will i write the code in my java program to
activate this agenda group instead of "MAIN".
I have already tried with the following option:
Agenda agenda=workingMemory.getAgenda();
AgendaGroup Check=agenda.getAgendaGroup("Check");
workingMemory.setFocus(Check);
workingMemory.fireAllRules();
But after this when i wrote System.out.println("The focussed agenda group is
"+workingMemory.getFocus());
Then the output was The focussed agenda group is AgendaGroup 'MAIN'
So now could you please help me.
With Regards
Prateek
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain proprietary, confidential or privileged information. If you are not
the intended recipient, you should not disseminate, distribute or copy this
e-mail. Please notify the sender immediately and destroy all copies of this
message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The
company accepts no liability for any damage caused by any virus transmitted
by this email.
www.wipro.com