Package org.kie.internal.runtime

Examples of org.kie.internal.runtime.StatelessKnowledgeSession


                        "            list.add(\"OK\");\n" +
                        "    end";
        KnowledgeBase kb = getKieBaseFromString( source );
        TraitFactory.setMode( mode, kb );

        StatelessKnowledgeSession ksession = kb.newStatelessKnowledgeSession();

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

        ksession.execute( CommandFactory.newFireAllRules() );

        assertEquals( 1, list.size() );
        assertTrue( list.contains( "OK" ) );

    }
View Full Code Here


        inXml += "      <oldPrice>0</oldPrice>";
        inXml += "    </org.drools.camel.testdomain.Cheese>";
        inXml += "  </insert-elements>";
        inXml += "</batch-execution>";

        StatelessKnowledgeSession ksession = getStatelessKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
        setExec( ksession );

        String outXml = template.requestBody( "direct:exec",
                                              inXml,
                                              String.class );
View Full Code Here

        inXml += "      <oldPrice>0</oldPrice>";
        inXml += "  </org.drools.camel.testdomain.Cheese>";
        inXml += "  </insert>";
        inXml += "</batch-execution>";

        StatelessKnowledgeSession ksession = getStatelessKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
        setExec( ksession );

        String outXml = template.requestBody( "direct:exec",
                                              inXml,
                                              String.class );
View Full Code Here

        inXml += "    </org.drools.camel.testdomain.Cheese>";
        inXml += "  </insert>";
        inXml += "  <get-global identifier='list' out-identifier='out-list'/>";
        inXml += "</batch-execution>";

        StatelessKnowledgeSession ksession = getStatelessKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
        setExec( ksession );

        String outXml = template.requestBody( "direct:exec",
                                              inXml,
                                              String.class );
View Full Code Here

        inXml += "    </org.drools.camel.testdomain.Cheese>";
        inXml += "  </insert-elements>";
        inXml += "  <get-objects out-identifier='list' />";
        inXml += "</batch-execution>";

        StatelessKnowledgeSession ksession = getStatelessKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
        setExec( ksession );

        String outXml = template.requestBody( "direct:exec",
                                              inXml,
                                              String.class );
View Full Code Here

        inXml += "      <oldPrice>5</oldPrice>";
        inXml += "    </org.drools.camel.testdomain.Cheese>";
        inXml += "  </insert>";
        inXml += "</batch-execution>";

        StatelessKnowledgeSession ksession = getStatelessKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
        setExec( ksession );

        String outXml = template.requestBody( "direct:exec",
                                              inXml,
                                              String.class );
View Full Code Here

        }

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

        StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
        setExec( ksession );
        List<String> list = new ArrayList<String>();
        ksession.setGlobal( "list",
                            list );
        TestVariable person = new TestVariable( "John Doe" );

        String inXml = "";
        inXml += "<batch-execution>";
View Full Code Here

        Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

        kbase.addKnowledgePackages( pkgs );
        StatelessKnowledgeSession session = kbase.newStatelessKnowledgeSession();

        return session;
    }
View Full Code Here

    public void testNotInStatelessSession() throws Exception {
        KieBaseConfiguration kbc = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
        kbc.setOption( RuleEngineOption.RETEOO );
        kbc.setOption( SequentialOption.YES );
        KnowledgeBase kbase = SerializationHelper.serializeObject( loadKnowledgeBase( kbc, "test_NotInStatelessSession.drl" ) );
        StatelessKnowledgeSession session = createStatelessKnowledgeSession( kbase );

        List list = new ArrayList();
        session.setGlobal( "list",
                           list );
        session.execute( "not integer" );
        assertEquals( "not integer",
                      list.get( 0 ) );
    }
View Full Code Here

    }

    @Test
    public void testBasicOperation() throws Exception {
        KnowledgeBase kbase = loadKnowledgeBase(kconf, "simpleSequential.drl");
        StatelessKnowledgeSession ksession = createStatelessKnowledgeSession( kbase );
        final List list = new ArrayList();
        ksession.setGlobal( "list",
                           list );

        final Person p1 = new Person( "p1",
                                      "stilton" );
        final Person p2 = new Person( "p2",
                                      "cheddar" );
        final Person p3 = new Person( "p3",
                                      "stilton" );

        final Cheese stilton = new Cheese( "stilton",
                                           15 );
        final Cheese cheddar = new Cheese( "cheddar",
                                           15 );


        ksession.execute( CommandFactory.newInsertElements(Arrays.asList( new Object[]{p1, stilton, p2, cheddar, p3} )) );

        assertEquals( 3,
                      list.size() );
    }
View Full Code Here

TOP

Related Classes of org.kie.internal.runtime.StatelessKnowledgeSession

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.