Package org.kie.api

Examples of org.kie.api.KieBase.newKieSession()


        str += "then \n";
        str += "    list.add( $str ); \n";
        str += "end \n";

        KieBase kbase = loadKnowledgeBaseFromString(str);
        KieSession ksession = kbase.newKieSession();

        List list = new ArrayList();
        ksession.setGlobal( "list", list );
        ksession.insert( "hello1" );
        ksession.insert( "hello2" );
View Full Code Here


        str += "    if ( list.size() == 2 ) {\n";
        str += "        drools.halt();\n";
        str += "    }";
        str += "end \n";
        KieBase kbase = loadKnowledgeBaseFromString(str);
        KieSession ksession = kbase.newKieSession();
        List list = new ArrayList();
        ksession.setGlobal( "list", list );
        ksession.insert( "hello1" );
        ksession.insert( "hello2" );
        ksession.insert( "hello3" );
View Full Code Here

    }

    @Test
    public void testLockOnActiveWithModify() throws Exception {
        KieBase kbase = loadKnowledgeBase("test_LockOnActiveWithUpdate.drl");
        KieSession ksession =  kbase.newKieSession();

        final List list = new ArrayList();
        ksession.setGlobal( "list", list );

        final Cheese brie = new Cheese( "brie", 13 );
View Full Code Here

    }

    @Test
    public void testLockOnActiveWithModify2() throws Exception {
        KieBase kbase = loadKnowledgeBase("test_LockOnActiveWithModify.drl");
        KieSession ksession = kbase.newKieSession();

        // populating working memory
        final int size = 3;

        Cell[][] cells = new Cell[size][];
View Full Code Here

    }

    @Test
    public void testAgendaGroups() throws Exception {
        KieBase kbase = loadKnowledgeBase("test_AgendaGroups.drl");
        KieSession ksession = kbase.newKieSession();

        final List list = new ArrayList();
        ksession.setGlobal( "list", list );

        final Cheese brie = new Cheese( "brie", 12 );
View Full Code Here

    }

    @Test
    public void testActivationGroups() throws Exception {
        KieBase kbase = loadKnowledgeBase("test_ActivationGroups.drl");
        KieSession ksession = kbase.newKieSession();


        final List list = new ArrayList();
        ksession.setGlobal( "list", list );
View Full Code Here

                "            }" +
                "    });" +
                "end";

        KieBase kbase = loadKnowledgeBaseFromString(str);
        KieSession ksession = kbase.newKieSession();

        ksession.setGlobal("totalHolder", new TotalHolder());
        Father abraham = new Father("abraham", null, 100);
        Father homer = new Father("homer", null, 20);
        Father bart = new Father("bart", null, 3);
View Full Code Here

                 + "        $a.setOutcome(\"setting null\");\n"
                 + "end\n" + "\n"
                 + "";

        KieBase kbase = loadKnowledgeBaseFromString(str);
        KieSession ksession = kbase.newKieSession();

        Holder inrec = new Holder( 1 );
        System.out.println( "Holds: " + inrec.getValue() );
        ksession.insert( inrec );
        ksession.fireAllRules();
View Full Code Here

        ksession.fireAllRules();
        Assert.assertEquals( 1, ksession.getFactHandles().size() );
        Assert.assertEquals( "setting 1", inrec.getOutcome() );

        ksession.dispose();
        ksession = kbase.newKieSession();
        inrec = new Holder( null );
        System.out.println( "Holds: " + inrec.getValue() );
        ksession.insert( inrec );
        ksession.fireAllRules();
        Assert.assertEquals( 1, ksession.getFactHandles().size() );
View Full Code Here

        ksession.fireAllRules();
        Assert.assertEquals( 1, ksession.getFactHandles().size() );
        Assert.assertEquals( "setting null", inrec.getOutcome() );

        ksession.dispose();
        ksession = kbase.newKieSession();
        inrec = new Holder( 0 );
        System.out.println( "Holds: " + inrec.getValue() );
        ksession.insert( inrec );
        ksession.fireAllRules(); // appropriate rule is not fired!
        Assert.assertEquals( 1, ksession.getFactHandles().size() );
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.