protected void isAuthorized() {
   // check permissions
   boolean userHasPermission = false;
   String permissionName = AwardPermissionConstants.VIEW_AWARD.getAwardPermission();
   userHasPermission =
       getUnitAuthorizationService()
           .hasPermission(
               GlobalVariables.getUserSession().getPrincipalId(), "KC-AWARD", permissionName);
   if (!userHasPermission) {
     permissionName = AwardPermissionConstants.MODIFY_AWARD.getAwardPermission();
     userHasPermission =
         getUnitAuthorizationService()
             .hasPermission(
                 GlobalVariables.getUserSession().getPrincipalId(), "KC-AWARD", permissionName);
   }
   if (!userHasPermission) {
     permissionName = AwardPermissionConstants.MODIFY_AWARD_REPORT_TRACKING.getAwardPermission();
     userHasPermission =
         getUnitAuthorizationService()
             .hasPermission(
                 GlobalVariables.getUserSession().getPrincipalId(), "KC-AWARD", permissionName);
   }
   if (!userHasPermission) {
     throw new AuthorizationException(
         GlobalVariables.getUserSession().getPrincipalName(), "Search", "Report Tracking");
   }
 }
  @Override
  protected void populateAdHocActionRequestCodes(KualiDocumentFormBase formBase) {
    Document document = formBase.getDocument();
    DocumentAuthorizer documentAuthorizer =
        getDocumentHelperService().getDocumentAuthorizer(document);
    Map<String, String> adHocActionRequestCodes = new HashMap<String, String>();

    if (documentAuthorizer.canSendAdHocRequests(
        document,
        KewApiConstants.ACTION_REQUEST_FYI_REQ,
        GlobalVariables.getUserSession().getPerson())) {
      adHocActionRequestCodes.put(
          KewApiConstants.ACTION_REQUEST_FYI_REQ, KewApiConstants.ACTION_REQUEST_FYI_REQ_LABEL);
    }
    if ((document.getDocumentHeader().getWorkflowDocument().isInitiated()
            || document.getDocumentHeader().getWorkflowDocument().isSaved()
            || document.getDocumentHeader().getWorkflowDocument().isEnroute())
        && documentAuthorizer.canSendAdHocRequests(
            document,
            KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ,
            GlobalVariables.getUserSession().getPerson())) {
      adHocActionRequestCodes.put(
          KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ,
          KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL);
    }
    formBase.setAdHocActionRequestCodes(adHocActionRequestCodes);
  }
 /**
  * Takes a routeHeaderId for a particular document and constructs the URL to forward to that
  * document Copied from KraTransactionalDocument as this does not extend from that.
  *
  * @param routeHeaderId
  * @return String
  */
 protected String buildForwardUrl(String routeHeaderId) {
   ResearchDocumentService researchDocumentService =
       KraServiceLocator.getService(ResearchDocumentService.class);
   String forward = researchDocumentService.getDocHandlerUrl(routeHeaderId);
   // forward = forward.replaceFirst(DEFAULT_TAB, ALTERNATE_OPEN_TAB);
   if (forward.indexOf("?") == -1) {
     forward += "?";
   } else {
     forward += "&";
   }
   forward += KewApiConstants.DOCUMENT_ID_PARAMETER + "=" + routeHeaderId;
   forward +=
       "&"
           + KewApiConstants.COMMAND_PARAMETER
           + "="
           + NotificationConstants.NOTIFICATION_DETAIL_VIEWS.DOC_SEARCH_VIEW;
   if (GlobalVariables.getUserSession().isBackdoorInUse()) {
     forward +=
         "&"
             + KewApiConstants.BACKDOOR_ID_PARAMETER
             + "="
             + GlobalVariables.getUserSession().getPrincipalName();
   }
   return forward;
 }
  /**
   * Validates the condition code exists in the condition table
   *
   * @param conditionCode
   * @param detail
   * @return boolean
   */
  protected boolean validateConditionCode(
      String conditionCode, BarcodeInventoryErrorDetail detail) {
    boolean result = true;
    String label =
        SpringContext.getBean(DataDictionaryService.class)
            .getDataDictionary()
            .getBusinessObjectEntry(BarcodeInventoryErrorDetail.class.getName())
            .getAttributeDefinition(CamsPropertyConstants.BarcodeInventory.ASSET_CONDITION_CODE)
            .getLabel();

    AssetCondition condition;
    HashMap<String, Object> fields = new HashMap<String, Object>();
    fields.put(
        CamsPropertyConstants.BarcodeInventory.ASSET_CONDITION_CODE,
        detail.getAssetConditionCode());
    condition = getBusinessObjectService().findByPrimaryKey(AssetCondition.class, fields);

    if (ObjectUtils.isNull(condition)) {
      GlobalVariables.getMessageMap()
          .putError(
              CamsPropertyConstants.BarcodeInventory.ASSET_CONDITION_CODE,
              CamsKeyConstants.BarcodeInventory.ERROR_INVALID_FIELD,
              label);
      result &= false;
    } else if (!condition.isActive()) {
      GlobalVariables.getMessageMap()
          .putError(
              CamsPropertyConstants.BarcodeInventory.ASSET_CONDITION_CODE,
              CamsKeyConstants.BarcodeInventory.ERROR_INACTIVE_FIELD,
              label);
      result &= false;
    }

    return result;
  }
  /**
   * Iterates over the list of errors each records might have and returns a single string with all
   * the errors for each asset
   *
   * @param errorPath
   * @return String
   */
  protected String getErrorMessages(String errorPath) {
    String message = "";
    String[] fields = {
      CamsPropertyConstants.BarcodeInventory.ASSET_TAG_NUMBER,
      CamsPropertyConstants.BarcodeInventory.INVENTORY_DATE,
      CamsPropertyConstants.BarcodeInventory.CAMPUS_CODE,
      CamsPropertyConstants.BarcodeInventory.BUILDING_CODE,
      CamsPropertyConstants.BarcodeInventory.BUILDING_ROOM_NUMBER,
      CamsPropertyConstants.BarcodeInventory.ASSET_CONDITION_CODE
    };

    for (int i = 0; i < fields.length; i++) {
      String propertyName = errorPath + "." + fields[i];
      if (GlobalVariables.getMessageMap().doesPropertyHaveError(propertyName)) {
        for (Object errorMessage : GlobalVariables.getMessageMap().getMessages(propertyName)) {
          String errorMsg =
              getKualiConfigurationService()
                  .getPropertyValueAsString(((ErrorMessage) errorMessage).getErrorKey());
          message +=
              ", "
                  + MessageFormat.format(
                      errorMsg, (Object[]) ((ErrorMessage) errorMessage).getMessageParameters());
        }
      }
    }
    return (StringUtils.isEmpty(message) ? message : message.substring(2));
  }
  /**
   * Validates the campus code exists in the campus code table
   *
   * @param campusCode
   * @param detail
   * @return boolean
   */
  protected boolean validateCampusCode(String campusCode, BarcodeInventoryErrorDetail detail) {
    boolean result = true;
    String label =
        SpringContext.getBean(DataDictionaryService.class)
            .getDataDictionary()
            .getBusinessObjectEntry(BarcodeInventoryErrorDetail.class.getName())
            .getAttributeDefinition(CamsPropertyConstants.BarcodeInventory.CAMPUS_CODE)
            .getLabel();

    Campus campus;
    HashMap<String, Object> fields = new HashMap<String, Object>();
    fields.put(KFSPropertyConstants.CAMPUS_CODE, detail.getCampusCode());
    campus =
        SpringContext.getBean(CampusService.class)
            .getCampus(campusCode /*RICE_20_REFACTORME  fields */);

    if (ObjectUtils.isNull(campus)) {
      GlobalVariables.getMessageMap()
          .putError(
              CamsPropertyConstants.BarcodeInventory.CAMPUS_CODE,
              CamsKeyConstants.BarcodeInventory.ERROR_INVALID_FIELD,
              label);
      result = false;
    } else if (!campus.isActive()) {
      GlobalVariables.getMessageMap()
          .putError(
              CamsPropertyConstants.BarcodeInventory.CAMPUS_CODE,
              CamsKeyConstants.BarcodeInventory.ERROR_INACTIVE_FIELD,
              label);
      result &= false;
    }
    return result;
  }
  /**
   * Validates that the existance of the building room number is consistent with the asset type
   * requirements.
   *
   * @param roomNumber
   * @param detail
   * @prarm asset
   * @return boolean
   * @deprecated this method is replaced by
   *     validateBuildingCodeAndRoomNumber(BarcodeInventoryErrorDetail, Asset)
   */
  @Deprecated
  protected boolean validateBuildingRoomNumber(
      String roomNumber, BarcodeInventoryErrorDetail detail, Asset asset) {
    boolean result = true;
    String label =
        SpringContext.getBean(DataDictionaryService.class)
            .getDataDictionary()
            .getBusinessObjectEntry(BarcodeInventoryErrorDetail.class.getName())
            .getAttributeDefinition(CamsPropertyConstants.BarcodeInventory.BUILDING_ROOM_NUMBER)
            .getLabel();
    // String description = asset.getCapitalAssetType().getCapitalAssetTypeDescription();
    String description = asset.getCapitalAssetTypeCode();

    // if the asset has empty building room number, then the BCIE should too
    if (StringUtils.isBlank(asset.getBuildingRoomNumber())) {
      if (StringUtils.isNotBlank(roomNumber)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_ROOM_NUMBER,
                CamsKeyConstants.BarcodeInventory.ERROR_NOT_ALLOWED_FIELD,
                label,
                description);
        result &= false;
      }
    }
    // otherwise the BCIE should have a non-empty and existing active building room number
    else {
      HashMap<String, Object> fields = new HashMap<String, Object>();
      fields.put(KFSPropertyConstants.CAMPUS_CODE, detail.getCampusCode());
      fields.put(KFSPropertyConstants.BUILDING_CODE, detail.getBuildingCode());
      fields.put(KFSPropertyConstants.BUILDING_ROOM_NUMBER, detail.getBuildingRoomNumber());
      Room room = getBusinessObjectService().findByPrimaryKey(Room.class, fields);

      if (StringUtils.isBlank(roomNumber)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_ROOM_NUMBER,
                CamsKeyConstants.BarcodeInventory.ERROR_REQUIRED_FIELD,
                label,
                description);
        result &= false;
      } else if (ObjectUtils.isNull(room)) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_ROOM_NUMBER,
                CamsKeyConstants.BarcodeInventory.ERROR_INVALID_FIELD,
                label);
        result = false;
      } else if (!room.isActive()) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.BUILDING_ROOM_NUMBER,
                CamsKeyConstants.BarcodeInventory.ERROR_INACTIVE_FIELD,
                label);
        result &= false;
      }
    }

    return result;
  }
  /**
   * validates the asset tag number exists in only one active asset.
   *
   * @param tagNumber
   * @return boolean
   * @deprecated this method is replaced by validateTagNumberAndRetrieveActiveAsset(String)
   */
  @Deprecated
  protected boolean validateTagNumber(String tagNumber) {
    boolean result = true;
    // Getting a list of active assets.
    Collection<Asset> assets = getAssetService().findAssetsMatchingTagNumber(tagNumber);

    if (ObjectUtils.isNull(assets) || assets.isEmpty()) {
      GlobalVariables.getMessageMap()
          .putError(
              CamsPropertyConstants.BarcodeInventory.ASSET_TAG_NUMBER,
              CamsKeyConstants.BarcodeInventory.ERROR_CAPITAL_ASSET_DOESNT_EXIST);
      result = false;
    } else {
      int activeAssets = assets.size();
      for (Asset asset : assets) {
        if (getAssetService().isAssetRetired(asset)) {
          activeAssets--;
        }
      }
      if (activeAssets == 0) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.ASSET_TAG_NUMBER,
                CamsKeyConstants.BarcodeInventory.ERROR_CAPITAL_ASSET_IS_RETIRED);
        result = false;
      } else if (activeAssets > 1) {
        GlobalVariables.getMessageMap()
            .putError(
                CamsPropertyConstants.BarcodeInventory.ASSET_TAG_NUMBER,
                CamsKeyConstants.BarcodeInventory.ERROR_DUPLICATED_TAG_NUMBER);
        result = false;
      }
    }
    return result;
  }
Example #9
0
  /*
   * validate required/format of the properties of bo. also validate business rules.
   */
  private boolean isValidToSave(MeetingHelperBase meetingHelper, boolean readOnly) {
    if (readOnly) {
      return false;
    }

    GlobalVariables.getMessageMap().addToErrorPath(COMMITTEE_SCHEDULE_ERROR_PATH);
    getDictionaryValidationService().validateBusinessObject(meetingHelper.getCommitteeSchedule());
    GlobalVariables.getMessageMap().removeFromErrorPath(COMMITTEE_SCHEDULE_ERROR_PATH);
    boolean valid = GlobalVariables.getMessageMap().hasNoErrors();
    try {
      valid &=
          applyRules(
              new MeetingSaveEvent(
                  Constants.EMPTY_STRING,
                  getCommitteeDocument(
                      meetingHelper
                          .getCommitteeSchedule()
                          .getParentCommittee()
                          .getCommitteeDocument()
                          .getDocumentHeader()
                          .getDocumentNumber()),
                  meetingHelper,
                  ErrorType.HARDERROR));
    } catch (NullPointerException e) {
      // NPE When Accessing Meeting Actions Tab on IRB Schedule
      // https://github.com/rSmart/issues/issues/449
      LOG.warn(
          "Possible behavior change; not changing value of `valid` variable. It remains: " + valid);
    }
    return valid;
  }
 protected boolean validAssignGroup(IdentityManagementGroupDocument document) {
   boolean rulePassed = true;
   Map<String, String> additionalPermissionDetails = new HashMap<String, String>();
   additionalPermissionDetails.put(
       KimConstants.AttributeConstants.NAMESPACE_CODE, document.getGroupNamespace());
   additionalPermissionDetails.put(
       KimConstants.AttributeConstants.GROUP_NAME, document.getGroupName());
   if (document.getMembers() != null && document.getMembers().size() > 0) {
     if (!getDocumentDictionaryService()
         .getDocumentAuthorizer(document)
         .isAuthorizedByTemplate(
             document,
             KimConstants.NAMESPACE_CODE,
             KimConstants.PermissionTemplateNames.POPULATE_GROUP,
             GlobalVariables.getUserSession().getPrincipalId(),
             additionalPermissionDetails,
             null)) {
       GlobalVariables.getMessageMap()
           .putError(
               "document.groupName",
               RiceKeyConstants.ERROR_ASSIGN_GROUP,
               new String[] {document.getGroupNamespace(), document.getGroupName()});
       rulePassed = false;
     }
   }
   return rulePassed;
 }
  @Override
  public List<KeyValue> getKeyValues() {
    List<KeyValue> keyValues = new ArrayList<KeyValue>();
    TimeAndMoneyDocument document = (TimeAndMoneyDocument) getDocument();

    document.setAwardHierarchyItems(
        ((TimeAndMoneyDocument)
                GlobalVariables.getUserSession()
                    .retrieveObject(
                        GlobalVariables.getUserSession().getKualiSessionId()
                            + Constants.TIME_AND_MONEY_DOCUMENT_STRING_FOR_SESSION))
            .getAwardHierarchyItems());

    if (document.getAwardHierarchyItems() != null
        && document.getAwardHierarchyItems().size() != 0) {
      Object[] keyset = document.getAwardHierarchyItems().keySet().toArray();
      Arrays.sort(keyset);
      for (Object awardNumber : keyset) {
        keyValues.add(
            new ConcreteKeyValue(
                (String) awardNumber,
                document.getAwardHierarchyItems().get(awardNumber).getAwardNumber()));
      }
    }

    return keyValues;
  }
Example #12
0
 /**
  * Does the property have any errors in the message map?
  *
  * @param propertyName
  * @return
  */
 public boolean propertyHasErrorReported(String propertyName) {
   boolean result = false;
   if (GlobalVariables.getMessageMap().getErrorMessagesForProperty(propertyName) != null) {
     result = GlobalVariables.getMessageMap().getErrorMessagesForProperty(propertyName).size() > 0;
   }
   return result;
 }
Example #13
0
 private ActionForward doEndDateConfirmation(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response,
     String questionId,
     String yesMethodName)
     throws Exception {
   List<ErrorMessage> errors =
       GlobalVariables.getMessageMap()
           .getErrorMessagesForProperty(ProposalHierarchyKeyConstants.FIELD_CHILD_NUMBER);
   List<String> proposalNumbers = new ArrayList<String>();
   for (ErrorMessage error : errors) {
     if (error
         .getErrorKey()
         .equals(ProposalHierarchyKeyConstants.QUESTION_EXTEND_PROJECT_DATE_CONFIRM)) {
       proposalNumbers.add(error.getMessageParameters()[0]);
     }
   }
   String proposalNumberList = StringUtils.join(proposalNumbers, ',');
   StrutsConfirmation question =
       buildParameterizedConfirmationQuestion(
           mapping,
           form,
           request,
           response,
           questionId,
           ProposalHierarchyKeyConstants.QUESTION_EXTEND_PROJECT_DATE_CONFIRM,
           proposalNumberList);
   GlobalVariables.getMessageMap().getErrorMessages().clear();
   GlobalVariables.getMessageMap().getWarningMessages().clear();
   GlobalVariables.getMessageMap().getInfoMessages().clear();
   return confirm(question, yesMethodName, "hierarchyActionCanceled");
 }
Example #14
0
 protected boolean updateSubAwardBudgetDetails(Budget budget, BudgetSubAwards subAward)
     throws Exception {
   List<String[]> errorMessages = new ArrayList<String[]>();
   boolean success =
       getKcBusinessRulesEngine().applyRules(new BudgetSubAwardsEvent(subAward, budget, ""));
   if (subAward.getNewSubAwardFile().getBytes().length == 0) {
     success = false;
   }
   if (success) {
     getPropDevBudgetSubAwardService()
         .updateSubAwardBudgetDetails(budget, subAward, errorMessages);
   }
   if (!errorMessages.isEmpty()) {
     for (String[] message : errorMessages) {
       String[] messageParameters = null;
       if (message.length > 1) {
         messageParameters = Arrays.copyOfRange(message, 1, message.length);
       }
       if (success) {
         GlobalVariables.getMessageMap()
             .putWarning(Constants.SUBAWARD_FILE_FIELD_NAME, message[0], messageParameters);
       } else {
         GlobalVariables.getMessageMap()
             .putError(Constants.SUBAWARD_FILE_FIELD_NAME, message[0], messageParameters);
       }
     }
   }
   if (success && errorMessages.isEmpty()) {
     GlobalVariables.getMessageMap()
         .putInfo(Constants.SUBAWARD_FILE_FIELD_NAME, Constants.SUBAWARD_FILE_DETAILS_UPDATED);
   }
   return success;
 }
 public ActionForward quickApproveDisclosure(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   CoiCustomSearchForm searchForm = (CoiCustomSearchForm) form;
   CustomAdminSearchHelper helper = searchForm.getCustomAdminSearchHelper();
   String coiDisclosureDocumentNumber = getCoiDisclosureDocumentNumber(request);
   CoiDisclosureDocument coiDisclosureDocument =
       (CoiDisclosureDocument)
           getDocumentService().getByDocumentHeaderId(coiDisclosureDocumentNumber);
   if (!helper.hasFinEnt(coiDisclosureDocument.getCoiDisclosure())
       && getKraAuthorizationService()
           .hasPermission(
               GlobalVariables.getUserSession().getPrincipalId(),
               coiDisclosureDocument.getCoiDisclosure(),
               PermissionConstants.APPROVE_COI_DISCLOSURE)) {
     getCoiDisclosureActionService()
         .approveDisclosure(
             coiDisclosureDocument.getCoiDisclosure(), CoiDispositionStatus.NO_CONFLICT_EXISTS);
     GlobalVariables.getMessageMap()
         .putInfo(Constants.NO_FIELD, KeyConstants.MESSAGE_COI_DISCLOSURE_QUICK_APPROVED);
   } else {
     GlobalVariables.getMessageMap()
         .putError(Constants.NO_FIELD, KeyConstants.ERROR_COI_NO_PERMISSION_APPROVE);
   }
   helper.setAllOpenReviews(getOpenReviews());
   helper.setPendingReviews(getPendingReviews());
   helper.setInProgressReviews(getInProgressReviews());
   return mapping.findForward(Constants.MAPPING_BASIC);
 }
Example #16
0
  protected boolean updateBudgetAttachment(
      Budget budget, BudgetSubAwards subAward, String fileName, byte[] fileData, String errorPath)
      throws Exception {

    GlobalVariables.getMessageMap().addToErrorPath(errorPath);
    subAward.setSubAwardXmlFileData(null);
    subAward.setFormName(null);
    subAward.setNamespace(null);
    if (subAward
        .getNewSubAwardFile()
        .getContentType()
        .equalsIgnoreCase(Constants.PDF_REPORT_CONTENT_TYPE)) {
      getPropDevBudgetSubAwardService()
          .populateBudgetSubAwardFiles(budget, subAward, fileName, fileData);
    }
    boolean success = updateSubAwardBudgetDetails(budget, subAward);
    if (success) {
      subAward
          .getBudgetSubAwardFiles()
          .get(0)
          .setSubAwardXmlFileData(
              KcServiceLocator.getService(KcAttachmentService.class)
                  .checkAndReplaceSpecialCharacters(
                      subAward
                          .getBudgetSubAwardFiles()
                          .get(0)
                          .getSubAwardXmlFileData()
                          .toString()));
      subAward.setSubAwardXmlFileData(
          subAward.getBudgetSubAwardFiles().get(0).getSubAwardXmlFileData());
    }
    GlobalVariables.getMessageMap().removeFromErrorPath(errorPath);
    return success;
  }
 public TemplateRuleTest() {
   GlobalVariables.setMessageMap(new MessageMap());
   GlobalVariables.setAuditErrorMap(new HashMap());
   prerequisite();
   assertEquals(expectedReturnValue, rule.processRules(event));
   checkRuleAssertions();
 }
 public boolean isValidStatus(String disclosureStatus, Integer dispositionStatus) {
   boolean isValid = true;
   if (StringUtils.isBlank(disclosureStatus)) {
     GlobalVariables.getMessageMap()
         .putError(ADMIN_ERRORS, KeyConstants.ERROR_COI_DISCLOSURE_STATUS_REQUIRED);
     isValid = false;
   }
   if (dispositionStatus == null) {
     GlobalVariables.getMessageMap()
         .putError(ADMIN_ERRORS, KeyConstants.ERROR_COI_DISPOSITON_STATUS_REQUIRED);
     isValid = false;
   }
   CoiDispositionStatus disposition =
       KraServiceLocator.getService(BusinessObjectService.class)
           .findBySinglePrimaryKey(CoiDispositionStatus.class, dispositionStatus);
   if (disposition == null) {
     GlobalVariables.getMessageMap()
         .putError(ADMIN_ERRORS, KeyConstants.ERROR_COI_DISPOSITON_STATUS_REQUIRED);
     isValid = false;
   }
   // if the disposition requires disapproval, then the disclosureStatus must be disapproved.
   if (StringUtils.equals(
           disposition.getCoiDisclosureStatusCode(), CoiDisclosureStatus.DISAPPROVED)
       && !StringUtils.equals(disclosureStatus, CoiDisclosureStatus.DISAPPROVED)) {
     GlobalVariables.getMessageMap()
         .putError(ADMIN_ERRORS, KeyConstants.ERROR_COI_DISCLOSURE_STATUS_INVALID);
     isValid = false;
   }
   return isValid;
 }
Example #19
0
  /** . The method is for doRouteStatusChange */
  @Override
  public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
    super.doRouteStatusChange(statusChangeEvent);

    String newStatus = statusChangeEvent.getNewRouteStatus();

    if (KewApiConstants.ROUTE_HEADER_FINAL_CD.equalsIgnoreCase(newStatus)) {
      getVersionHistoryService()
          .updateVersionHistory(
              getSubAward(),
              VersionStatus.ACTIVE,
              GlobalVariables.getUserSession().getPrincipalName());
    }
    if (newStatus.equalsIgnoreCase(KewApiConstants.ROUTE_HEADER_CANCEL_CD)
        || newStatus.equalsIgnoreCase(KewApiConstants.ROUTE_HEADER_DISAPPROVED_CD)) {
      getVersionHistoryService()
          .updateVersionHistory(
              getSubAward(),
              VersionStatus.CANCELED,
              GlobalVariables.getUserSession().getPrincipalName());
    }

    for (SubAward subAward : subAwardList) {
      subAward.setSubAwardDocument(this);
    }
  }
  /**
   * This method to check whether 'lookupreturn' is specified if lookupclass is selected.
   *
   * @param maintenanceDocument
   * @return
   */
  private boolean checkLookupReturn(MaintenanceDocument maintenanceDocument) {
    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "New maintainable is: " + maintenanceDocument.getNewMaintainableObject().getClass());
    }
    ProposalColumnsToAlter newEditableProposalField =
        (ProposalColumnsToAlter) maintenanceDocument.getNewMaintainableObject().getDataObject();

    if (StringUtils.isNotBlank(newEditableProposalField.getLookupClass())) {
      GlobalVariables.getUserSession()
          .addObject(
              Constants.LOOKUP_CLASS_NAME, (Object) newEditableProposalField.getLookupClass());
    }
    if (StringUtils.isNotBlank(newEditableProposalField.getLookupClass())
        && StringUtils.isBlank(newEditableProposalField.getLookupReturn())) {
      GlobalVariables.getMessageMap()
          .putError(
              Constants.PROPOSAL_EDITABLECOLUMN_LOOKUPRETURN,
              RiceKeyConstants.ERROR_REQUIRED,
              new String[] {"Lookup Return"});
      return false;
    }

    return true;
  }
 /**
  * Adds an error
  *
  * @param warningOnly whether error should be a true error or a warning only
  * @return true if rule suceeded, false otherwise
  */
 protected boolean addError() {
   boolean success = true;
   if (warningOnly) {
     GlobalVariables.getMessageMap()
         .putWarning(
             KFSConstants.DOCUMENT_PROPERTY_NAME
                 + "."
                 + TemPropertyConstants.EntertainmentFields.HOST_NAME,
             TemKeyConstants.HOST_CERTIFICATION_REQUIRED_IND);
   } else {
     success = false;
     GlobalVariables.getMessageMap()
         .putError(
             KFSConstants.DOCUMENT_PROPERTY_NAME
                 + "."
                 + TemPropertyConstants.EntertainmentFields.HOST_NAME,
             TemKeyConstants.HOST_CERTIFICATION_REQUIRED_IND);
     final String matchingErrorPath =
         StringUtils.join(GlobalVariables.getMessageMap().getErrorPath(), ".")
             + "."
             + TemPropertyConstants.EntertainmentFields.HOST_NAME;
     GlobalVariables.getMessageMap().removeAllWarningMessagesForProperty(matchingErrorPath);
   }
   return success;
 }
  /**
   * This method will use the DocumentService to create a new document. The documentTypeName is
   * gathered by using MaintenanceDocumentDictionaryService which uses Account class to get the
   * document type name.
   *
   * @param AccountCreationStatusDTO
   * @return document returns a new document for the account document type or null if there is an
   *     exception thrown.
   */
  public Document createCGAccountMaintenanceDocument(
      AccountCreationStatusDTO accountCreationStatus) {

    boolean internalUserSession = false;
    try {
      if (GlobalVariables.getUserSession() == null) {
        internalUserSession = true;
        GlobalVariables.setUserSession(new UserSession(KFSConstants.SYSTEM_USER));
        GlobalVariables.clear();
      }
      Document document =
          getDocumentService()
              .getNewDocument(
                  SpringContext.getBean(MaintenanceDocumentDictionaryService.class)
                      .getDocumentTypeName(Account.class));
      return document;

    } catch (Exception e) {
      accountCreationStatus.setErrorMessages(
          GlobalVariablesExtractHelper.extractGlobalVariableErrors());
      accountCreationStatus.setStatus(KcConstants.KcWebService.STATUS_KC_FAILURE);
      return null;
    } finally {
      // if a user session was established for this call, clear it our
      if (internalUserSession) {
        GlobalVariables.clear();
        GlobalVariables.setUserSession(null);
      }
    }
  }
  /** @see org.kuali.rice.krad.service.DocumentService#documentExists(java.lang.String) */
  @Override
  public boolean documentExists(String documentHeaderId) {
    // validate parameters
    if (StringUtils.isBlank(documentHeaderId)) {
      throw new IllegalArgumentException("invalid (blank) documentHeaderId");
    }

    boolean internalUserSession = false;
    try {
      // KFSMI-2543 - allowed method to run without a user session so it can be used
      // by workflow processes
      if (GlobalVariables.getUserSession() == null) {
        internalUserSession = true;
        GlobalVariables.setUserSession(new UserSession(KRADConstants.SYSTEM_USER));
        GlobalVariables.clear();
      }

      // look for workflowDocumentHeader, since that supposedly won't break the transaction
      if (getWorkflowDocumentService().workflowDocumentExists(documentHeaderId)) {
        // look for docHeaderId, since that fails without breaking the transaction
        return documentHeaderService.getDocumentHeaderById(documentHeaderId) != null;
      }

      return false;
    } finally {
      // if a user session was established for this call, clear it our
      if (internalUserSession) {
        GlobalVariables.clear();
        GlobalVariables.setUserSession(null);
      }
    }
  }
  /**
   * Retrieves validation errors from GlobalVariables MessageMap and appends to the given list of
   * RemotableAttributeError
   *
   * @param validationErrors list to append validation errors
   */
  protected void retrieveValidationErrorsFromGlobalVariables(
      List<RemotableAttributeError> validationErrors) {
    // can we use KualiConfigurationService?  It seemed to be used elsewhere...
    ConfigurationService configurationService =
        CoreApiServiceLocator.getKualiConfigurationService();

    if (GlobalVariables.getMessageMap().hasErrors()) {
      MessageMap deepCopy =
          (MessageMap) SerializationUtils.deepCopy(GlobalVariables.getMessageMap());
      for (String errorKey : deepCopy.getErrorMessages().keySet()) {
        List<ErrorMessage> errorMessages = deepCopy.getErrorMessages().get(errorKey);
        if (CollectionUtils.isNotEmpty(errorMessages)) {
          List<String> errors = new ArrayList<String>();
          for (ErrorMessage errorMessage : errorMessages) {
            // need to materialize the message from it's parameters so we can send it back to the
            // framework
            String error =
                MessageFormat.format(
                    configurationService.getPropertyValueAsString(errorMessage.getErrorKey()),
                    errorMessage.getMessageParameters());
            errors.add(error);
          }
          RemotableAttributeError remotableAttributeError =
              RemotableAttributeError.Builder.create(errorKey, errors).build();
          validationErrors.add(remotableAttributeError);
        }
      }
      // we should now strip the error messages from the map because they have moved to
      // validationErrors
      GlobalVariables.getMessageMap().clearErrorMessages();
    }
  }
 protected boolean vendorQuoteHasRequiredFields(PurchaseOrderVendorQuote vendorQuote) {
   boolean valid = true;
   if (StringUtils.isBlank(vendorQuote.getVendorName())) {
     GlobalVariables.getMessageMap()
         .putError(
             PurapPropertyConstants.NEW_PURCHASE_ORDER_VENDOR_QUOTE_VENDOR_NAME,
             KFSKeyConstants.ERROR_REQUIRED,
             "Vendor Name");
     valid = false;
   }
   if (StringUtils.isBlank(vendorQuote.getVendorLine1Address())) {
     GlobalVariables.getMessageMap()
         .putError(
             PurapPropertyConstants.NEW_PURCHASE_ORDER_VENDOR_QUOTE_VENDOR_LINE_1_ADDR,
             KFSKeyConstants.ERROR_REQUIRED,
             "Vendor Line 1 Address");
     valid = false;
   }
   if (StringUtils.isBlank(vendorQuote.getVendorCityName())) {
     GlobalVariables.getMessageMap()
         .putError(
             PurapPropertyConstants.NEW_PURCHASE_ORDER_VENDOR_QUOTE_VENDOR_CITY_NAME,
             KFSKeyConstants.ERROR_REQUIRED,
             "Vendor City Name");
     valid = false;
   }
   return valid;
 }
Example #26
0
  public boolean processSyncModularBusinessRules(Document document) {
    if (!(document instanceof BudgetDocument)) {
      return false;
    }

    boolean valid = true;

    BudgetDocument budgetDocument = (BudgetDocument) document;

    GlobalVariables.getMessageMap().addToErrorPath("document");

    List budgetPeriods = budgetDocument.getBudget().getBudgetPeriods();
    if (ObjectUtils.isNotNull(budgetPeriods) || budgetPeriods.size() >= 1) {
      BudgetPeriod period1 = (BudgetPeriod) budgetPeriods.get(0);
      if (ObjectUtils.isNull(period1.getBudgetLineItems())
          || period1.getBudgetLineItems().isEmpty()) {
        valid = false;
      }
    } else {
      valid = false;
    }

    if (!valid) {
      GlobalVariables.getMessageMap()
          .putError("modularBudget", KeyConstants.ERROR_NO_DETAILED_BUDGET);
    }

    GlobalVariables.getMessageMap().removeFromErrorPath("document");

    return valid;
  }
Example #27
0
  /**
   * route the document using the document service
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   * @throws Exception
   */
  @Override
  public ActionForward route(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    AwardBudgetDocument awardBudgetDocument = ((AwardBudgetForm) form).getAwardBudgetDocument();
    Award currentAward =
        getAwardBudgetService()
            .getActiveOrNewestAward(
                ((AwardDocument) awardBudgetDocument.getBudget().getBudgetParent().getDocument())
                    .getAward()
                    .getAwardNumber());
    ScaleTwoDecimal newCostLimit = getAwardBudgetService().getTotalCostLimit(currentAward);
    if (!newCostLimit.equals(awardBudgetDocument.getBudget().getTotalCostLimit())
        || !getAwardBudgetService()
            .limitsMatch(
                currentAward.getAwardBudgetLimits(),
                awardBudgetDocument.getAwardBudget().getAwardBudgetLimits())) {
      Object question = request.getParameter(KRADConstants.QUESTION_INST_ATTRIBUTE_NAME);
      Object buttonClicked = request.getParameter(KRADConstants.QUESTION_CLICKED_BUTTON);
      String methodToCall = ((KualiForm) form).getMethodToCall();
      if (question == null) {
        ConfigurationService kualiConfiguration =
            CoreApiServiceLocator.getKualiConfigurationService();
        return confirm(
            buildParameterizedConfirmationQuestion(
                mapping,
                form,
                request,
                response,
                UPDATE_COST_LIMITS_QUESTION,
                KeyConstants.QUESTION_TOTALCOSTLIMIT_CHANGED),
            methodToCall,
            methodToCall);
      } else if (UPDATE_COST_LIMITS_QUESTION.equals(question)
          && ConfirmationQuestion.YES.equals(buttonClicked)) {
        getAwardBudgetService().setBudgetLimits(awardBudgetDocument, currentAward);
        return mapping.findForward(Constants.MAPPING_AWARD_BASIC);
      } else {
        // do nothing and continue with route
      }
    }
    ((AwardBudgetForm) form).setAuditActivated(true);
    ValidationState state =
        KcServiceLocator.getService(AuditHelper.class)
            .isValidSubmission((AwardBudgetForm) form, true);
    if (state != ValidationState.ERROR) {
      getAwardBudgetService().processSubmision(awardBudgetDocument);
      return super.route(mapping, form, request, response);
    } else {
      GlobalVariables.getMessageMap().clearErrorMessages();
      GlobalVariables.getMessageMap()
          .putError("datavalidation", KeyConstants.ERROR_WORKFLOW_SUBMISSION, new String[] {});

      return mapping.findForward(Constants.MAPPING_AWARD_BASIC);
    }
  }
 /**
  * This method validates a new credit card receipt detail record.
  *
  * @param creditCardReceipt
  * @return boolean
  */
 protected boolean validateNewCreditCardReceipt(CreditCardDetail creditCardReceipt) {
   GlobalVariables.getMessageMap().addToErrorPath(KFSPropertyConstants.NEW_CREDIT_CARD_RECEIPT);
   boolean isValid =
       CreditCardReceiptDocumentRuleUtil.validateCreditCardReceipt(creditCardReceipt);
   GlobalVariables.getMessageMap()
       .removeFromErrorPath(KFSPropertyConstants.NEW_CREDIT_CARD_RECEIPT);
   return isValid;
 }
 @Override
 public String getReceivingDeliveryCampusCode(PurchaseOrderDocument po) {
   if (GlobalVariables.getUserSession() == null) {
     GlobalVariables.setUserSession(new UserSession(KRADConstants.SYSTEM_USER));
     GlobalVariables.clear();
   }
   return super.getReceivingDeliveryCampusCode(po);
 }
  /**
   * This method checks that an invoice paid applied is for a valid amount.
   *
   * @param invoicePaidApplied
   * @return
   */
  public static boolean validateInvoicePaidApplied(
      InvoicePaidApplied invoicePaidApplied,
      String fieldName,
      PaymentApplicationDocument document) {
    boolean isValid = true;

    invoicePaidApplied.refreshReferenceObject("invoiceDetail");
    if (ObjectUtils.isNull(invoicePaidApplied)
        || ObjectUtils.isNull(invoicePaidApplied.getInvoiceDetail())) {
      return true;
    }
    KualiDecimal amountOwed = invoicePaidApplied.getInvoiceDetail().getAmountOpen();
    KualiDecimal amountPaid = invoicePaidApplied.getInvoiceItemAppliedAmount();

    if (ObjectUtils.isNull(amountOwed)) {
      amountOwed = KualiDecimal.ZERO;
    }
    if (ObjectUtils.isNull(amountPaid)) {
      amountPaid = KualiDecimal.ZERO;
    }

    // Can't pay more than you owe.
    if (!amountPaid.isLessEqual(amountOwed)) {
      isValid = false;
      LOG.debug(
          "InvoicePaidApplied is not valid. Amount to be applied exceeds amount outstanding.");
      GlobalVariables.getMessageMap()
          .putError(
              fieldName,
              ArKeyConstants.PaymentApplicationDocumentErrors
                  .AMOUNT_TO_BE_APPLIED_EXCEEDS_AMOUNT_OUTSTANDING);
    }

    // Can't apply more than the amount received via the related CashControlDocument
    if (amountPaid.isGreaterThan(document.getTotalFromControl())) {
      isValid = false;
      LOG.debug(
          "InvoicePaidApplied is not valid. Cannot apply more than cash control total amount.");
      GlobalVariables.getMessageMap()
          .putError(
              fieldName,
              ArKeyConstants.PaymentApplicationDocumentErrors
                  .CANNOT_APPLY_MORE_THAN_CASH_CONTROL_TOTAL_AMOUNT);
    }

    //  cant apply negative amounts
    if (amountPaid.isNegative() && !document.hasCashControlDocument()) {
      isValid = false;
      LOG.debug("InvoicePaidApplied is not valid. Amount to be applied must be positive.");
      GlobalVariables.getMessageMap()
          .putError(
              fieldName,
              ArKeyConstants.PaymentApplicationDocumentErrors
                  .AMOUNT_TO_BE_APPLIED_MUST_BE_POSTIIVE);
    }
    return isValid;
  }