Search in sources :

Example 6 with TaskNotFoundException

use of org.jbpm.services.api.TaskNotFoundException in project jbpm by kiegroup.

the class UserTaskServiceImpl method completeAutoProgress.

@Override
public void completeAutoProgress(String deploymentId, Long taskId, String userId, Map<String, Object> params) {
    UserTaskInstanceDesc task = dataService.getTaskById(taskId);
    validateTask(deploymentId, taskId, task);
    RuntimeManager manager = getRuntimeManager(task);
    if (manager == null) {
        logger.warn("Cannot find runtime manager for task {}", taskId);
        return;
    }
    if (manager instanceof InternalRuntimeManager) {
        params = process(params, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
    }
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
    try {
        TaskService taskService = engine.getTaskService();
        // auto progress if needed
        if (task.getStatus().equals(Status.Ready.name())) {
            taskService.claim(taskId.longValue(), userId);
            taskService.start(taskId.longValue(), userId);
        } else if (task.getStatus().equals(Status.Reserved.name())) {
            taskService.start(taskId.longValue(), userId);
        }
        // perform actual operation
        taskService.complete(taskId, userId, params);
    } catch (PermissionDeniedException e) {
        throw new TaskNotFoundException(e.getMessage());
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskService(org.jbpm.services.api.UserTaskService) TaskService(org.kie.api.task.TaskService) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) PermissionDeniedException(org.jbpm.services.task.exception.PermissionDeniedException) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Example 7 with TaskNotFoundException

use of org.jbpm.services.api.TaskNotFoundException in project jbpm by kiegroup.

the class UserTaskServiceImpl method exit.

@Override
public void exit(String deploymentId, Long taskId, String userId) {
    UserTaskInstanceDesc task = dataService.getTaskById(taskId);
    validateTask(deploymentId, taskId, task);
    RuntimeManager manager = getRuntimeManager(task);
    if (manager == null) {
        logger.warn("Cannot find runtime manager for task {}", taskId);
        return;
    }
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
    try {
        TaskService taskService = engine.getTaskService();
        // perform actual operation
        taskService.exit(taskId, userId);
    } catch (PermissionDeniedException e) {
        throw new TaskNotFoundException(e.getMessage());
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskService(org.jbpm.services.api.UserTaskService) TaskService(org.kie.api.task.TaskService) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) PermissionDeniedException(org.jbpm.services.task.exception.PermissionDeniedException) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Example 8 with TaskNotFoundException

use of org.jbpm.services.api.TaskNotFoundException in project jbpm by kiegroup.

the class UserTaskServiceImpl method suspend.

@Override
public void suspend(String deploymentId, Long taskId, String userId) {
    UserTaskInstanceDesc task = dataService.getTaskById(taskId);
    validateTask(deploymentId, taskId, task);
    RuntimeManager manager = getRuntimeManager(task);
    if (manager == null) {
        logger.warn("Cannot find runtime manager for task {}", taskId);
        return;
    }
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
    try {
        TaskService taskService = engine.getTaskService();
        // perform actual operation
        taskService.suspend(taskId, userId);
    } catch (PermissionDeniedException e) {
        throw new TaskNotFoundException(e.getMessage());
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskService(org.jbpm.services.api.UserTaskService) TaskService(org.kie.api.task.TaskService) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) PermissionDeniedException(org.jbpm.services.task.exception.PermissionDeniedException) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Example 9 with TaskNotFoundException

use of org.jbpm.services.api.TaskNotFoundException in project jbpm by kiegroup.

the class UserTaskServiceImpl method delegate.

@Override
public void delegate(String deploymentId, Long taskId, String userId, String targetUserId) {
    UserTaskInstanceDesc task = dataService.getTaskById(taskId);
    validateTask(deploymentId, taskId, task);
    RuntimeManager manager = getRuntimeManager(task);
    if (manager == null) {
        logger.warn("Cannot find runtime manager for task {}", taskId);
        return;
    }
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
    try {
        TaskService taskService = engine.getTaskService();
        // perform actual operation
        taskService.delegate(taskId, userId, targetUserId);
    } catch (PermissionDeniedException e) {
        throw new TaskNotFoundException(e.getMessage());
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskService(org.jbpm.services.api.UserTaskService) TaskService(org.kie.api.task.TaskService) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) PermissionDeniedException(org.jbpm.services.task.exception.PermissionDeniedException) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Example 10 with TaskNotFoundException

use of org.jbpm.services.api.TaskNotFoundException in project jbpm by kiegroup.

the class UserTaskServiceImpl method nominate.

@Override
public void nominate(String deploymentId, Long taskId, String userId, List<OrganizationalEntity> potentialOwners) {
    UserTaskInstanceDesc task = dataService.getTaskById(taskId);
    validateTask(deploymentId, taskId, task);
    RuntimeManager manager = getRuntimeManager(task);
    if (manager == null) {
        logger.warn("Cannot find runtime manager for task {}", taskId);
        return;
    }
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
    try {
        TaskService taskService = engine.getTaskService();
        // perform actual operation
        taskService.nominate(taskId, userId, potentialOwners);
    } catch (PermissionDeniedException e) {
        throw new TaskNotFoundException(e.getMessage());
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskService(org.jbpm.services.api.UserTaskService) TaskService(org.kie.api.task.TaskService) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) PermissionDeniedException(org.jbpm.services.task.exception.PermissionDeniedException) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Aggregations

TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)17 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)16 UserTaskService (org.jbpm.services.api.UserTaskService)15 PermissionDeniedException (org.jbpm.services.task.exception.PermissionDeniedException)15 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)15 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)15 TaskService (org.kie.api.task.TaskService)15 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)15 InternalTaskService (org.kie.internal.task.api.InternalTaskService)15 HashMap (java.util.HashMap)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AdHocFragmentNotFoundException (org.jbpm.casemgmt.api.AdHocFragmentNotFoundException)1 CaseActiveException (org.jbpm.casemgmt.api.CaseActiveException)1 CaseCommentNotFoundException (org.jbpm.casemgmt.api.CaseCommentNotFoundException)1 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)1 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)1 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)1 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)1 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)1