Search in sources :

Example 6 with PcpStartInstruction

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;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismObject.asPrismObject(com.evolveum.midpoint.prism.PrismObject.asPrismObject) LocalizableMessage(com.evolveum.midpoint.util.LocalizableMessage) PcpStartInstruction(com.evolveum.midpoint.wf.impl.processors.primary.PcpStartInstruction)

Example 7 with PcpStartInstruction

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

Aggregations

PcpStartInstruction (com.evolveum.midpoint.wf.impl.processors.primary.PcpStartInstruction)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 ArrayList (java.util.ArrayList)4 LocalizableMessage (com.evolveum.midpoint.util.LocalizableMessage)2 CompiledGuiProfile (com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile)1 EvaluatedPolicyRule (com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule)1 LensContext (com.evolveum.midpoint.model.impl.lens.LensContext)1 LensFocusContext (com.evolveum.midpoint.model.impl.lens.LensFocusContext)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismObject.asPrismObject (com.evolveum.midpoint.prism.PrismObject.asPrismObject)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 ObjectTreeDeltas (com.evolveum.midpoint.schema.ObjectTreeDeltas)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)1 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)1 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)1 SystemException (com.evolveum.midpoint.util.exception.SystemException)1 ModelInvocationContext (com.evolveum.midpoint.wf.impl.processors.ModelInvocationContext)1 ProcessSpecification (com.evolveum.midpoint.wf.impl.processors.primary.policy.ProcessSpecifications.ProcessSpecification)1 Collections.singletonList (java.util.Collections.singletonList)1