@Override public List<Task> execute(CommandContext commandContext) { return CommandContextUtil.getTaskService().findTasksByParentTaskId(parentTaskId); }
public static TaskService getTaskService() { return getTaskService(getCommandContext()); }
@Override public void onStateTransition(CommandContext commandContext, DelegatePlanItemInstance planItemInstance, String transition) { if (PlanItemTransition.TERMINATE.equals(transition) || PlanItemTransition.EXIT.equals(transition)) { TaskService taskService = CommandContextUtil.getTaskService(commandContext); List<TaskEntity> taskEntities = taskService.findTasksBySubScopeIdScopeType(planItemInstance.getId(), ScopeTypes.CMMN); for (TaskEntity taskEntity : taskEntities) { TaskHelper.deleteTask(taskEntity, "cmmn-state-transition-" + transition, false, true); } } }
@Override public Task execute(CommandContext commandContext) { TaskEntity task = CommandContextUtil.getTaskService().createTask(); task.setId(taskId); task.setRevision(0); return task; }
@Override public Task execute(CommandContext commandContext) { Task task = CommandContextUtil.getTaskService().createTask(this.taskBuilder); if (CountingTaskUtil.isTaskRelatedEntityCountEnabledGlobally() && StringUtils.isNotEmpty(task.getParentTaskId())) { TaskEntity parentTaskEntity = CommandContextUtil.getTaskService().getTask(task.getParentTaskId()); if (CountingTaskUtil.isTaskRelatedEntityCountEnabled(parentTaskEntity)) { CountingTaskEntity countingParentTaskEntity = (CountingTaskEntity) parentTaskEntity; countingParentTaskEntity.setSubTaskCount(countingParentTaskEntity.getSubTaskCount() + 1); } } return task; } }
@Override protected Void execute(CommandContext commandContext, TaskEntity task) { task.setPriority(priority); CommandContextUtil.getCmmnHistoryManager(commandContext).recordTaskInfoChange(task); CommandContextUtil.getTaskService().updateTask(task, true); return null; }
@Override protected Void execute(CommandContext commandContext, TaskEntity task) { task.setDueDate(dueDate); CommandContextUtil.getCmmnHistoryManager(commandContext).recordTaskInfoChange(task); CommandContextUtil.getTaskService().updateTask(task, true); return null; }
public static void changeTaskOwner(TaskEntity taskEntity, String owner) { if ((taskEntity.getOwner() != null && !taskEntity.getOwner().equals(owner)) || (taskEntity.getOwner() == null && owner != null)) { CommandContextUtil.getTaskService().changeTaskOwner(taskEntity, owner); if (taskEntity.getId() != null) { addOwnerIdentityLink(taskEntity); } } }
public static void deleteTask(String taskId, String deleteReason, boolean cascade) { TaskEntity task = CommandContextUtil.getTaskService().getTask(taskId); if (task != null) { if (task.getScopeId() != null && ScopeTypes.CMMN.equals(task.getScopeType())) { throw new FlowableException("The task cannot be deleted because is part of a running case instance"); } deleteTask(task, deleteReason, cascade, true); } else if (cascade) { deleteHistoricTaskLogEntries(taskId); deleteHistoricTask(taskId); } }
protected void handleHumanTaskNewAssignee(PlanItemInstanceEntity taskPlanItemInstance, String newAssigneeId, CommandContext commandContext) { TaskService taskService = CommandContextUtil.getTaskService(commandContext); TaskEntityImpl task = (TaskEntityImpl) taskService.createTaskQuery().subScopeId(taskPlanItemInstance.getId()).scopeType(ScopeTypes.CMMN).singleResult(); TaskHelper.changeTaskAssignee(task, newAssigneeId); }
public static void changeTaskAssignee(TaskEntity taskEntity, String assignee) { if ((taskEntity.getAssignee() != null && !taskEntity.getAssignee().equals(assignee)) || (taskEntity.getAssignee() == null && assignee != null)) { CommandContextUtil.getTaskService().changeTaskAssignee(taskEntity, assignee); CommandContextUtil.getCmmnEngineConfiguration().getListenerNotificationHelper().executeTaskListeners(taskEntity, TaskListener.EVENTNAME_ASSIGNMENT); if (taskEntity.getId() != null) { addAssigneeIdentityLinks(taskEntity); } } }
@Override public void trigger(CommandContext commandContext, PlanItemInstanceEntity planItemInstance) { if (!PlanItemInstanceState.ACTIVE.equals(planItemInstance.getState())) { throw new FlowableException("Can only trigger a human task plan item that is in the ACTIVE state"); } TaskService taskService = CommandContextUtil.getTaskService(commandContext); List<TaskEntity> taskEntities = taskService.findTasksBySubScopeIdScopeType(planItemInstance.getId(), ScopeTypes.CMMN); if (taskEntities == null || taskEntities.isEmpty()) { throw new FlowableException("No task entity found for plan item instance " + planItemInstance.getId()); } // Should be only one for (TaskEntity taskEntity : taskEntities) { if (!taskEntity.isDeleted()) { TaskHelper.deleteTask(taskEntity, null, false, true); } } CommandContextUtil.getAgenda(commandContext).planCompletePlanItemInstanceOperation((PlanItemInstanceEntity) planItemInstance); }
@Override public T execute(CommandContext commandContext) { if (taskId == null) { throw new FlowableIllegalArgumentException("taskId is null"); } TaskEntity task = CommandContextUtil.getTaskService().getTask(taskId); if (task == null) { throw new FlowableObjectNotFoundException("Cannot find task with id " + taskId, Task.class); } if (task.isSuspended()) { throw new FlowableException(getSuspendedTaskException()); } return execute(commandContext, task); }
protected CaseDefinition getCaseDefinition(IdentityLinkEntity identityLink) { String caseDefinitionId = null; if (ScopeTypes.CMMN.equals(identityLink.getScopeType()) && identityLink.getScopeId() != null) { CaseInstance caseInstance = CommandContextUtil.getCaseInstanceEntityManager().findById(identityLink.getScopeId()); if (caseInstance != null) { caseDefinitionId = caseInstance.getCaseDefinitionId(); } } else if (identityLink.getTaskId() != null) { TaskEntity task = CommandContextUtil.getTaskService().getTask(identityLink.getTaskId()); if (task != null && ScopeTypes.CMMN.equals(task.getScopeType())) { caseDefinitionId = task.getScopeDefinitionId(); } } return CaseDefinitionUtil.getCaseDefinition(caseDefinitionId); }
@Override public Boolean execute(CommandContext commandContext) { if (taskId == null) { throw new FlowableIllegalArgumentException("taskId is null"); } if (variableName == null) { throw new FlowableIllegalArgumentException("variableName is null"); } TaskEntity task = CommandContextUtil.getTaskService().getTask(taskId); if (task == null) { throw new FlowableObjectNotFoundException("task " + taskId + " doesn't exist", Task.class); } boolean hasVariable = false; if (isLocal) { hasVariable = task.hasVariableLocal(variableName); } else { hasVariable = task.hasVariable(variableName); } return hasVariable; } }
@Override public Object execute(CommandContext commandContext) { if (taskId == null) { throw new FlowableIllegalArgumentException("taskId is null"); } if (variableName == null) { throw new FlowableIllegalArgumentException("variableName is null"); } TaskEntity task = CommandContextUtil.getTaskService().getTask(taskId); if (task == null) { throw new FlowableObjectNotFoundException("task " + taskId + " doesn't exist", Task.class); } Object value; if (isLocal) { value = task.getVariableLocal(variableName, false); } else { value = task.getVariable(variableName, false); } return value; } }
@Override public VariableInstance execute(CommandContext commandContext) { if (taskId == null) { throw new FlowableIllegalArgumentException("taskId is null"); } if (variableName == null) { throw new FlowableIllegalArgumentException("variableName is null"); } TaskEntity task = CommandContextUtil.getTaskService().getTask(taskId); if (task == null) { throw new FlowableObjectNotFoundException("task " + taskId + " doesn't exist", Task.class); } VariableInstance variableEntity; if (isLocal) { variableEntity = task.getVariableInstanceLocal(variableName, false); } else { variableEntity = task.getVariableInstance(variableName, false); } return variableEntity; } }
TaskEntity task = CommandContextUtil.getTaskService().getTask(taskId);
public static void insertTask(TaskEntity taskEntity, boolean fireCreateEvent) { if (taskEntity.getOwner() != null) { addOwnerIdentityLink(taskEntity); } if (taskEntity.getAssignee() != null) { addAssigneeIdentityLinks(taskEntity); CommandContextUtil.getCmmnEngineConfiguration().getListenerNotificationHelper().executeTaskListeners(taskEntity, TaskListener.EVENTNAME_ASSIGNMENT); } CommandContextUtil.getTaskService().insertTask(taskEntity, fireCreateEvent); CommandContextUtil.getCmmnHistoryManager().recordTaskCreated(taskEntity); }
TaskEntity task = CommandContextUtil.getTaskService().getTask(taskId);