Package org.drools.rule.builder.dialect.mvel

Examples of org.drools.rule.builder.dialect.mvel.MVELAnalysisResult


           
            Map<String, Class<?>> variables = new HashMap<String,Class<?>>();
           
            context.setTypesafe( false ); // we can't know all the types ahead of time with processes, but we don't need return types, so it's ok
            BoundIdentifiers boundIdentifiers = new BoundIdentifiers(variables, context.getPackageBuilder().getGlobals());
            MVELAnalysisResult analysis = ( MVELAnalysisResult ) dialect.analyzeBlock( context,
                                                                                       descr,
                                                                                       dialect.getInterceptors(),
                                                                                       text,
                                                                                       boundIdentifiers,
                                                                                       null,
                                                                                       "context",
                                                                                       org.drools.runtime.process.ProcessContext.class );                     
            context.setTypesafe( typeSafe );

            Set<String> variableNames = analysis.getNotBoundedIdentifiers();
            if (contextResolver != null) {
                for (String variableName: variableNames) {
                    if analysis.getMvelVariables().keySet().contains( variableName ) ||  variableName.equals( "kcontext" ) || variableName.equals( "context" ) ) {
                        continue;
                    }                   
                    VariableScope variableScope = (VariableScope) contextResolver.resolveContext(VariableScope.VARIABLE_SCOPE, variableName);
                    if (variableScope == null) {
                        context.getErrors().add(
View Full Code Here


           
            Map<String, Class<?>> variables = new HashMap<String,Class<?>>();
           
            context.setTypesafe( false ); // we can't know all the types ahead of time with processes, but we don't need return types, so it's ok
            BoundIdentifiers boundIdentifiers = new BoundIdentifiers(variables, context.getPackageBuilder().getGlobals());
            MVELAnalysisResult analysis = ( MVELAnalysisResult ) dialect.analyzeBlock( context,
                                                                                       actionDescr,
                                                                                       dialect.getInterceptors(),
                                                                                       text,
                                                                                       boundIdentifiers,
                                                                                       null,
                                                                                       "context",
                                                                                       org.drools.runtime.process.ProcessContext.class );                      
            context.setTypesafe( typeSafe );
           
            Set<String> variableNames = analysis.getNotBoundedIdentifiers();
            if (contextResolver != null) {
              for (String variableName: variableNames) {
                  if ( analysis.getMvelVariables().keySet().contains( variableName ) ||  variableName.equals( "kcontext" ) || variableName.equals( "context" ) ) {
                      continue;
                  }
                VariableScope variableScope = (VariableScope) contextResolver.resolveContext(VariableScope.VARIABLE_SCOPE, variableName);
                if (variableScope == null) {
                  context.getErrors().add(
View Full Code Here

                                                   String code,
                                                   BoundIdentifiers bindings,
                                                   Map<String, Class<?>> parentVars) {
        MVELDialect mvel = (MVELDialect) context.getDialect("mvel");

        MVELAnalysisResult mvelAnalysis = null;
        try {
            mvelAnalysis = (MVELAnalysisResult) mvel.analyzeBlock(context,
                    context.getRuleDescr(),
                    null,
                    code,
                    bindings,
                    parentVars,
                    "drools",
                    KnowledgeHelper.class);
        } catch (Exception e) {
            // swallow this as the error will be reported else where
        }

        return (mvelAnalysis != null) ? mvelAnalysis.getMvelVariables() : new HashMap<String, Class<?>>();
    }
View Full Code Here

                            "Unable to resolve type " + local.getType() + ":\n" + e.getMessage()));
                }
            }
        }

        MVELAnalysisResult mvelAnalysis = ( MVELAnalysisResult ) mvel.analyzeBlock( context,
                                                                                   context.getRuleDescr(),
                                                                                   mvel.getInterceptors(),
                                                                                   d.getTargetExpression(),
                                                                                   bindings,
                                                                                   localTypes,
                                                                                   "drools",
                                                                                   KnowledgeHelper.class);
        context.setTypesafe( typeSafety );
        if ( mvelAnalysis == null ) {
           // something bad happened, issue already logged in errors
           return false;
        }

        Class ret = mvelAnalysis.getReturnType();

        if ( ret == null ) {
           // not possible to evaluate expression return value
           context.addError(new DescrBuildError(context.getParentDescr(),
                   context.getRuleDescr(),
View Full Code Here

            context.init( this, pkg, typeDescr, pkgRegistry.getDialectCompiletimeRegistry(), dialect, null );
            if ( !type.isTypesafe() ) {
                context.setTypesafe( false );
            }
           
            MVELAnalysisResult results = ( MVELAnalysisResult )
                                context.getDialect().analyzeExpression( context,
                                                                        typeDescr,
                                                                        timestamp,
                                                                        new BoundIdentifiers( Collections.EMPTY_MAP,
                                                                                              Collections.EMPTY_MAP,
                                                                                              Collections.EMPTY_MAP,
                                                                                              type.getTypeClass() ) );

            if ( results != null ) {
                InternalReadAccessor reader = pkg.getClassFieldAccessorStore().getMVELReader( ClassUtils.getPackage(type.getTypeClass()),
                                                                                              type.getTypeClass().getName(),
                                                                                              timestamp,
                                                                                              type.isTypesafe(),
                                                                                              results.getReturnType() );

                MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData( "mvel" );
                data.addCompileable( (MVELCompileable) reader );
                ( (MVELCompileable) reader ).compile( data );
                type.setTimestampExtractor( reader );
            } else {
                this.results.add( new TypeDeclarationError( typeDescr,
                                                            "Error creating field accessors for timestamp field '" + timestamp +
                                                            "' for type '" +
                                                            type.getTypeName() +
                                                            "'" ) );
            }
        }

        annotationDescr = typeDescr.getAnnotation( TypeDeclaration.ATTR_DURATION );
        String duration = ( annotationDescr != null ) ? annotationDescr.getSingleValue() : null;
        if (duration != null) {
            type.setDurationAttribute( duration );
            Package pkg = pkgRegistry.getPackage();
           
            MVELDialect dialect = ( MVELDialect ) pkgRegistry.getDialectCompiletimeRegistry().getDialect( "mvel" );           
            PackageBuildContext context = new PackageBuildContext();           
            context.init( this, pkg, typeDescr, pkgRegistry.getDialectCompiletimeRegistry(), dialect, null );
            if ( !type.isTypesafe() ) {
                context.setTypesafe( false );
            }
           
            MVELAnalysisResult results = ( MVELAnalysisResult )
                                context.getDialect().analyzeExpression( context,
                                                                        typeDescr,
                                                                        duration,
                                                                        new BoundIdentifiers( Collections.EMPTY_MAP,
                                                                                              Collections.EMPTY_MAP,
                                                                                              Collections.EMPTY_MAP,
                                                                                              type.getTypeClass() ) );           

            if (results != null) {
                InternalReadAccessor reader = pkg.getClassFieldAccessorStore().getMVELReader( ClassUtils.getPackage( type.getTypeClass() ),
                                                                                              type.getTypeClass().getName(),
                                                                                              duration,
                                                                                              type.isTypesafe(),
                                                                                              results.getReturnType()  );

                MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData( "mvel" );
                data.addCompileable( (MVELCompileable) reader );
                ( (MVELCompileable) reader ).compile( data );
                type.setDurationExtractor( reader );
View Full Code Here

                                                   String code,
                                                   BoundIdentifiers bindings,
                                                   Map<String, Class<?>> parentVars) {
        MVELDialect mvel = (MVELDialect) context.getDialect("mvel");

        MVELAnalysisResult mvelAnalysis = null;
        try {
            mvelAnalysis = (MVELAnalysisResult) mvel.analyzeBlock(context,
                    context.getRuleDescr(),
                    null,
                    code,
                    bindings,
                    parentVars,
                    "drools",
                    KnowledgeHelper.class);
        } catch (Exception e) {
            // swallow this as the error will be reported else where
        }

        return (mvelAnalysis != null) ? mvelAnalysis.getMvelVariables() : new HashMap<String, Class<?>>();
    }
View Full Code Here

                                                                  "Unable to resolve type " + local.getType() + ":\n" + e.getMessage() ) );
                }
            }
        }

           MVELAnalysisResult mvelAnalysis = ( MVELAnalysisResult ) mvel.analyzeBlock( context,
                                                                                       context.getRuleDescr(),
                                                                                       mvel.getInterceptors(),
                                                                                       d.getTargetExpression(),
                                                                                       bindings,
                                                                                       localTypes,
                                                                                       "drools",
                                                                                       KnowledgeHelper.class);
           context.setTypesafe( typeSafety );
           if ( mvelAnalysis == null ) {
               // something bad happened, issue already logged in errors
               return false;
           }

           Class ret = mvelAnalysis.getReturnType();

           if ( ret == null ) {
               // not possible to evaluate expression return value
               context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                             context.getRuleDescr(),
View Full Code Here

                                                   String code,
                                                   BoundIdentifiers bindings,
                                                   Map<String, Class<?>> parentVars) {
        MVELDialect mvel = (MVELDialect) context.getDialect("mvel");

        MVELAnalysisResult mvelAnalysis = null;
        try {
            mvelAnalysis = (MVELAnalysisResult) mvel.analyzeBlock(context,
                    context.getRuleDescr(),
                    null,
                    code,
                    bindings,
                    parentVars,
                    "drools",
                    KnowledgeHelper.class);
        } catch (Exception e) {
            // swallow this as the error will be reported else where
        }

        return (mvelAnalysis != null) ? mvelAnalysis.getMvelVariables() : new HashMap<String, Class<?>>();
    }
View Full Code Here

                                                                  "Unable to resolve type " + local.getType() + ":\n" + e.getMessage() ) );
                }
            }
        }

           MVELAnalysisResult mvelAnalysis = ( MVELAnalysisResult ) mvel.analyzeBlock( context,
                                                                                       context.getRuleDescr(),
                                                                                       mvel.getInterceptors(),
                                                                                       d.getTargetExpression(),
                                                                                       bindings,
                                                                                       localTypes,
                                                                                       "drools",
                                                                                       KnowledgeHelper.class);
           context.setTypesafe( typeSafety );
           if ( mvelAnalysis == null ) {
               // something bad happened, issue already logged in errors
               return false;
           }

           Class ret = mvelAnalysis.getReturnType();

           if ( ret == null ) {
               // not possible to evaluate expression return value
               context.getErrors().add( new DescrBuildError( context.getParentDescr(),
                                                             context.getRuleDescr(),
View Full Code Here

                                           String code,
                                           BoundIdentifiers bindings,
                                           Map<String, Class<?>> parentVars) {       
        MVELDialect mvel = (MVELDialect) context.getDialect( "mvel" );
       
        MVELAnalysisResult mvelAnalysis = null;
        try {
            mvelAnalysis = ( MVELAnalysisResult ) mvel.analyzeBlock( context,
                                                                     context.getRuleDescr(),
                                                                     null,
                                                                     code,
                                                                     bindings,
                                                                     parentVars,
                                                                     "drools",
                                                                     KnowledgeHelper.class );
        } catch(Exception e) {
            // swallow this as the error will be reported else where
        }       
               
        return (mvelAnalysis != null) ? mvelAnalysis.getMvelVariables() : new HashMap<String, Class<?>>();
    }
View Full Code Here

TOP

Related Classes of org.drools.rule.builder.dialect.mvel.MVELAnalysisResult

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.