示例#1
0
 /**
  * This method cancels a batch.
  *
  * @param batchIdString a string representing the batch id
  * @param cancelNote the cancelation note entered by the user
  * @param user the current user
  */
 private boolean performCancel(String batchIdString, String cancelNote, Person user) {
   try {
     Integer batchId = Integer.parseInt(batchIdString);
     return batchMaintenanceService.cancelPendingBatch(batchId, cancelNote, user);
   } catch (NumberFormatException e) {
     GlobalVariables.getMessageMap()
         .putError(
             PdpPropertyConstants.BatchConstants.BATCH_ID,
             PdpKeyConstants.BatchConstants.ErrorMessages.ERROR_BATCH_ID_IS_NOT_NUMERIC);
     return false;
   }
 }
  /**
   * @see
   *     org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#getCustomActionUrls(org.kuali.rice.krad.bo.BusinessObject,
   *     java.util.List)
   */
  @Override
  public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {

    if (businessObject instanceof Batch) {
      Person person = GlobalVariables.getUserSession().getPerson();
      Batch batch = (Batch) businessObject;
      Integer batchId = batch.getId().intValue();
      List<HtmlData> anchorHtmlDataList = new ArrayList<HtmlData>();
      String linkText = KFSConstants.EMPTY_STRING;
      String url = KFSConstants.EMPTY_STRING;
      String basePath =
          configurationService.getPropertyValueAsString(KFSConstants.APPLICATION_URL_KEY)
              + "/"
              + PdpConstants.Actions.BATCH_SEARCH_DETAIL_ACTION;

      if (pdpAuthorizationService.hasCancelPaymentPermission(person.getPrincipalId())
          && batchMaintenanceService.doBatchPaymentsHaveOpenOrHeldStatus(batchId)) {

        Properties params = new Properties();
        params.put(
            KFSConstants.DISPATCH_REQUEST_PARAMETER,
            PdpConstants.ActionMethods.CONFIRM_CANCEL_ACTION);
        params.put(
            PdpParameterConstants.BatchConstants.BATCH_ID_PARAM,
            UrlFactory.encode(String.valueOf(batchId)));
        url = UrlFactory.parameterizeUrl(basePath, params);

        linkText =
            configurationService.getPropertyValueAsString(
                PdpKeyConstants.BatchConstants.LinkText.CANCEL_BATCH);

        AnchorHtmlData anchorHtmlData =
            new AnchorHtmlData(url, PdpConstants.ActionMethods.CONFIRM_CANCEL_ACTION, linkText);
        anchorHtmlDataList.add(anchorHtmlData);
      }

      if (pdpAuthorizationService.hasHoldPaymentPermission(person.getPrincipalId())) {

        if (batchMaintenanceService.doBatchPaymentsHaveHeldStatus(batchId)) {

          Properties params = new Properties();
          params.put(
              KFSConstants.DISPATCH_REQUEST_PARAMETER,
              PdpConstants.ActionMethods.CONFIRM_REMOVE_HOLD_ACTION);
          params.put(
              PdpParameterConstants.BatchConstants.BATCH_ID_PARAM,
              UrlFactory.encode(String.valueOf(batchId)));
          url = UrlFactory.parameterizeUrl(basePath, params);

          linkText =
              configurationService.getPropertyValueAsString(
                  PdpKeyConstants.BatchConstants.LinkText.REMOVE_BATCH_HOLD);

          AnchorHtmlData anchorHtmlData =
              new AnchorHtmlData(
                  url, PdpConstants.ActionMethods.CONFIRM_REMOVE_HOLD_ACTION, linkText);
          anchorHtmlDataList.add(anchorHtmlData);
        } else if (batchMaintenanceService.doBatchPaymentsHaveOpenStatus(batchId)) {

          Properties params = new Properties();
          params.put(
              KFSConstants.DISPATCH_REQUEST_PARAMETER,
              PdpConstants.ActionMethods.CONFIRM_HOLD_ACTION);
          params.put(
              PdpParameterConstants.BatchConstants.BATCH_ID_PARAM,
              UrlFactory.encode(String.valueOf(batchId)));
          url = UrlFactory.parameterizeUrl(basePath, params);

          linkText =
              configurationService.getPropertyValueAsString(
                  PdpKeyConstants.BatchConstants.LinkText.HOLD_BATCH);
          AnchorHtmlData anchorHtmlData =
              new AnchorHtmlData(url, PdpConstants.ActionMethods.CONFIRM_HOLD_ACTION, linkText);
          anchorHtmlDataList.add(anchorHtmlData);
        }
      }

      if (anchorHtmlDataList.isEmpty()) {
        AnchorHtmlData anchorHtmlData = new AnchorHtmlData(url, "&nbsp;", "&nbsp;");
        anchorHtmlDataList.add(anchorHtmlData);
      }

      return anchorHtmlDataList;
    }
    return super.getEmptyActionUrls();
  }