Package org.kie.api.command

Examples of org.kie.api.command.KieCommands


   
    @Test   
    public void tessDefaultClassPathKBase() throws IOException, ClassNotFoundException, InterruptedException {
        assertNotNull( defaultClassPathSKSession );
       
        KieCommands cmds  = KieServices.Factory.get().getCommands();
       
        List<String> list = new ArrayList<String>();
        defaultClassPathSKSession.setGlobal( "list", list );
        defaultClassPathSKSession.execute( cmds.newFireAllRules() );
       
        assertEquals( 2, list.size() );
        assertTrue( list.get(0).endsWith( "2.0" ) );
        assertTrue( list.get(1).endsWith( "2.0" ) );       
    }
View Full Code Here


   
    @Test   
    public void tessDefaultDynamicKBase() throws IOException, ClassNotFoundException, InterruptedException {
        assertNotNull( defaultDynamicSKSession );
       
        KieCommands cmds  = KieServices.Factory.get().getCommands();
               
        List<String> list = new ArrayList<String>();
        defaultDynamicSKSession.setGlobal( "list", list );
        defaultDynamicSKSession.execute( cmds.newFireAllRules() );
       
        assertEquals( 2, list.size() );
        assertTrue( list.get(0).endsWith( "1.0" ) );
        assertTrue( list.get(1).endsWith( "1.0" ) );       
   
View Full Code Here

    @Test
    public void testDynamicStatelessKieSessionReleaseId() throws IOException, ClassNotFoundException, InterruptedException {
        assertNotNull( kbase1ksession1v10 );
        assertNotNull( kbase1ksession1v10 );
       
        KieCommands cmds  = KieServices.Factory.get().getCommands();
               
        List<String> list = new ArrayList<String>();
        kbase1ksession1v10.setGlobal( "list", list );
        kbase1ksession1v10.execute( cmds.newFireAllRules() );
       
        assertEquals( 2, list.size() );
        assertTrue( list.get(0).endsWith( "1.0" ) );
        assertTrue( list.get(1).endsWith( "1.0" ) );
       
        list = new ArrayList<String>();
        kbase1ksession1v11.setGlobal( "list", list );
        kbase1ksession1v11.execute( cmds.newFireAllRules() );
       
        assertEquals( 2, list.size() );
        assertTrue( list.get(0).endsWith( "1.1" ) );
        assertTrue( list.get(1).endsWith( "1.1" ) );       
    }   
View Full Code Here

        assertNotNull(kbase1ksession1sks22);
       
        assertNotSame(kbase1ksession1sks1, kbase1ksession1sks2);
        assertSame( kbase1ksession1sks2, kbase1ksession1sks22);    
       
        KieCommands cmds  = KieServices.Factory.get().getCommands();
       
        List<String> list = new ArrayList<String>();
        kbase1ksession1sks1.setGlobal( "list", list );
        kbase1ksession1sks1.execute( cmds.newFireAllRules() );
       
        assertEquals( 2, list.size() );
        assertTrue( list.get(0).endsWith( "1.0" ) );
        assertTrue( list.get(1).endsWith( "1.0" ) );
       
        list = new ArrayList<String>();
        kbase1ksession1sks2.setGlobal( "list", list );
        kbase1ksession1sks2.execute( cmds.newFireAllRules() );
       
        assertEquals( 2, list.size() );
        assertTrue( list.get(0).endsWith( "1.0" ) );
        assertTrue( list.get(1).endsWith( "1.0" ) );         
    }  
View Full Code Here

        Object message = messageClass.newInstance();
        Method setter = messageClass.getMethod("setText", String.class);
        Method getter = messageClass.getMethod("getText");
        setter.invoke( message, "HelloWorld");

        KieCommands kcmd = ks.getCommands();
        Command<?> insert = kcmd.newInsert(message, "message");
        Command<?> fire = kcmd.newFireAllRules();
        BatchExecutionCommand batch = kcmd.newBatchExecution(Arrays.asList(insert, fire), "defaultKieSession");

        String payload = BatchExecutionHelper.newXStreamMarshaller().toXML(batch);

        ServiceResponse<String> reply = client.executeCommands("kie1", payload);
        Assert.assertEquals(ServiceResponse.ResponseType.SUCCESS, reply.getType());
View Full Code Here

        Class<?> messageClass = cl.loadClass("org.pkg1.Message");
        Object message = messageClass.newInstance();
        Method setter = messageClass.getMethod("setText", String.class);
        setter.invoke(message, "HelloWorld");

        KieCommands kcmd = ks.getCommands();
        Command<?> insert = kcmd.newInsert(message, "message");
        Command<?> fire = kcmd.newFireAllRules();
        BatchExecutionCommand batch = kcmd.newBatchExecution(Arrays.asList(insert, fire), "defaultKieSession");

        String payload = BatchExecutionHelper.newXStreamMarshaller().toXML(batch);

        String containerId = "command-script-container";
        KieServerCommand create = new CreateContainerCommand(new KieContainerResource( containerId, releaseId1, null));
View Full Code Here

                setGlobals(inputMessage, operation, session);
                if (ExchangePattern.IN_ONLY.equals(exchangePattern)) {
                    List<Object> facts = getInputList(inputMessage, operation, session);
                    session.getStateless().execute(facts);
                } else if (ExchangePattern.IN_OUT.equals(exchangePattern)) {
                    KieCommands cmds = KieServices.Factory.get().getCommands();
                    List<Command<?>> batch = new ArrayList<Command<?>>();
                    Map<String, Object> inouts = getInputOutputMap(inputMessage, operation, session);
                    for (Entry<String, Object> inout : inouts.entrySet()) {
                        batch.add(cmds.newInsert(inout.getValue(), inout.getKey()));
                    }
                    List<Object> facts = getInputOnlyList(inputMessage, operation, session);
                    batch.add(cmds.newInsertElements(facts));
                    batch.add(cmds.newFireAllRules());
                    BatchExecutionCommand exec = cmds.newBatchExecution(batch, KnowledgeConstants.RESULT);
                    ExecutionResults results = session.getStateless().execute(exec);
                    for (String id : inouts.keySet()) {
                        expressionVariables.put(id, results.getValue(id));
                    }
                    expressionVariables.putAll(getGlobalVariables(session));
View Full Code Here

TOP

Related Classes of org.kie.api.command.KieCommands

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.