コード例 #1
0
 public DataModel<Story> getStories() {
   if (sprintManager.getCurrentSprint() != null) {
     this.stories = new ListDataModel<Story>(sprintManager.getCurrentSprint().getStories());
     return stories;
   } else {
     return new ListDataModel<Story>();
   }
 }
コード例 #2
0
  public String remove() {
    final Story story = stories.getRowData();
    if (story != null) {
      try {
        doInTransaction(
            new PersistenceActionWithoutResult() {

              public void execute(EntityManager em) {
                if (em.contains(story)) {
                  em.remove(story);
                } else {
                  em.remove(em.merge(story));
                }
              }
            });
        sprintManager.getCurrentSprint().removeStory(story);
        getStoryList().remove(story);
      } catch (Exception e) {
        getLogger(getClass()).log(Level.SEVERE, "Error on try to remove Story: " + currentStory, e);
        addMessage("Error on try to remove Story", FacesMessage.SEVERITY_ERROR);
        return null;
      }
    }
    return "show";
  }
コード例 #3
0
  public String save() {
    if (currentStory != null) {
      try {
        Story merged =
            doInTransaction(
                new PersistenceAction<Story>() {

                  public Story execute(EntityManager em) {
                    if (currentStory.isNew()) {
                      em.persist(currentStory);
                    } else if (!em.contains(currentStory)) {
                      return em.merge(currentStory);
                    }
                    return currentStory;
                  }
                });
        if (!currentStory.equals(merged)) {
          setCurrentStory(merged);
          int idx = getStoryList().indexOf(currentStory);
          if (idx != -1) {
            getStoryList().set(idx, merged);
          }
        }
        sprintManager.getCurrentSprint().addStory(merged);
        if (!storyList.contains(merged)) {
          getStoryList().add(merged);
        }
      } catch (Exception e) {
        getLogger(getClass()).log(Level.SEVERE, "Error on try to save Story: " + currentStory, e);
        addMessage("Error on try to save Story", FacesMessage.SEVERITY_ERROR);
        return null;
      }
    }
    return "show";
  }
コード例 #4
0
  public void init() {
    Sprint currentSprint = sprintManager.getCurrentSprint();

    if (currentSprint != null) {
      Story story = new Story();
      story.setSprint(currentSprint);
      setCurrentStory(story);
    }
  }
コード例 #5
0
  public void init() {

    Sprint currentSprint = sprintManager.getCurrentSprint();

    if (currentSprint != null) {
      Story story = new Story();
      setStoryList(new LinkedList<Story>(currentSprint.getStories()));
      story.setSprint(currentSprint);
      setCurrentStory(story);
    } else {
      setStoryList(new ArrayList<Story>());
    }
    stories = new ListDataModel<Story>(getStoryList());
  }
コード例 #6
0
  public String remove(final Story story) {
    if (story != null) {
      try {
        doInTransaction(
            new PersistenceActionWithoutResult() {

              public void execute(EntityManager em) {
                Query query = em.createNamedQuery("task.remove.ByProject");
                query.setParameter("project", story.getSprint().getProject());
                query.executeUpdate();

                em.remove(em.find(Story.class, story.getId()));
              }
            });
        sprintManager.getCurrentSprint().removeStory(story);
      } catch (Exception e) {
        getLogger(getClass()).log(Level.SEVERE, "Error on try to remove Story: " + currentStory, e);
        addMessage("Error on try to remove Story", FacesMessage.SEVERITY_ERROR);
        return null;
      }
    }
    return "show";
  }
コード例 #7
0
 /** @return the storyList */
 public List<Story> getStoryList() {
   if (sprintManager.getCurrentSprint() != null) {
     this.storyList = sprintManager.getCurrentSprint().getStories();
   }
   return this.storyList;
 }
コード例 #8
0
 public Sprint getSprint() {
   return sprintManager.getCurrentSprint();
 }
コード例 #9
0
 public String create() {
   Story story = new Story();
   story.setSprint(sprintManager.getCurrentSprint());
   setCurrentStory(story);
   return "create";
 }