[rules-users] Please help me to fix the AgendaFilter related issue

Wolfgang Laun wolfgang.laun at gmail.com
Mon Aug 23 08:45:52 EDT 2010


The error message says Stateful*Rule*Session, but I'd say you have a
Stateful*Knowledge*Session ksession.

Do a cast:
   org.drools.runtime.rule.StatefulRuleSession sfrs =
(org.drools.runtime.rule.StatefulRuleSession)ksession;
and use this one for firing all rules with an agenda filter.

-W


On 23 August 2010 14:32, Sanjib Karmakar <sanjibk at skytechsolutions.co.in>wrote:

>
> import org.drools.runtime.StatefulKnowledgeSession;
> import org.drools.spi.Activation;
> import org.drools.spi.AgendaFilter;
>
>
> .
> .
> .
>
>   KnowledgeBuilder kbuilder =
> KnowledgeBuilderFactory.newKnowledgeBuilder();
>   kbuilder.add(
>                ResourceFactory.newClassPathResource(resourceIndicator),
>                ResourceType.XDRL
>              );
>   KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
>   kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
> .
> .
> .
>
>   public Object getSpecificRuleReport(
>                                Object requestDTO,
>                                Object responseDTO,
>                                final String ruleAry[]
>                                 )
>   throws Exception
>   {
>      AgendaFilter agendafilter =
>            new StatefulKnowledgeSessionImpl.AgendaFilterWrapper(null)
>        {
>            public boolean accept(Activation activation)
>            {
>               boolean returnFlag = false;
>               int ruleArySize = ruleAry.length;
>
>                    for (int cnt=0; cnt<ruleArySize; cnt++)
>                 {
>                if (activation.getRule().getName().equals(ruleAry[cnt]))
>                        returnFlag =  false;
>                else
>                        returnFlag =  true;
>                 }
>
>                return returnFlag;
>            }
>        };
>
>        try
>         {
>            ksession.insert(requestDTO);
>            ksession.insert(responseDTO);
>            ksession.fireAllRules(agendafilter);
>         }catch(Exception t)
>          {
>             _logger.error(t.getMessage()+"\n"+t);
>          }
>
>        return responseDTO;
>     }
>
> Eclipse is showing that there is a method fireAllRules() which takes
> AgendaFilter as a parameter
> but I am getting error "The method fireAllRules(int) in the type
> StatefulRuleSession is not applicable for the arguments (AgendaFilter)" at
> 'ksession.fireAllRules(agendafilter);'
>
> I am trying to execute specific rules out of set of rules. Please help me
> to
> fix this issue.
>
>
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Please-help-me-to-fix-the-AgendaFilter-related-issue-tp1289855p1289855.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100823/d2e1fd3c/attachment.html 


More information about the rules-users mailing list