Package org.kie.api.runtime

Examples of org.kie.api.runtime.KieSession


                     "end";

        KieServices ks = KieServices.Factory.get();
        KieFileSystem kfs = ks.newKieFileSystem().write( "src/main/resources/r1.drl", str );
        ks.newKieBuilder( kfs ).buildAll();
        KieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();

        int n = ksession.fireAllRules();
        assertEquals(7, n);
    }
View Full Code Here


                     "end";

        KieServices ks = KieServices.Factory.get();
        KieFileSystem kfs = ks.newKieFileSystem().write( "src/main/resources/r1.drl", str );
        ks.newKieBuilder( kfs ).buildAll();
        KieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();

        int n = ksession.fireAllRules();
        assertEquals(8, n);
    }
View Full Code Here

                     "end";

        KieServices ks = KieServices.Factory.get();
        KieFileSystem kfs = ks.newKieFileSystem().write( "src/main/resources/r1.drl", str );
        ks.newKieBuilder( kfs ).buildAll();
        KieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();

        int n = ksession.fireAllRules();
        assertEquals(1, n);
    }
View Full Code Here

                     "end";

        KieServices ks = KieServices.Factory.get();
        KieFileSystem kfs = ks.newKieFileSystem().write( "src/main/resources/r1.drl", str );
        ks.newKieBuilder( kfs ).buildAll();
        KieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();

        List<Integer> list = new ArrayList<Integer>();
        ksession.setGlobal("list", list);

        ksession.insert(0);
        ksession.fireAllRules();
        ksession.insert(1);
        ksession.fireAllRules();

        assertEquals(1, list.size());
        assertEquals(0, (int)list.get(0));
    }
View Full Code Here

                     "      update( $thing2 ); " +
                     "end";

        KieHelper helper = new KieHelper();
        helper.addContent( drl, ResourceType.DRL );
        KieSession session = helper.build().newKieSession();

        session.insert( "hello" );
        session.insert( new Integer( 42 ) );

        // set the agenda groups in reverse order so that stack is preserved
        session.getAgenda().getAgendaGroup( "End" ).setFocus();
        session.getAgenda().getAgendaGroup( "Start" ).setFocus();

        int x = session.fireAllRules( 10 );
        assertEquals( 2, x );
        session.dispose();
    }
View Full Code Here

                     "        insert(new Trailer(Trailer.TypeStatus.WAITING));\n" +
                     "end";

        KieHelper helper = new KieHelper();
        helper.addContent( drl, ResourceType.DRL );
        KieSession ksession = helper.build().newKieSession();

        ArrayList<Trailer> trailerList = new ArrayList<Trailer>();
        ksession.setGlobal("trailerList", trailerList);

        Trailer trailer1 = new Trailer(Trailer.TypeStatus.WAITING);

        ksession.insert(trailer1);

        // set the agenda groups in reverse order so that stack is preserved
        ksession.getAgenda().getAgendaGroup( "Start" ).setFocus();
        ksession.getAgenda().getAgendaGroup( "End" ).setFocus();
        ksession.getAgenda().getAgendaGroup( "Start" ).setFocus();

        ksession.fireAllRules();

        assertEquals(2, trailerList.size());
    }
View Full Code Here

                "then\n" +
                "end";

        KieHelper helper = new KieHelper();
        helper.addContent( drl, ResourceType.DRL );
        KieSession ksession = helper.build().newKieSession();

        ksession.insert(new Host());
        ksession.insert("host");
        ksession.fireAllRules();
    }
View Full Code Here

                "    $d.setValue($result.intValue());\n" +
                "end";

        KieHelper helper = new KieHelper();
        helper.addContent( drl, ResourceType.DRL );
        KieSession ksession = helper.build().newKieSession();

        ksession.insert(new TypeA());
        ksession.insert(new TypeB());
        ksession.insert(new TypeC());
        TypeD d = new TypeD();
        ksession.insert(d);
        ksession.fireAllRules();
        assertEquals(1, d.getValue());
    }
View Full Code Here

                "    update(alarm);\n" +
                "end";

        KieHelper helper = new KieHelper();
        helper.addContent( drl, ResourceType.DRL );
        KieSession ksession = helper.build().newKieSession();

        ksession.insert("t1");

        ksession.insert(new Reading("t1", 12));
        ksession.fireAllRules();
        ksession.insert(new Reading("t1", 0));
        ksession.fireAllRules();
        ksession.insert(new Reading("t1", 0));
        ksession.fireAllRules();

        ksession.insert(new Reading("t1", 16));
        ksession.fireAllRules();
        ksession.insert(new Reading("t1", 32));
        ksession.fireAllRules();
        ksession.insert(new Reading("t1", -6));
        ksession.fireAllRules();
    }
View Full Code Here

                "    update( $c1 );\n" +
                "end";

        KieHelper helper = new KieHelper();
        helper.addContent( drl, ResourceType.DRL );
        KieSession ksession = helper.build().newKieSession();

        ksession.insert(new C1());
        ksession.fireAllRules();
    }
View Full Code Here

TOP

Related Classes of org.kie.api.runtime.KieSession

Copyright © 2018 www.massapicom. 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.