Package org.drools.reteoo

Examples of org.drools.reteoo.ReteooWorkingMemoryInterface


            ((StatelessKnowledgeSessionImpl) session).workingMemoryEventSupport.addEventListener( this );
            ((StatelessKnowledgeSessionImpl) session).agendaEventSupport.addEventListener( this );
            ((StatelessKnowledgeSessionImpl) session).processEventSupport.addEventListener( this );
            ((StatelessKnowledgeSessionImpl) session).getRuleBase().addEventListener( this );
        } else if (session instanceof CommandBasedStatefulKnowledgeSession) {
            ReteooWorkingMemoryInterface eventManager =
                ((StatefulKnowledgeSessionImpl)((KnowledgeCommandContext)((CommandBasedStatefulKnowledgeSession) session).getCommandService().getContext()).getStatefulKnowledgesession()).session;
            eventManager.addEventListener( (WorkingMemoryEventListener) this );
            eventManager.addEventListener( (AgendaEventListener) this );
            InternalProcessRuntime processRuntime = eventManager.getProcessRuntime();
            eventManager.addEventListener( (RuleBaseEventListener) this );
            if (processRuntime != null) {
                processRuntime.addEventListener( (ProcessEventListener) this );
            }
        } else {
            throw new IllegalArgumentException("Not supported session in logger: " + session.getClass());
View Full Code Here


        this.agendaFilter = agendaFilter;
    }

    public Integer execute(Context context) {
        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
        final ReteooWorkingMemoryInterface session = ((StatefulKnowledgeSessionImpl)ksession).session;
       
        new Thread(new Runnable() {
            public void run() {
                if ( agendaFilter != null ) {
                    session.fireUntilHalt( new StatefulKnowledgeSessionImpl.AgendaFilterWrapper( agendaFilter ) );
                } else {
                    session.fireUntilHalt();
                }
            }
        }).start();

        return null;
View Full Code Here

            factHandle = ksession.insert( object );
        } else {
            factHandle = ksession.getWorkingMemoryEntryPoint( this.entryPoint ).insert( object );
        }
       
        ReteooWorkingMemoryInterface session = ((StatefulKnowledgeSessionImpl)ksession).session;

        if ( outIdentifier != null ) {
            if ( this.returnObject ) {
                session.getExecutionResult().getResults().put( this.outIdentifier,
                                                               object );
            }
            session.getExecutionResult().getFactHandles().put( this.outIdentifier,
                                                         factHandle );
        }
        if ( disconnected ) {
            DefaultFactHandle disconnectedHandle = ((DefaultFactHandle)factHandle).clone();
            disconnectedHandle.disconnect();
View Full Code Here

        this.agendaFilter = agendaFilter;
    }

    public Integer execute(Context context) {
        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
        final ReteooWorkingMemoryInterface session = ((StatefulKnowledgeSessionImpl)ksession).session;
       
        new Thread(new Runnable() {
            public void run() {
                if ( agendaFilter != null ) {
                    session.fireUntilHalt( new StatefulKnowledgeSessionImpl.AgendaFilterWrapper( agendaFilter ) );
                } else {
                    session.fireUntilHalt();
                }
            }
        }).start();

        return null;
View Full Code Here

            factHandle = ksession.insert( object );
        } else {
            factHandle = ksession.getWorkingMemoryEntryPoint( this.entryPoint ).insert( object );
        }
       
        ReteooWorkingMemoryInterface session = ((StatefulKnowledgeSessionImpl)ksession).session;

        if ( outIdentifier != null ) {
            if ( this.returnObject ) {
                session.getExecutionResult().getResults().put( this.outIdentifier,
                                                               object );
            }
            session.getExecutionResult().getFactHandles().put( this.outIdentifier,
                                                         factHandle );
        }
        if ( disconnected ){
            DefaultFactHandle disconnectedHandle = ((DefaultFactHandle)factHandle).clone();
            disconnectedHandle.disconnect();
View Full Code Here

            ((StatelessKnowledgeSessionImpl) session).workingMemoryEventSupport.addEventListener( this );
            ((StatelessKnowledgeSessionImpl) session).agendaEventSupport.addEventListener( this );
            ((StatelessKnowledgeSessionImpl) session).processEventSupport.addEventListener( this );
            ((StatelessKnowledgeSessionImpl) session).getRuleBase().addEventListener( this );
        } else if (session instanceof CommandBasedStatefulKnowledgeSession) {
            ReteooWorkingMemoryInterface eventManager =
                ((StatefulKnowledgeSessionImpl)((KnowledgeCommandContext)((CommandBasedStatefulKnowledgeSession) session).getCommandService().getContext()).getStatefulKnowledgesession()).session;
            eventManager.addEventListener( (WorkingMemoryEventListener) this );
            eventManager.addEventListener( (AgendaEventListener) this );
            InternalProcessRuntime processRuntime = eventManager.getProcessRuntime();
            eventManager.addEventListener( (RuleBaseEventListener) this );
            if (processRuntime != null) {
                processRuntime.addEventListener( (ProcessEventListener) this );
            }
        } else {
            throw new IllegalArgumentException("Not supported session in logger: " + session.getClass());
View Full Code Here

            factHandle = ksession.insert( object );
        } else {
            factHandle = ksession.getWorkingMemoryEntryPoint( this.entryPoint ).insert( object );
        }
       
        ReteooWorkingMemoryInterface session = ((StatefulKnowledgeSessionImpl)ksession).session;

        if ( outIdentifier != null ) {
            if ( this.returnObject ) {
                session.getExecutionResult().getResults().put( this.outIdentifier,
                                                               object );
            }
            session.getExecutionResult().getFactHandles().put( this.outIdentifier,
                                                         factHandle );
        }
        if ( disconnected ) {
            DefaultFactHandle disconnectedHandle = ((DefaultFactHandle)factHandle).clone();
            disconnectedHandle.disconnect();
View Full Code Here

        assertNotNull( retractedWorker );

        StatefulKnowledgeSessionImpl sessionImpl = (StatefulKnowledgeSessionImpl) ksession;

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

        InternalRuleBase ruleBase = (InternalRuleBase) abstractWorkingMemory.getRuleBase();
        Collection<EntryPointNode> entryPointNodes = ruleBase.getRete().getEntryPointNodes().values();
View Full Code Here

                node = n;
                break;
            }
        }
       
        ReteooWorkingMemoryInterface 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
        JoinNode j4 = ( JoinNode ) j3.getSinkPropagator().getSinks()[0]// $p4
        JoinNode j5 = ( JoinNode ) j4.getSinkPropagator().getSinks()[0]// $p5
        //JoinNode j6 = ( JoinNode ) j5.getSinkPropagator().getSinks()[0];  // $p6 // won't compile
        JoinNode j7 = ( JoinNode ) j5.getSinkPropagator().getSinks()[0]// $p7
        JoinNode j8 = ( JoinNode ) j7.getSinkPropagator().getSinks()[0]// $p8
        JoinNode j9 = ( JoinNode ) j8.getSinkPropagator().getSinks()[0]// $p9
        JoinNode j10 = ( JoinNode ) j9.getSinkPropagator().getSinks()[0]// $p10
        JoinNode j11 = ( JoinNode ) j10.getSinkPropagator().getSinks()[0]// $p11
       
        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 );
       
        c = ( SingleBetaConstraints ) j4.getRawConstraints();
        assertEquals( "$p1", ((VariableConstraint)c.getConstraint()).getRequiredDeclarations()[0].getIdentifier() );
        assertFalse( c.isIndexed() );  
        bm = ( BetaMemory ) wm.getNodeMemory( j4 );
        assertTrue( bm.getLeftTupleMemory() instanceof LeftTupleList );
        assertTrue( bm.getRightTupleMemory() instanceof RightTupleList );
       
        c = ( SingleBetaConstraints ) j5.getRawConstraints();
        assertEquals( "name", ((VariableConstraint)c.getConstraint()).getRequiredDeclarations()[0].getIdentifier() );
        assertTrue( c.isIndexed() );  
        bm = ( BetaMemory ) wm.getNodeMemory( j5 );
        assertTrue( bm.getLeftTupleMemory() instanceof LeftTupleIndexHashTable );
        assertTrue( bm.getRightTupleMemory() instanceof RightTupleIndexHashTable );  
       
        // won't compile
//        c = ( SingleBetaConstraints ) j6.getRawConstraints();
//        assertEquals( "name", ((VariableConstraint)c.getConstraint()).getRequiredDeclarations()[0].getIdentifier() );
//        assertFalse( c.isIndexed() );  
//        bm = ( BetaMemory ) wm.getNodeMemory( j6 );
//        assertTrue( bm.getLeftTupleMemory() instanceof LeftTupleList );
//        assertTrue( bm.getRightTupleMemory() instanceof RightTupleList );  
       
        c = ( SingleBetaConstraints ) j7.getRawConstraints();
        assertEquals( "name", ((VariableConstraint)c.getConstraint()).getRequiredDeclarations()[0].getIdentifier() );
        assertTrue( c.isIndexed() );  
        bm = ( BetaMemory ) wm.getNodeMemory( j7 );
        assertTrue( bm.getLeftTupleMemory() instanceof LeftTupleIndexHashTable );
        assertTrue( bm.getRightTupleMemory() instanceof RightTupleIndexHashTable );  
       
        c = ( SingleBetaConstraints ) j8.getRawConstraints();
        assertEquals( "name", ((VariableConstraint)c.getConstraint()).getRequiredDeclarations()[0].getIdentifier() );
        assertTrue( c.isIndexed() );  
        bm = ( BetaMemory ) wm.getNodeMemory( j8 );
        assertTrue( bm.getLeftTupleMemory() instanceof LeftTupleIndexHashTable );
        assertTrue( bm.getRightTupleMemory() instanceof RightTupleIndexHashTable );    
       
        c = ( SingleBetaConstraints ) j9.getRawConstraints();
        assertEquals( "$p1", ((VariableConstraint)c.getConstraint()).getRequiredDeclarations()[0].getIdentifier() );
        assertFalse( c.isIndexed() );  
        bm = ( BetaMemory ) wm.getNodeMemory( j9 );
        assertTrue( bm.getLeftTupleMemory() instanceof LeftTupleList );
        assertTrue( bm.getRightTupleMemory() instanceof RightTupleList )
       
        c = ( SingleBetaConstraints ) j10.getRawConstraints();
        assertEquals( "name", ((VariableConstraint)c.getConstraint()).getRequiredDeclarations()[0].getIdentifier() );
        assertTrue( c.isIndexed() );  
        bm = ( BetaMemory ) wm.getNodeMemory( j10 );
        assertTrue( bm.getLeftTupleMemory() instanceof LeftTupleIndexHashTable );
        assertTrue( bm.getRightTupleMemory() instanceof RightTupleIndexHashTable )
       
        c = ( SingleBetaConstraints ) j11.getRawConstraints();
        assertEquals( "$p1", ((PredicateConstraint)c.getConstraint()).getRequiredDeclarations()[0].getIdentifier() );
        assertFalse( c.isIndexed() );  
        bm = ( BetaMemory ) wm.getNodeMemory( j11 );
        assertTrue( bm.getLeftTupleMemory() instanceof LeftTupleList );
        assertTrue( bm.getRightTupleMemory() instanceof RightTupleList );         
    }
View Full Code Here

                node = n;
                break;
            }
        }   
       
        ReteooWorkingMemoryInterface 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

TOP

Related Classes of org.drools.reteoo.ReteooWorkingMemoryInterface

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.