Example #1
0
 public ActionForward delete(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   BudgetForm budgetForm = (BudgetForm) form;
   AwardBudgetDocument awardBudgetDocument = budgetForm.getBudgetDocument();
   int selectedLineNumber = getSelectedLine(request);
   BudgetSubAwards subAward =
       awardBudgetDocument.getBudget().getBudgetSubAwards().get(selectedLineNumber);
   for (BudgetPeriod period : awardBudgetDocument.getBudget().getBudgetPeriods()) {
     Iterator<BudgetLineItem> iter = period.getBudgetLineItems().iterator();
     while (iter.hasNext()) {
       BudgetLineItem item = iter.next();
       if (org.apache.commons.lang3.ObjectUtils.equals(
           subAward.getSubAwardNumber(), item.getSubAwardNumber())) {
         iter.remove();
       }
     }
   }
   awardBudgetDocument.getBudget().getBudgetSubAwards().remove(selectedLineNumber);
   Collections.sort(awardBudgetDocument.getBudget().getBudgetSubAwards());
   return mapping.findForward(Constants.MAPPING_BASIC);
 }
Example #2
0
 public ActionForward addSubAward(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   BudgetForm budgetForm = (BudgetForm) form;
   AwardBudgetDocument awardBudgetDocument = budgetForm.getBudgetDocument();
   BudgetSubAwards newBudgetSubAward = budgetForm.getNewSubAward();
   newBudgetSubAward.setBudgetId(awardBudgetDocument.getBudget().getBudgetId());
   newBudgetSubAward.setSubAwardNumber(generateSubAwardNumber(awardBudgetDocument));
   newBudgetSubAward.setBudgetVersionNumber(
       awardBudgetDocument.getBudget().getBudgetVersionNumber());
   newBudgetSubAward.setSubAwardStatusCode(1);
   newBudgetSubAward.getBudgetSubAwardPeriodDetails().clear();
   for (BudgetPeriod period : awardBudgetDocument.getBudget().getBudgetPeriods()) {
     newBudgetSubAward
         .getBudgetSubAwardPeriodDetails()
         .add(new BudgetSubAwardPeriodDetail(newBudgetSubAward, period));
   }
   boolean success = true;
   if (newBudgetSubAward.getNewSubAwardFile() != null) {
     String fileName = newBudgetSubAward.getNewSubAwardFile().getOriginalFilename();
     byte[] fileData = newBudgetSubAward.getNewSubAwardFile().getBytes();
     success =
         updateBudgetAttachment(
             budgetForm.getBudget(), newBudgetSubAward, fileName, fileData, "newSubAward");
   }
   String contentType = newBudgetSubAward.getNewSubAwardFile().getContentType();
   if (success && contentType.equalsIgnoreCase(Constants.PDF_REPORT_CONTENT_TYPE)) {
     budgetForm.setNewSubAward(new BudgetSubAwards());
     awardBudgetDocument.getBudget().getBudgetSubAwards().add(newBudgetSubAward);
   }
   return mapping.findForward(Constants.MAPPING_BASIC);
 }
Example #3
0
 public ActionForward execute(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   BudgetForm budgetForm = (BudgetForm) form;
   for (BudgetSubAwards subAward :
       budgetForm.getBudgetDocument().getBudget().getBudgetSubAwards()) {
     subAward.computePeriodDetails();
   }
   return super.execute(mapping, budgetForm, request, response);
 }
Example #4
0
  protected boolean updateBudgetAttachment(
      Budget budget, BudgetSubAwards subAward, String fileName, byte[] fileData, String errorPath)
      throws Exception {

    GlobalVariables.getMessageMap().addToErrorPath(errorPath);
    subAward.setSubAwardXmlFileData(null);
    subAward.setFormName(null);
    subAward.setNamespace(null);
    if (subAward
        .getNewSubAwardFile()
        .getContentType()
        .equalsIgnoreCase(Constants.PDF_REPORT_CONTENT_TYPE)) {
      getPropDevBudgetSubAwardService()
          .populateBudgetSubAwardFiles(budget, subAward, fileName, fileData);
    }
    boolean success = updateSubAwardBudgetDetails(budget, subAward);
    if (success) {
      subAward
          .getBudgetSubAwardFiles()
          .get(0)
          .setSubAwardXmlFileData(
              KcServiceLocator.getService(KcAttachmentService.class)
                  .checkAndReplaceSpecialCharacters(
                      subAward
                          .getBudgetSubAwardFiles()
                          .get(0)
                          .getSubAwardXmlFileData()
                          .toString()));
      subAward.setSubAwardXmlFileData(
          subAward.getBudgetSubAwardFiles().get(0).getSubAwardXmlFileData());
    }
    GlobalVariables.getMessageMap().removeFromErrorPath(errorPath);
    return success;
  }
Example #5
0
 protected boolean updateSubAwardBudgetDetails(Budget budget, BudgetSubAwards subAward)
     throws Exception {
   List<String[]> errorMessages = new ArrayList<String[]>();
   boolean success =
       getKcBusinessRulesEngine().applyRules(new BudgetSubAwardsEvent(subAward, budget, ""));
   if (subAward.getNewSubAwardFile().getBytes().length == 0) {
     success = false;
   }
   if (success) {
     getPropDevBudgetSubAwardService()
         .updateSubAwardBudgetDetails(budget, subAward, errorMessages);
   }
   if (!errorMessages.isEmpty()) {
     for (String[] message : errorMessages) {
       String[] messageParameters = null;
       if (message.length > 1) {
         messageParameters = Arrays.copyOfRange(message, 1, message.length);
       }
       if (success) {
         GlobalVariables.getMessageMap()
             .putWarning(Constants.SUBAWARD_FILE_FIELD_NAME, message[0], messageParameters);
       } else {
         GlobalVariables.getMessageMap()
             .putError(Constants.SUBAWARD_FILE_FIELD_NAME, message[0], messageParameters);
       }
     }
   }
   if (success && errorMessages.isEmpty()) {
     GlobalVariables.getMessageMap()
         .putInfo(Constants.SUBAWARD_FILE_FIELD_NAME, Constants.SUBAWARD_FILE_DETAILS_UPDATED);
   }
   return success;
 }
Example #6
0
 public ActionForward viewXML(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   BudgetSubAwards subAward = getSelectedBudgetSubAward(form, request);
   subAward.refreshNonUpdateableReferences();
   if (!subAward.getBudgetSubAwardFiles().isEmpty()) {
     BudgetSubAwardFiles subAwardFiles = subAward.getBudgetSubAwardFiles().get(0);
     downloadFile(
         form,
         request,
         response,
         subAwardFiles.getSubAwardXmlFileData().getBytes(),
         createXMLFileName(subAward),
         CONTENT_TYPE_XML);
   }
   return null;
 }
Example #7
0
 public ActionForward updateBudgetAttachment(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   BudgetForm budgetForm = (BudgetForm) form;
   AwardBudgetDocument awardBudgetDocument = budgetForm.getBudgetDocument();
   BudgetSubAwards subAward = getSelectedBudgetSubAward(form, request);
   byte[] subAwardData = subAward.getNewSubAwardFile().getBytes();
   String subAwardFileName = subAward.getNewSubAwardFile().getOriginalFilename();
   updateBudgetAttachment(
       budgetForm.getBudget(),
       subAward,
       subAwardFileName,
       subAwardData,
       SUBAWARD_BUDGET_EDIT_LINE_STARTER
           + getSelectedLine(request)
           + SUBAWARD_BUDGET_EDIT_LINE_ENDER);
   Collections.sort(awardBudgetDocument.getBudget().getBudgetSubAwards());
   return mapping.findForward(Constants.MAPPING_BASIC);
 }
Example #8
0
 public ActionForward viewXFD(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   BudgetSubAwards subAward = getSelectedBudgetSubAward(form, request);
   subAward.refreshNonUpdateableReferences();
   if (!subAward.getBudgetSubAwardFiles().isEmpty()) {
     BudgetSubAwardFiles subAwardFiles = subAward.getBudgetSubAwardFiles().get(0);
     downloadFile(
         form,
         request,
         response,
         subAwardFiles.getSubAwardXfdFileData(),
         subAward.getSubAwardXfdFileName(),
         CONTENT_TYPE_PDF);
   } else {
     return mapping.findForward(Constants.MAPPING_BASIC);
   }
   return null;
 }
Example #9
0
 private String createXMLFileName(BudgetSubAwards subAward) {
   return subAward
           .getSubAwardXfdFileName()
           .substring(0, subAward.getSubAwardXfdFileName().lastIndexOf(".") + 1)
       + XML_FILE_EXTENSION;
 }