Search in sources :

Example 1 with PrimaryChangeAspect

use of com.evolveum.midpoint.wf.impl.processors.primary.aspect.PrimaryChangeAspect in project midpoint by Evolveum.

the class WfTaskUtil method getPrimaryChangeAspect.

@NotNull
public PrimaryChangeAspect getPrimaryChangeAspect(Task task, Collection<PrimaryChangeAspect> aspects) {
    WfContextType wfc = getWorkflowContextChecked(task);
    WfProcessorSpecificStateType pss = wfc.getProcessorSpecificState();
    if (!(pss instanceof WfPrimaryChangeProcessorStateType)) {
        throw new IllegalStateException("Expected " + WfPrimaryChangeProcessorStateType.class + " but got " + pss + " in task " + task);
    }
    WfPrimaryChangeProcessorStateType pcps = ((WfPrimaryChangeProcessorStateType) pss);
    String aspectClassName = pcps.getChangeAspect();
    if (aspectClassName == null) {
        throw new IllegalStateException("No wf primary change aspect defined in task " + task);
    }
    for (PrimaryChangeAspect a : aspects) {
        if (aspectClassName.equals(a.getClass().getName())) {
            return a;
        }
    }
    throw new IllegalStateException("Primary change aspect " + aspectClassName + " is not registered.");
}
Also used : PrimaryChangeAspect(com.evolveum.midpoint.wf.impl.processors.primary.aspect.PrimaryChangeAspect) WfContextType(com.evolveum.midpoint.xml.ns._public.common.common_3.WfContextType) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PrimaryChangeAspect

use of com.evolveum.midpoint.wf.impl.processors.primary.aspect.PrimaryChangeAspect in project midpoint by Evolveum.

the class PrimaryChangeProcessor method gatherStartInstructions.

private List<PcpChildWfTaskCreationInstruction> gatherStartInstructions(@NotNull ObjectTreeDeltas changesBeingDecomposed, ModelInvocationContext ctx, @NotNull OperationResult result) throws SchemaException, ObjectNotFoundException {
    PrimaryChangeProcessorConfigurationType processorConfigurationType = ctx.wfConfiguration != null ? ctx.wfConfiguration.getPrimaryChangeProcessor() : null;
    List<PcpChildWfTaskCreationInstruction> startProcessInstructions = new ArrayList<>();
    for (PrimaryChangeAspect aspect : getActiveChangeAspects(processorConfigurationType)) {
        if (changesBeingDecomposed.isEmpty()) {
            // nothing left
            break;
        }
        List<PcpChildWfTaskCreationInstruction> instructions = aspect.prepareTasks(changesBeingDecomposed, ctx, result);
        logAspectResult(aspect, instructions, changesBeingDecomposed);
        if (instructions != null) {
            startProcessInstructions.addAll(instructions);
        }
    }
    return startProcessInstructions;
}
Also used : PrimaryChangeAspect(com.evolveum.midpoint.wf.impl.processors.primary.aspect.PrimaryChangeAspect)

Example 3 with PrimaryChangeAspect

use of com.evolveum.midpoint.wf.impl.processors.primary.aspect.PrimaryChangeAspect in project midpoint by Evolveum.

the class PrimaryChangeProcessor method onProcessEnd.

//endregion
//region Processing process finish event
@Override
public void onProcessEnd(ProcessEvent event, WfTask wfTask, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
    PcpWfTask pcpJob = new PcpWfTask(wfTask);
    PrimaryChangeAspect aspect = pcpJob.getChangeAspect();
    pcpJob.storeResultingDeltas(aspect.prepareDeltaOut(event, pcpJob, result));
}
Also used : PrimaryChangeAspect(com.evolveum.midpoint.wf.impl.processors.primary.aspect.PrimaryChangeAspect)

Example 4 with PrimaryChangeAspect

use of com.evolveum.midpoint.wf.impl.processors.primary.aspect.PrimaryChangeAspect in project midpoint by Evolveum.

the class PrimaryChangeProcessor method gatherStartInstructions.

private <O extends ObjectType> List<PcpStartInstruction> gatherStartInstructions(@NotNull ObjectTreeDeltas<O> changesBeingDecomposed, @NotNull ModelInvocationContext<O> ctx, @NotNull OperationResult parentResult) throws SchemaException, ObjectNotFoundException {
    OperationResult result = parentResult.subresult(OP_GATHER_START_INSTRUCTIONS).setMinor().build();
    try {
        PrimaryChangeProcessorConfigurationType processorConfigurationType = ctx.wfConfiguration != null ? ctx.wfConfiguration.getPrimaryChangeProcessor() : null;
        List<PcpStartInstruction> startProcessInstructions = new ArrayList<>();
        for (PrimaryChangeAspect aspect : getActiveChangeAspects(processorConfigurationType)) {
            if (changesBeingDecomposed.isEmpty()) {
                // nothing left
                break;
            }
            List<PcpStartInstruction> instructions = aspect.getStartInstructions(changesBeingDecomposed, ctx, result);
            logAspectResult(aspect, instructions, changesBeingDecomposed);
            startProcessInstructions.addAll(instructions);
        }
        result.addParam("instructionsCount", startProcessInstructions.size());
        return startProcessInstructions;
    } catch (Throwable t) {
        result.recordFatalError(t);
        throw t;
    } finally {
        result.computeStatusIfUnknown();
    }
}
Also used : ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrimaryChangeAspect(com.evolveum.midpoint.wf.impl.processors.primary.aspect.PrimaryChangeAspect)

Aggregations

PrimaryChangeAspect (com.evolveum.midpoint.wf.impl.processors.primary.aspect.PrimaryChangeAspect)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 WfContextType (com.evolveum.midpoint.xml.ns._public.common.common_3.WfContextType)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1