Package org.drools.core.common

Examples of org.drools.core.common.EventFactHandle


    @Test
    public void testMetBy() {
        registry.addEvaluatorDefinition( DuringEvaluatorDefinition.class.getName() );

        EventFactHandle foo = new EventFactHandle( 1,
                                                   "foo",
                                                   1,
                                                   10,
                                                   8,
                                                   new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle bar = new EventFactHandle( 2,
                                                   "bar",
                                                   1,
                                                   2,
                                                   8,
                                                   new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle drool = new EventFactHandle( 1,
                                                     "drool",
                                                     1,
                                                     5,
                                                     3,
                                                     new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle mole = new EventFactHandle( 1,
                                                    "mole",
                                                    1,
                                                    4,
                                                    7,
                                                    new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
View Full Code Here


    @Test
    public void testOverlaps() {
        registry.addEvaluatorDefinition( DuringEvaluatorDefinition.class.getName() );

        EventFactHandle foo = new EventFactHandle( 1,
                                                   "foo",
                                                   1,
                                                   2,
                                                   8,
                                                   new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle bar = new EventFactHandle( 2,
                                                   "bar",
                                                   1,
                                                   7,
                                                   7,
                                                   new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle drool = new EventFactHandle( 1,
                                                     "drool",
                                                     1,
                                                     11,
                                                     5,
                                                     new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle mole = new EventFactHandle( 1,
                                                    "mole",
                                                    1,
                                                    5,
                                                    5,
                                                    new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
View Full Code Here

    @Test
    public void testOverlapedBy() {
        registry.addEvaluatorDefinition( DuringEvaluatorDefinition.class.getName() );

        EventFactHandle foo = new EventFactHandle( 1,
                                                   "foo",
                                                   1,
                                                   7,
                                                   8,
                                                   new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle bar = new EventFactHandle( 2,
                                                   "bar",
                                                   1,
                                                   2,
                                                   8,
                                                   new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle drool = new EventFactHandle( 1,
                                                     "drool",
                                                     1,
                                                     11,
                                                     5,
                                                     new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
        EventFactHandle mole = new EventFactHandle( 1,
                                                    "mole",
                                                    1,
                                                    7,
                                                    3,
                                                    new DisconnectedWorkingMemoryEntryPoint( "DEFAULT" ) );
View Full Code Here

                                                     _handle.getId(),
                                                     _handle.getRecency() );
                break;
            }
            case EVENT : {
                handle = new EventFactHandle( _handle.getId(),
                                              object,
                                              _handle.getRecency(),
                                              _handle.getTimestamp(),
                                              _handle.getDuration(),
                                              entryPoint );
View Full Code Here

            long duration = 0;
            if ( type.getDurationExtractor() != null ) {
                duration = type.getDurationExtractor().getLongValue( workingMemory,
                                                                     object );
            }
            return new EventFactHandle( id,
                                        object,
                                        recency,
                                        timestamp,
                                        duration,
                                        wmEntryPoint );
View Full Code Here

    public void assertObject(final InternalFactHandle factHandle,
                             final PropagationContext pctx,
                             final InternalWorkingMemory workingMemory) {
        final WindowMemory memory = (WindowMemory) workingMemory.getNodeMemory(this);

        EventFactHandle evFh = ( EventFactHandle ) factHandle;
        // must guarantee single thread from now on
        memory.gate.lock();
        try {
            int index = 0;
            for (AlphaNodeFieldConstraint constraint : constraints) {
                if (!constraint.isAllowed(evFh, workingMemory, memory.context[index++])) {
                    return;
                }
            }

            RightTuple rightTuple = new RightTuple( evFh, this );
            rightTuple.setPropagationContext( pctx );

            InternalFactHandle clonedFh = evFh.cloneAndLink()// this is cloned, as we need to separate the child RightTuple references
            rightTuple.setObject( clonedFh );

            // process the behavior
            if (!behavior.assertFact(memory, clonedFh, pctx, workingMemory)) {
                return;
View Full Code Here

        final WindowMemory memory = (WindowMemory) workingMemory.getNodeMemory(this);

        // must guarantee single thread from now on
        memory.gate.lock();

        EventFactHandle originalFactHandle = ( EventFactHandle ) rightTuple.getFactHandle();
        EventFactHandle cloneFactHandle  = ( EventFactHandle ) rightTuple.getObject();
        originalFactHandle.quickCloneUpdate( cloneFactHandle ); // make sure all fields are updated

        // behavior modify
        try {
            int index = 0;
            boolean isAllowed = true;
            for (AlphaNodeFieldConstraint constraint : constraints) {
                if (!constraint.isAllowed(cloneFactHandle,
                                          workingMemory,
                                          memory.context[index++])) {
                    isAllowed = false;
                    break;
                }
            }

            if  ( isAllowed ) {
                ModifyPreviousTuples modifyPreviousTuples = new ModifyPreviousTuples(cloneFactHandle.getFirstLeftTuple(), cloneFactHandle.getFirstRightTuple(), true );
                cloneFactHandle.clearLeftTuples();
                cloneFactHandle.clearRightTuples();

                this.sink.propagateModifyObject(cloneFactHandle,
                                                modifyPreviousTuples,
                                                context,
                                                workingMemory);
View Full Code Here

                              final PropagationContext pctx,
                              final InternalWorkingMemory workingMemory) {
        SlidingLengthWindowContext window = (SlidingLengthWindowContext) context;
        window.pos = (window.pos + 1) % window.handles.length;
        if ( window.handles[window.pos] != null ) {
            final EventFactHandle previous = window.handles[window.pos];
            // retract previous
            final PropagationContext expiresPctx = new PropagationContextImpl( pctx.getPropagationNumber(),
                                                                               PropagationContext.EXPIRATION,
                                                                               null,
                                                                               null,
View Full Code Here

                                                     id,
                                                     recency );
                break;
            }
            case 2: {
                handle = new EventFactHandle( id, object, recency, startTimeStamp, duration, entryPoint );
                ( (EventFactHandle) handle ).setExpired( expired );
                ( (EventFactHandle) handle ).setActivationsCount( activationsCount );
                break;
            }
            default: {
View Full Code Here

        stream.writeInt( handle.getId() );
        stream.writeLong( handle.getRecency() );
       
        if ( type == 2) {
            // is event
            EventFactHandle efh = ( EventFactHandle ) handle;
            stream.writeLong( efh.getStartTimestamp() );
            stream.writeLong( efh.getDuration() );
            stream.writeBoolean( efh.isExpired() );
            stream.writeLong( efh.getActivationsCount() );
        }

        //context.out.println( "Object : int:" + handle.getId() + " long:" + handle.getRecency() );
        //context.out.println( handle.getObject() );
View Full Code Here

TOP

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

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.