Example #1
0
 /** Delete an attachment */
 public void deleteAttachmentOfIssue() {
   Attachment deleteAttachment = selectedAttachment;
   attachmentService.delete(deleteAttachment);
   attachmentService.deleteFile(deleteAttachment.getDiskFilename(), projectId);
   attachmentListByIssue = attachmentService.findAttachmentByIssue(issue);
   if (issue.getUserStory() != null) {
     attachmentListByIssue.addAll(
         attachmentService.findAttachmentByUserStory(issue.getUserStory()));
   }
 }
Example #2
0
  /** Delete an attachment in temp when editing issue */
  public void deleteAttachmentNotAddById() {
    try {
      Attachment deleteAttachment = this.attachmentNotAdd;
      this.attachmentService.deleteFileInTemp(deleteAttachment.getDiskFilename());
      this.attachmentService.delete(deleteAttachment);
      this.attachmentNotAddList.remove(deleteAttachment);
      getAttachmentListByIssue();
    } catch (Exception e) {

    }
  }
 private void saveAttachmentsToDatabase(UserStory us) {
   try {
     for (Attachment attachment : this.notAddedAttachmentList) {
       attachment.setContainerId(us.getUserStoryId());
       attachment.setTemp(false);
       this.attachmentService.moveAttachmentFile(attachment, us.getProject().getProjectId());
       this.attachmentService.save(attachment);
     }
   } catch (Exception e) {
     LOGGER.error("saveAttachmentsToDatabase " + e);
   }
 }
Example #4
0
 /** Add attachment(s) for an issue */
 public void addAttachment() {
   if (this.attachmentNotAddList != null) {
     for (Attachment att : this.attachmentNotAddList) {
       att.setContainerId(this.issue.getIssueId());
       att.setTemp(false);
       if (this.projectId != null) {
         this.attachmentService.moveAttachmentFile(att, this.projectId);
       }
     }
     this.attachmentNotAddList = new ArrayList<Attachment>();
   }
 }
 private void prepareUploadFile() {
   if (this.notAddedAttachmentList.size() > 0) {
     for (Attachment att : this.notAddedAttachmentList) {
       this.attachmentService.delete(att);
       this.attachmentService.deleteFileInTemp(att.getDiskFilename());
     }
     this.notAddedAttachmentList.clear();
   } else {
     this.notAddedAttachmentList = new ArrayList<Attachment>();
   }
   this.attachment = new Attachment();
   this.attachmentList = new ArrayList<Attachment>();
   this.attachmentList.clear();
 }
 public void deleteNotAddedAttachment() {
   try {
     this.attachmentService.deleteFileInTemp(deleteAttachment.getDiskFilename());
     this.notAddedAttachmentList.remove(deleteAttachment);
   } catch (Exception e) {
     LOGGER.error("deleteAttachment at sprintBackLog " + e);
   }
 }
 public void uploadAttachment() {
   if (saveAttachment()) {
     Attachment newAttachment =
         this.attachmentService.findAttachmentById(this.attachment.getAttachmentId());
     if (this.notAddedAttachmentList == null) {
       setNotAddedAttachmentList(new ArrayList<Attachment>());
     }
     if (newAttachment.getContainerId() != null) {
       this.attachment.setTemp(false);
       this.attachmentService.moveAttachmentFile(
           this.attachment, this.userStory.getProject().getProjectId());
       this.attachmentService.update(newAttachment);
     } else {
       this.attachment.setTemp(true);
       this.notAddedAttachmentList.add(newAttachment);
     }
     setAttachmentList(this.attachmentService.findAttachmentByUserStory(this.userStory));
   }
 }
Example #8
0
 /** Delete an issue and delete its all attachment */
 public void deleteIssue() {
   Issue issueTemp = this.issue;
   try {
     this.attachmentListByIssue = this.attachmentService.findAttachmentByIssue(this.issue);
     if (this.attachmentListByIssue != null) {
       for (Attachment att : this.attachmentListByIssue) {
         this.attachmentService.deleteFile(
             att.getDiskFilename(),
             this.projectService.findProjectOfIssue(this.issue).getProjectId());
         this.attachmentService.delete(att);
       }
     }
     List<History> historyOfIssue = new ArrayList<History>();
     historyOfIssue = historyService.findHistoryByContainer("Issue", this.issue.getIssueId());
     for (History history : historyOfIssue) {
       historyService.delete(history);
     }
     Issue issueParent = issueTemp.getParent();
     this.issueService.deleteIssue(this.issue);
     // delete kanban issue if has the same subject with issue
     // check exist kanban issue by content and userstory
     // check last sprint of team
     Sprint lastSprint = sprintService.findLastSprintByTeamId(teamId);
     if (lastSprint != null
         && lastSprint.getSprintId().compareTo(issueTemp.getSprint().getSprintId()) == 0) {
       kanbanIssueService.deleteKanbanIssueByIssueId(issueTemp.getIssueId());
     }
     if (issueParent != null) {
       issueService.updateStatusOfIssueParent(issueParent);
     }
     resetIssueForm();
     resetIssueValue();
     this.issueList.remove(issueTemp);
     this.filteredIssues = new ArrayList<Issue>(this.issueList);
     this.selectedIssues = new ArrayList<Issue>();
     resetAttachmentList();
   } catch (Exception a) {
     a.printStackTrace();
     logger.error("delete issue unsuccessful", a);
   }
 }
Example #9
0
  /** Upload attachment file for issue */
  public void uploadFile() {
    String filename = JSFUtils.getRequestParameter("filename");
    String diskFileName =
        this.attachmentService.fileNameProcess(FilenameUtils.removeExtension(filename));
    diskFileName = this.attachmentService.replaceFile(filename, diskFileName);
    attachment = new Attachment();
    attachment.setFilename(filename);
    attachment.setDiskFilename(diskFileName);
    attachment.setContainerId(issue.getIssueId());
    attachment.setContainerType(Attachment.ISSUE_ATTACHMENT);
    // add files of Issue in user story for easy to handle.
    if (issue.getUserStory() != null) {
      attachment.setContainerId(issue.getUserStory().getUserStoryId());
      attachment.setContainerType(Attachment.USERSTORY_ATTACHMENT);
    }

    attachment.setTemp(false);
    attachment.setCreatedOn(new Date());
    attachment.setAuthor(utils.getLoggedInMember());
    attachmentService.save(attachment);
    Attachment newAttachment = attachmentService.findAttachmentById(attachment.getAttachmentId());

    if (attachmentNotAddList == null) {
      attachmentNotAddList = new ArrayList<Attachment>();
    }

    if (newAttachment.getContainerId() != null) {
      attachment.setTemp(false);
      attachmentService.moveAttachmentFile(attachment, projectId);
    } else {
      attachment.setTemp(true);
      attachmentNotAddList.add(newAttachment);
    }

    attachmentListByIssue = attachmentService.findAttachmentByIssue(issue);
    if (issue.getUserStory() != null) {
      attachmentListByIssue.addAll(
          attachmentService.findAttachmentByUserStory(issue.getUserStory()));
    }
  }