@Override public List<Task> getOpenTasks() { return getTasksForExample(Task.createTaskWithAllValuesSetToNull()); }
@Override public Task getTaskForId(String id) throws TaskboxException { Task example = Task.createTaskWithAllValuesSetToNull(); example.setTaskId(id); List<Task> list = getTasksForExample(example); if (list.size() != 1) { throw new TaskboxException((list.size() == 0 ? "No" : "More than one") + " task with ID " + id + " found!"); } return list.get(0); }
@Override public List<Task> getTasksForProcessId(String id) { Task example = Task.createTaskWithAllValuesSetToNull(); example.setProcessId(id); return getTasksForExample(example); }
@Override public synchronized void finishTask(Task task) throws WorkflowException { InternalWorkflowEvent finishedEvent = new InternalWorkflowEvent("TaskFinished", task); Task t = Task.createTaskWithAllValuesSetToNull(); t.setTaskId(task.getTaskId()); List<Task> old = getTasksForExample(t); if (old.size() > 0) { try { updateInRunningWorkflow(old.get(0), task); persistence.delete(t); } catch (PersistenceException e) { throw new WorkflowException(e); } workflowService.processEvent(finishedEvent); LOGGER.info("finished task {}", task.getTaskId()); } else { LOGGER.error("tried to finish task {}, BUT there is no such task.", task.getTaskId()); } }