@SuppressWarnings("unchecked")
 @Override
 public List<KanbanHistory> getByKanbanIssue(KanbanIssue kanbanIssue) {
   try {
     return sessionFactory
         .getCurrentSession()
         .createCriteria(KanbanHistory.class)
         .add(Restrictions.eq("containerId", kanbanIssue.getIssueId()))
         .add(Restrictions.eq("containerType", KanbanHistory.ContainerType.KanbanIssue))
         .addOrder(Order.desc("dateCreated"))
         .list();
   } catch (Exception e) {
     e.printStackTrace();
     logger.error("error getByKanbanIssue ", e);
     return new ArrayList<KanbanHistory>();
   }
 }
示例#2
0
  @SuppressWarnings("static-access")
  public void saveIssue() {
    // update userstory
    try {
      String estimatePoint = this.issue.getEstimate().trim();
      // this.issue.setPointFormat(this.issueService.checkingPointFormat(estimatePoint));
      this.issue.setPointFormat("1"); // default DT format
      estimatePoint = this.issueService.checkingEstimatePoint(estimatePoint);
      this.issue.setEstimate(estimatePoint);
      this.issue.setRemain(estimatePoint);

      // 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}", ""));

      if (this.issueService.saveIssue(this.issue)) {
        // check last sprint of team
        Sprint lastSprint = sprintService.findLastSprintByTeamId(teamId);
        if (lastSprint != null
            && lastSprint.getSprintId().compareTo(issue.getSprint().getSprintId()) == 0) {
          // check exist kanban issue by content and userstory
          if (!kanbanIssueService.existKanbanIssueByUserStoryAndSubject(
              this.issue.getParent().getUserStory(), this.issue.getSubject())) {
            // add new kanban issue
            KanbanIssue addKanbanIssue = new KanbanIssue();
            addKanbanIssue.setUserStory(this.issue.getParent().getUserStory());
            addKanbanIssue.setSubject(this.issue.getSubject());
            addKanbanIssue.setDescription(this.issue.getDescription());
            addKanbanIssue.setNote(this.issue.getNote());
            addKanbanIssue.setColumnDone(false);
            addKanbanIssue.setRemain(this.issue.getRemain());
            addKanbanIssue.setEstimate(this.issue.getEstimate());
            addKanbanIssue.setPointFormat("1");
            addKanbanIssue.setType("Task");
            addKanbanIssue.setIsSubIssue(false);
            addKanbanIssue.setTeam(issue.getSprint().getTeam());
            addKanbanIssue.setIssueOfLastSprint(issue.getIssueId());
            kanbanIssueService.saveKanbanIssue(addKanbanIssue);
          }
        }
      }
      issueService.updateStatusOfIssueParent(this.issue.getParent());

      // check update status us when sprint is valid time
      if (!sprintService.isPastSprint(issue.getSprint())) {
        // Update status userstory
        UserStory userStory = this.userStoryService.findUserStoryByIssue(this.issue);
        UserStory.StatusType status = this.userStoryService.findStatusOfUserStory(userStory);
        if (userStory.getStatus().compareTo(status) != 0) {
          userStory.setStatus(status);
          this.userStoryService.update(userStory);
          // update kanbanissue status belong to userstory
          kanbanIssueService.updateAllKanbanIssueByUserStoryStatusOfTeam(
              userStory, sprint.getTeam());
        }
      }

      addAttachment();
      // insert into point remain
      updateRemainPointPerDay(this.issue);
      JSFUtils.addCallBackParam("save", true);
      JSFUtils.addSuccessMessage("msgs", this.utils.getMessage("myagile.SaveSuccess", null));
    } catch (Exception e) {
      JSFUtils.addWarningMessage("msgs", this.utils.getMessage("myagile.SaveUnsucces", null));
    }
  }