Esempio n. 1
0
  /**
   * Calls <code>CreditMemoService</code> to perform the duplicate credit memo check. If one is
   * found, a question is setup and control is forwarded to the question action method. Coming back
   * from the question prompt, the button that was clicked is checked, and if 'no' was selected,
   * they are forward back to the page still in init mode.
   *
   * @param mapping An ActionMapping
   * @param form An ActionForm
   * @param request The HttpServletRequest
   * @param response The HttpServletResponse
   * @param creditMemoDocument The CreditMemoDocument
   * @throws Exception
   * @return An ActionForward
   * @see org.kuali.kfs.module.purap.document.service.CreditMemoService
   */
  protected ActionForward performDuplicateCreditMemoCheck(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response,
      VendorCreditMemoDocument creditMemoDocument)
      throws Exception {
    ActionForward forward = null;
    String duplicateMessage =
        SpringContext.getBean(CreditMemoService.class)
            .creditMemoDuplicateMessages(creditMemoDocument);
    if (StringUtils.isNotBlank(duplicateMessage)) {
      Object question = request.getParameter(KFSConstants.QUESTION_INST_ATTRIBUTE_NAME);
      if (question == null) {

        return this.performQuestionWithoutInput(
            mapping,
            form,
            request,
            response,
            PurapConstants.PREQDocumentsStrings.DUPLICATE_INVOICE_QUESTION,
            duplicateMessage,
            KFSConstants.CONFIRMATION_QUESTION,
            "continueCreditMemo",
            "");
      }

      Object buttonClicked = request.getParameter(KFSConstants.QUESTION_CLICKED_BUTTON);
      if ((PurapConstants.PREQDocumentsStrings.DUPLICATE_INVOICE_QUESTION.equals(question))
          && ConfirmationQuestion.NO.equals(buttonClicked)) {
        forward = mapping.findForward(KFSConstants.MAPPING_BASIC);
      }
    }

    return forward;
  }
Esempio n. 2
0
  /**
   * This method prompts for a reason to perfomr an action on a batch (cancel, hold, remove hold).
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @param confirmationQuestion
   * @param confirmationText
   * @param caller
   * @param callback
   * @return
   * @throws Exception
   */
  private ActionForward askQuestionWithInput(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response,
      String confirmationQuestion,
      String confirmationText,
      String successMessage,
      String caller,
      PdpBatchQuestionCallback callback)
      throws Exception {
    Object question = request.getParameter(KRADConstants.QUESTION_INST_ATTRIBUTE_NAME);
    String reason = request.getParameter(KRADConstants.QUESTION_REASON_ATTRIBUTE_NAME);
    String noteText = KFSConstants.EMPTY_STRING;
    Person person = GlobalVariables.getUserSession().getPerson();
    boolean actionStatus;
    String message = KFSConstants.EMPTY_STRING;

    String batchId = request.getParameter(PdpParameterConstants.BatchConstants.BATCH_ID_PARAM);
    if (batchId == null) {
      batchId = request.getParameter(KRADConstants.QUESTION_CONTEXT);
    }

    ConfigurationService kualiConfiguration = SpringContext.getBean(ConfigurationService.class);
    confirmationText = kualiConfiguration.getPropertyValueAsString(confirmationText);
    confirmationText = MessageFormat.format(confirmationText, batchId);

    if (question == null) {
      // ask question if not already asked
      return this.performQuestionWithInput(
          mapping,
          form,
          request,
          response,
          confirmationQuestion,
          confirmationText,
          KRADConstants.CONFIRMATION_QUESTION,
          caller,
          batchId);
    } else {
      Object buttonClicked = request.getParameter(KRADConstants.QUESTION_CLICKED_BUTTON);
      if ((confirmationQuestion.equals(question))
          && ConfirmationQuestion.NO.equals(buttonClicked)) {
        actionStatus = false;
      } else {
        noteText = reason;
        int noteTextLength = (reason == null) ? 0 : noteText.length();
        int noteTextMaxLength = PdpKeyConstants.BatchConstants.Confirmation.NOTE_TEXT_MAX_LENGTH;

        if (StringUtils.isBlank(reason)) {

          if (reason == null) {
            // prevent a NPE by setting the reason to a blank string
            reason = KFSConstants.EMPTY_STRING;
          }
          return this.performQuestionWithInputAgainBecauseOfErrors(
              mapping,
              form,
              request,
              response,
              confirmationQuestion,
              confirmationText,
              KRADConstants.CONFIRMATION_QUESTION,
              KFSConstants.MAPPING_BASIC,
              batchId,
              reason,
              PdpKeyConstants.BatchConstants.ErrorMessages.ERROR_NOTE_EMPTY,
              KRADConstants.QUESTION_REASON_ATTRIBUTE_NAME,
              "");
        } else if (noteTextLength > noteTextMaxLength) {
          return this.performQuestionWithInputAgainBecauseOfErrors(
              mapping,
              form,
              request,
              response,
              confirmationQuestion,
              confirmationText,
              KRADConstants.CONFIRMATION_QUESTION,
              KFSConstants.MAPPING_BASIC,
              batchId,
              reason,
              PdpKeyConstants.BatchConstants.ErrorMessages.ERROR_NOTE_TOO_LONG,
              KRADConstants.QUESTION_REASON_ATTRIBUTE_NAME,
              "");
        }

        actionStatus = callback.doPostQuestion(batchId, noteText, person);
        if (actionStatus) {
          message = successMessage;
        }
      }
    }

    String returnUrl = buildUrl(batchId, actionStatus, message, buildErrorMesageKeyList());
    return new ActionForward(returnUrl, true);
  }
Esempio n. 3
0
  public ActionForward reject(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;

    Object question = request.getParameter(KNSConstants.QUESTION_INST_ATTRIBUTE_NAME);
    Object buttonClicked = request.getParameter(KNSConstants.QUESTION_CLICKED_BUTTON);
    String reason = request.getParameter(KNSConstants.QUESTION_REASON_ATTRIBUTE_NAME);
    String methodToCall = ((KualiForm) form).getMethodToCall();
    final String questionText = "Are you sure you want to reject this document?";
    ActionForward forward;
    if (question == null) {
      forward =
          this.performQuestionWithInput(
              mapping,
              form,
              request,
              response,
              DOCUMENT_REJECT_QUESTION,
              questionText,
              KNSConstants.CONFIRMATION_QUESTION,
              methodToCall,
              "");
    } else if ((DOCUMENT_REJECT_QUESTION.equals(question))
        && ConfirmationQuestion.NO.equals(buttonClicked)) {
      forward = mapping.findForward(Constants.MAPPING_BASIC);
    } else {
      if (StringUtils.isEmpty(reason)) {
        String context = "";
        String errorKey = KeyConstants.ERROR_BUDGET_REJECT_NO_REASON;
        String errorPropertyName = DOCUMENT_REJECT_QUESTION;
        String errorParameter = "";
        reason = reason == null ? "" : reason;
        forward =
            this.performQuestionWithInputAgainBecauseOfErrors(
                mapping,
                form,
                request,
                response,
                DOCUMENT_REJECT_QUESTION,
                questionText,
                KNSConstants.CONFIRMATION_QUESTION,
                methodToCall,
                context,
                reason,
                errorKey,
                errorPropertyName,
                errorParameter);
      } else {
        // reject the document using the service.
        BudgetDocument document = ((BudgetForm) form).getDocument();
        document.documentHasBeenRejected(reason);
        KraServiceLocator.getService(KraDocumentRejectionService.class)
            .reject(
                document.getDocumentNumber(),
                reason,
                GlobalVariables.getUserSession().getPrincipalId());
        // tell the document it is being rejected and returned to the initial node.
        forward = super.returnToSender(request, mapping, kualiDocumentFormBase);
      }
    }
    return forward;
  }