Search in sources :

Example 1 with TriggerCreationType

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;
}
Also used : TriggerCreationType(com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerCreationType) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) RecomputeActionExpressionType(com.evolveum.midpoint.xml.ns._public.model.scripting_3.RecomputeActionExpressionType)

Example 2 with TriggerCreationType

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");
        }
    }
}
Also used : AssignmentHolderType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType)

Aggregations

ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)1 AssignmentHolderType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType)1 TriggerCreationType (com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerCreationType)1 RecomputeActionExpressionType (com.evolveum.midpoint.xml.ns._public.model.scripting_3.RecomputeActionExpressionType)1