Package org.drools.rule

Examples of org.drools.rule.Declaration


        }
        return Collections.unmodifiableList( list );
    }

    public Object getDeclarationValue(String variableName) {
        Declaration decl = this.rtn.getSubRule().getOuterDeclarations().get( variableName );
        InternalFactHandle handle = this.tuple.get( decl );
        // need to double check, but the working memory reference is only used for resolving globals, right?
        return decl.getValue( null, handle.getObject() );
    }
View Full Code Here


                                                       Set<Declaration> requiredDecl,
                                                       final BoundIdentifiers usedIdentifiers ) {
        final Declaration[] previousDeclarations = new Declaration[usedIdentifiers.getDeclrClasses().size()];
        int i = 0;
        for ( String key : usedIdentifiers.getDeclrClasses().keySet() ) {
            Declaration d = declsInScope.get( key );
            previousDeclarations[i++] = d;
            requiredDecl.add( d );
        }
        return previousDeclarations;
    }
View Full Code Here

                                   int index,
                                   InternalReadAccessor arrayReader,
                                   AccumulateFunctionCallDescr fc,
                                   AccumulateFunction function ) {
        // bind function result on the result pattern
        Declaration declr = pattern.addDeclaration( fc.getBind() );

        Class< ? > type = function instanceof TypedAccumulateFunction ? ((TypedAccumulateFunction) function).getResultType() : Object.class;

        // this bit is different, notice its the ArrayElementReader that we wire up to, not the declaration.
        ArrayElementReader reader = new ArrayElementReader( arrayReader,
                                                            index,
                                                            type );
        declr.setReadAccessor( reader );
    }
View Full Code Here

       
       
        Collection<Declaration> declrCollection = new ArrayList( results.getDeclarations(0).values() );
       
        for ( Iterator<Declaration> it =  declrCollection.iterator(); it.hasNext(); ) {
            Declaration declr = it.next();
            if ( set.contains( declr.getIdentifier()  ) ) {
                it.remove();
            }
        }  
       
        Declaration[] declrs = new Declaration[parameters.length + declrCollection.size() ];
        int i = 0;
        for ( Declaration declr : parameters ) {
            declrs[i++] = declr;
        }
        for ( Declaration declr : declrCollection ) {
            declrs[i++] = declr;
        }      
       

        this.results = new ArrayList<ArrayList<Object>>( results.size() );
        this.factHandles = new ArrayList<ArrayList<FactHandle>> ( results.size() );

        int length = declrs.length;
       
        identifiers = new LinkedHashMap<String, Integer>( length );
        for ( i = 0; i < length; i++ ) {
            identifiers.put( declrs[i].getIdentifier(),
                             i );
        }
       
       
        for ( org.drools.QueryResult result : results ) {
            ArrayList<Object> row = new ArrayList<Object>();
            ArrayList<FactHandle> rowHandle = new ArrayList<FactHandle>();

            for ( i = 0; i < length; i++ ) {
                Declaration declr = declrs[i];
                row.add( result.get( declr ) );
                rowHandle.add( result.getFactHandle( declr ) );
            }

            this.results.add( row );
View Full Code Here

    public Object get(String identifier) {
        if ( factHandles == null ) {
            this.factHandles = this.leftTuple.toFactHandles();
        }
        Declaration declr = this.rule.getDeclaration( identifier );
        if ( declr == null ) {
            throw new RuntimeException("The identifier '" + identifier + "' does not exist as a bound varirable for this query" );
        }
        InternalFactHandle factHandle = getFactHandle( declr );
        return declr.getValue( null, factHandle.getObject() );
    }
View Full Code Here

    public FactHandle getFactHandle(String identifier) {
        if ( factHandles == null ) {
            this.factHandles = this.leftTuple.toFactHandles();
        }
        Declaration declr = this.rule.getDeclaration( identifier );
        if ( declr == null ) {
            throw new RuntimeException("The identifier '" + identifier + "' does not exist as a bound varirable for this query" );
        }
        InternalFactHandle factHandle = getFactHandle( declr );
        return factHandle;
View Full Code Here

       
       
        Collection<Declaration> declrCollection = new ArrayList( results.getDeclarations(0).values() );
       
        for ( Iterator<Declaration> it =  declrCollection.iterator(); it.hasNext(); ) {
            Declaration declr = it.next();
            if ( set.contains( declr.getIdentifier()  ) ) {
                it.remove();
            }
        }  
       
        String[] declrs = new String[parameters.length + declrCollection.size() ];
        int i = 0;
        for ( Declaration declr : parameters ) {
            declrs[i++] = declr.getIdentifier();
        }
        for ( Declaration declr : declrCollection ) {
            declrs[i++] = declr.getIdentifier();
        }      
        identifiers = declrs;
        return identifiers;
    }
View Full Code Here

        }
        return Collections.unmodifiableList( list );
    }

    public Object getDeclarationValue(String variableName) {
        Declaration decl = this.rtn.getSubRule().getOuterDeclarations().get( variableName );
        InternalFactHandle handle = this.tuple.get( decl );
        // need to double check, but the working memory reference is only used for resolving globals, right?
        return decl.getValue( null, handle.getObject() );
    }
View Full Code Here

                extractor = store.getReader( reteTesterHelper.getTypeResolver().resolveType( type ),
                                             field,
                                             getClass().getClassLoader() );
            }           

            Declaration declr = new Declaration( name,
                                                 extractor,
                                                 pattern );
            context.put( name,
                         declr );
        } catch ( Exception e ) {
View Full Code Here

                                                               getClass().getClassLoader() );

        final Pattern pattern = new Pattern( 0,
                                             new ClassObjectType( Person.class ) );

        final Declaration declaration = new Declaration( "age",
                                                         ageExtractor,
                                                         pattern );

        MvelConstraint variableConstraint = new MvelConstraintTestUtil("price == age", declaration, priceExtractor);
View Full Code Here

TOP

Related Classes of org.drools.rule.Declaration

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.