Package org.drools.command.runtime

Examples of org.drools.command.runtime.BatchExecutionCommandImpl


    }

    @Test
    public void testQuery() throws Exception {
        BatchExecutionCommandImpl cmd = new BatchExecutionCommandImpl();
        cmd.setLookup( "ksession1" );
        cmd.getCommands().add( new InsertObjectCommand( new Person( "lucaz" ) ) );
        cmd.getCommands().add( new InsertObjectCommand( new Person( "hadrian" ) ) );
        cmd.getCommands().add( new InsertObjectCommand( new Person( "baunax",
                                                                    43 ) ) );
        cmd.getCommands().add( new InsertObjectCommand( new Person( "baunax",
                                                                    21 ) ) );
        cmd.getCommands().add( new QueryCommand( "persons",
                                                 "persons",
                                                 null ) );
        cmd.getCommands().add( new QueryCommand( "person",
                                                 "personWithName",
                                                 new String[]{"baunax"} ) );

        StringWriter xmlReq = new StringWriter();
        Marshaller marshaller = getJaxbContext().createMarshaller();
View Full Code Here


    }

    @Test
    public void testProcess() throws Exception {

        BatchExecutionCommandImpl cmd = new BatchExecutionCommandImpl();
        cmd.setLookup( "ksession1" );

        StartProcessCommand start = new StartProcessCommand( "org.drools.actions" , "process-instance-id" );
        start.putParameter( "person",
                            new Person( "lucaz",
                                        25 ) );
        start.putParameter( "person2",
                            new Person( "hadrian",
                                        25 ) );
        start.putParameter( "person3",
                            new Person( "baunax",
                                        21 ) );

        cmd.getCommands().add( start );

        StringWriter xmlReq = new StringWriter();
        Marshaller marshaller = getJaxbContext().createMarshaller();
        marshaller.setProperty( "jaxb.formatted.output",
                                true );
View Full Code Here

        StatefulKnowledgeSession ksession = registerKnowledgeRuntime( "ksession1",
                                                                      rule );
        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();
    }
View Full Code Here

                                           "p" ) );
        cmds.add( new GetGlobalCommand( "xxx" ) );
        cmds.add( new SetGlobalCommand( "yyy",
                                        new Person( "yoda",
                                                    21 ) ) );
        BatchExecutionCommandImpl batch = new BatchExecutionCommandImpl( cmds );

        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT,
                                Boolean.TRUE );
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        marshaller.marshal( batch,
                            baos );

        System.out.println( baos );

        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        BatchExecutionCommandImpl batch2 = (BatchExecutionCommandImpl) unmarshaller.unmarshal( new ByteArrayInputStream( baos.toByteArray() ) );
        baos = new ByteArrayOutputStream();
        marshaller.marshal( batch2,
                            baos );
        System.out.println( baos );
    }
View Full Code Here

        StatefulKnowledgeSession ksession = registerKnowledgeRuntime( "ksession1",
                                                                      null );
        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();
    }
View Full Code Here

        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
       
        BatchExecutionCommandImpl script = new BatchExecutionCommandImpl( Arrays.asList( new GenericCommand<?>[] { new FireAllRulesCommand( "fired" ) } )  );

        ExecutionResults results = ksession.execute( script );

        Assert.assertEquals( 2,
                      (int) (Integer) results.getValue( "fired" ) );
View Full Code Here

        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        node.get(DirectoryLookupFactoryService.class).register( "ksession1",
                              ksession );

        BatchExecutionCommandImpl script = new BatchExecutionCommandImpl( Arrays.asList( new GenericCommand<?>[] { new FireAllRulesCommand( "fired" ) } )  );
       
        ExecutionResults results = node.get(DirectoryLookupFactoryService.class).lookup( "ksession1" ).execute( script );

        Assert.assertEquals( 2,
                      (int) (Integer) results.getValue( "fired" ) );
View Full Code Here

        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        node.get(DirectoryLookupFactoryService.class).register( "ksession1",
                              ksession );

        BatchExecutionCommandImpl script = new BatchExecutionCommandImpl( Arrays.asList( new GenericCommand<?>[] { new FireAllRulesCommand( "fired" ) } )  );
       
        ExecutionResults results = node.get(DirectoryLookupFactoryService.class).lookup( "ksession1" ).execute( script );

        Assert.assertEquals( 2, (int ) ( Integer) results.getValue( "fired" ) );
    }
View Full Code Here

TOP

Related Classes of org.drools.command.runtime.BatchExecutionCommandImpl

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.