use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.
the class ConstraintReferenceMatcher method filterMatches.
private boolean filterMatches(PrismObject<?> object, String contextDescription) throws SchemaException {
assert targetReference != null;
QName typeNameLookingFor = MoreObjects.firstNonNull(targetReference.getType(), ObjectType.COMPLEX_TYPE);
PrismObjectDefinition<?> objectDefLookingFor = PrismContext.get().getSchemaRegistry().findObjectDefinitionByType(typeNameLookingFor);
if (!object.canRepresent(objectDefLookingFor.getCompileTimeClass())) {
return false;
}
SearchFilterType filterBean = MiscUtil.requireNonNull(targetReference.getFilter(), () -> "No filter in " + contextDescription);
if (filter == null) {
filter = PrismContext.get().getQueryConverter().parseFilter(filterBean, objectDefLookingFor);
VariablesMap variables = new VariablesMap();
variables.put(ExpressionConstants.VAR_POLICY_RULE, evalContext.policyRule, EvaluatedPolicyRule.class);
ModelExpressionThreadLocalHolder.pushExpressionEnvironment(new ExpressionEnvironment<>(evalContext.lensContext, null, evalContext.task, operationResult));
try {
filter = ExpressionUtil.evaluateFilterExpressions(filter, variables, MiscSchemaUtil.getExpressionProfile(), expressionFactory, expressionFactory.getPrismContext(), contextDescription, evalContext.task, operationResult);
} catch (ObjectNotFoundException | SecurityViolationException | ConfigurationException | CommunicationException | ExpressionEvaluationException e) {
throw new SystemException("Error occurred during expression evaluation", e);
} finally {
ModelExpressionThreadLocalHolder.popExpressionEnvironment();
}
}
return filter.match(object.getValue(), SchemaService.get().matchingRuleRegistry());
}
use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.
the class ScriptingTaskCreator method createVariables.
private VariablesMap createVariables() throws SchemaException {
VariablesMap variables = ModelImplUtils.getDefaultVariablesMap(actx.context, null, true);
actx.putIntoVariables(variables);
return variables;
}
use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.
the class ModelImplUtils method getDefaultVariablesMap.
public static <O extends ObjectType> VariablesMap getDefaultVariablesMap(PrismObject<? extends ObjectType> focus, PrismObject<? extends ShadowType> shadow, ResourceShadowDiscriminator discr, PrismObject<ResourceType> resource, PrismObject<SystemConfigurationType> configuration, LensElementContext<O> affectedElementContext, PrismContext prismContext) {
VariablesMap variables = new VariablesMap();
addDefaultVariablesMap(variables, focus, shadow, discr, resource, configuration, affectedElementContext, prismContext);
return variables;
}
use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.
the class AdvancedActivityRunSupportImpl method evaluateQueryExpressions.
@Override
public ObjectQuery evaluateQueryExpressions(@NotNull ObjectQuery query, ExpressionProfile expressionProfile, @NotNull RunningTask task, OperationResult result) throws CommonException {
PrismObject<SystemConfigurationType> configuration = systemObjectCache.getSystemConfiguration(result);
VariablesMap variables = ModelImplUtils.getDefaultVariablesMap(null, null, null, configuration != null ? configuration.asObjectable() : null, PrismContext.get());
try {
ExpressionEnvironment<?, ?, ?> env = new ExpressionEnvironment<>(task, result);
ModelExpressionThreadLocalHolder.pushExpressionEnvironment(env);
return ExpressionUtil.evaluateQueryExpressions(query, variables, expressionProfile, expressionFactory, prismContext, "evaluate query expressions", task, result);
} finally {
ModelExpressionThreadLocalHolder.popExpressionEnvironment();
}
}
use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.
the class TestExpressionSpec method prepareBasicVariablesNoDelta.
private VariablesMap prepareBasicVariablesNoDelta() {
VariablesMap variables = new VariablesMap();
variables.put(VAR_FOO, "fooValue", String.class);
variables.put(VAR_BAR, "barValue", String.class);
return variables;
}
Aggregations