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;
}
Aggregations