Package org.drools.runtime

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


        List<Setter> setterList = new ArrayList<Setter>();
        setterList.add(CommandFactory.newSetter("age", String.valueOf(p.getAge())));
        setterList.add(CommandFactory.newSetter("name", p.getName()));
        setterList.add(CommandFactory.newSetter("likes", p.getLikes()));

        ksession.execute(CommandFactory.newModify(fh, setterList));
    }

    @Test
    public void testMVELTypeCoercion() {
        String str = "package org.drools.test; \n" +
View Full Code Here


        KnowledgeBase kbase = loadKnowledgeBaseFromString( str );
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        Person p1 = new Person("John", "nobody", 25);
        ksession.execute(CommandFactory.newInsert(p1));
        org.drools.runtime.rule.FactHandle fh = ksession.getFactHandle(p1);

        Person p = new Person("Frank", "nobody", 30);
        List<Setter> setterList = new ArrayList<Setter>();
        setterList.add(CommandFactory.newSetter("age", String.valueOf(p.getAge())));
View Full Code Here

        List<Setter> setterList = new ArrayList<Setter>();
        setterList.add(CommandFactory.newSetter("age", String.valueOf(p.getAge())));
        setterList.add(CommandFactory.newSetter("name", p.getName()));
        setterList.add(CommandFactory.newSetter("likes", p.getLikes()));

        ksession.execute(CommandFactory.newModify(fh, setterList));
    }

    @Test
    public void testMVELTypeCoercion() {
        String str = "package org.drools.test; \n" +
View Full Code Here

        Řehoř.setVěk(30);
        Řehoř.setJméno("Řehoř");
        commands.add(CommandFactory.newInsert(Řehoř));
        commands.add(CommandFactory.newFireAllRules());

        ksession.execute(CommandFactory.newBatchExecution(commands));

        // people with age greater than 18 should be added to list of adults
        assertNotNull(kbase.getRule("org.drools.decisiontable", "přidej k dospělým"));
        assertEquals(dospělí.size(), 1);
        assertEquals(dospělí.iterator().next().getJméno(), "Řehoř");
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

                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

                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

        List<Command> commands = new ArrayList<Command>();
        commands.add(CommandFactory.newInsert(new Person("darth", 105), "p"));
        commands.add(CommandFactory.newFireAllRules());

        ExecutionResults res1 = ksession.execute( CommandFactory.newBatchExecution(commands) );

        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
                Boolean.TRUE);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
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();
    }
}
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 = ksession.execute( cmds );
        stilton = ( Cheese ) result.getValue( "outStilton" );
        assertEquals( 30,
                      stilton.getPrice() );     
       
        Object o = ksession.getObject( (FactHandle) result.getFactHandle( "outStilton" ) );
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.