Search in sources :

Example 6 with WorkflowService

use of com.evolveum.midpoint.model.api.WorkflowService in project midpoint by Evolveum.

the class PageWorkItems method approveOrRejectWorkItemsPerformed.

private void approveOrRejectWorkItemsPerformed(AjaxRequestTarget target, boolean approve) {
    List<WorkItemDto> workItemDtoList = getWorkItemsPanel().getSelectedWorkItems();
    if (!isSomeItemSelected(workItemDtoList, target)) {
        return;
    }
    OperationResult mainResult = new OperationResult(OPERATION_APPROVE_OR_REJECT_ITEMS);
    WorkflowService workflowService = getWorkflowService();
    for (WorkItemDto workItemDto : workItemDtoList) {
        OperationResult result = mainResult.createSubresult(OPERATION_APPROVE_OR_REJECT_ITEM);
        try {
            workflowService.completeWorkItem(workItemDto.getWorkItemId(), approve, null, null, result);
            result.computeStatus();
        } catch (Exception e) {
            result.recordPartialError("Couldn't approve/reject work item due to an unexpected exception.", e);
        }
    }
    if (mainResult.isUnknown()) {
        mainResult.recomputeStatus();
    }
    if (mainResult.isSuccess()) {
        mainResult.recordStatus(OperationResultStatus.SUCCESS, "The work item(s) have been successfully " + (approve ? "approved." : "rejected."));
    }
    showResult(mainResult);
    resetWorkItemCountModel();
    target.add(this);
}
Also used : WorkflowService(com.evolveum.midpoint.model.api.WorkflowService) WorkItemDto(com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException)

Example 7 with WorkflowService

use of com.evolveum.midpoint.model.api.WorkflowService in project midpoint by Evolveum.

the class PageWorkItems method claimWorkItemsPerformed.

private void claimWorkItemsPerformed(AjaxRequestTarget target) {
    List<WorkItemDto> workItemDtoList = getWorkItemsPanel().getSelectedWorkItems();
    if (!isSomeItemSelected(workItemDtoList, target)) {
        return;
    }
    OperationResult mainResult = new OperationResult(OPERATION_CLAIM_ITEMS);
    WorkflowService workflowService = getWorkflowService();
    for (WorkItemDto workItemDto : workItemDtoList) {
        OperationResult result = mainResult.createSubresult(OPERATION_CLAIM_ITEM);
        try {
            workflowService.claimWorkItem(workItemDto.getWorkItemId(), result);
            result.computeStatusIfUnknown();
        } catch (ObjectNotFoundException | SecurityViolationException | RuntimeException e) {
            result.recordPartialError("Couldn't claim work item due to an unexpected exception.", e);
        }
    }
    if (mainResult.isUnknown()) {
        mainResult.recomputeStatus();
    }
    if (mainResult.isSuccess()) {
        mainResult.recordStatus(OperationResultStatus.SUCCESS, "The work item(s) have been successfully claimed.");
    }
    showResult(mainResult);
    resetWorkItemCountModel();
    target.add(this);
}
Also used : SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) WorkflowService(com.evolveum.midpoint.model.api.WorkflowService) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) WorkItemDto(com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

WorkflowService (com.evolveum.midpoint.model.api.WorkflowService)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)5 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4 WorkItemDto (com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)1 Selectable (com.evolveum.midpoint.web.component.util.Selectable)1 ProcessInstanceDto (com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto)1 ProcessInstanceDtoProvider (com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDtoProvider)1 ArrayList (java.util.ArrayList)1