Package org.drools.lang.descr.AccumulateDescr

Examples of org.drools.lang.descr.AccumulateDescr.AccumulateFunctionCallDescr


            visit( descr.getInput() );
        }
        tmpstr += this.template;

        if ( descr.isExternalFunction() ) {
            AccumulateFunctionCallDescr func = descr.getFunctions().get( 0 );
            tmpstr += "<external-function evaluator=\"" + func.getFunction() + "\" expression=\"" + func.getParams()[0] + "\"/>";
        } else tmpstr += "<init>" + descr.getInitCode() + "</init><action>" + descr.getActionCode() + "</action><result>" + descr.getResultCode() + "</result>";

        this.template = tmpstr + " </accumulate> </from> ";
    }
View Full Code Here


                       
            BoundIdentifiers boundIds = new BoundIdentifiers( declarationClasses, context.getPackageBuilder().getGlobals() ) ;         
           
            if ( accumDescr.isExternalFunction() ) {
                // build an external function executor
                AccumulateFunctionCallDescr func = accumDescr.getFunctions().get( 0 );
                AccumulateFunction function = context.getConfiguration().getAccumulateFunction( func.getFunction() );

                if( function == null ) {
                    context.getErrors().add( new DescrBuildError( accumDescr,
                                                                  context.getRuleDescr(),
                                                                  null,
                                                                  "Unknown accumulate function: '"+func.getFunction()+"' on rule '"+context.getRuleDescr().getName()+"'. All accumulate functions must be registered before building a resource." ) );
                    return null;
                }

                final AnalysisResult analysis = dialect.analyzeExpression( context,
                                                                           accumDescr,
                                                                           func.getParams()[0],
                                                                           boundIds );

               
                MVELCompilationUnit unit = dialect.getMVELCompilationUnit( func.getParams()[0],
                                                                           analysis,
                                                                           getUsedDeclarations( decls, analysis ),
                                                                           getUsedDeclarations( sourceOuterDeclr, analysis ),
                                                                           null,
                                                                           context,
View Full Code Here

        Accumulate accumulate = null;

        if ( accumDescr.isExternalFunction() ) {
            // if it is an external function, build a method for it
            // TODO: add the support to multiple functions
            AccumulateFunctionCallDescr func = accumDescr.getFunctions().get( 0 );
            AccumulateFunction function = context.getConfiguration().getAccumulateFunction( func.getFunction() );

            if ( function == null ) {
                context.getErrors().add( new DescrBuildError( accumDescr,
                                                              context.getRuleDescr(),
                                                              null,
                                                              "Unknown accumulate function: '" + func.getFunction() + "' on rule '" + context.getRuleDescr().getName() + "'. All accumulate functions must be registered before building a resource." ) );
                return null;
            }

            final JavaAnalysisResult analysis = (JavaAnalysisResult) context.getDialect().analyzeBlock( context,
                                                                                                        accumDescr,
                                                                                                        func.getParams().length > 0 ? func.getParams()[0] : "\"\"",
                                                                                                        new BoundIdentifiers( declCls, context.getPackageBuilder().getGlobals() ) );

            final BoundIdentifiers usedIdentifiers = analysis.getBoundIdentifiers();

            final Declaration[] previousDeclarations = usedIdentifiers.getDeclarations().values().toArray(new Declaration[usedIdentifiers.getDeclarations().size()]);
            final Declaration[] sourceDeclArr = (Declaration[]) source.getOuterDeclarations().values().toArray( new Declaration[0] );

            final String className = "accumulateExpression" + context.getNextId();

            final Map<String, Object> map = createVariableContext( className,
                                                                   func.getParams().length > 0 ? func.getParams()[0] : "\"\"",
                                                                   context,
                                                                   previousDeclarations,
                                                                   sourceDeclArr,
                                                                   usedIdentifiers.getGlobals(),
                                                                   null );
View Full Code Here

            visit( descr.getInput() );
        }
        tmpstr += this.template;

        if ( descr.isExternalFunction() ) {
            AccumulateFunctionCallDescr func = descr.getFunctions().get( 0 );
            tmpstr += "<external-function evaluator=\"" + func.getFunction() + "\" expression=\"" + func.getParams()[0] + "\"/>";
        } else tmpstr += "<init>" + descr.getInitCode() + "</init><action>" + descr.getActionCode() + "</action><result>" + descr.getResultCode() + "</result>";

        this.template = tmpstr + " </accumulate> </from> ";
    }
View Full Code Here

TOP

Related Classes of org.drools.lang.descr.AccumulateDescr.AccumulateFunctionCallDescr

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.