This is the way to implement an AgendaFilter so that you can use it with ksession.fireAllRules<br><br>import org.drools.runtime.rule.Activation;<br>import org.drools.runtime.rule.AgendaFilter;<br><br>public class MySimpleFilter implements AgendaFilter {<br>
// ... constructor etc.<br><br> public boolean accept(Activation item) {<br> return true; // change this, using constructor arguments ...<br> }<br> }<br> <br>AgendaFilter mySimplefilter = new MySimpleFilter(...);<br>
session.fireAllRules( mySimplefilter );<br><br>Through Activation you get at the rule and the rule name, and your accept method can be more sophisticated.<br><br>-W<br><br><br><div class="gmail_quote">2010/8/23 Sanjib Karmakar <span dir="ltr"><<a href="mailto:SanjibK@skytechsolutions.co.in">SanjibK@skytechsolutions.co.in</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;">
<br><font size="2" face="sans-serif">Sir</font>
<br>
<br><font size="2" face="sans-serif">I have modified according to your suggestion
but still I am getting the same error.</font>
<br><font size="2" face="sans-serif"><br>
Regards<br>
Sanjib Karmakar<br>
SkyTech Solutions Pvt. Ltd<br>
<br>
Please consider the environment before printing this email.</font>
<br>
<br>
<br>
<table width="100%">
<tbody><tr valign="top">
<td width="40%"><font size="1" face="sans-serif"><b>Wolfgang Laun <<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></b>
</font>
<br><font size="1" face="sans-serif">Sent by: <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a></font>
<p><font size="1" face="sans-serif">08/23/2010 06:15 PM</font>
</p><table border="1">
<tbody><tr valign="top">
<td bgcolor="white">
<div align="center"><font size="1" face="sans-serif">Please respond to<br>
Rules Users List <<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>></font></div></td></tr></tbody></table>
<br>
</td><td width="59%">
<table width="100%">
<tbody><tr valign="top">
<td>
<div align="right"><font size="1" face="sans-serif">To</font></div>
</td><td><font size="1" face="sans-serif">Rules Users List <<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>></font>
</td></tr><tr valign="top">
<td>
<div align="right"><font size="1" face="sans-serif">cc</font></div>
</td><td>
</td></tr><tr valign="top">
<td>
<div align="right"><font size="1" face="sans-serif">Subject</font></div>
</td><td><font size="1" face="sans-serif">Re: [rules-users] Please help me to
fix the AgendaFilter related issue</font></td></tr></tbody></table>
<br>
<table>
<tbody><tr valign="top">
<td>
</td><td></td></tr></tbody></table>
<br></td></tr></tbody></table><div><div></div><div class="h5">
<br>
<br>
<br><font size="3">The error message says Stateful<b>Rule</b>Session, but
I'd say you have a Stateful<b>Knowledge</b>Session ksession.<br>
<br>
Do a cast:<br>
org.drools.runtime.rule.StatefulRuleSession sfrs = (org.drools.runtime.rule.StatefulRuleSession)ksession;<br>
and use this one for firing all rules with an agenda filter.<br>
<br>
-W<br>
<br>
</font>
<br><font size="3">On 23 August 2010 14:32, Sanjib Karmakar <</font><a href="mailto:sanjibk@skytechsolutions.co.in" target="_blank"><font size="3" color="blue"><u>sanjibk@skytechsolutions.co.in</u></font></a><font size="3">>
wrote:</font>
<br><font size="3"><br>
import org.drools.runtime.StatefulKnowledgeSession;<br>
import org.drools.spi.Activation;<br>
import org.drools.spi.AgendaFilter;<br>
<br>
<br>
.<br>
.<br>
.<br>
<br>
KnowledgeBuilder kbuilder =<br>
KnowledgeBuilderFactory.newKnowledgeBuilder();<br>
kbuilder.add(<br>
ResourceFactory.newClassPathResource(resourceIndicator),<br>
ResourceType.XDRL<br>
);<br>
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();<br>
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());<br>
.<br>
.<br>
.<br>
<br>
public Object getSpecificRuleReport(<br>
Object requestDTO,<br>
Object responseDTO,<br>
final String ruleAry[]<br>
)<br>
throws Exception<br>
{<br>
AgendaFilter agendafilter =<br>
new StatefulKnowledgeSessionImpl.AgendaFilterWrapper(null)<br>
{<br>
public boolean accept(Activation
activation)<br>
{<br>
boolean returnFlag = false;<br>
int ruleArySize = ruleAry.length;<br>
<br>
for
(int cnt=0; cnt<ruleArySize; cnt++)<br>
{<br>
if (activation.getRule().getName().equals(ruleAry[cnt]))<br>
returnFlag = false;<br>
else<br>
returnFlag = true;<br>
}<br>
<br>
return returnFlag;<br>
}<br>
};<br>
<br>
try<br>
{<br>
ksession.insert(requestDTO);<br>
ksession.insert(responseDTO);<br>
ksession.fireAllRules(agendafilter);<br>
}catch(Exception t)<br>
{<br>
_logger.error(t.getMessage()+"\n"+t);<br>
}<br>
<br>
return responseDTO;<br>
}<br>
<br>
Eclipse is showing that there is a method fireAllRules() which takes<br>
AgendaFilter as a parameter<br>
but I am getting error "The method fireAllRules(int) in the type<br>
StatefulRuleSession is not applicable for the arguments (AgendaFilter)"
at<br>
'ksession.fireAllRules(agendafilter);'<br>
<br>
I am trying to execute specific rules out of set of rules. Please help
me to<br>
fix this issue.</font><font size="3" color="#888888"><br>
<br>
<br>
--<br>
View this message in context: </font><a href="http://drools-java-rules-engine.46999.n3.nabble.com/Please-help-me-to-fix-the-AgendaFilter-related-issue-tp1289855p1289855.html" target="_blank"><font size="3" color="blue"><u>http://drools-java-rules-engine.46999.n3.nabble.com/Please-help-me-to-fix-the-AgendaFilter-related-issue-tp1289855p1289855.html</u></font></a><font size="3" color="#888888"><br>
Sent from the Drools - User mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list</font><font size="3" color="blue"><u><br>
</u></font><a href="mailto:rules-users@lists.jboss.org" target="_blank"><font size="3" color="blue"><u>rules-users@lists.jboss.org</u></font></a><font size="3" color="blue"><u><br>
</u></font><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank"><font size="3" color="blue"><u>https://lists.jboss.org/mailman/listinfo/rules-users</u></font></a>
<br><font size="2"><tt>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
</tt></font>
<br></div></div><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>