public ActionForward editIntellectualPropertyReview(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    InstitutionalProposalForm institutionalProposalForm = (InstitutionalProposalForm) form;
    InstitutionalProposalDocument institutionalProposalDocument =
        (InstitutionalProposalDocument) institutionalProposalForm.getDocument();
    institutionalProposalDocument
        .getInstitutionalProposal()
        .getProposalIpReviewJoin()
        .refreshReferenceObject("intellectualPropertyReview");

    if (ObjectUtils.isNotNull(
        institutionalProposalDocument
            .getInstitutionalProposal()
            .getProposalIpReviewJoin()
            .getIntellectualPropertyReview())) {
      response.sendRedirect(
          "kr/maintenance.do?businessObjectClassName=org.kuali.kra.institutionalproposal.ipreview.IntellectualPropertyReview&methodToCall=copy&ipReviewId="
              + institutionalProposalDocument
                  .getInstitutionalProposal()
                  .getProposalIpReviewJoin()
                  .getIntellectualPropertyReview()
                  .getIpReviewId()
              + "&proposalId="
              + institutionalProposalDocument.getInstitutionalProposal().getProposalId());
    }

    return null;
  }
  /**
   * This method is for adding AwardSpecialReview to the list.
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   * @throws Exception
   */
  public ActionForward addSpecialReview(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    InstitutionalProposalForm institutionalProposalForm = (InstitutionalProposalForm) form;
    InstitutionalProposalDocument document =
        institutionalProposalForm.getInstitutionalProposalDocument();
    InstitutionalProposalSpecialReview specialReview =
        institutionalProposalForm.getSpecialReviewHelper().getNewSpecialReview();
    List<InstitutionalProposalSpecialReview> specialReviews =
        document.getInstitutionalProposal().getSpecialReviews();
    boolean isProtocolLinkingEnabled = false;
    if (SpecialReviewType.HUMAN_SUBJECTS.equals(specialReview.getSpecialReviewTypeCode())) {
      isProtocolLinkingEnabled =
          institutionalProposalForm.getSpecialReviewHelper().getIsIrbProtocolLinkingEnabled();
    } else if (SpecialReviewType.ANIMAL_USAGE.equals(specialReview.getSpecialReviewTypeCode())) {
      isProtocolLinkingEnabled =
          institutionalProposalForm.getSpecialReviewHelper().getIsIacucProtocolLinkingEnabled();
    }

    institutionalProposalForm.getSpecialReviewHelper().prepareProtocolLinkViewFields(specialReview);

    ActionForward forward = mapping.findForward(Constants.MAPPING_AWARD_BASIC);
    if (applyRules(
        new AddSpecialReviewEvent<InstitutionalProposalSpecialReview>(
            document, specialReview, specialReviews, isProtocolLinkingEnabled))) {
      specialReview.setSpecialReviewNumber(
          document.getDocumentNextValue(Constants.SPECIAL_REVIEW_NUMBER));
      document.getInstitutionalProposal().getSpecialReviews().add(specialReview);
      institutionalProposalForm
          .getSpecialReviewHelper()
          .setNewSpecialReview(new InstitutionalProposalSpecialReview());
      if (specialReview.getSpecialReviewType() == null) {
        specialReview.refreshReferenceObject("specialReviewType");
      }
      if (StringUtils.equals(
          specialReview.getSpecialReviewType().getSpecialReviewTypeCode(),
          SpecialReviewType.HUMAN_SUBJECTS)) {
        InstitutionalProposalNotificationContext context =
            new InstitutionalProposalNotificationContext(
                document.getInstitutionalProposal(),
                "552",
                "Special Review Inserted",
                Constants.MAPPING_INSTITUTIONAL_PROPOSAL_SPECIAL_REVIEW_PAGE);
        if (institutionalProposalForm
            .getNotificationHelper()
            .getPromptUserForNotificationEditor(context)) {
          institutionalProposalForm.getNotificationHelper().initializeDefaultValues(context);
          forward = mapping.findForward("notificationEditor");
        } else {
          getNotificationService().sendNotification(context);
        }
      }
    }

    return forward;
  }
  @Override
  public ActionForward save(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    ActionForward forward = mapping.findForward(Constants.MAPPING_BASIC);

    InstitutionalProposalForm institutionalProposalForm = (InstitutionalProposalForm) form;
    InstitutionalProposalDocument document =
        institutionalProposalForm.getInstitutionalProposalDocument();
    List<InstitutionalProposalSpecialReview> specialReviews =
        document.getInstitutionalProposal().getSpecialReviews();
    List<String> linkedProtocolNumbers =
        institutionalProposalForm.getSpecialReviewHelper().getLinkedProtocolNumbers();
    boolean isIPIrbProtocolLinkingEnabled =
        institutionalProposalForm.getSpecialReviewHelper().getIsIrbProtocolLinkingEnabled();
    boolean isIPIacucProtocolLinkingEnabled =
        institutionalProposalForm.getSpecialReviewHelper().getIsIacucProtocolLinkingEnabled();

    if (isIPIrbProtocolLinkingEnabled || isIPIacucProtocolLinkingEnabled) {
      if (applyRules(
          new SaveSpecialReviewLinkEvent<InstitutionalProposalSpecialReview>(
              document, specialReviews, linkedProtocolNumbers))) {
        institutionalProposalForm
            .getSpecialReviewHelper()
            .syncProtocolFundingSourcesWithSpecialReviews();
      }
    }

    if (applyRules(
        new SaveSpecialReviewEvent<InstitutionalProposalSpecialReview>(
            SAVE_SPECIAL_REVIEW_FIELD,
            document,
            specialReviews,
            isIPIrbProtocolLinkingEnabled,
            isIPIacucProtocolLinkingEnabled))) {
      // For reasons unknown to me, to enforce saving special review records in order between
      // successive saves, we must save the document before saving
      // anything else (like the special review indicator) on the document.  This statement can be
      // safely removed if the special review indicator is no
      // longer being set at this point...
      getDocumentService().saveDocument(document);

      if (!document.getInstitutionalProposal().getSpecialReviews().isEmpty()) {
        document.getInstitutionalProposal().setSpecialReviewIndicator("1");
      } else {
        document.getInstitutionalProposal().setSpecialReviewIndicator("0");
      }

      forward = super.save(mapping, form, request, response);
    }

    return forward;
  }
  /**
   * Deletes a special review item only if the user confirms it.
   *
   * @param mapping the action mapping
   * @param form the action form
   * @param request the request
   * @param response the response
   * @return the action forward
   * @throws Exception if unable to delete the special review
   */
  public ActionForward confirmDeleteSpecialReview(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    ActionForward forward = mapping.findForward(Constants.MAPPING_BASIC);
    Object question = request.getParameter(KRADConstants.QUESTION_INST_ATTRIBUTE_NAME);
    if (CONFIRM_DELETE_SPECIAL_REVIEW_KEY.equals(question)) {
      InstitutionalProposalForm institutionalProposalForm = (InstitutionalProposalForm) form;
      InstitutionalProposalDocument document =
          institutionalProposalForm.getInstitutionalProposalDocument();

      InstitutionalProposalSpecialReview specialReview =
          document.getInstitutionalProposal().getSpecialReviews().get(getLineToDelete(request));
      document.getInstitutionalProposal().getSpecialReviews().remove(specialReview);
      if (StringUtils.equals(
          specialReview.getSpecialReviewType().getSpecialReviewTypeCode(),
          SpecialReviewType.HUMAN_SUBJECTS)) {
        InstitutionalProposalNotificationContext context =
            new InstitutionalProposalNotificationContext(
                document.getInstitutionalProposal(),
                "553",
                "Special Review Deleted",
                Constants.MAPPING_INSTITUTIONAL_PROPOSAL_SPECIAL_REVIEW_PAGE);
        if (institutionalProposalForm
            .getNotificationHelper()
            .getPromptUserForNotificationEditor(context)) {
          institutionalProposalForm.getNotificationHelper().initializeDefaultValues(context);
          forward = mapping.findForward("notificationEditor");
        } else {
          getNotificationService().sendNotification(context);
        }
      }
    }

    return forward;
  }
  /**
   * This method gets called upon navigation to Medusa tab.
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return
   */
  public ActionForward medusa(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    InstitutionalProposalForm institutionalProposalForm = (InstitutionalProposalForm) form;
    if (institutionalProposalForm.getDocument().getDocumentNumber() == null) {
      // if we are loading this from the medusa link on the search
      loadDocumentInForm(request, institutionalProposalForm);
    }
    InstitutionalProposalDocument document =
        (InstitutionalProposalDocument) institutionalProposalForm.getDocument();

    institutionalProposalForm.getMedusaBean().setMedusaViewRadio("0");
    institutionalProposalForm.getMedusaBean().setModuleName("IP");
    institutionalProposalForm
        .getMedusaBean()
        .setModuleIdentifier(document.getInstitutionalProposal().getProposalId());
    institutionalProposalForm.getMedusaBean().generateParentNodes();
    handleAttachmentsDocument(form);
    return mapping.findForward(Constants.MAPPING_INSTITUTIONAL_PROPOSAL_MEDUSA_PAGE);
  }
 protected List<String> getUnitRulesMessages(InstitutionalProposalDocument ipDoc) {
   KrmsRulesExecutionService rulesService =
       KcServiceLocator.getService(KrmsRulesExecutionService.class);
   return rulesService.processUnitValidations(ipDoc.getLeadUnitNumber(), ipDoc);
 }