Exemple #1
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);
 }
Exemple #2
0
 public ActionForward printBudgetForm(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   BudgetForm budgetForm = (BudgetForm) form;
   Budget budget = budgetForm.getBudgetDocument().getBudget();
   Integer selectedLine = getSelectedLine(request);
   String budgetFormToPrint = budget.getBudgetPrintForms().get(selectedLine).getBudgetReportId();
   if (budgetForm.getSelectedToPrintComment() != null && budgetFormToPrint != null) {
     String forms[] = budgetForm.getSelectedToPrintComment();
     if (forms[0].equals(budgetFormToPrint)) {
       budget.setPrintBudgetCommentFlag("true");
     }
   }
   budgetForm.setSelectedToPrintComment(null);
   BudgetPrintService budgetPrintService = KcServiceLocator.getService(BudgetPrintService.class);
   ActionForward forward = mapping.findForward(MAPPING_BASIC);
   if (budgetFormToPrint != null) {
     AttachmentDataSource dataStream =
         budgetPrintService.readBudgetPrintStream(budget, budgetFormToPrint);
     if (dataStream.getData() != null) {
       streamToResponse(dataStream, response);
       forward = null;
     }
   }
   return forward;
 }
Exemple #3
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);
 }
Exemple #4
0
 public ActionForward budgetVersions(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response) {
   final BudgetForm budgetForm = (BudgetForm) form;
   final String headerTabCall = getHeaderTabDispatch(request);
   if (StringUtils.isEmpty(headerTabCall)) {
     budgetForm.getDocument().refreshPessimisticLocks();
   }
   return mapping.findForward(Constants.BUDGET_VERSIONS_PAGE);
 }
Exemple #5
0
 /**
  * Override to set the update time and user, then convert to String
  *
  * @see BudgetAction#save(org.apache.struts.action.ActionMapping,
  *     org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
  *     javax.servlet.http.HttpServletResponse)
  */
 @Override
 public ActionForward save(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   BudgetForm budgetForm = (BudgetForm) form;
   Budget budget = budgetForm.getBudgetDocument().getBudget();
   getBudgetJustificationService().preSave(budget, getBudgetJusticationWrapper(form));
   return super.save(mapping, form, request, response);
 }
Exemple #6
0
 @Override
 public ActionForward reload(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   ActionForward forward = super.reload(mapping, form, request, response);
   BudgetForm budgetForm = (BudgetForm) form;
   Budget budget = budgetForm.getBudgetDocument().getBudget();
   getPropDevBudgetSubAwardService().populateBudgetSubAwardAttachments(budget);
   return forward;
 }
Exemple #7
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);
 }
Exemple #8
0
 public ActionForward deleteSubAwardAttachment(
     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);
   getPropDevBudgetSubAwardService().removeSubAwardAttachment(subAward);
   return mapping.findForward(Constants.MAPPING_BASIC);
 }
Exemple #9
0
 public ActionForward syncFromBudgetAttachment(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   BudgetForm budgetForm = (BudgetForm) form;
   AwardBudgetDocument awardBudgetDocument = budgetForm.getBudgetDocument();
   BudgetSubAwards subAward = getSelectedBudgetSubAward(form, request);
   String errorPath =
       SUBAWARD_BUDGET_EDIT_LINE_STARTER
           + getSelectedLine(request)
           + SUBAWARD_BUDGET_EDIT_LINE_ENDER;
   GlobalVariables.getMessageMap().addToErrorPath(errorPath);
   updateSubAwardBudgetDetails(awardBudgetDocument.getBudget(), subAward);
   GlobalVariables.getMessageMap().removeFromErrorPath(errorPath);
   return mapping.findForward(Constants.MAPPING_BASIC);
 }
Exemple #10
0
  /**
   * Close the document and take the user back to the index; only after asking the user if they want
   * to save the document first. Only users who have the "canSave()" permission are given this
   * option.
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   * @throws Exception
   */
  @Override
  public ActionForward close(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    KualiDocumentFormBase docForm = (KualiDocumentFormBase) form;
    // only want to prompt them to save if they already can save
    if (docForm.getDocumentActions().containsKey(KRADConstants.KUALI_ACTION_CAN_SAVE)) {
      Object question = request.getParameter(KRADConstants.QUESTION_INST_ATTRIBUTE_NAME);
      ConfigurationService kualiConfiguration =
          CoreApiServiceLocator.getKualiConfigurationService();

      // logic for close question
      if (question == null) {
        // ask question if not already asked
        return this.performQuestionWithoutInput(
            mapping,
            form,
            request,
            response,
            KRADConstants.DOCUMENT_SAVE_BEFORE_CLOSE_QUESTION,
            kualiConfiguration.getPropertyValueAsString(
                RiceKeyConstants.QUESTION_SAVE_BEFORE_CLOSE),
            KRADConstants.CONFIRMATION_QUESTION,
            KRADConstants.MAPPING_CLOSE,
            "");
      } else {
        BudgetForm budgetForm = (BudgetForm) form;
        Budget budget = budgetForm.getBudgetDocument().getBudget();

        Object buttonClicked = request.getParameter(KRADConstants.QUESTION_CLICKED_BUTTON);
        if ((KRADConstants.DOCUMENT_SAVE_BEFORE_CLOSE_QUESTION.equals(question))
            && ConfirmationQuestion.YES.equals(buttonClicked)) {
          // if yes button clicked - save the doc
          getBudgetJustificationService().preSave(budget, getBudgetJusticationWrapper(form));
        }
        // else go to close logic below
      }
    }

    return super.close(mapping, form, request, response);
  }
Exemple #11
0
  /**
   * This method consolidates Budget Line Item Justification text into a single Justification field,
   * with last user/time update meta data
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ActionForward consolidateExpenseJustifications(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    BudgetForm budgetForm = (BudgetForm) form;
    Budget budget = budgetForm.getBudgetDocument().getBudget();
    try {
      getBudgetJustificationService()
          .consolidateExpenseJustifications(budget, getBudgetJusticationWrapper(form));
    } catch (BudgetException exc) {
      GlobalVariables.getMessageMap()
          .putError(
              "budgetJustificationWrapper.justificationText",
              "error.custom",
              "There are no line item budget justifications");
    }

    return mapping.findForward(MAPPING_BASIC);
  }
Exemple #12
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);
 }
Exemple #13
0
 private BudgetSubAwards getSelectedBudgetSubAward(ActionForm form, HttpServletRequest request) {
   BudgetForm budgetForm = (BudgetForm) form;
   Budget budget = budgetForm.getBudgetDocument().getBudget();
   int selectedLineNumber = getSelectedLine(request);
   return budget.getBudgetSubAwards().get(selectedLineNumber);
 }