Package org.kie.runtime

Examples of org.kie.runtime.StatefulKnowledgeSession.dispose()


        // Save the sessionInfo id in order to retrieve it later
        int sessionInfoId = commandKSession.getId();
       
        // Clean up the session, environment, etc.
        PersistenceContextManager pcm = (PersistenceContextManager) commandKSession.getEnvironment().get(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER);
        commandKSession.dispose();
        pcm.dispose();
        emf.close();
    
        // Reload session from the database
        emf = Persistence.createEntityManagerFactory(DROOLS_PERSISTENCE_UNIT_NAME);
View Full Code Here


        for (Line l : lines) {
            session.insert( l );
        }
        session.insert( new Stage( Stage.DUPLICATE ) );
        session.fireAllRules();
        session.dispose();
    }

    private KnowledgeBase readRule() {
        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
        kbuilder.add( ResourceFactory.newInputStreamResource( getClass().getResourceAsStream( "/waltz.drl" ) ), ResourceType.DRL );
View Full Code Here

        Applicant applicant = new Applicant();
        applicant.setAge(10);
        session.insert(applicant);
        //session.addEventListener(new DebugWorkingMemoryEventListener());
        session.fireAllRules();
        session.dispose();
        //occupation = 0, age = 30, validLicence -1, initialScore=100
        assertEquals(129.0,applicant.getTotalScore());

        session = kbase.newStatefulKnowledgeSession();
        applicant = new Applicant();
View Full Code Here

        applicant = new Applicant();
        applicant.setOccupation("SKYDIVER");
        applicant.setAge(0);
        session.insert( applicant );
        session.fireAllRules();
        session.dispose();
        //occupation = -10, age = +10, validLicense = -1, initialScore=100;
        assertEquals(99.0, applicant.getTotalScore());

        session = kbase.newStatefulKnowledgeSession();
        applicant = new Applicant();
View Full Code Here

        applicant.setOccupation("TEACHER");
        applicant.setAge(20);
        applicant.setValidLicense(true);
        session.insert( applicant );
        session.fireAllRules();
        session.dispose();
        //occupation = +10, age = +40, state = -10, validLicense = 1, initialScore=100
        assertEquals(141.0,applicant.getTotalScore());
    }

    @Test
View Full Code Here

        Applicant applicant = new Applicant();
        applicant.setAge(10);
        session.insert(applicant);
        //session.addEventListener(new DebugWorkingMemoryEventListener());
        session.fireAllRules();
        session.dispose();
        //occupation = 0, age = 30, validLicence -1, initialScore=100
        assertEquals(129.0,applicant.getTotalScore());
        assertTrue(applicant.getReasonCodes().size() > 0);

        session = kbase.newStatefulKnowledgeSession();
View Full Code Here

        applicant = new Applicant();
        applicant.setOccupation("SKYDIVER");
        applicant.setAge(0);
        session.insert( applicant );
        session.fireAllRules();
        session.dispose();
        //occupation = -10, age = +10, validLicense = -1, initialScore=100;
        assertEquals(99.0, applicant.getTotalScore());

        session = kbase.newStatefulKnowledgeSession();
        applicant = new Applicant();
View Full Code Here

        applicant.setOccupation("TEACHER");
        applicant.setAge(20);
        applicant.setValidLicense(true);
        session.insert( applicant );
        session.fireAllRules();
        session.dispose();
        //occupation = +10, age = +40, state = -10, validLicense = 1, initialScore=100
        assertEquals(141.0,applicant.getTotalScore());
    }
}
View Full Code Here

        DroolsScorecard scorecard = (DroolsScorecard) scorecardType.newInstance();
        scorecardType.set(scorecard, "age", 10);
        session.insert(scorecard);
        session.fireAllRules();
        session.dispose();
        //age = 30, validLicence -1
        assertTrue(29 == scorecard.getCalculatedScore());
        //age-reasoncode=AGE02, license-reasoncode=VL002
        assertEquals(2, scorecard.getReasonCodes().size());
        assertTrue(scorecard.getReasonCodes().contains("AGE02"));
View Full Code Here

        scorecard = (DroolsScorecard) scorecardType.newInstance();
        scorecardType.set(scorecard, "age", 0);
        scorecardType.set(scorecard, "occupation", "SKYDIVER");
        session.insert(scorecard);
        session.fireAllRules();
        session.dispose();
        //occupation = -10, age = +10, validLicense = -1;
        assertTrue(-1 == scorecard.getCalculatedScore());
        assertEquals(3, scorecard.getReasonCodes().size());
        //[AGE01, VL002, OCC01]
        assertTrue(scorecard.getReasonCodes().contains("AGE01"));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.