Examples of ReteooWorkingMemory


Examples of org.drools.reteoo.ReteooWorkingMemory

            endNode, Node.CONNECTION_DEFAULT_TYPE
        );
       
        AbstractRuleBase ruleBase = (AbstractRuleBase) RuleBaseFactory.newRuleBase();
        ruleBase.addProcess(process);
        InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1, ruleBase);
        ProcessInstance processInstance = workingMemory.startProcess("org.drools.process.event");
        assertEquals(0, myList.size());
        Person jack = new Person();
        jack.setName("Jack");
        processInstance.signalEvent("myEvent", jack);
        assertEquals(1, myList.size());
View Full Code Here

Examples of org.drools.reteoo.ReteooWorkingMemory

            Node.CONNECTION_DEFAULT_TYPE);
        forEachNode.setVariable("child", personDataType);
       
        AbstractRuleBase ruleBase = (AbstractRuleBase) RuleBaseFactory.newRuleBase();
        ruleBase.addProcess(process);
        InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1, ruleBase);
        Map<String, Object> parameters = new HashMap<String, Object>();
        List<Person> persons = new ArrayList<Person>();
        persons.add(new Person("John Doe", 30));
        persons.add(new Person("Jane Doe", 20));
        persons.add(new Person("Jack", 60));
        parameters.put("persons", persons);
        workingMemory.startProcess("org.drools.process.foreach", parameters);
        assertEquals(3, myList.size());
    }
View Full Code Here

Examples of org.drools.reteoo.ReteooWorkingMemory

            endNode, Node.CONNECTION_DEFAULT_TYPE
        );
       
        ruleBase.addProcess(process);
       
        InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1, ruleBase);
        workingMemory.startProcess("org.drools.process.process");
        assertTrue(executed);
        assertEquals(0, workingMemory.getProcessInstances().size());
    }
View Full Code Here

Examples of org.drools.reteoo.ReteooWorkingMemory

            endNode, Node.CONNECTION_DEFAULT_TYPE
        );
       
        ruleBase.addProcess(process);
       
        InternalWorkingMemory workingMemory = new ReteooWorkingMemory(1, ruleBase);
        workingMemory.getWorkItemManager().registerWorkItemHandler("MyWork", new WorkItemHandler() {
      public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
        System.out.println("Executing work item");
        SubProcessTest.this.workItem = workItem;
      }
      public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
      }
        });
        workingMemory.startProcess("org.drools.process.process");
        assertNotNull(workItem);
        assertEquals(2, workingMemory.getProcessInstances().size());
       
        workingMemory.getWorkItemManager().completeWorkItem(workItem.getId(), null);
        assertEquals(0, workingMemory.getProcessInstances().size());
    }
View Full Code Here

Examples of org.drools.reteoo.ReteooWorkingMemory

        return this.ruleBase;
    }

    public InternalWorkingMemory newWorkingMemory() {
        synchronized ( this.ruleBase.getPackagesMap() ) {
            ReteooWorkingMemory wm = new ReteooWorkingMemory( this.ruleBase.nextWorkingMemoryCounter(),
                                                                this.ruleBase,
                                                                (SessionConfiguration) this.conf,
                                                                this.environment );

            StatefulKnowledgeSessionImpl ksession = new StatefulKnowledgeSessionImpl( wm, new KnowledgeBaseImpl( this.ruleBase ), mappedWorkingMemoryListeners, mappedAgendaListeners, mappedProcessListeners );
           
            ((Globals) wm.getGlobalResolver()).setDelegate( this.sessionGlobals );
            wm.setKnowledgeRuntime( ksession );
            wm.setWorkingMemoryEventSupport( this.workingMemoryEventSupport );
            wm.setAgendaEventSupport( this.agendaEventSupport );
            wm.setRuleFlowEventSupport( this.ruleFlowEventSupport );

            final InitialFactHandleDummyObject initialFact = new InitialFactHandleDummyObject();
            final InitialFactHandle handle = new InitialFactHandle( wm.getFactHandleFactory().newFactHandle( initialFact,
                                                                                                             wm.getObjectTypeConfigurationRegistry().getObjectTypeConf( EntryPoint.DEFAULT,
                                                                                                                                                                        initialFact ),
                                                                                                             wm ) );

            wm.queueWorkingMemoryAction( new WorkingMemoryReteAssertAction( handle,
                                                                            false,
                                                                            true,
                                                                            null,
                                                                            null ) );
            return wm;
View Full Code Here

Examples of org.drools.reteoo.ReteooWorkingMemory

    public Globals getGlobals() {
        return this.sessionGlobals;
    }

    public BatchExecutionResults execute(Command command) {       
        ReteooWorkingMemory session = ( ReteooWorkingMemory ) newWorkingMemory();
        try {
            session.startBatchExecution();
            ((org.drools.process.command.Command)command).execute( session );
            session.fireAllRules( this.agendaFilter );
            BatchExecutionResults result = session.getBatchExecutionResult();
            return result;
        } finally {
            session.endBatchExecution();
        }
    }
View Full Code Here

Examples of org.drools.reteoo.ReteooWorkingMemory

                node = n;
                break;
            }
        }
       
        ReteooWorkingMemory wm = ((StatefulKnowledgeSessionImpl)kbase.newStatefulKnowledgeSession()).session;
       
        LeftInputAdapterNode liaNode = (LeftInputAdapterNode) node.getSinkPropagator().getSinks()[0];
        JoinNode j2 = ( JoinNode ) liaNode.getSinkPropagator().getSinks()[0]; // $p2
        JoinNode j3 = ( JoinNode ) j2.getSinkPropagator().getSinks()[0]// $p3
       
        SingleBetaConstraints c = ( SingleBetaConstraints ) j2.getRawConstraints();
        assertEquals( "$name", ((VariableConstraint)c.getConstraint()).getRequiredDeclarations()[0].getIdentifier() );
        assertTrue( c.isIndexed() );       
        BetaMemory bm = ( BetaMemory ) wm.getNodeMemory( j2 );
        assertTrue( bm.getLeftTupleMemory() instanceof LeftTupleIndexHashTable );
        assertTrue( bm.getRightTupleMemory() instanceof RightTupleIndexHashTable );
       
        c = ( SingleBetaConstraints ) j3.getRawConstraints();
        assertEquals( "name", ((VariableConstraint)c.getConstraint()).getRequiredDeclarations()[0].getIdentifier() );
        assertTrue( c.isIndexed() );  
        bm = ( BetaMemory ) wm.getNodeMemory( j3 );
        assertTrue( bm.getLeftTupleMemory() instanceof LeftTupleIndexHashTable );
        assertTrue( bm.getRightTupleMemory() instanceof RightTupleIndexHashTable );
    }
View Full Code Here

Examples of org.drools.reteoo.ReteooWorkingMemory

                node = n;
                break;
            }
        }   
       
        ReteooWorkingMemory wm = ((StatefulKnowledgeSessionImpl)kbase.newStatefulKnowledgeSession()).session;
       
        AlphaNode alphanode = ( AlphaNode ) node.getSinkPropagator().getSinks()[0];
        LeftInputAdapterNode liaNode = (LeftInputAdapterNode) alphanode.getSinkPropagator().getSinks()[0];
        JoinNode j = ( JoinNode ) liaNode.getSinkPropagator().getSinks()[0]; // $p2
       
        TripleNonIndexSkipBetaConstraints c = ( TripleNonIndexSkipBetaConstraints ) j.getRawConstraints();
        //assertEquals( "$name", ((VariableConstraint)c.getConstraint()).getRequiredDeclarations()[0].getIdentifier() );
        assertTrue( c.isIndexed() );       
        BetaMemory bm = ( BetaMemory ) wm.getNodeMemory( j );
        assertTrue( bm.getLeftTupleMemory() instanceof LeftTupleIndexHashTable );
        assertTrue( bm.getRightTupleMemory() instanceof RightTupleIndexHashTable );       
    }
View Full Code Here

Examples of org.drools.reteoo.ReteooWorkingMemory

        PropagationContext context = new PropagationContextImpl( 0,
                                                                 PropagationContext.INSERTION,
                                                                 null,
                                                                 null,
                                                                 null );
        ReteooWorkingMemory workingMemory = new ReteooWorkingMemory( 1,
                                                                     (ReteooRuleBase) RuleBaseFactory.newRuleBase() );

        BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( join1 );

        final DefaultFactHandle f0 = new DefaultFactHandle( 0,
                                                            0 );
        final LeftTupleImpl tuple0 = new LeftTupleImpl( f0,
                                                join1,
View Full Code Here

Examples of org.drools.reteoo.ReteooWorkingMemory

        assertNotNull( retractedWorker );

        StatefulKnowledgeSessionImpl sessionImpl = (StatefulKnowledgeSessionImpl) ksession;

        ReteooWorkingMemory reteWorkingMemory = sessionImpl.session;
        AbstractWorkingMemory abstractWorkingMemory = (AbstractWorkingMemory) reteWorkingMemory;

        InternalRuleBase ruleBase = (InternalRuleBase) abstractWorkingMemory.getRuleBase();
        Collection<EntryPointNode> entryPointNodes = ruleBase.getRete().getEntryPointNodes().values();
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.