Search in sources :

Example 1 with MVELDialectRuntimeData

use of org.drools.core.rule.MVELDialectRuntimeData in project drools by kiegroup.

the class TypeDeclarationConfigurator method getFieldExtractor.

private static InternalReadAccessor getFieldExtractor(TypeDeclaration type, String timestampField, InternalKnowledgePackage pkg, MVELAnalysisResult results) {
    InternalReadAccessor reader = pkg.getClassFieldAccessorStore().getMVELReader(ClassUtils.getPackage(type.getTypeClass()), type.getTypeClass().getName(), timestampField, type.isTypesafe(), results.getReturnType());
    MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData("mvel");
    data.addCompileable((MVELCompileable) reader);
    ((MVELCompileable) reader).compile(data);
    return reader;
}
Also used : MVELDialectRuntimeData(org.drools.core.rule.MVELDialectRuntimeData) MVELCompileable(org.drools.core.base.mvel.MVELCompileable) InternalReadAccessor(org.drools.core.spi.InternalReadAccessor)

Example 2 with MVELDialectRuntimeData

use of org.drools.core.rule.MVELDialectRuntimeData in project drools by kiegroup.

the class PhreakJoinNodeTest method createContext.

public BuildContext createContext() {
    RuleBaseConfiguration conf = new RuleBaseConfiguration();
    KnowledgeBaseImpl rbase = new KnowledgeBaseImpl("ID", conf);
    BuildContext buildContext = new BuildContext(rbase);
    RuleImpl rule = new RuleImpl("rule1").setPackage("org.pkg1");
    InternalKnowledgePackage pkg = new KnowledgePackageImpl("org.pkg1");
    pkg.getDialectRuntimeRegistry().setDialectData("mvel", new MVELDialectRuntimeData());
    pkg.addRule(rule);
    buildContext.setRule(rule);
    return buildContext;
}
Also used : RuleBaseConfiguration(org.drools.core.RuleBaseConfiguration) MVELDialectRuntimeData(org.drools.core.rule.MVELDialectRuntimeData) BuildContext(org.drools.core.reteoo.builder.BuildContext) KnowledgeBaseImpl(org.drools.core.impl.KnowledgeBaseImpl) RuleImpl(org.drools.core.definitions.rule.impl.RuleImpl) KnowledgePackageImpl(org.drools.core.definitions.impl.KnowledgePackageImpl) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Example 3 with MVELDialectRuntimeData

use of org.drools.core.rule.MVELDialectRuntimeData in project drools by kiegroup.

the class PhreakNotNodeTest method createContext.

public BuildContext createContext() {
    RuleBaseConfiguration conf = new RuleBaseConfiguration();
    KnowledgeBaseImpl rbase = new KnowledgeBaseImpl("ID", conf);
    BuildContext buildContext = new BuildContext(rbase);
    RuleImpl rule = new RuleImpl("rule1").setPackage("org.pkg1");
    InternalKnowledgePackage pkg = new KnowledgePackageImpl("org.pkg1");
    pkg.getDialectRuntimeRegistry().setDialectData("mvel", new MVELDialectRuntimeData());
    pkg.addRule(rule);
    buildContext.setRule(rule);
    return buildContext;
}
Also used : RuleBaseConfiguration(org.drools.core.RuleBaseConfiguration) MVELDialectRuntimeData(org.drools.core.rule.MVELDialectRuntimeData) BuildContext(org.drools.core.reteoo.builder.BuildContext) KnowledgeBaseImpl(org.drools.core.impl.KnowledgeBaseImpl) RuleImpl(org.drools.core.definitions.rule.impl.RuleImpl) KnowledgePackageImpl(org.drools.core.definitions.impl.KnowledgePackageImpl) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Example 4 with MVELDialectRuntimeData

use of org.drools.core.rule.MVELDialectRuntimeData in project drools by kiegroup.

the class SegmentPropagationTest method createContext.

public BuildContext createContext() {
    RuleBaseConfiguration conf = new RuleBaseConfiguration();
    KnowledgeBaseImpl rbase = new KnowledgeBaseImpl("ID", conf);
    BuildContext buildContext = new BuildContext(rbase);
    RuleImpl rule = new RuleImpl("rule1").setPackage("org.pkg1");
    InternalKnowledgePackage pkg = new KnowledgePackageImpl("org.pkg1");
    pkg.getDialectRuntimeRegistry().setDialectData("mvel", new MVELDialectRuntimeData());
    pkg.addRule(rule);
    buildContext.setRule(rule);
    return buildContext;
}
Also used : RuleBaseConfiguration(org.drools.core.RuleBaseConfiguration) MVELDialectRuntimeData(org.drools.core.rule.MVELDialectRuntimeData) BuildContext(org.drools.core.reteoo.builder.BuildContext) KnowledgeBaseImpl(org.drools.core.impl.KnowledgeBaseImpl) RuleImpl(org.drools.core.definitions.rule.impl.RuleImpl) KnowledgePackageImpl(org.drools.core.definitions.impl.KnowledgePackageImpl) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Example 5 with MVELDialectRuntimeData

use of org.drools.core.rule.MVELDialectRuntimeData in project drools by kiegroup.

the class MVELEnabledExpression method getValue.

public boolean getValue(final Tuple tuple, final Declaration[] declrs, final RuleImpl rule, final WorkingMemory workingMemory) {
    VariableResolverFactory factory = unit.getFactory(null, declrs, rule, null, (LeftTuple) tuple, null, (InternalWorkingMemory) workingMemory, workingMemory.getGlobalResolver());
    // do we have any functions for this namespace?
    InternalKnowledgePackage pkg = workingMemory.getKnowledgeBase().getPackage("MAIN");
    if (pkg != null) {
        MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData(this.id);
        factory.setNextFactory(data.getFunctionFactory());
    }
    return ((Boolean) MVEL.executeExpression(this.expr, null, factory)).booleanValue();
}
Also used : MVELDialectRuntimeData(org.drools.core.rule.MVELDialectRuntimeData) VariableResolverFactory(org.mvel2.integration.VariableResolverFactory) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Aggregations

MVELDialectRuntimeData (org.drools.core.rule.MVELDialectRuntimeData)34 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)14 DescrBuildError (org.drools.compiler.compiler.DescrBuildError)10 MVELCompilationUnit (org.drools.core.base.mvel.MVELCompilationUnit)10 Declaration (org.drools.core.rule.Declaration)9 VariableResolverFactory (org.mvel2.integration.VariableResolverFactory)9 KnowledgePackageImpl (org.drools.core.definitions.impl.KnowledgePackageImpl)8 BoundIdentifiers (org.drools.compiler.compiler.BoundIdentifiers)7 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)5 ParserConfiguration (org.mvel2.ParserConfiguration)5 AnalysisResult (org.drools.compiler.compiler.AnalysisResult)4 RuleBaseConfiguration (org.drools.core.RuleBaseConfiguration)4 Test (org.junit.Test)4 ParserContext (org.mvel2.ParserContext)4 StringReader (java.io.StringReader)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)3 PackageBuildContext (org.drools.compiler.rule.builder.PackageBuildContext)3 MVELDialect (org.drools.compiler.rule.builder.dialect.mvel.MVELDialect)3