protected ModelAndView navigate(
     ProposalDevelopmentDocumentForm form,
     BindingResult result,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   if (form.getDevelopmentProposal().getS2sOpportunity() != null
       && !getProposalDevelopmentService()
           .isGrantsGovEnabledForProposal(form.getDevelopmentProposal())) {
     ((ProposalDevelopmentViewHelperServiceImpl) form.getViewHelperService())
         .clearOpportunity(form.getDevelopmentProposal());
   }
   populateAdHocRecipients(form.getProposalDevelopmentDocument());
   String navigateToPageId = form.getActionParamaterValue(UifParameters.NAVIGATE_TO_PAGE_ID);
   if (isNavigateToDeliveryInfoPage(navigateToPageId)) {
     if (form.getDevelopmentProposal().getS2sOpportunity() != null) {
       getGlobalVariableService()
           .getMessageMap()
           .putInfo(
               ProposalDevelopmentConstants.KradConstants.DELIVERY_INFO_PAGE,
               KeyConstants.DELIVERY_INFO_NOT_NEEDED);
     }
   }
   if (form.isCanEditView()) {
     return save(form);
   } else {
     return getNavigationControllerService().navigate(form);
   }
 }
 @Transactional
 @RequestMapping(
     value = "/proposalDevelopment",
     params = {"methodToCall=viewUserAttachedFormPDF"})
 public ModelAndView viewUserAttachedFormPDF(
     ProposalDevelopmentDocumentForm form,
     HttpServletResponse response,
     @RequestParam("selectedLine") String selectedLine)
     throws Exception {
   DevelopmentProposal developmentProposal = form.getDevelopmentProposal();
   List<S2sUserAttachedForm> s2sAttachedForms = developmentProposal.getS2sUserAttachedForms();
   S2sUserAttachedForm selectedForm = s2sAttachedForms.get(Integer.parseInt(selectedLine));
   S2sUserAttachedFormFileContract userAttachedFormFile =
       getUserAttachedFormService().findUserAttachedFormFile(selectedForm);
   if (userAttachedFormFile != null) {
     ControllerFileUtils.streamToResponse(
         userAttachedFormFile.getFormFile(),
         selectedForm.getFormFileName(),
         CONTENT_TYPE_PDF,
         response);
   } else {
     return getModelAndViewService().getModelAndView(form);
   }
   return null;
 }
 @Transactional
 @RequestMapping(
     value = "/proposalDevelopment",
     params = {"methodToCall=printFormsXml"})
 public ModelAndView printFormsXml(
     @ModelAttribute("KualiForm") ProposalDevelopmentDocumentForm form,
     HttpServletResponse response)
     throws Exception {
   form.getDevelopmentProposal().setGrantsGovSelectFlag(true);
   return printForms(form, response);
 }
 @Transactional
 @RequestMapping(
     value = "/proposalDevelopment",
     params = {"methodToCall=clearOpportunity"})
 public ModelAndView clearOpportunity(
     @ModelAttribute("KualiForm") ProposalDevelopmentDocumentForm form,
     BindingResult result,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   ((ProposalDevelopmentViewHelperServiceImpl) form.getViewHelperService())
       .clearOpportunity(form.getDevelopmentProposal());
   return getRefreshControllerService().refresh(form);
 }
 @Transactional
 @RequestMapping(
     value = "/proposalDevelopment",
     params = {"methodToCall=deleteUserAttachedForm"})
 public ModelAndView deleteUserAttachedForm(
     ProposalDevelopmentDocumentForm form,
     HttpServletResponse response,
     @RequestParam("selectedLine") String selectedLine)
     throws Exception {
   S2sUserAttachedForm deleteForm =
       form.getDevelopmentProposal()
           .getS2sUserAttachedForms()
           .remove(Integer.parseInt(selectedLine));
   getDataObjectService().delete(deleteForm);
   getS2sUserAttachedFormService()
       .resetFormAvailability(form.getProposalDevelopmentDocument(), deleteForm.getNamespace());
   return getModelAndViewService().getModelAndView(form);
 }
  public ModelAndView save(ProposalDevelopmentDocumentForm form) throws Exception {
    ProposalDevelopmentDocument proposalDevelopmentDocument =
        (ProposalDevelopmentDocument) form.getDocument();

    if (StringUtils.equalsIgnoreCase(form.getPageId(), Constants.PROP_DEV_PERMISSIONS_PAGE)) {
      saveDocumentPermissions(form);
    }

    if (StringUtils.equalsIgnoreCase(
        form.getPageId(), ProposalDevelopmentDataValidationConstants.ATTACHMENT_PAGE_ID)) {
      ((ProposalDevelopmentViewHelperServiceImpl) form.getViewHelperService())
          .populateAttachmentReferences(form.getDevelopmentProposal());
    }

    if (getGlobalVariableService().getMessageMap().getErrorCount() == 0
        && form.getEditableCollectionLines() != null) {
      form.getEditableCollectionLines().clear();
    }
    if (StringUtils.equalsIgnoreCase(
        form.getPageId(), ProposalDevelopmentDataValidationConstants.DETAILS_PAGE_ID)) {
      handleSponsorChange(proposalDevelopmentDocument);
    }

    preSave(proposalDevelopmentDocument);

    proposalDevelopmentService.initializeUnitOrganizationLocation(proposalDevelopmentDocument);
    proposalDevelopmentService.initializeProposalSiteNumbers(proposalDevelopmentDocument);

    for (ProposalPersonBiography biography : form.getDevelopmentProposal().getPropPersonBios()) {
      getProposalPersonBiographyService()
          .prepareProposalPersonBiographyForSave(form.getDevelopmentProposal(), biography);
    }

    ((ProposalDevelopmentViewHelperServiceImpl) form.getViewHelperService())
        .setOrdinalPosition(form.getDevelopmentProposal().getProposalPersons());
    saveAnswerHeaders(form, form.getPageId());

    getTransactionalDocumentControllerService().save(form);
    if (form.isAuditActivated()) {
      getAuditHelper().auditConditionally(form);
    }

    populateAdHocRecipients(form.getProposalDevelopmentDocument());

    if (StringUtils.equalsIgnoreCase(form.getPageId(), Constants.CREDIT_ALLOCATION_PAGE)) {
      ((ProposalDevelopmentViewHelperServiceImpl) form.getViewHelperService())
          .populateCreditSplits(form);
    }

    if (StringUtils.equalsIgnoreCase(form.getPageId(), Constants.QUESTIONS_PAGE)) {
      ((ProposalDevelopmentViewHelperServiceImpl) form.getViewHelperService())
          .populateQuestionnaires(form);
    }
    String pageId = form.getActionParamaterValue(UifParameters.NAVIGATE_TO_PAGE_ID);
    final ModelAndView view;
    if (StringUtils.isNotBlank(pageId)
        && getGlobalVariableService().getMessageMap().hasNoErrors()) {
      form.setDirtyForm(false);
      view = getModelAndViewService().getModelAndView(form, pageId);
    } else {
      view = getModelAndViewService().getModelAndView(form);
    }

    if (form.getProposalDevelopmentDocument().getDevelopmentProposal() != null
        && form.getProposalDevelopmentDocument().getDevelopmentProposal().getPropSpecialReviews()
            != null) {
      form.getProposalDevelopmentDocument()
          .getDevelopmentProposal()
          .getPropSpecialReviews()
          .stream()
          .filter(specialReview -> !specialReview.isLinkedToProtocol())
          .forEach(
              specialReview ->
                  form.getSpecialReviewHelper().prepareProtocolLinkViewFields(specialReview));
    }
    getProjectPublisher()
        .publishProject(
            getPropDevProjectRetrievalService()
                .retrieveProject(
                    form.getProposalDevelopmentDocument()
                        .getDevelopmentProposal()
                        .getProposalNumber()));

    return view;
  }