[rules-users] Stateful Session giving major issues
Wolfgang Laun
wolfgang.laun at gmail.com
Sat Jan 26 06:40:22 EST 2013
On 26/01/2013, starfish15 <pooja.ghosh at accenture.com> wrote:
> Hello,
>
> I am using Drools 5.2. I am not sure why not able to find the result here.
> I am supposed to get the value from the Action in this rule as shown below.
> But its never found. Kindly assist me with what is it that i have'nt
> included.
You haven't included any proof that the three facts you insert
match the conditions for their properties: CD == "ES", EOC_IN == "Y",
IN == "N" and CMPG == 123, 01_NO == "12" and dummyCond == "result",
respectively.
-W
>
> First the rules
>
> //generated from Decision Table
> import boa.poc.java.SSI;
> import boa.poc.java.CMPG_REF;
> import boa.poc.java.Result_Rules;
> // rule values at C12, header at C7
> rule "Access sql table_12"
> when
> ssi : SSI(CD == "ES", EOC_IN == "Y", IN == "N")
> cmpgRef : CMPG_REF(CMPG == 123, 01_NO == "12")
> result : Result_Rules(dummyCond == "result")
> then
> result.setDummyAction("Access I");
> end
>
> Second the code
>
> @SuppressWarnings("rawtypes")
> public HashMap<String, List> retrievRuleResult(HashMap hm) {
> try {
> // load up the knowledge base
> KnowledgeBase kbase = readKnowledgeBase();
>
> SSI ssi = (SSI)hm.get("pa_cycle_ssi");
> CMPG_REF cmpRef = (CMPG_REF)hm.get("pa_cmpg_ref");
> Result_Rules rulesResult = (Result_Rules)hm.get("dummyCond");
>
> StatefulKnowledgeSession ksession =
> kbase.newStatefulKnowledgeSession();
> ksession.insert(ssi);
> ksession.insert(cmpRef);
> ksession.insert(rulesResult);
> ksession.fireAllRules();
> ksession.dispose();
>
> System.out.println("Result 1 : "+rulesResult.getDummyAction());
>
> return ;
> }
>
>
> public KnowledgeBase readKnowledgeBase() throws Exception {
>
> KnowledgeBuilder kbuilder =
> KnowledgeBuilderFactory.newKnowledgeBuilder();
>
>
> kbuilder.add(ResourceFactory.newClassPathResource("poc/rules/rules.pkg"),
> ResourceType.PKG);
> KnowledgeBuilderErrors errors = kbuilder.getErrors();
> if (errors.size() > 0) {
> for (KnowledgeBuilderError error: errors) {
> System.err.println(error);
> }
> throw new IllegalArgumentException("Could not parse knowledge.");
> }
> KnowledgeBase kbase = kbuilder.newKnowledgeBase();
>
> return kbase;
> }
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Stateful-Session-giving-major-issues-tp4021832.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list