Search in sources :

Example 21 with RuntimeManager

use of org.kie.api.runtime.manager.RuntimeManager in project jbpm by kiegroup.

the class UserTaskServiceImpl method fail.

@Override
public void fail(String deploymentId, Long taskId, String userId, Map<String, Object> faultData) {
    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) {
        faultData = process(faultData, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
    }
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
    try {
        TaskService taskService = engine.getTaskService();
        // perform actual operation
        taskService.fail(taskId, userId, faultData);
    } 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 22 with RuntimeManager

use of org.kie.api.runtime.manager.RuntimeManager in project jbpm by kiegroup.

the class UserTaskServiceImpl method setName.

@Override
public void setName(String deploymentId, Long taskId, String name) {
    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 {
        InternalI18NText text = (InternalI18NText) TaskModelProvider.getFactory().newI18NText();
        text.setLanguage("en-UK");
        text.setText(name);
        List<I18NText> names = new ArrayList<I18NText>();
        names.add(text);
        TaskService taskService = engine.getTaskService();
        // perform actual operation
        ((InternalTaskService) taskService).setTaskNames(taskId, names);
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) 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) ArrayList(java.util.ArrayList) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Example 23 with RuntimeManager

use of org.kie.api.runtime.manager.RuntimeManager in project jbpm by kiegroup.

the class UserTaskServiceImpl method activate.

@Override
public void activate(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.activate(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 24 with RuntimeManager

use of org.kie.api.runtime.manager.RuntimeManager 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 25 with RuntimeManager

use of org.kie.api.runtime.manager.RuntimeManager in project jbpm by kiegroup.

the class UserTaskServiceImpl method setPriority.

@Override
public void setPriority(String deploymentId, Long taskId, int priority) {
    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
        ((InternalTaskService) taskService).setPriority(taskId, priority);
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) 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) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Aggregations

RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)150 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)116 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)79 KieSession (org.kie.api.runtime.KieSession)55 TaskService (org.kie.api.task.TaskService)53 Test (org.junit.Test)51 HashMap (java.util.HashMap)49 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)46 InternalTaskService (org.kie.internal.task.api.InternalTaskService)44 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)38 UserTaskService (org.jbpm.services.api.UserTaskService)36 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)35 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)23 TaskSummary (org.kie.api.task.model.TaskSummary)21 ArrayList (java.util.ArrayList)19 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)19 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)18 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)15 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)15 PermissionDeniedException (org.jbpm.services.task.exception.PermissionDeniedException)15