Пример #1
0
  /**
   * refreshes a given Collection of attachment's references that can change.
   *
   * @param attachments the attachments.
   */
  private void refreshAttachmentReferences(List<SubAwardAttachments> attachments) {
    assert attachments != null : "the attachments was null";

    for (final SubAwardAttachments attachment : attachments) {
      attachment.refreshReferenceObject("typeAttachment");
    }
  }
Пример #2
0
 /**
  * assigns a document id to all attachments in the passed in collection based on the passed in
  * type to doc number map.
  *
  * @param <T> the type of attachments
  * @param attachments the collection of attachments that require doc number assignment
  * @param typeToDocNumber the map that contains all the highest doc numbers of existing
  *     attachments based on type code
  */
 private void assignDocumentId(
     List<SubAwardAttachments> attachments, final Map<String, Integer> typeToDocNumber) {
   for (SubAwardAttachments attachment : attachments) {
     if (attachment.isNew()) {
       final Integer nextDocNumber =
           SubAwardAttachmentFormBean.createNextDocNumber(
               typeToDocNumber.get(attachment.getSubAwardAttachmentTypeCode()));
       attachment.setDocumentId(nextDocNumber);
     }
   }
 }
Пример #3
0
  /**
   * Creates a map containing the highest doc number from a collection of attachments for each type
   * code.
   *
   * @param <T> the type
   * @param attachments the collection of attachments
   * @return the map
   */
  private Map<String, Integer> createTypeToMaxDocNumber(List<SubAwardAttachments> attachments) {

    final Map<String, Integer> typeToDocNumber = new HashMap<String, Integer>();

    for (SubAwardAttachments attachment : attachments) {
      final Integer curMax = typeToDocNumber.get(attachment.getSubAwardAttachmentTypeCode());
      if (curMax == null || curMax.intValue() < attachment.getDocumentId().intValue()) {
        typeToDocNumber.put(attachment.getSubAwardAttachmentTypeCode(), attachment.getDocumentId());
      }
    }

    return typeToDocNumber;
  }
Пример #4
0
  private void syncNewFiles(List<SubAwardAttachments> attachments) {
    assert attachments != null : "the attachments was null";

    for (SubAwardAttachments attachment : attachments) {
      if (SubAwardAttachmentFormBean.doesNewFileExist(attachment)) {
        final AttachmentFile newFile = AttachmentFile.createFromFormFile(attachment.getNewFile());
        // setting the sequence number to the old file sequence number
        if (attachment.getFile() != null) {
          newFile.setSequenceNumber(attachment.getFile().getSequenceNumber());
        }
        attachment.setFile(newFile);
      }
    }
  }
Пример #5
0
 /**
  * Checks if a new file exists on an attachment
  *
  * @param attachment the attachment
  * @return true if new false if not
  */
 private static boolean doesNewFileExist(SubAwardAttachments attachment) {
   return attachment.getNewFile() != null
       && StringUtils.isNotBlank(attachment.getNewFile().getFileName());
 }