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();
}
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;
}
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);
}
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);
}
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);
}
Aggregations