Search in sources :

Example 6 with PcpChildWfTaskCreationInstruction

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

the class ModifyAssignmentAspect method prepareJobCreateInstructions.

private List<PcpChildWfTaskCreationInstruction> prepareJobCreateInstructions(ModelContext<?> modelContext, Task taskFromModel, OperationResult result, List<ApprovalRequest<AssignmentModification>> approvalRequestList) throws SchemaException {
    List<PcpChildWfTaskCreationInstruction> instructions = new ArrayList<>();
    String focusName = MiscDataUtil.getFocusObjectName(modelContext);
    for (ApprovalRequest<AssignmentModification> approvalRequest : approvalRequestList) {
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Approval request = {}", approvalRequest);
        }
        AssignmentModification itemToApprove = approvalRequest.getItemToApprove();
        T target = (T) itemToApprove.getTarget();
        Validate.notNull(target);
        String targetName = getTargetDisplayName(target);
        String focusOid = MiscDataUtil.getFocusObjectOid(modelContext);
        PrismObject<UserType> requester = baseModelInvocationProcessingHelper.getRequester(taskFromModel, result);
        String approvalTaskName = "Approve modifying assignment of " + targetName + " to " + focusName;
        // create a JobCreateInstruction for a given change processor (primaryChangeProcessor in this case)
        PcpChildWfTaskCreationInstruction instruction = PcpChildWfTaskCreationInstruction.createItemApprovalInstruction(getChangeProcessor(), approvalTaskName, approvalRequest.getApprovalSchemaType(), null);
        // set some common task/process attributes
        instruction.prepareCommonAttributes(this, modelContext, requester);
        // prepare and set the delta that has to be approved
        ObjectDelta<? extends ObjectType> delta = requestToDelta(modelContext, approvalRequest, focusOid);
        instruction.setDeltasToProcess(delta);
        instruction.setObjectRef(modelContext, result);
        instruction.setTargetRef(ObjectTypeUtil.createObjectRef(target), result);
        // set the names of midPoint task and activiti process instance
        String andExecuting = instruction.isExecuteApprovedChangeImmediately() ? "and execution " : "";
        instruction.setTaskName("Approval " + andExecuting + " of modifying assignment of " + targetName + " to " + focusName);
        instruction.setProcessInstanceName("Modifying assignment of " + targetName + " to " + focusName);
        // setup general item approval process
        itemApprovalProcessInterface.prepareStartInstruction(instruction);
        instructions.add(instruction);
    }
    return instructions;
}
Also used : PcpChildWfTaskCreationInstruction(com.evolveum.midpoint.wf.impl.processors.primary.PcpChildWfTaskCreationInstruction) AssignmentModification(com.evolveum.midpoint.wf.impl.processes.modifyAssignment.AssignmentModification)

Aggregations

PcpChildWfTaskCreationInstruction (com.evolveum.midpoint.wf.impl.processors.primary.PcpChildWfTaskCreationInstruction)6 ArrayList (java.util.ArrayList)2 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 ObjectTreeDeltas (com.evolveum.midpoint.schema.ObjectTreeDeltas)1 ApprovalRequest (com.evolveum.midpoint.wf.impl.processes.itemApproval.ApprovalRequest)1 AssignmentModification (com.evolveum.midpoint.wf.impl.processes.modifyAssignment.AssignmentModification)1 NotNull (org.jetbrains.annotations.NotNull)1