Search in sources :

Example 1 with TaskService

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

the class HalIdentityLinkResolver method resolveNotCachedLinks.

protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) {
    TaskService taskService = processEngine.getTaskService();
    List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(linkedIds[0]);
    List<HalResource<?>> resolvedIdentityLinks = new ArrayList<HalResource<?>>();
    for (IdentityLink identityLink : identityLinks) {
        resolvedIdentityLinks.add(HalIdentityLink.fromIdentityLink(identityLink));
    }
    return resolvedIdentityLinks;
}
Also used : TaskService(org.camunda.bpm.engine.TaskService) ArrayList(java.util.ArrayList) HalResource(org.camunda.bpm.engine.rest.hal.HalResource) IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 2 with TaskService

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

the class TaskRestServiceImpl method createTask.

public void createTask(TaskDto taskDto) {
    ProcessEngine engine = getProcessEngine();
    TaskService taskService = engine.getTaskService();
    Task newTask = taskService.newTask(taskDto.getId());
    taskDto.updateTask(newTask);
    try {
        taskService.saveTask(newTask);
    } catch (NotValidException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e, "Could not save task: " + e.getMessage());
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) NotValidException(org.camunda.bpm.engine.exception.NotValidException) TaskService(org.camunda.bpm.engine.TaskService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 3 with TaskService

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

the class TaskResourceImpl method resolve.

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

Example 4 with TaskService

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

the class TaskResourceImpl method getIdentityLinks.

@Override
public List<IdentityLinkDto> getIdentityLinks(String type) {
    TaskService taskService = engine.getTaskService();
    List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
    List<IdentityLinkDto> result = new ArrayList<IdentityLinkDto>();
    for (IdentityLink link : identityLinks) {
        if (type == null || type.equals(link.getType())) {
            result.add(IdentityLinkDto.fromIdentityLink(link));
        }
    }
    return result;
}
Also used : TaskService(org.camunda.bpm.engine.TaskService) IdentityLinkDto(org.camunda.bpm.engine.rest.dto.task.IdentityLinkDto) ArrayList(java.util.ArrayList) IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 5 with TaskService

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

the class TaskResourceImpl method claim.

@Override
public void claim(UserIdDto dto) {
    TaskService taskService = engine.getTaskService();
    taskService.claim(taskId, dto.getUserId());
}
Also used : TaskService(org.camunda.bpm.engine.TaskService)

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