Search in sources :

Example 1 with PathExpressionEvaluatorFactory

use of com.evolveum.midpoint.model.common.expression.evaluator.PathExpressionEvaluatorFactory in project midpoint by Evolveum.

the class ExpressionTestUtil method createInitializedExpressionFactory.

public static ExpressionFactory createInitializedExpressionFactory(ObjectResolver resolver, ProtectorImpl protector, PrismContext prismContext, SecurityEnforcer securityEnforcer) {
    ExpressionFactory expressionFactory = new ExpressionFactory(resolver, securityEnforcer, prismContext);
    // asIs
    AsIsExpressionEvaluatorFactory asIsFactory = new AsIsExpressionEvaluatorFactory(prismContext, protector);
    expressionFactory.addEvaluatorFactory(asIsFactory);
    expressionFactory.setDefaultEvaluatorFactory(asIsFactory);
    // value
    LiteralExpressionEvaluatorFactory valueFactory = new LiteralExpressionEvaluatorFactory(prismContext);
    expressionFactory.addEvaluatorFactory(valueFactory);
    // const
    ConstantsManager constManager = new ConstantsManager(createConfiguration());
    ConstExpressionEvaluatorFactory constFactory = new ConstExpressionEvaluatorFactory(protector, constManager, prismContext);
    expressionFactory.addEvaluatorFactory(constFactory);
    // path
    PathExpressionEvaluatorFactory pathFactory = new PathExpressionEvaluatorFactory(prismContext, resolver, protector);
    expressionFactory.addEvaluatorFactory(pathFactory);
    // generate
    ValuePolicyProcessor valuePolicyGenerator = new ValuePolicyProcessor();
    valuePolicyGenerator.setExpressionFactory(expressionFactory);
    GenerateExpressionEvaluatorFactory generateFactory = new GenerateExpressionEvaluatorFactory(protector, resolver, valuePolicyGenerator, prismContext);
    expressionFactory.addEvaluatorFactory(generateFactory);
    // script
    Collection<FunctionLibrary> functions = new ArrayList<FunctionLibrary>();
    functions.add(FunctionLibraryUtil.createBasicFunctionLibrary(prismContext, protector));
    functions.add(FunctionLibraryUtil.createLogFunctionLibrary(prismContext));
    ScriptExpressionFactory scriptExpressionFactory = new ScriptExpressionFactory(resolver, prismContext, protector);
    scriptExpressionFactory.setFunctions(functions);
    XPathScriptEvaluator xpathEvaluator = new XPathScriptEvaluator(prismContext);
    scriptExpressionFactory.registerEvaluator(XPathScriptEvaluator.XPATH_LANGUAGE_URL, xpathEvaluator);
    Jsr223ScriptEvaluator groovyEvaluator = new Jsr223ScriptEvaluator("Groovy", prismContext, protector);
    scriptExpressionFactory.registerEvaluator(groovyEvaluator.getLanguageUrl(), groovyEvaluator);
    ScriptExpressionEvaluatorFactory scriptExpressionEvaluatorFactory = new ScriptExpressionEvaluatorFactory(scriptExpressionFactory, securityEnforcer);
    expressionFactory.addEvaluatorFactory(scriptExpressionEvaluatorFactory);
    return expressionFactory;
}
Also used : ScriptExpressionFactory(com.evolveum.midpoint.model.common.expression.script.ScriptExpressionFactory) Jsr223ScriptEvaluator(com.evolveum.midpoint.model.common.expression.script.jsr223.Jsr223ScriptEvaluator) ScriptExpressionFactory(com.evolveum.midpoint.model.common.expression.script.ScriptExpressionFactory) ExpressionFactory(com.evolveum.midpoint.repo.common.expression.ExpressionFactory) ConstantsManager(com.evolveum.midpoint.model.common.ConstantsManager) ArrayList(java.util.ArrayList) FunctionLibrary(com.evolveum.midpoint.model.common.expression.functions.FunctionLibrary) AsIsExpressionEvaluatorFactory(com.evolveum.midpoint.repo.common.expression.evaluator.AsIsExpressionEvaluatorFactory) LiteralExpressionEvaluatorFactory(com.evolveum.midpoint.repo.common.expression.evaluator.LiteralExpressionEvaluatorFactory) ValuePolicyProcessor(com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyProcessor) ConstExpressionEvaluatorFactory(com.evolveum.midpoint.model.common.expression.evaluator.ConstExpressionEvaluatorFactory) GenerateExpressionEvaluatorFactory(com.evolveum.midpoint.model.common.expression.evaluator.GenerateExpressionEvaluatorFactory) ScriptExpressionEvaluatorFactory(com.evolveum.midpoint.model.common.expression.script.ScriptExpressionEvaluatorFactory) PathExpressionEvaluatorFactory(com.evolveum.midpoint.model.common.expression.evaluator.PathExpressionEvaluatorFactory) XPathScriptEvaluator(com.evolveum.midpoint.model.common.expression.script.xpath.XPathScriptEvaluator)

Aggregations

ConstantsManager (com.evolveum.midpoint.model.common.ConstantsManager)1 ConstExpressionEvaluatorFactory (com.evolveum.midpoint.model.common.expression.evaluator.ConstExpressionEvaluatorFactory)1 GenerateExpressionEvaluatorFactory (com.evolveum.midpoint.model.common.expression.evaluator.GenerateExpressionEvaluatorFactory)1 PathExpressionEvaluatorFactory (com.evolveum.midpoint.model.common.expression.evaluator.PathExpressionEvaluatorFactory)1 FunctionLibrary (com.evolveum.midpoint.model.common.expression.functions.FunctionLibrary)1 ScriptExpressionEvaluatorFactory (com.evolveum.midpoint.model.common.expression.script.ScriptExpressionEvaluatorFactory)1 ScriptExpressionFactory (com.evolveum.midpoint.model.common.expression.script.ScriptExpressionFactory)1 Jsr223ScriptEvaluator (com.evolveum.midpoint.model.common.expression.script.jsr223.Jsr223ScriptEvaluator)1 XPathScriptEvaluator (com.evolveum.midpoint.model.common.expression.script.xpath.XPathScriptEvaluator)1 ValuePolicyProcessor (com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyProcessor)1 ExpressionFactory (com.evolveum.midpoint.repo.common.expression.ExpressionFactory)1 AsIsExpressionEvaluatorFactory (com.evolveum.midpoint.repo.common.expression.evaluator.AsIsExpressionEvaluatorFactory)1 LiteralExpressionEvaluatorFactory (com.evolveum.midpoint.repo.common.expression.evaluator.LiteralExpressionEvaluatorFactory)1 ArrayList (java.util.ArrayList)1