use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class ChangeExecutor method prepareScripts.
private <F extends ObjectType, T extends ObjectType> OperationProvisioningScriptsType prepareScripts(PrismObject<T> changedObject, LensContext<F> context, LensElementContext<T> objectContext, ProvisioningOperationTypeType operation, ResourceType resource, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
if (resource == null) {
LOGGER.warn("Resource does not exist. Skipping processing scripts.");
return null;
}
OperationProvisioningScriptsType resourceScripts = resource.getScripts();
PrismObject<? extends ShadowType> resourceObject = (PrismObject<? extends ShadowType>) changedObject;
PrismObject<F> user = null;
if (context.getFocusContext() != null) {
if (context.getFocusContext().getObjectNew() != null) {
user = context.getFocusContext().getObjectNew();
} else if (context.getFocusContext().getObjectOld() != null) {
user = context.getFocusContext().getObjectOld();
}
}
ResourceShadowDiscriminator discr = ((LensProjectionContext) objectContext).getResourceShadowDiscriminator();
ExpressionVariables variables = Utils.getDefaultExpressionVariables(user, resourceObject, discr, resource.asPrismObject(), context.getSystemConfiguration(), objectContext);
return evaluateScript(resourceScripts, discr, operation, null, variables, context, objectContext, task, result);
}
use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class Utils method getDefaultExpressionVariables.
public static <O extends ObjectType> ExpressionVariables getDefaultExpressionVariables(PrismObject<? extends ObjectType> focus, PrismObject<? extends ShadowType> shadow, ResourceShadowDiscriminator discr, PrismObject<ResourceType> resource, PrismObject<SystemConfigurationType> configuration, LensElementContext<O> affectedElementContext) {
ExpressionVariables variables = new ExpressionVariables();
addDefaultExpressionVariables(variables, focus, shadow, discr, resource, configuration, affectedElementContext);
return variables;
}
use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class CorrelationConfirmationEvaluator method satisfyCondition.
private boolean satisfyCondition(ShadowType currentShadow, ConditionalSearchFilterType conditionalFilter, ResourceType resourceType, SystemConfigurationType configurationType, String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
if (conditionalFilter.getCondition() == null) {
return true;
}
ExpressionType condition = conditionalFilter.getCondition();
ExpressionVariables variables = Utils.getDefaultExpressionVariables(null, currentShadow, resourceType, configurationType);
ItemDefinition outputDefinition = new PrismPropertyDefinitionImpl(ExpressionConstants.OUTPUT_ELEMENT_NAME, DOMUtil.XSD_BOOLEAN, prismContext);
PrismPropertyValue<Boolean> satisfy = (PrismPropertyValue) ExpressionUtil.evaluateExpression(variables, outputDefinition, condition, expressionFactory, shortDesc, task, parentResult);
if (satisfy.getValue() == null) {
return false;
}
return satisfy.getValue();
}
use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class CustomTransport method getDefaultVariables.
protected ExpressionVariables getDefaultVariables(Message message, Event event) throws UnsupportedEncodingException {
ExpressionVariables variables = new ExpressionVariables();
variables.addVariableDefinition(SchemaConstants.C_MESSAGE, message);
variables.addVariableDefinition(SchemaConstants.C_EVENT, event);
return variables;
}
use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class SimpleSmsTransport method getDefaultVariables.
protected ExpressionVariables getDefaultVariables(String from, String to, Message message) throws UnsupportedEncodingException {
ExpressionVariables variables = new ExpressionVariables();
variables.addVariableDefinition(SchemaConstants.C_FROM, from);
variables.addVariableDefinition(SchemaConstants.C_TO, to);
variables.addVariableDefinition(SchemaConstants.C_ENCODED_MESSAGE_TEXT, URLEncoder.encode(message.getBody(), "US-ASCII"));
variables.addVariableDefinition(SchemaConstants.C_MESSAGE, message);
return variables;
}
Aggregations