Search in sources :

Example 1 with PcpChildWfTaskCreationInstruction

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;
}
Also used : PcpChildWfTaskCreationInstruction(com.evolveum.midpoint.wf.impl.processors.primary.PcpChildWfTaskCreationInstruction)

Example 2 with PcpChildWfTaskCreationInstruction

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;
}
Also used : PcpChildWfTaskCreationInstruction(com.evolveum.midpoint.wf.impl.processors.primary.PcpChildWfTaskCreationInstruction) ObjectTreeDeltas(com.evolveum.midpoint.schema.ObjectTreeDeltas)

Example 3 with PcpChildWfTaskCreationInstruction

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;
}
Also used : PcpChildWfTaskCreationInstruction(com.evolveum.midpoint.wf.impl.processors.primary.PcpChildWfTaskCreationInstruction) ArrayList(java.util.ArrayList)

Example 4 with PcpChildWfTaskCreationInstruction

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;
}
Also used : PcpChildWfTaskCreationInstruction(com.evolveum.midpoint.wf.impl.processors.primary.PcpChildWfTaskCreationInstruction) ArrayList(java.util.ArrayList) ApprovalRequest(com.evolveum.midpoint.wf.impl.processes.itemApproval.ApprovalRequest) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with PcpChildWfTaskCreationInstruction

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));
        }
    }
}
Also used : PcpChildWfTaskCreationInstruction(com.evolveum.midpoint.wf.impl.processors.primary.PcpChildWfTaskCreationInstruction)

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