Search in sources :

Example 1 with TaskEntity

use of org.activiti.engine.impl.persistence.entity.TaskEntity in project Activiti by Activiti.

the class GetIdentityLinksForTaskCmd method execute.

@SuppressWarnings({ "unchecked", "rawtypes" })
public List<IdentityLink> execute(CommandContext commandContext) {
    TaskEntity task = commandContext.getTaskEntityManager().findTaskById(taskId);
    List<IdentityLink> identityLinks = (List) task.getIdentityLinks();
    // and of course this leads to exception while trying to delete a non-existing identityLink
    if (task.getAssignee() != null) {
        IdentityLinkEntity identityLink = new IdentityLinkEntity();
        identityLink.setUserId(task.getAssignee());
        identityLink.setType(IdentityLinkType.ASSIGNEE);
        identityLink.setTaskId(task.getId());
        identityLinks.add(identityLink);
    }
    if (task.getOwner() != null) {
        IdentityLinkEntity identityLink = new IdentityLinkEntity();
        identityLink.setUserId(task.getOwner());
        identityLink.setTaskId(task.getId());
        identityLink.setType(IdentityLinkType.OWNER);
        identityLinks.add(identityLink);
    }
    return (List) task.getIdentityLinks();
}
Also used : IdentityLinkEntity(org.activiti.engine.impl.persistence.entity.IdentityLinkEntity) TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity) List(java.util.List) IdentityLink(org.activiti.engine.task.IdentityLink)

Example 2 with TaskEntity

use of org.activiti.engine.impl.persistence.entity.TaskEntity in project Activiti by Activiti.

the class AbstractSetProcessInstanceStateCmd method execute.

public Void execute(CommandContext commandContext) {
    if (executionId == null) {
        throw new ActivitiIllegalArgumentException("ProcessInstanceId cannot be null.");
    }
    ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findExecutionById(executionId);
    if (executionEntity == null) {
        throw new ActivitiObjectNotFoundException("Cannot find processInstance for id '" + executionId + "'.", Execution.class);
    }
    if (!executionEntity.isProcessInstanceType()) {
        throw new ActivitiException("Cannot set suspension state for execution '" + executionId + "': not a process instance.");
    }
    SuspensionStateUtil.setSuspensionState(executionEntity, getNewState());
    // All child executions are suspended
    List<ExecutionEntity> childExecutions = commandContext.getExecutionEntityManager().findChildExecutionsByProcessInstanceId(executionId);
    for (ExecutionEntity childExecution : childExecutions) {
        if (!childExecution.getId().equals(executionId)) {
            SuspensionStateUtil.setSuspensionState(childExecution, getNewState());
        }
    }
    // All tasks are suspended
    List<TaskEntity> tasks = commandContext.getTaskEntityManager().findTasksByProcessInstanceId(executionId);
    for (TaskEntity taskEntity : tasks) {
        SuspensionStateUtil.setSuspensionState(taskEntity, getNewState());
    }
    return null;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 3 with TaskEntity

use of org.activiti.engine.impl.persistence.entity.TaskEntity in project Activiti by Activiti.

the class TaskAssignedEventHandler method generateEventLogEntry.

@Override
public EventLogEntryEntity generateEventLogEntry(CommandContext commandContext) {
    TaskEntity task = (TaskEntity) ((ActivitiEntityEvent) event).getEntity();
    Map<String, Object> data = handleCommonTaskFields(task);
    return createEventLogEntry(task.getProcessDefinitionId(), task.getProcessInstanceId(), task.getExecutionId(), task.getId(), data);
}
Also used : TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity)

Example 4 with TaskEntity

use of org.activiti.engine.impl.persistence.entity.TaskEntity in project Activiti by Activiti.

the class TaskCreatedEventHandler method generateEventLogEntry.

@Override
public EventLogEntryEntity generateEventLogEntry(CommandContext commandContext) {
    TaskEntity task = (TaskEntity) ((ActivitiEntityEvent) event).getEntity();
    Map<String, Object> data = handleCommonTaskFields(task);
    return createEventLogEntry(task.getProcessDefinitionId(), task.getProcessInstanceId(), task.getExecutionId(), task.getId(), data);
}
Also used : TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity)

Example 5 with TaskEntity

use of org.activiti.engine.impl.persistence.entity.TaskEntity in project Activiti by Activiti.

the class TaskCollectionResource method createTask.

@RequestMapping(value = "/runtime/tasks", method = RequestMethod.POST, produces = "application/json")
public TaskResponse createTask(@RequestBody TaskRequest taskRequest, HttpServletRequest request, HttpServletResponse response) {
    Task task = taskService.newTask();
    // Populate the task properties based on the request
    populateTaskFromRequest(task, taskRequest);
    if (taskRequest.isTenantIdSet()) {
        ((TaskEntity) task).setTenantId(taskRequest.getTenantId());
    }
    taskService.saveTask(task);
    response.setStatus(HttpStatus.CREATED.value());
    return restResponseFactory.createTaskResponse(task);
}
Also used : Task(org.activiti.engine.task.Task) TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

TaskEntity (org.activiti.engine.impl.persistence.entity.TaskEntity)21 ActivitiException (org.activiti.engine.ActivitiException)5 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)5 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)4 ActivitiEntityEventImpl (org.activiti.engine.delegate.event.impl.ActivitiEntityEventImpl)4 Date (java.util.Date)3 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)3 Task (org.activiti.engine.task.Task)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Expression (org.activiti.engine.delegate.Expression)1 ActivitiEntityEvent (org.activiti.engine.delegate.event.ActivitiEntityEvent)1 ActivitiEntityWithVariablesEvent (org.activiti.engine.delegate.event.ActivitiEntityWithVariablesEvent)1 TaskFormData (org.activiti.engine.form.TaskFormData)1 BusinessCalendar (org.activiti.engine.impl.calendar.BusinessCalendar)1 DueDateBusinessCalendar (org.activiti.engine.impl.calendar.DueDateBusinessCalendar)1 FormEngine (org.activiti.engine.impl.form.FormEngine)1 TaskFormHandler (org.activiti.engine.impl.form.TaskFormHandler)1 CommentEntity (org.activiti.engine.impl.persistence.entity.CommentEntity)1