예제 #1
0
  /** Create a new Issue by information entered in view and save into database */
  public void addIssue() {

    // Remove Control Characters
    newIssue.setSubject(newIssue.getSubject().replaceAll("\\p{Cntrl}", ""));
    newIssue.setDescription(newIssue.getDescription().replaceAll("\\p{Cntrl}", ""));
    newIssue.setNote(newIssue.getNote().replaceAll("\\p{Cntrl}", ""));

    newIssue.setParent(selectedIssue);
    newIssue.setSprint(selectedIssue.getSprint());
    newIssue.setStatus(
        statusService.findStatusStartBySprintId(selectedIssue.getSprint().getSprintId()));
    newIssue.setEstimate("D0T0");
    newIssue.setRemain("D0T0");
    newIssue.setType("Task");
    newIssue.setPointFormat("1");
    newIssue.setPriority("MUST");
    newIssue.setOldId(null);
    newIssue.setCreatedDate(new Date());
    issueService.saveIssue(newIssue);

    // Update status userstory
    UserStory userStory = userStoryService.findUserStoryByIssue(newIssue);
    UserStory.StatusType status = userStoryService.findStatusOfUserStory(userStory);
    userStory.setStatus(status);
    userStoryService.update(userStory);

    resetForm();
    RequestContext.getCurrentInstance().addCallbackParam("save", true);
    loadIssues();
  }
예제 #2
0
 public void updateUserStoryWhenUpdateIssue() {
   if (this.issue.getIssueId() != null) {
     updateIssue();
     UserStory userStoryOfIssue = this.issue.getUserStory();
     if (userStoryOfIssue != null) {
       // Update status userstory
       boolean updateStatusUs = false;
       UserStory.StatusType status =
           userStoryService.findStatusOfUserStoryBySprintAndUserStory(
               userStoryOfIssue, this.sprint);
       if (userStoryOfIssue.getStatus().compareTo(status) != 0) {
         updateStatusUs = true;
       }
       userStoryOfIssue.setPriority(PriorityType.valueOf(issue.getPriority()));
       userStoryOfIssue.setStatus(status);
       userStoryOfIssue.setName(this.issue.getSubject());
       userStoryOfIssue.setDescription(this.issue.getDescription());
       userStoryOfIssue.setNote(this.issue.getNote());
       if (userStoryService.update(userStoryOfIssue)) {
         userStoryService.updateAllIssueOfUserStoryHaveTheSameContent(userStoryOfIssue);
         // update kanbanissue status belong to userstory
         if (!sprintService.isPastSprint(issue.getSprint()) && updateStatusUs) {
           kanbanIssueService.updateAllKanbanIssueByUserStoryStatusOfTeam(
               userStoryOfIssue, sprint.getTeam());
         }
       }
     }
   }
   // Reset issueList and issue value
   resetIssueForm();
   resetIssueValue();
   resetAttachmentList();
   refreshIssueListTable();
 }
 /** Set status Destroy VOID for current user story */
 public void destroyVoid() {
   UserStory usTemp = userStoryService.findUserStoryById(selectedUserStoryId);
   usTemp.setStatus(usTemp.getPreviousStatus());
   userStoryService.update(usTemp);
   setValueForUsList();
   issueService.destroyVoidAllUnexpiredIssuesWhenDestroyVoidUserStory(usTemp.getUserStoryId());
   kanbanIssueService.destroyVoidAllKanbanIssueWhenDestroyVoidUserStory(usTemp.getUserStoryId());
 }
  /** delete user story */
  public void deleteUserStory() {
    try {
      boolean flag = true;
      Member owner = memberService.findProjectOwner(getProjectId());
      UserStory userStoryTemp = userStoryService.findUserStoryById(Long.parseLong(deleteId));
      userStoryService.delete(Long.parseLong(deleteId));
      Member member = utils.getLoggedInMember();

      String mailContent =
          "User story #"
              + userStoryTemp.getUserStoryId()
              + " has been removed by <b>"
              + member.getLastName()
              + " "
              + member.getFirstName()
              + "</b><br/>";
      mailContent += "<hr>";
      mailContent +=
          "<h3>User story #"
              + userStoryTemp.getUserStoryId()
              + ": "
              + userStoryTemp.getName()
              + "</h3>";
      mailContent += "<ul><li>Name: " + userStoryTemp.getName() + "</li>";
      mailContent += "<li>Description: " + userStoryTemp.getDescription() + "</li>";
      mailContent += "<li>Value: " + userStoryTemp.getValue() + "</li>";
      mailContent += "<li>Status: " + userStoryTemp.getStatus() + "</li></ul>";
      mailContent += "<hr>";
      mailContent +=
          "You have received this notification because you have either subscribed to it, or are involved in it.";

      List<Team> teamList = teamService.findTeamsByProjectId(getProjectId());

      for (int i = 0; i < teamList.size(); i++) {
        List<TeamMember> teamMemberList =
            memberService.findTeamMemberListByTeamId(teamList.get(i).getTeamId());
        for (int j = 0; j < teamMemberList.size(); j++) {
          if (teamMemberList.get(j).getMember().getUsername().equals(owner.getUsername())) {
            flag = false;
          }
          mailService.sendMail(
              "Inform about remove user story",
              mailContent,
              teamMemberList.get(j).getMember().getUsername());
        }
      }
      if (flag) {
        mailService.sendMail("Inform about remove user story", mailContent, owner.getUsername());
      }
      this.setValueForUsList();
      JSFUtils.resloveMethodExpression(
          "#{homeBean.setDefaultHistoryList}", Void.class, new Class<?>[0], new Object[0]);
    } catch (Exception e) {

    }
  }
  /**
   * update user story on menu backlog (sprint backlog)
   *
   * @param userStoryId
   * @param name
   * @param value
   */
  public void updatePBLOnBacklogPage() {
    try {
      RequestContext requestContext = RequestContext.getCurrentInstance();
      String id = JSFUtils.getRequestParameter("Id");
      String name = JSFUtils.getRequestParameter("name");
      String description = JSFUtils.getRequestParameter("description");
      String value = JSFUtils.getRequestParameter("value");
      String risk = JSFUtils.getRequestParameter("risk");
      UserStory current = userStoryService.findUserStoryById(Long.parseLong(id.trim()));
      if (current == null) {
        requestContext.addCallbackParam("userStoryId", id);
        requestContext.addCallbackParam("error", EXCEPTION);
        return;
      }

      if (name.equals("")) {
        requestContext.addCallbackParam("userStoryId", id);
        requestContext.addCallbackParam("error", EMPTY_ERROR);
        return;
      }

      if ((userStoryService.checkExistUserStory(
                  Utils.standardizeString(name), current.getProject().getProjectId())
              != null)
          && !(current.getName().equals(Utils.standardizeString(name)))) {
        requestContext.addCallbackParam("userStoryId", id);
        requestContext.addCallbackParam("error", DUPPLICATE_ERROR);
        return;
      }
      if (Integer.parseInt(value) > MAX_BUSSINESS_VALUE || Integer.parseInt(value) < 0) {
        requestContext.addCallbackParam("userStoryId", id);
        requestContext.addCallbackParam("error", VALUE_ERROR);
        return;
      }
      if (Integer.parseInt(risk) > MAX_RISK_VALUE || Integer.parseInt(risk) < 0) {
        requestContext.addCallbackParam("userStoryId", id);
        requestContext.addCallbackParam("error", RISK_ERROR);
        return;
      }
      current.setName(name.replaceAll("\\p{Cntrl}", ""));
      current.setValue(Integer.parseInt(value));
      current.setRisk(Integer.parseInt(risk));
      current.setDescription(description.replaceAll("\\p{Cntrl}", ""));
      if (userStoryService.update(current)) {
        userStoryService.updateAllIssueOfUserStoryHaveTheSameContent(current);
      }
      requestContext.execute("PrimeFaces.ab({source:'',update:'form2'});");
    } catch (Exception e) {

    }
  }
  /** Set status VOID for current user story */
  public void setVoid() {
    try {
      UserStory usTemp = userStoryService.findUserStoryById(selectedUserStoryId);
      usTemp.setPreviousStatus(usTemp.getStatus());
      usTemp.setStatus(UserStory.StatusType.VOID);
      //		kanbanIssueService.deleteAllKanbanIssueByUserStoryID(usTemp.getUserStoryId());
      issueService.setVoidAllUnexpiredIssuesWhenSetUserStoryVoid(usTemp.getUserStoryId());
      kanbanIssueService.setVoidAllKanbanIssueWhenSetVoidUserStory(usTemp.getUserStoryId());
      userStoryService.update(usTemp);

      setValueForUsList();
      JSFUtils.resloveMethodExpression(
          "#{homeBean.setDefaultHistoryList}", Void.class, new Class<?>[0], new Object[0]);
    } catch (Exception e) {
      LOGGER.error(e);
    }
  }
 public void setUsList(List<UserStory> usList) {
   try {
     for (UserStory us : usList) {
       userStoryService.update(us);
     }
     this.userStoryList = usList;
   } catch (Exception e) {
   }
 }
  public void updateUserStory() {
    RequestContext context = RequestContext.getCurrentInstance();
    if (userStory == null) {
      context.addCallbackParam("userStoryId", userStory.getUserStoryId());
      context.addCallbackParam("error", EXCEPTION);
      return;
    }

    if (userStory.getName().equals("")) {
      context.addCallbackParam("userStoryId", userStory.getUserStoryId());
      context.addCallbackParam("error", EMPTY_ERROR);
      return;
    }

    if (userStoryService.checkExistUserStory(
                Utils.standardizeString(userStory.getName()), getProjectId())
            != null
        && !(userStory.getName().equals(Utils.standardizeString(userStory.getName())))) {
      context.addCallbackParam("userStoryId", userStory.getUserStoryId());
      context.addCallbackParam("error", DUPPLICATE_ERROR);
      return;
    }

    if (userStory.getValue() > MAX_BUSSINESS_VALUE || userStory.getValue() < 0) {
      context.addCallbackParam("userStoryId", userStory.getUserStoryId());
      context.addCallbackParam("error", VALUE_ERROR);
      return;
    }

    userStory.setName(userStory.getName().replaceAll("\\p{Cntrl}", ""));
    userStory.setDescription(userStory.getDescription().replaceAll("\\p{Cntrl}", ""));

    if (userStoryService.update(userStory)) {
      userStoryService.updateAllIssueOfUserStoryHaveTheSameContent(userStory);
      setValueForUsList();
      context.addCallbackParam("error", NO_ERROR);
      context.addCallbackParam("userStoryId", userStory.getUserStoryId());
      JSFUtils.resloveMethodExpression(
          "#{homeBean.setDefaultHistoryList}", Void.class, new Class<?>[0], new Object[0]);
    } else {
      context.addCallbackParam("userStoryId", userStory.getUserStoryId());
      context.addCallbackParam("error", EXCEPTION);
    }
  }
 private List<UserStory> loadUserStoriesByCriteria() {
   List<UserStory> resultList = new ArrayList<UserStory>();
   String keyword = searchedKeyWord.trim();
   List<UserStory.StatusType> statusFilter = new ArrayList<UserStory.StatusType>();
   for (String statusString : selectedFilter) {
     statusFilter.add(UserStory.StatusType.valueOf(statusString));
   }
   resultList.addAll(
       userStoryService.findUserStoriesByCriteria(
           statusFilter, getProjectId(), order, Integer.parseInt(orderBy), keyword));
   return resultList;
 }
  public void validateUserStoryName(FacesContext context, UIComponent validate, Object value)
      throws ValidatorException {

    if (userStoryService.checkExistUserStory(
            Utils.standardizeString(value.toString()), getProjectId())
        != null) {
      @SuppressWarnings("static-access")
      FacesMessage msg = new FacesMessage(utils.getMessage("myagile.backlog.Exists", null));
      throw new ValidatorException(msg);
    }
    if (utils.isExistTooLongWord(value.toString())) {
      @SuppressWarnings("static-access")
      FacesMessage msg = new FacesMessage(utils.getMessage("myagile.backlog.LongestLength", null));
      throw new ValidatorException(msg);
    }
  }
  /** Create new user story with information entered in view, then save it into database */
  public void addUserStory() {
    RequestContext requestContext = RequestContext.getCurrentInstance();

    if (getProjectId() == 0) {
      requestContext.addCallbackParam("success", false);
      return;
    }
    try {
      UserStory us = new UserStory();

      // Remove Control Characters
      us.setName(Utils.standardizeString(userStory.getName()).replaceAll("\\p{Cntrl}", ""));
      us.setDescription(userStory.getDescription().replaceAll("\\p{Cntrl}", ""));

      us.setStatus(UserStory.StatusType.TODO);
      us.setValue(userStory.getValue());
      us.setProject(projectService.findProjectById(getProjectId()));
      us.setRisk(0);
      us.setPriority(UserStory.PriorityType.NONE);
      if (userStoryService.create(us)) {
        saveAttachmentsToDatabase(us);

        resetUserStoryValue();
        setValueForUsList();
        setCreateMode(false);
        requestContext.addCallbackParam("success", true);
        JSFUtils.resloveMethodExpression(
            "#{homeBean.setDefaultHistoryList}", Void.class, new Class<?>[0], new Object[0]);
      } else {
        throw new Exception();
      }
    } catch (Exception e) {
      requestContext.addCallbackParam("success", false);
      LOGGER.error("HomePage addUserStory: " + e);
    }
  }
 public UserStory.StatusType loadStatusOfUserStory(UserStory userStory) {
   if (userStory.getStatus() == UserStory.StatusType.VOID) {
     return UserStory.StatusType.VOID;
   }
   return userStoryService.findStatusOfUserStory(userStory);
 }
 public Integer calculateProgressOfUserStory(UserStory userStory) {
   return userStoryService.findProgressOfUserStory(userStory);
 }
예제 #14
0
  @SuppressWarnings("static-access")
  public void updateIssue() {
    try {
      // String typeFormatPoint = ""; TODO Knight check to use or delete
      // typeFormatPoint = this.issueService.checkingPointFormat(estimatePoint); TODO Knight check
      // to use or delete

      String remainPoint = this.issue.getRemain();
      String estimatePoint = this.issue.getEstimate();
      estimatePoint = this.issueService.checkingEstimatePoint(estimatePoint);
      remainPoint = this.issueService.checkingRemainPoint(remainPoint);

      if ((this.issue.getStatus() != null)
          && (this.issue.getStatus().getType() == Status.StatusType.START)) {
        remainPoint = estimatePoint;
      }

      issueService.updatePointRemain(remainPoint, this.issue.getIssueId());
      this.issue.setRemain(remainPoint);
      this.issue.setEstimate(estimatePoint);
      this.issue.setPointFormat("1"); // alway set default format is DT

      // Remove Control Characters
      this.issue.setSubject(this.issue.getSubject().replaceAll("\\p{Cntrl}", ""));
      this.issue.setNote(this.issue.getNote().replaceAll("\\p{Cntrl}", ""));
      this.issue.setDescription(this.issue.getDescription().trim().replaceAll("\\p{Cntrl}", ""));
      this.issueService.updateIssue(this.issue);
      // check last sprint of team
      Sprint lastSprint = sprintService.findLastSprintByTeamId(teamId);

      if (lastSprint != null
          && lastSprint.getSprintId().compareTo(issue.getSprint().getSprintId()) == 0) {
        // update kanban issue if exist
        kanbanIssueService.updateKanbanIssueByIssueId(issue.getIssueId());
      }

      if (this.issue.getParent() != null) {
        issueService.updateStatusOfIssueParent(this.issue.getParent());
        // check update status us when sprint is valid time
        if (!sprintService.isPastSprint(issue.getSprint())) {
          // Update status userstory
          UserStory userStory = userStoryService.findUserStoryByIssue(this.issue);
          UserStory.StatusType status =
              userStoryService.findStatusOfUserStoryBySprintAndUserStory(userStory, this.sprint);

          if (userStory.getStatus().compareTo(status) != 0) {
            userStory.setStatus(status);
            userStoryService.update(userStory);
            // update kanbanissue status belong to userstory
            kanbanIssueService.updateAllKanbanIssueByUserStoryStatusOfTeam(
                userStory, sprint.getTeam());
          }
        }
      }

      updateRemainPointPerDay(this.issue);

      JSFUtils.addCallBackParam("edited", true);
      JSFUtils.addSuccessMessage("msgs", this.utils.getMessage("myagile.UpdateSuccess", null));
    } catch (Exception e) {
      JSFUtils.addWarningMessage("msgs", this.utils.getMessage("myagile.UpdateUnsuccess", null));
    }
  }