use of com.evolveum.midpoint.wf.impl.processors.primary.PcpStartInstruction in project midpoint by Evolveum.
the class AssignmentPolicyAspectPart method prepareAssignmentRelatedStartInstruction.
private PcpStartInstruction prepareAssignmentRelatedStartInstruction(ApprovalSchemaBuilder.Result builderResult, EvaluatedAssignment<?> evaluatedAssignment, ObjectDelta<? extends ObjectType> deltaToApprove, PrismObject<? extends FocusType> requester, ModelInvocationContext<?> ctx, OperationResult result) throws SchemaException {
ModelContext<?> modelContext = ctx.modelContext;
@SuppressWarnings("unchecked") PrismObject<? extends ObjectType> target = (PrismObject<? extends ObjectType>) evaluatedAssignment.getTarget();
Validate.notNull(target, "assignment target is null");
LocalizableMessage processName = main.createProcessName(builderResult, evaluatedAssignment, ctx, result);
if (main.useDefaultProcessName(processName)) {
processName = createDefaultProcessName(ctx, evaluatedAssignment, target);
}
String processNameInDefaultLocale = localizationService.translate(processName, Locale.getDefault(), "(unnamed)");
PcpStartInstruction instruction = PcpStartInstruction.createItemApprovalInstruction(main.getChangeProcessor(), builderResult.schemaType, builderResult.attachedRules);
instruction.prepareCommonAttributes(main, modelContext, requester);
instruction.setDeltasToApprove(deltaToApprove);
instruction.setObjectRef(ctx);
instruction.setTargetRef(createObjectRef(target, prismContext), result);
instruction.setName(processNameInDefaultLocale, processName);
return instruction;
}
use of com.evolveum.midpoint.wf.impl.processors.primary.PcpStartInstruction in project midpoint by Evolveum.
the class AddAssociationAspect method prepareJobCreateInstructions.
private List<PcpStartInstruction> prepareJobCreateInstructions(ModelInvocationContext<?> ctx, OperationResult result, List<Request> approvalRequestList) throws SchemaException, ObjectNotFoundException {
List<PcpStartInstruction> instructions = new ArrayList<>();
String assigneeName = ctx.getFocusObjectName();
PrismObject<? extends FocusType> requester = ctx.getRequestor(result);
for (Request approvalRequest : approvalRequestList) {
LOGGER.trace("Approval request = {}", approvalRequest);
AssociationAdditionType associationAddition = approvalRequest.addition;
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)";
// create a JobCreateInstruction for a given change processor (primaryChangeProcessor in this case)
PcpStartInstruction instruction = PcpStartInstruction.createItemApprovalInstruction(getChangeProcessor(), approvalRequest.schema, null);
// set some common task/process attributes
instruction.prepareCommonAttributes(this, ctx.modelContext, requester);
// prepare and set the delta that has to be approved
ObjectTreeDeltas objectTreeDeltas = associationAdditionToDelta(ctx.modelContext, associationAddition);
instruction.setDeltasToApprove(objectTreeDeltas);
// TODO - or should we take shadow as an object?
instruction.setObjectRef(ctx);
instruction.setTargetRef(ObjectTypeUtil.createObjectRef(target, prismContext), result);
// set the names of midPoint task and process instance
String andExecuting = instruction.isExecuteApprovedChangeImmediately() ? "and execution " : "";
instruction.setName("Approval " + andExecuting + "of adding " + targetName + " to " + assigneeName);
// instruction.setProcessInstanceName("Adding " + targetName + " to " + assigneeName);
instructions.add(instruction);
}
return instructions;
}
Aggregations