Package org.drools.core.common

Examples of org.drools.core.common.DefaultFactHandle


                                              any( InternalFactHandle.class ) ) ).thenReturn( true );
        when( constraint.isAllowedCachedRight( any( LeftTupleImpl.class ),
                                               any( ContextEntry.class ) ) ).thenReturn( true );

        // setup 2 tuples 3 fact handles
        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory
                .insert( "test0" );
        this.node.assertObject( f0,
                                this.context,
                                this.workingMemory );

        final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory
                .insert( "test1" );
        final LeftTupleImpl tuple1 = new LeftTupleImpl( f1, this.node, true );
        this.node.assertLeftTuple( tuple1,
                                   this.context,
                                   this.workingMemory );

        final DefaultFactHandle f2 = (DefaultFactHandle) this.workingMemory
                .insert( "test2" );
        final LeftTupleImpl tuple2 = new LeftTupleImpl( f2, this.node, true );
        this.node.assertLeftTuple( tuple2,
                                   this.context,
                                   this.workingMemory );

        final DefaultFactHandle f3 = (DefaultFactHandle) this.workingMemory
                .insert( "test3" );
        this.node.assertObject( f3,
                                this.context,
                                this.workingMemory );

        final DefaultFactHandle f4 = (DefaultFactHandle) this.workingMemory
                .insert( "test4" );
        this.node.assertObject( f4,
                                this.context,
                                this.workingMemory );

        assertLength( 6,
                      this.sink.getAsserted() );

        // Double check the item is in memory
        final BetaMemory memory = (BetaMemory) this.workingMemory
                .getNodeMemory( this.node );
        assertTrue( memory.getRightTupleMemory().contains(
                                                           f0.getFirstRightTuple() ) );

        // Retract an object, check propagations and memory
        this.node.retractRightTuple( f0.getFirstRightTuple(),
                                     this.context,
                                     this.workingMemory );
        assertLength( 2,
                      this.sink.getRetracted() );

        List tuples = new ArrayList();
        tuples.add( ( (Object[]) this.sink.getRetracted().get( 0 ) )[0] );
        tuples.add( ( (Object[]) this.sink.getRetracted().get( 1 ) )[0] );

        assertTrue( tuples.contains( new LeftTupleImpl( tuple1, f0
                .getFirstRightTuple(), this.sink, true ) ) );
        assertTrue( tuples.contains( new LeftTupleImpl( tuple1, f0
                .getFirstRightTuple(), this.sink, true ) ) );

        // Now check the item is no longer in memory
        assertFalse( memory.getRightTupleMemory().contains(
                                                            f0.getFirstRightTuple() ) );

        this.node.retractLeftTuple( tuple2,
                                    this.context,
                                    this.workingMemory );
        assertEquals( 4,
                      this.sink.getRetracted().size() );

        tuples = new ArrayList();
        tuples.add( ( (Object[]) this.sink.getRetracted().get( 2 ) )[0] );
        tuples.add( ( (Object[]) this.sink.getRetracted().get( 3 ) )[0] );

        assertTrue( tuples.contains( new LeftTupleImpl( tuple2, f3
                .getFirstRightTuple(), this.sink, true ) ) );
        assertTrue( tuples.contains( new LeftTupleImpl( tuple2, f4
                .getFirstRightTuple(), this.sink, true ) ) );
    }
View Full Code Here


                                              any( InternalFactHandle.class ) ) ).thenReturn( false );
        when( constraint.isAllowedCachedRight( any( LeftTupleImpl.class ),
                                               any( ContextEntry.class ) ) ).thenReturn( false );

        // assert first right object
        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory
                .insert( "test0" );
        this.node.assertObject( f0,
                                this.context,
                                this.workingMemory );

        // assert tuple, should add left memory should be 2
        final DefaultFactHandle f1 = new DefaultFactHandle( 1, "cheese" );
        final LeftTupleImpl tuple1 = new LeftTupleImpl( f1, this.node, true );
        this.node.assertLeftTuple( tuple1,
                                   this.context,
                                   this.workingMemory );
View Full Code Here

        // Add the first tuple sink and assert a tuple and object
        // The sink has no memory
        final MockLeftTupleSink sink1 = new MockLeftTupleSink( 2 );
        joinNode.addTupleSink( sink1 );

        final DefaultFactHandle f0 = new DefaultFactHandle( 0, "string0" );

        final LeftTupleImpl tuple1 = new LeftTupleImpl( f0, this.node, true );

        joinNode.assertLeftTuple( tuple1,
                                  this.context,
                                  workingMemory );

        final String string1 = "string1";
        final DefaultFactHandle string1Handle = new DefaultFactHandle( 1,
                                                                       string1 );

        joinNode.assertObject( string1Handle,
                               this.context,
                               workingMemory );
View Full Code Here

        // Add the first tuple sink and assert a tuple and object
        // The sink has no memory
        final MockLeftTupleSink sink1 = new MockLeftTupleSink(2);
        joinNode.addTupleSink(sink1);

        final DefaultFactHandle f0 = new DefaultFactHandle(0, "string0");

        final LeftTupleImpl tuple1 = new LeftTupleImpl(f0, this.node, true);

        joinNode.assertLeftTuple(tuple1, this.context, workingMemory);

        final String string1 = "string1";
        final DefaultFactHandle string1Handle = new DefaultFactHandle(1, string1);

        ModifyPreviousTuples modifyPreviousTuples = new ModifyPreviousTuples(null, null, new EntryPointNode() );

        assertLength(0, sink1.getAsserted());
View Full Code Here

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

        int entryCounter = 0;
        for ( Entry entry : entries ) {
            if ( entry != null ) {
                entryCounter++;
                ObjectEntry oEntry = (ObjectEntry) entry;
                DefaultFactHandle factHandle = (DefaultFactHandle) oEntry.getValue();
                assertNull( factHandle.getObject() );
            }
        }
    }
View Full Code Here

            }
        }

        public Object unmarshal(HierarchicalStreamReader reader,
                                UnmarshallingContext context) {
            FactHandle factHandle = new DefaultFactHandle( reader.getAttribute( "fact-handle" ) );
            String identifierOut = reader.getAttribute( "out-identifier" );

            GetObjectCommand cmd = new GetObjectCommand( factHandle );
            if ( identifierOut != null ) {
                cmd.setOutIdentifier( identifierOut );
View Full Code Here

                    reader.moveUp();
                    reader.moveUp();
                } else if ( reader.getNodeName().equals( "fact-handle" ) ) {
                    String identifier = reader.getAttribute( "identifier" );
                    facts.put( identifier,
                               new DefaultFactHandle( reader.getAttribute( "external-form" ) ) );
                } else if ( reader.getNodeName().equals( "fact-handles" ) ) {
                    String identifier = reader.getAttribute( "identifier" );
                    List<FactHandle> list = new ArrayList<FactHandle>();
                    while ( reader.hasMoreChildren() ) {
                        reader.moveDown();
                        list.add( new DefaultFactHandle( reader.getAttribute( "external-form" ) ) );
                        reader.moveUp();
                    }
                    facts.put( identifier,
                               list );
                } else {
View Full Code Here

                                              context,
                                              null );
                    reader.moveUp();

                    reader.moveDown();
                    FactHandle handle = new DefaultFactHandle( reader.getAttribute( "external-form" ) );
                    reader.moveUp();

                    objects.add( object );
                    handles.add( handle );
                }
View Full Code Here

            endBatchExecution();
        }
    }

    public void initInitialFact(InternalKnowledgeBase kBase, MarshallerReaderContext context) {
        this.initialFactHandle = new DefaultFactHandle(0, InitialFactImpl.getInstance(), 0,  defaultEntryPoint );

        ObjectTypeConf otc = this.defaultEntryPoint.getObjectTypeConfigurationRegistry()
                                                   .getObjectTypeConf(this.defaultEntryPoint.getEntryPoint(), this.initialFactHandle.getObject());
        PropagationContextFactory ctxFact = kBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
View Full Code Here

TOP

Related Classes of org.drools.core.common.DefaultFactHandle

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.