Package org.drools.rule

Examples of org.drools.rule.ContextEntry


        }
    }

    public ContextEntry createContextEntry() {
        if (declarations.length == 0) return null;
        ContextEntry contextEntry = new MvelContextEntry(declarations);
        if (isUnification) {
            contextEntry = new UnificationContextEntry(contextEntry, declarations[0]);
        }
        return contextEntry;
    }
View Full Code Here


        }
    }

    public ContextEntry createContextEntry() {
        if (declarations.length == 0) return null;
        ContextEntry contextEntry = new MvelContextEntry(declarations);
        if (isUnification) {
            contextEntry = new UnificationContextEntry(contextEntry, declarations[0]);
        }
        return contextEntry;
    }
View Full Code Here

   * Setup the BetaNode used in each of the tests
   */
  public void setUp() {
    // create mock objects
    constraint = mock(BetaNodeFieldConstraint.class);
    final ContextEntry c = mock(ContextEntry.class);

    when(constraint.createContextEntry()).thenReturn(c);

    this.rule = new Rule("test-rule");
    this.context = new PropagationContextImpl(0,
View Full Code Here

     * @throws IntrospectionException
     */
    public void setUp() throws IntrospectionException {
        // create mock objects
        constraint = mock( BetaNodeFieldConstraint.class );
        final ContextEntry c = mock( ContextEntry.class );
       
        when( constraint.createContextEntry() ).thenReturn(c);

        this.rule = new Rule( "test-rule" );
        this.context = new PropagationContextImpl( 0,
View Full Code Here

    public DefaultBetaConstraints(final BetaNodeFieldConstraint[] constraints,
                                  final RuleBaseConfiguration conf,
                                  final boolean disableIndexing ) {
        this.indexed = -1;
        this.constraints = new LinkedList();
        ContextEntry current = null;
        final int depth = conf.getCompositeKeyDepth();

        // First create a LinkedList of constraints, with the indexed constraints first.
        for ( int i = 0, length = constraints.length; i < length; i++ ) {
            // Determine  if this constraint is indexable
            if ( (!disableIndexing) && conf.isIndexLeftBetaMemory() && conf.isIndexRightBetaMemory() && isIndexable( constraints[i] ) && ( this.indexed < depth-1 ) ) {
                if ( depth >= 1 && this.indexed == -1 ) {
                    // first index, so just add to the front
                    this.constraints.insertAfter( null,
                                                  new LinkedListEntry( constraints[i] ) );
                    this.indexed++;
                } else {
                    // insert this index after  the previous index
                    this.constraints.insertAfter( findNode( this.indexed++ ),
                                                  new LinkedListEntry( constraints[i] ) );
                }
            } else {
                // not indexed, so just add to the  end
                this.constraints.add( new LinkedListEntry( constraints[i] ) );
            }
        }

        // Now create the ContextEntries  in the same order the constraints
        for ( LinkedListEntry entry = (LinkedListEntry) this.constraints.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) {
            final BetaNodeFieldConstraint constraint = (BetaNodeFieldConstraint) entry.getObject();
            final ContextEntry context = constraint.getContextEntry();
            if ( current == null ) {
                current = context;
                this.contexts = context;
            } else {
                current.setNext( context );
View Full Code Here

        }
        return current;
    }

    private ContextEntry findContext(final int pos) {
        ContextEntry current = this.contexts;
        for ( int i = 0; i < pos; i++ ) {
            current = current.getNext();
        }
        return current;
    }
View Full Code Here

     */
    public boolean isAllowedCachedLeft(final Object object) {
        // skip the indexed constraints
        LinkedListEntry entry = (LinkedListEntry) findNode( this.indexed );

        ContextEntry context = findContext( this.indexed );
        while ( entry != null ) {
            if ( !((BetaNodeFieldConstraint) entry.getObject()).isAllowedCachedLeft( context,
                                                                                     object ) ) {
                return false;
            }
            entry = (LinkedListEntry) entry.getNext();
            context = context.getNext();
        }
        return true;
    }
View Full Code Here

     */
    public boolean isAllowedCachedRight(final ReteTuple tuple) {
        // skip the indexed constraints
        LinkedListEntry entry = (LinkedListEntry) findNode( this.indexed );

        ContextEntry context = findContext( this.indexed );
        while ( entry != null ) {
            if ( !((BetaNodeFieldConstraint) entry.getObject()).isAllowedCachedRight( tuple,
                                                                                      context ) ) {
                return false;
            }
            entry = (LinkedListEntry) entry.getNext();
            context = context.getNext();
        }
        return true;
    }
View Full Code Here

        }
    }

    public ContextEntry createContextEntry() {
        if (declarations.length == 0) return null;
        ContextEntry contextEntry = new MvelContextEntry(declarations);
        if (isUnification) {
            contextEntry = new UnificationContextEntry(contextEntry, declarations[0]);
        }
        return contextEntry;
    }
View Full Code Here

     */
    @Before
    public void setUp() throws IntrospectionException {
        // create mock objects
        constraint = mock( BetaNodeFieldConstraint.class );
        final ContextEntry c = mock( ContextEntry.class );
       
        when( constraint.createContextEntry() ).thenReturn(c);

        this.rule = new Rule( "test-rule" );
        this.context = new PropagationContextImpl( 0,
View Full Code Here

TOP

Related Classes of org.drools.rule.ContextEntry

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.