use of com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerCreationType in project midpoint by Evolveum.
the class RecomputeExecutor method execute.
@Override
public PipelineData execute(ActionExpressionType action, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException, SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
boolean dryRun = operationsHelper.getDryRun(action, input, context, globalResult);
ModelExecuteOptions options = operationsHelper.getOptions(action, input, context, globalResult);
options.reconcile(true);
TriggerCreationType triggerCreation = action instanceof RecomputeActionExpressionType ? ((RecomputeActionExpressionType) action).getTriggered() : null;
iterateOverObjects(input, context, globalResult, (object, item, result) -> recompute(object, dryRun, options, triggerCreation, context, result), (object, exception) -> context.println("Failed to recompute " + object + drySuffix(dryRun) + exceptionSuffix(exception)));
return input;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerCreationType in project midpoint by Evolveum.
the class RecomputeExecutor method recompute.
private void recompute(PrismObject<? extends AssignmentHolderType> object, boolean dryRun, ModelExecuteOptions options, TriggerCreationType triggerCreation, ExecutionContext context, OperationResult result) throws ScriptExecutionException, SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
AssignmentHolderType objectable = object.asObjectable();
if (triggerCreation == null) {
ObjectDelta<? extends AssignmentHolderType> emptyDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(objectable.getClass(), objectable.getOid());
operationsHelper.applyDelta(emptyDelta, options, dryRun, context, result);
context.println("Recomputed " + object.toString() + drySuffix(dryRun));
} else if (dryRun) {
context.println("Skipping dry run of triggered-recompute of " + object.toString());
} else if (triggerCreation.getFireAfter() == null) {
// direct trigger creation
midpointFunctions.createRecomputeTrigger(objectable.getClass(), objectable.getOid());
context.println("Triggered recompute of " + object.toString());
} else {
// optimized trigger creation
long fireAfter = XmlTypeConverter.toMillis(triggerCreation.getFireAfter());
long safetyMargin = triggerCreation.getSafetyMargin() != null ? XmlTypeConverter.toMillis(triggerCreation.getSafetyMargin()) : 0;
boolean triggerCreated = midpointFunctions.getOptimizingTriggerCreator(fireAfter, safetyMargin).createForObject(objectable.getClass(), objectable.getOid());
if (triggerCreated) {
context.println("Triggered recompute of " + object.toString());
} else {
context.println("Skipped triggering recompute of " + object.toString() + " because a trigger was already present");
}
}
}
Aggregations