Example #1
0
  public String save() {
    if (currentTask != null) {
      try {
        Task merged =
            doInTransaction(
                new PersistenceAction<Task>() {

                  public Task execute(EntityManager em) {
                    if (currentTask.isNew()) {
                      em.persist(currentTask);
                    } else if (!em.contains(currentTask)) {
                      return em.merge(currentTask);
                    }
                    return currentTask;
                  }
                });
        if (!currentTask.equals(merged)) {
          setCurrentTask(merged);
          int idx = taskList.indexOf(currentTask);
          if (idx != -1) {
            taskList.set(idx, merged);
          }
        }
        storyManager.getCurrentStory().addTask(merged);
        if (!taskList.contains(merged)) {
          taskList.add(merged);
        }
      } catch (Exception e) {
        getLogger(getClass()).log(Level.SEVERE, "Error on try to save Task: " + currentTask, e);
        addMessage("Error on try to save Task", FacesMessage.SEVERITY_ERROR);
        return null;
      }
    }
    return "show";
  }
Example #2
0
  private String editTask(Task currentTask) {
    if (currentTask == null) return "";

    taskManager.setCurrentTask(currentTask);
    Story currentStory = storyManager.getCurrentStory();
    if (currentStory != currentTask.getStory()) {
      storyManager.setCurrentStory(currentTask.getStory());
    }
    return "/task/edit";
  }
Example #3
0
 public void init() {
   Task task = new Task();
   Story currentStory = storyManager.getCurrentStory();
   task.setStory(currentStory);
   setCurrentTask(task);
   if (currentStory != null) {
     taskList = new LinkedList<Task>(currentStory.getTasks());
   } else {
     taskList = new ArrayList<Task>();
   }
   tasks = new ListDataModel<Task>(taskList);
 }
Example #4
0
 public String edit() {
   setCurrentTask(tasks.getRowData());
   return "edit";
 }
Example #5
0
 public String create() {
   Task task = new Task();
   task.setStory(storyManager.getCurrentStory());
   setCurrentTask(task);
   return "create";
 }