Package org.drools.runtime

Examples of org.drools.runtime.StatefulKnowledgeSession.execute()


        InsertObjectCommand cmd = new InsertObjectCommand( me );
        cmd.setOutIdentifier( "camel-rider" );
        cmd.setReturnObject( false );
        BatchExecutionCommandImpl script = new BatchExecutionCommandImpl( Arrays.asList( new GenericCommand< ? >[]{cmd} ) );

        ExecutionResults results = ksession.execute( script );
        handle = ((FactHandle) results.getFactHandle( "camel-rider" )).toExternalForm();
    }

    @Override
    protected StatefulKnowledgeSession registerKnowledgeRuntime(String identifier,
View Full Code Here


       
        List<Person> persons = new ArrayList<Person>();
        persons.add(new Person("john", "john", 25));
        persons.add(new Person("sarah", "john", 35));
       
        session.execute(CommandFactory.newInsertElements(persons));
        assertEquals(2, session.getFactCount());
       
        QueryResults results = query("people over the age of x", new Object[] {30});
        assertNotNull(results);
    }
View Full Code Here

        InsertObjectCommand cmd = new InsertObjectCommand( me );
        cmd.setOutIdentifier( "camel-rider" );
        cmd.setReturnObject( false );
        BatchExecutionCommandImpl script = new BatchExecutionCommandImpl( Arrays.asList( new GenericCommand< ? >[]{cmd} ) );

        ExecutionResults results = ksession.execute( script );
        handle = ((FactHandle) results.getFactHandle( "camel-rider" )).toExternalForm();
    }

    @Override
    protected StatefulKnowledgeSession registerKnowledgeRuntime(String identifier,
View Full Code Here

        if( ksession instanceof StatefulKnowledgeSessionImpl ) {
            kresults = ((StatefulKnowledgeSessionImpl)ksession).execute(context, this.command );
        }
        else {
            // Graceful failure
            kresults = ksession.execute(this.command);
        }
       
        if ( this.outIdentifier != null ) {
            ((ExecutionResultImpl)((KnowledgeCommandContext) context ).getExecutionResults()).getResults().put( this.outIdentifier, kresults );
        }
View Full Code Here

        Command insertCmd = CommandFactory.newInsert( stilton, "outStilton" );
        Command fireCmd = CommandFactory.newFireAllRules();
       
        Command cmds = CommandFactory.newBatchExecution( Arrays.asList( new Command[] { insertCmd,fireCmd} ) );
       
        ExecutionResults result = (ExecutionResults) ksession.execute( cmds );
        stilton = ( Cheese ) result.getValue( "outStilton" );
        assertEquals( 30,
                      stilton.getPrice() );
       
        Object o = ksession.getObject( (FactHandle) result.getFactHandle( "outStilton" ) );
View Full Code Here

        cmds.add((GenericCommand<?>)CommandFactory.newSetGlobal("myGlobalObj", new MyObject("myglobalObj")));
        cmds.add((GenericCommand<?>)CommandFactory.newInsert(new MyObject("obj1"), "myObject1"));
        cmds.add((GenericCommand<?>)CommandFactory.newFireAllRules());
        BatchExecutionCommandImpl batch = new BatchExecutionCommandImpl(cmds, "out");
       
        ExecutionResults results = ksession.execute(batch);
       
      
        System.out.println("Results = "+results);
        Assert.assertNotNull(results);
        Assert.assertEquals(1, results.getIdentifiers().size());
View Full Code Here

        MyObject myObject = new MyObject("obj1");
        cmds.add(CommandFactory.newInsert(myObject));
        cmds.add(CommandFactory.newFireAllRules());
        AsyncBatchExecutionCommandImpl batch = new AsyncBatchExecutionCommandImpl(cmds);
       
        ExecutionResults results = ksession.execute(batch);
       
      
       
        Assert.assertNull(results);
       
View Full Code Here

       
        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
       
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
       
        ExecutionResults results = ksession.execute( new FireAllRulesCommand( "fired" ) );
      
        assertEquals( 2, (int ) ( Integer) results.getValue( "fired" ) );
    }   

}
View Full Code Here

       
        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
       
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
       
        ExecutionResults results = ksession.execute( new FireAllRulesCommand( "fired" ) );
      
        assertEquals( 2, (int ) ( Integer) results.getValue( "fired" ) );
    }  
   
    public void testNamedService() throws Exception {
View Full Code Here

                list.size() );
        String externalForm = atomicFH.toExternalForm();
       
        ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(ksession.getId(), kbase, null, env);
       
        atomicFH = ksession.execute(CommandFactory.fromExternalFactHandleCommand(externalForm));
       
        value.addAndGet(1);
        ksession.update(atomicFH, value);
       
        ksession.fireAllRules();
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.