Search in sources :

Example 16 with TaskService

use of org.camunda.bpm.engine.TaskService in project camunda-bpm-platform by camunda.

the class TaskResourceImpl method updateTask.

public void updateTask(TaskDto taskDto) {
    TaskService taskService = engine.getTaskService();
    Task task = getTaskById(taskId);
    if (task == null) {
        throw new InvalidRequestException(Status.NOT_FOUND, "No matching task with id " + taskId);
    }
    taskDto.updateTask(task);
    taskService.saveTask(task);
}
Also used : Task(org.camunda.bpm.engine.task.Task) HalTask(org.camunda.bpm.engine.rest.hal.task.HalTask) TaskService(org.camunda.bpm.engine.TaskService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 17 with TaskService

use of org.camunda.bpm.engine.TaskService in project camunda-bpm-platform by camunda.

the class TaskResourceImpl method addIdentityLink.

@Override
public void addIdentityLink(IdentityLinkDto identityLink) {
    TaskService taskService = engine.getTaskService();
    identityLink.validate();
    if (identityLink.getUserId() != null) {
        taskService.addUserIdentityLink(taskId, identityLink.getUserId(), identityLink.getType());
    } else if (identityLink.getGroupId() != null) {
        taskService.addGroupIdentityLink(taskId, identityLink.getGroupId(), identityLink.getType());
    }
}
Also used : TaskService(org.camunda.bpm.engine.TaskService)

Example 18 with TaskService

use of org.camunda.bpm.engine.TaskService in project camunda-bpm-platform by camunda.

the class TaskResourceImpl method complete.

@Override
public void complete(CompleteTaskDto dto) {
    TaskService taskService = engine.getTaskService();
    try {
        VariableMap variables = VariableValueDto.toMap(dto.getVariables(), engine, objectMapper);
        taskService.complete(taskId, variables);
    } catch (RestException e) {
        String errorMessage = String.format("Cannot complete task %s: %s", taskId, e.getMessage());
        throw new InvalidRequestException(e.getStatus(), e, errorMessage);
    } catch (AuthorizationException e) {
        throw e;
    } catch (ProcessEngineException e) {
        String errorMessage = String.format("Cannot complete task %s: %s", taskId, e.getMessage());
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
    }
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) TaskService(org.camunda.bpm.engine.TaskService) RestException(org.camunda.bpm.engine.rest.exception.RestException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 19 with TaskService

use of org.camunda.bpm.engine.TaskService in project camunda-bpm-platform by camunda.

the class TaskResourceImpl method deleteIdentityLink.

@Override
public void deleteIdentityLink(IdentityLinkDto identityLink) {
    TaskService taskService = engine.getTaskService();
    identityLink.validate();
    if (identityLink.getUserId() != null) {
        taskService.deleteUserIdentityLink(taskId, identityLink.getUserId(), identityLink.getType());
    } else if (identityLink.getGroupId() != null) {
        taskService.deleteGroupIdentityLink(taskId, identityLink.getGroupId(), identityLink.getType());
    }
}
Also used : TaskService(org.camunda.bpm.engine.TaskService)

Example 20 with TaskService

use of org.camunda.bpm.engine.TaskService in project camunda-bpm-platform by camunda.

the class ProcessEngineRuleJunit4Test method ruleUsageExample.

@Test
@Deployment
public void ruleUsageExample() {
    RuntimeService runtimeService = engineRule.getRuntimeService();
    runtimeService.startProcessInstanceByKey("ruleUsage");
    TaskService taskService = engineRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("My Task", task.getName());
    taskService.complete(task.getId());
    assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
Also used : Task(org.camunda.bpm.engine.task.Task) RuntimeService(org.camunda.bpm.engine.RuntimeService) TaskService(org.camunda.bpm.engine.TaskService) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

TaskService (org.camunda.bpm.engine.TaskService)22 Task (org.camunda.bpm.engine.task.Task)11 Test (org.junit.Test)6 RuntimeService (org.camunda.bpm.engine.RuntimeService)5 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)4 Deployment (org.camunda.bpm.engine.test.Deployment)4 FilterService (org.camunda.bpm.engine.FilterService)3 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 ArrayList (java.util.ArrayList)2 TimerTask (java.util.TimerTask)2 IdentityService (org.camunda.bpm.engine.IdentityService)2 RepositoryService (org.camunda.bpm.engine.RepositoryService)2 StandaloneProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration)2 RestException (org.camunda.bpm.engine.rest.exception.RestException)2 IdentityLink (org.camunda.bpm.engine.task.IdentityLink)2 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)2 VariableMap (org.camunda.bpm.engine.variable.VariableMap)2 HashMap (java.util.HashMap)1 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)1