Search in sources :

Example 1 with ChangesByState

use of com.evolveum.midpoint.wf.util.ChangesByState in project midpoint by Evolveum.

the class TaskDto method fillInWorkflowAttributes.

private void fillInWorkflowAttributes(TaskType taskType, ModelInteractionService modelInteractionService, WorkflowManager workflowManager, PrismContext prismContext, Task opTask, OperationResult thisOpResult) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
    workflowDeltasIn = retrieveDeltasToProcess(taskType, modelInteractionService, opTask, thisOpResult);
    workflowDeltasOut = retrieveResultingDeltas(taskType, modelInteractionService, opTask, thisOpResult);
    final TaskType rootTask;
    if (parentTaskType == null) {
        rootTask = taskType;
    } else {
        rootTask = parentTaskType;
    }
    WfContextType wfc = taskType.getWorkflowContext();
    if (wfc != null && parentTaskType != null && (wfc.getProcessorSpecificState() instanceof WfPrimaryChangeProcessorStateType)) {
        ChangesByState changesByState = workflowManager.getChangesByState(taskType, rootTask, modelInteractionService, prismContext, thisOpResult);
        List<TaskChangesDto> changeCategories = computeChangesCategorizationList(changesByState, modelInteractionService, prismContext, opTask, thisOpResult);
        if (changeCategories.size() > 1) {
            throw new IllegalStateException("More than one task change category for task " + taskType + ": " + changeCategories);
        } else if (changeCategories.size() == 1) {
            changesBeingApproved = changeCategories.get(0);
        }
    }
    workflowRequests = new ArrayList<>();
    for (TaskType wfSubtask : rootTask.getSubtask()) {
        final WfContextType subWfc = wfSubtask.getWorkflowContext();
        if (subWfc != null && subWfc.getProcessInstanceId() != null) {
            if (this.getOid() == null || !this.getOid().equals(wfSubtask.getOid())) {
                workflowRequests.add(new ProcessInstanceDto(wfSubtask));
            }
        }
    }
    ChangesByState changesByState = workflowManager.getChangesByState(rootTask, modelInteractionService, prismContext, opTask, thisOpResult);
    this.changesCategorizationList = computeChangesCategorizationList(changesByState, modelInteractionService, prismContext, opTask, thisOpResult);
}
Also used : ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) ChangesByState(com.evolveum.midpoint.wf.util.ChangesByState)

Example 2 with ChangesByState

use of com.evolveum.midpoint.wf.util.ChangesByState in project midpoint by Evolveum.

the class MiscDataUtil method getChangesByStateForRoot.

// TODO move somewhere else?
public ChangesByState getChangesByStateForRoot(TaskType rootTask, ModelInteractionService modelInteractionService, PrismContext prismContext, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException {
    ChangesByState rv = new ChangesByState(prismContext);
    recordChanges(rv, rootTask.getModelOperationContext(), modelInteractionService, task, result);
    for (TaskType subtask : rootTask.getSubtask()) {
        recordChanges(rv, subtask.getModelOperationContext(), modelInteractionService, task, result);
        final WfContextType wfc = subtask.getWorkflowContext();
        if (wfc != null && wfc.getProcessInstanceId() != null) {
            Boolean isApproved = ApprovalUtils.approvalBooleanValueFromUri(wfc.getOutcome());
            if (isApproved == null) {
                if (wfc.getEndTimestamp() == null) {
                    recordChangesWaitingToBeApproved(rv, wfc, prismContext);
                } else {
                    recordChangesCanceled(rv, wfc, prismContext);
                }
            } else if (isApproved) {
                recordChangesApprovedIfNeeded(rv, subtask, rootTask, prismContext);
            } else {
                recordChangesRejected(rv, wfc, prismContext);
            }
        }
    }
    return rv;
}
Also used : ChangesByState(com.evolveum.midpoint.wf.util.ChangesByState)

Example 3 with ChangesByState

use of com.evolveum.midpoint.wf.util.ChangesByState in project midpoint by Evolveum.

the class MiscDataUtil method getChangesByStateForChild.

// TODO move somewhere else?
public ChangesByState getChangesByStateForChild(TaskType childTask, TaskType rootTask, ModelInteractionService modelInteractionService, PrismContext prismContext, OperationResult result) throws SchemaException, ObjectNotFoundException {
    ChangesByState rv = new ChangesByState(prismContext);
    final WfContextType wfc = childTask.getWorkflowContext();
    if (wfc != null && wfc.getProcessInstanceId() != null) {
        Boolean isApproved = ApprovalUtils.approvalBooleanValueFromUri(wfc.getOutcome());
        if (isApproved == null) {
            if (wfc.getEndTimestamp() == null) {
                recordChangesWaitingToBeApproved(rv, wfc, prismContext);
            } else {
                recordChangesCanceled(rv, wfc, prismContext);
            }
        } else if (isApproved) {
            if (rootTask.getModelOperationContext() != null) {
                // this is "execute after all approvals"
                if (rootTask.getModelOperationContext().getState() == ModelStateType.FINAL) {
                    recordResultingChanges(rv.getApplied(), wfc, prismContext);
                } else if (!containsHandler(rootTask, WfPrepareRootOperationTaskHandler.HANDLER_URI)) {
                    recordResultingChanges(rv.getBeingApplied(), wfc, prismContext);
                } else {
                    recordResultingChanges(rv.getWaitingToBeApplied(), wfc, prismContext);
                }
            } else {
                // "execute immediately"
                if (childTask.getModelOperationContext().getState() == ModelStateType.FINAL) {
                    recordResultingChanges(rv.getApplied(), wfc, prismContext);
                } else if (!containsHandler(childTask, WfPrepareChildOperationTaskHandler.HANDLER_URI)) {
                    recordResultingChanges(rv.getBeingApplied(), wfc, prismContext);
                } else {
                    recordResultingChanges(rv.getWaitingToBeApplied(), wfc, prismContext);
                }
            }
        } else {
            recordChangesRejected(rv, wfc, prismContext);
        }
    }
    return rv;
}
Also used : ChangesByState(com.evolveum.midpoint.wf.util.ChangesByState)

Aggregations

ChangesByState (com.evolveum.midpoint.wf.util.ChangesByState)3 ProcessInstanceDto (com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto)1