/** * Generates an empty task to be used for persistence queries (to get all * tasks). */ public static Task createTaskWithAllValuesSetToNull() { Task emptyTask = new Task(); emptyTask.removeAllProperties(); emptyTask.setEmpty(); return emptyTask; }
private void init() { if (!containsProperty("taskId")) { addOrReplaceProperty("taskId", UUID.randomUUID().toString()); } if (!containsProperty("taskCreationTimestamp")) { addOrReplaceProperty("taskCreationTimestamp", new Date()); } }
@Override public List<Task> getTasksForProcessId(String id) { Task example = Task.createTaskWithAllValuesSetToNull(); example.setProcessId(id); return getTasksForExample(example); }
task = t; add(new Label("taskid", task.getTaskId())); add(new Label("taskname", task.getName())); add(new Label("tasktype", task.getTaskType() != null ? task.getTaskType() : "N/A")); add(new Label("taskdescription", task.getDescription() != null ? task.getDescription() : "N/A")); StringValidator.minimumLength(2))); form.add(new Label("taskcreationTimestamp", task.getTaskCreationTimestamp() != null ? task.getTaskCreationTimestamp().toString() : "N/A")); form.add(new TextArea<String>("taskdescription", new PropertyModel<String>(task, "description")) .setRequired(true)); add(new ListView<String>("propertiesList", new ArrayList<String>(task.propertyKeySet())) { @Override protected void populateItem(ListItem<String> item) {
@Override public int compare(Task arg0, Task arg1) { int ret = 0; try { if (sp.getProperty().equals("taskId")) { ret = arg0.getTaskId().compareTo(arg1.getTaskId()); } else if (sp.getProperty().equals("taskType")) { ret = arg0.getTaskType().compareTo(arg1.getTaskType()); } else if (sp.getProperty().equals("description")) { ret = arg0.getDescription().compareTo(arg1.getDescription()); } else if (sp.getProperty().equals("taskCreationTimestamp")) { ret = arg0.getTaskCreationTimestamp().compareTo(arg1.getTaskCreationTimestamp()); } } catch (NullPointerException ex) { ret = -1; } if (!sp.isAscending()) { return ret * -1; } return ret; }
@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()); } }
public boolean match(Task task) { if (getTaskId() != null) { if (!task.getTaskId().startsWith(getTaskId())) { return false; } } if (getTaskType() != null) { if (!task.getTaskType().startsWith(getTaskType())) { return false; } } if (getDescription() != null) { if (!(task.getDescription().toLowerCase().indexOf(getDescription().toLowerCase()) > -1)) { return false; } } return true; } }
@Override public IModel<Task> model(Task object) { return new LoadableTaskModel(object.getTaskId(), taskboxService); }
private void updateInRunningWorkflow(Task oldTask, Task task) { if (oldTask.getProcessId() == null) { return; } long id = Long.parseLong(oldTask.getProcessId()); ProcessBag bag = null; try { bag = workflowService.getProcessBagForInstance(id); } catch (IllegalArgumentException e) { return; } if (Objects.equal(oldTask, bag)) { bag.setProperties(task.getProperties()); } } }
@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); }
public UserActionsPanel(String id, Task t) { super(id); task = t; Link<Task> link = new Link<Task>("taskLink") { @Override public void onClick() { try { Panel newPanel = webtaskboxService.getTaskPanel(task, "taskPanel"); newPanel.setOutputMarkupId(true); panel.replaceWith(newPanel); panel = newPanel; } catch (TaskboxException e) { LOGGER.error("Taskbox panel could not be started", e); } } }; link.add(new Label("linkLabel", String.format("%s (%s)", task == null ? "null" : task.getName(), task == null ? "null" : task.getTaskType()))); add(link); }
public String getName() { return (String) getProperty("name"); }
public void setTaskCreationTimestamp(Date taskCreationTimestamp) { addOrReplaceProperty("taskCreationTimestamp", taskCreationTimestamp); } }
@Override public List<Task> getOpenTasks() { return getTasksForExample(Task.createTaskWithAllValuesSetToNull()); }
@Override public void updateTask(Task task) throws WorkflowException { Task oldTask = getTaskForId(task.getTaskId()); try { persistence.update(oldTask, task); updateInRunningWorkflow(oldTask, task); LOGGER.info("updated task {}", task.getTaskId()); } catch (PersistenceException e) { LOGGER.error("tried to update task {}, but it didnt work!", task.getTaskId()); throw new WorkflowException(e); } }
public String getDescription() { return (String) getProperty("description"); }
public void setTaskId(String id) { addOrReplaceProperty("taskId", id); }
public String getTaskId() { return (String) getProperty("taskId"); }
public void setDescription(String description) { addOrReplaceProperty("description", description); }