[rules-users] inserted object now working

Joe White Joe.White at recondotech.com
Wed Mar 26 13:46:18 EDT 2014


You're inserting an object of type "TClaim" but your rule is written against "Claim". Change your rule to TClaim and maybe it will work.

From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Gopu Shrestha
Sent: Wednesday, March 26, 2014 11:40 AM
To: Rules Users List
Subject: Re: [rules-users] inserted object now working

Here is the console output..
......CategoryOfService---------15
......ProviderclaimNumber--130430007701
........Executing......message rule
Hello World
Goodbye cruel world
........Executing......message rule


From: rules-users-bounces at lists.jboss.org<mailto:rules-users-bounces at lists.jboss.org> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Gopu Shrestha
Sent: Wednesday, March 26, 2014 1:38 PM
To: Rules Users List
Subject: [rules-users] inserted object now working

I am struggling to identify why my another object (Claim) inserted into ksession is not working..
However, I tried the object Message() is working but not Claim(). I printed values of Claim Object its working but not in rule.

Where I missed??? Please help...

Here is the code.

     KnowledgeBase kbase = readKnowledgeBase();
            StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

            // go !
            Message message = new Message();
            message.setMessage("Hello World");
            message.setStatus(Message.HELLO);

            TClaim claim = loadFile();

              System.out.println("......CategoryOfService---------"+claim.getClaimIdentificationInfo().getCategoryOfService().getValue());//working
              System.out.println("......ProviderclaimNumber--"+claim.getClaimIdentificationInfo().getProviderClaimNumber().getValue()); //working

            ksession.insert(message);
            ksession.insert(claim);
            ksession.fireAllRules();

private static TClaim loadFile() throws JAXBException, FileNotFoundException {
       JAXBContext jaxbContext = JAXBContext.newInstance("com.sample");
              Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
              JAXBElement<?> unmarshalledObject = (JAXBElement<?>) unmarshaller.unmarshal(new FileInputStream("Encounter.xml"));
              TClaim claim = (TClaim) unmarshalledObject.getValue();

              return claim;
       }

private static KnowledgeBase readKnowledgeBase() throws Exception {
        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
        kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"), ResourceType.DRL);
        kbuilder.add(ResourceFactory.newClassPathResource("setBaseECN.drl"), ResourceType.DRL);

        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 = KnowledgeBaseFactory.newKnowledgeBase();
        kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
        return kbase;
    }

----Rule file setBaseECN.drl----

rule "testing claim rule"

when
Claim();
then
       System.out.println("..........Executing.......claim...rule.");//not working
end

rule "testing message rule"
when
       Message()
then
       System.out.println("........Executing......message rule");//working
end

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20140326/bb6a5b7b/attachment-0001.html 


More information about the rules-users mailing list