Search in sources :

Example 1 with CompleteWorkItemsRequest

use of com.evolveum.midpoint.cases.api.request.CompleteWorkItemsRequest in project midpoint by Evolveum.

the class WorkItemManager method completeWorkItem.

public void completeWorkItem(WorkItemId workItemId, @NotNull AbstractWorkItemOutputType output, WorkItemEventCauseInformationType causeInformation, Task task, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SchemaException, ObjectAlreadyExistsException {
    OperationResultBuilder builder = parentResult.subresult(OPERATION_COMPLETE_WORK_ITEM).addArbitraryObjectAsParam("workItemId", workItemId).addParam("decision", output.getOutcome()).addParam("comment", output.getComment());
    boolean tracingRequested = startTracingIfRequested(builder, task, parentResult);
    OperationResult result = builder.build();
    try {
        LOGGER.trace("Completing work item {} with decision of {} ['{}']; cause: {}", workItemId, output.getOutcome(), output.getComment(), causeInformation);
        CompleteWorkItemsRequest request = new CompleteWorkItemsRequest(workItemId.caseOid, causeInformation);
        request.getCompletions().add(new CompleteWorkItemsRequest.SingleCompletion(workItemId.id, output));
        caseEngine.executeRequest(request, task, result);
    } catch (SecurityViolationException | RuntimeException | SchemaException | ObjectAlreadyExistsException e) {
        result.recordFatalError("Couldn't complete the work item " + workItemId + ": " + e.getMessage(), e);
        throw e;
    } finally {
        result.computeStatusIfUnknown();
        storeTraceIfRequested(tracingRequested, task, result, parentResult);
    }
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) OperationResultBuilder(com.evolveum.midpoint.schema.result.OperationResultBuilder) CompleteWorkItemsRequest(com.evolveum.midpoint.cases.api.request.CompleteWorkItemsRequest)

Aggregations

CompleteWorkItemsRequest (com.evolveum.midpoint.cases.api.request.CompleteWorkItemsRequest)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 OperationResultBuilder (com.evolveum.midpoint.schema.result.OperationResultBuilder)1