Ejemplo n.º 1
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;
  }
Ejemplo n.º 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);
     }
   }
 }