Search in sources :

Example 1 with DelegateWorkItemsRequest

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

the class WorkItemManager method delegateWorkItem.

// TODO when calling from model API, what should we put into escalationLevelName+DisplayName ?
// Probably the API should look different. E.g. there could be an "Escalate" button, that would look up the
// appropriate escalation timed action, and invoke it. We'll solve this when necessary. Until that time, be
// aware that escalationLevelName/DisplayName are for internal use only.
// We can eventually provide bulk version of this method as well.
void delegateWorkItem(@NotNull WorkItemId workItemId, @NotNull WorkItemDelegationRequestType delegationRequest, WorkItemEscalationLevelType escalation, Duration newDuration, WorkItemEventCauseInformationType causeInformation, XMLGregorianCalendar now, Task task, OperationResult parentResult) throws ObjectNotFoundException, SecurityViolationException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
    List<ObjectReferenceType> delegates = delegationRequest.getDelegate();
    WorkItemDelegationMethodType method = delegationRequest.getMethod();
    String comment = delegationRequest.getComment();
    OperationResultBuilder builder = parentResult.subresult(OPERATION_DELEGATE_WORK_ITEM).addArbitraryObjectAsParam("workItemId", workItemId).addArbitraryObjectAsParam("escalation", escalation).addArbitraryObjectCollectionAsParam("delegates", delegates).addArbitraryObjectAsParam("method", method).addParam("comment", delegationRequest.getComment());
    boolean tracingRequested = startTracingIfRequested(builder, task, parentResult);
    OperationResult result = builder.build();
    try {
        LOGGER.trace("Delegating work item {} to {} ({}): escalation={}; cause={}; comment={}", workItemId, delegates, method, escalation != null ? escalation.getName() + "/" + escalation.getDisplayName() : "none", causeInformation, comment);
        DelegateWorkItemsRequest request = new DelegateWorkItemsRequest(workItemId.caseOid, causeInformation, now);
        request.getDelegations().add(new DelegateWorkItemsRequest.SingleDelegation(workItemId.id, delegationRequest, escalation, newDuration));
        caseEngine.executeRequest(request, task, result);
    } catch (SecurityViolationException | RuntimeException | ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException e) {
        result.recordFatalError("Couldn't delegate/escalate work item " + workItemId + ": " + e.getMessage(), e);
        throw e;
    } catch (ObjectAlreadyExistsException e) {
        throw new IllegalStateException(e);
    } finally {
        result.computeStatusIfUnknown();
        storeTraceIfRequested(tracingRequested, task, result, parentResult);
    }
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DelegateWorkItemsRequest(com.evolveum.midpoint.cases.api.request.DelegateWorkItemsRequest) OperationResultBuilder(com.evolveum.midpoint.schema.result.OperationResultBuilder)

Aggregations

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