use of com.evolveum.midpoint.wf.impl.processors.primary.PcpChildWfTaskCreationInstruction in project midpoint by Evolveum.
the class ChangePasswordAspect method createStartProcessInstruction.
private PcpChildWfTaskCreationInstruction createStartProcessInstruction(ModelContext<?> modelContext, ItemDelta delta, ApprovalRequest approvalRequest, Task taskFromModel, OperationResult result) throws SchemaException {
String userName = MiscDataUtil.getFocusObjectName(modelContext);
String objectOid = MiscDataUtil.getFocusObjectOid(modelContext);
PrismObject<UserType> requester = baseModelInvocationProcessingHelper.getRequester(taskFromModel, result);
String approvalTaskName = "Approve changing password for " + userName;
// 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
instruction.setDeltasToProcess(itemDeltaToObjectDelta(objectOid, delta));
instruction.setObjectRef(modelContext, result);
instruction.setTargetRef(null, result);
// set the names of midPoint task and activiti process instance
instruction.setTaskName("Approval of password change for " + userName);
instruction.setProcessInstanceName("Changing password for " + userName);
// setup general item approval process
itemApprovalProcessInterface.prepareStartInstruction(instruction);
return instruction;
}
use of com.evolveum.midpoint.wf.impl.processors.primary.PcpChildWfTaskCreationInstruction in project midpoint by Evolveum.
the class AddAssociationAspect method prepareJobCreateInstructions.
private List<PcpChildWfTaskCreationInstruction> prepareJobCreateInstructions(ModelContext<?> modelContext, Task taskFromModel, OperationResult result, List<ApprovalRequest<AssociationAdditionType>> approvalRequestList) throws SchemaException, ObjectNotFoundException {
List<PcpChildWfTaskCreationInstruction> instructions = new ArrayList<>();
String assigneeName = MiscDataUtil.getFocusObjectName(modelContext);
String assigneeOid = MiscDataUtil.getFocusObjectOid(modelContext);
PrismObject<UserType> requester = baseModelInvocationProcessingHelper.getRequester(taskFromModel, result);
for (ApprovalRequest<AssociationAdditionType> approvalRequest : approvalRequestList) {
LOGGER.trace("Approval request = {}", approvalRequest);
AssociationAdditionType associationAddition = approvalRequest.getItemToApprove();
ShadowAssociationType association = associationAddition.getAssociation();
ShadowType target = getAssociationApprovalTarget(association, result);
Validate.notNull(target, "No target in association to be approved");
String targetName = target.getName() != null ? target.getName().getOrig() : "(unnamed)";
String approvalTaskName = "Approve adding " + targetName + " to " + assigneeName;
// 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
ObjectTreeDeltas objectTreeDeltas = associationAdditionToDelta(modelContext, associationAddition, assigneeOid);
instruction.setDeltasToProcesses(objectTreeDeltas);
// TODO - or should we take shadow as an object?
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 adding " + targetName + " to " + assigneeName);
instruction.setProcessInstanceName("Adding " + targetName + " to " + assigneeName);
// setup general item approval process
itemApprovalProcessInterface.prepareStartInstruction(instruction);
instructions.add(instruction);
}
return instructions;
}
use of com.evolveum.midpoint.wf.impl.processors.primary.PcpChildWfTaskCreationInstruction in project midpoint by Evolveum.
the class AddObjectAspect method prepareJobCreateInstructions.
private List<PcpChildWfTaskCreationInstruction> prepareJobCreateInstructions(ModelContext<?> modelContext, Task taskFromModel, OperationResult result, List<ApprovalRequest<T>> approvalRequestList) throws SchemaException {
List<PcpChildWfTaskCreationInstruction> instructions = new ArrayList<>();
for (ApprovalRequest<T> approvalRequest : approvalRequestList) {
// there should be just one
LOGGER.trace("Approval request = {}", approvalRequest);
T objectToAdd = approvalRequest.getItemToApprove();
Validate.notNull(objectToAdd);
String objectLabel = getObjectLabel(objectToAdd);
PrismObject<UserType> requester = baseModelInvocationProcessingHelper.getRequester(taskFromModel, result);
String approvalTaskName = "Approve creating " + objectLabel;
// 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 = assignmentToDelta(modelContext);
instruction.setDeltasToProcess(delta);
instruction.setObjectRef(modelContext, result);
instruction.setTargetRef(null, result);
// set the names of midPoint task and activiti process instance
String andExecuting = instruction.isExecuteApprovedChangeImmediately() ? "and execution " : "";
instruction.setTaskName("Approval " + andExecuting + "of creation of " + objectLabel);
instruction.setProcessInstanceName("Creating " + objectLabel);
// setup general item approval process
itemApprovalProcessInterface.prepareStartInstruction(instruction);
instructions.add(instruction);
}
return instructions;
}
use of com.evolveum.midpoint.wf.impl.processors.primary.PcpChildWfTaskCreationInstruction in project midpoint by Evolveum.
the class ChangePasswordAspect method prepareTasks.
@NotNull
@Override
public List<PcpChildWfTaskCreationInstruction> prepareTasks(@NotNull ObjectTreeDeltas objectTreeDeltas, ModelInvocationContext ctx, @NotNull OperationResult result) throws SchemaException {
List<ApprovalRequest<String>> approvalRequestList = new ArrayList<>();
List<PcpChildWfTaskCreationInstruction> instructions = new ArrayList<>();
ObjectDelta changeRequested = objectTreeDeltas.getFocusChange();
if (changeRequested == null || changeRequested.getChangeType() != ChangeType.MODIFY) {
return Collections.emptyList();
}
Iterator<? extends ItemDelta> deltaIterator = changeRequested.getModifications().iterator();
ItemPath passwordPath = new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE);
while (deltaIterator.hasNext()) {
ItemDelta delta = deltaIterator.next();
// also, what if we replace whole 'credentials' container?
if (passwordPath.equivalent(delta.getPath())) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Found password-changing delta, moving it into approval request. Delta = " + delta.debugDump());
}
ApprovalRequest<String> approvalRequest = createApprovalRequest(delta, ctx.modelContext, ctx.taskFromModel, result);
approvalRequestList.add(approvalRequest);
instructions.add(createStartProcessInstruction(ctx.modelContext, delta, approvalRequest, ctx.taskFromModel, result));
deltaIterator.remove();
}
}
return instructions;
}
use of com.evolveum.midpoint.wf.impl.processors.primary.PcpChildWfTaskCreationInstruction in project midpoint by Evolveum.
the class ItemApprovalProcessInterface method prepareStartInstruction.
public void prepareStartInstruction(WfTaskCreationInstruction instruction) {
instruction.setProcessName(PROCESS_DEFINITION_KEY);
instruction.setSimple(false);
instruction.setSendStartConfirmation(true);
instruction.setProcessInterfaceBean(this);
if (LOGGER.isDebugEnabled() && instruction instanceof PcpChildWfTaskCreationInstruction) {
PcpChildWfTaskCreationInstruction instr = (PcpChildWfTaskCreationInstruction) instruction;
LOGGER.debug("About to start approval process instance '{}'", instr.getProcessInstanceName());
if (instr.getProcessContent() instanceof ItemApprovalSpecificContent) {
ItemApprovalSpecificContent iasc = (ItemApprovalSpecificContent) instr.getProcessContent();
LOGGER.debug("Approval schema XML:\n{}", PrismUtil.serializeQuietlyLazily(prismContext, iasc.approvalSchemaType));
LOGGER.debug("Attached rules:\n{}", PrismUtil.serializeQuietlyLazily(prismContext, iasc.policyRules));
}
}
}
Aggregations