use of org.kie.internal.task.api.TaskQueryService in project jbpm by kiegroup.
the class CancelDeadlineCommand method execute.
@Override
public Void execute(Context cntxt) {
TaskContext context = (TaskContext) cntxt;
TaskDeadlinesService deadlineService = context.getTaskDeadlinesService();
TaskQueryService queryService = context.getTaskQueryService();
TaskPersistenceContext persistenceContext = context.getPersistenceContext();
InternalTask task = (InternalTask) queryService.getTaskInstanceById(taskId);
if (task == null || task.getDeadlines() == null) {
return null;
}
Iterator<? extends Deadline> it = null;
if (removeStart) {
if (task.getDeadlines().getStartDeadlines() != null) {
deadlineService.unschedule(taskId, DeadlineType.START);
it = task.getDeadlines().getStartDeadlines().iterator();
while (it.hasNext()) {
persistenceContext.removeDeadline(it.next());
it.remove();
}
}
}
if (removeEnd) {
if (task.getDeadlines().getEndDeadlines() != null) {
deadlineService.unschedule(taskId, DeadlineType.END);
it = task.getDeadlines().getEndDeadlines().iterator();
while (it.hasNext()) {
persistenceContext.removeDeadline(it.next());
it.remove();
}
}
}
return null;
}
use of org.kie.internal.task.api.TaskQueryService in project jbpm by kiegroup.
the class ProcessSubTaskCommand method execute.
@Override
public Void execute(Context cntxt) {
TaskContext context = (TaskContext) cntxt;
TaskInstanceService instanceService = context.getTaskInstanceService();
TaskQueryService queryService = context.getTaskQueryService();
Task task = queryService.getTaskInstanceById(taskId);
if (task == null) {
return null;
}
Task parentTask = null;
if (task.getTaskData().getParentId() != -1) {
parentTask = queryService.getTaskInstanceById(task.getTaskData().getParentId());
}
if (parentTask != null) {
if (((InternalTask) parentTask).getSubTaskStrategy() != null && ((InternalTask) parentTask).getSubTaskStrategy().equals(SubTasksStrategy.EndParentOnAllSubTasksEnd)) {
List<TaskSummary> subTasks = queryService.getSubTasksByParent(parentTask.getId());
// If there are no more sub tasks or if the last sub task is the one that we are completing now
if (subTasks.isEmpty() || (subTasks.size() == 1 && subTasks.get(0).getId().equals(taskId))) {
// Completing parent task if all the sub task has being completed, including the one that we are completing now
instanceService.complete(parentTask.getId(), "Administrator", data);
}
}
}
if (((InternalTask) task).getSubTaskStrategy() != null && ((InternalTask) task).getSubTaskStrategy().equals(SubTasksStrategy.SkipAllSubTasksOnParentSkip)) {
List<TaskSummary> subTasks = queryService.getSubTasksByParent(task.getId());
for (TaskSummary taskSummary : subTasks) {
Task subTask = queryService.getTaskInstanceById(taskSummary.getId());
// Exit each sub task because the parent task was aborted
instanceService.skip(subTask.getId(), "Administrator");
}
}
return null;
}
Aggregations