/** * 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; }
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; }
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; }
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"); }
/** * 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; }
/* * 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; }
/** * 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; }
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); }
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; }
/** * 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 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 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 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; }
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; }
/** * 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; }
/** * @param customerInvoiceDetail * @param paymentApplicationDocument * @return */ public static boolean validateAmountAppliedToCustomerInvoiceDetailByPaymentApplicationDocument( CustomerInvoiceDetail customerInvoiceDetail, PaymentApplicationDocument paymentApplicationDocument, KualiDecimal totalFromControl) throws WorkflowException { boolean isValid = true; // This let's us highlight a specific invoice detail line String propertyName = MessageFormat.format( ArPropertyConstants.PaymentApplicationDocumentFields.AMOUNT_TO_BE_APPLIED_LINE_N, customerInvoiceDetail.getSequenceNumber().toString()); KualiDecimal amountAppliedByAllOtherDocuments = customerInvoiceDetail.getAmountAppliedExcludingAnyAmountAppliedBy( paymentApplicationDocument.getDocumentNumber()); KualiDecimal amountAppliedByThisDocument = customerInvoiceDetail.getAmountAppliedBy(paymentApplicationDocument.getDocumentNumber()); KualiDecimal totalAppliedAmount = amountAppliedByAllOtherDocuments.add(amountAppliedByThisDocument); // Can't apply more than the total amount of the detail if (!totalAppliedAmount.isLessEqual(totalFromControl)) { isValid = false; GlobalVariables.getMessageMap() .putError( propertyName, ArKeyConstants.PaymentApplicationDocumentErrors .AMOUNT_TO_BE_APPLIED_EXCEEDS_AMOUNT_OUTSTANDING); } // Can't apply a negative amount. if (KualiDecimal.ZERO.isGreaterThan(amountAppliedByThisDocument)) { isValid = false; GlobalVariables.getMessageMap() .putError( propertyName, ArKeyConstants.PaymentApplicationDocumentErrors .AMOUNT_TO_BE_APPLIED_MUST_BE_GREATER_THAN_ZERO); } // Can't apply more than the total amount outstanding on the cash control document. CashControlDocument cashControlDocument = paymentApplicationDocument.getCashControlDocument(); if (ObjectUtils.isNotNull(cashControlDocument)) { if (cashControlDocument.getCashControlTotalAmount().isLessThan(amountAppliedByThisDocument)) { isValid = false; GlobalVariables.getMessageMap() .putError( propertyName, ArKeyConstants.PaymentApplicationDocumentErrors .CANNOT_APPLY_MORE_THAN_BALANCE_TO_BE_APPLIED); } } return isValid; }
/** * 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; }
/** * This method validates the unapplied attribute of the document. * * @param document * @return * @throws WorkflowException */ public static boolean validateNonAppliedHolding( PaymentApplicationDocument applicationDocument, KualiDecimal totalFromControl) throws WorkflowException { NonAppliedHolding nonAppliedHolding = applicationDocument.getNonAppliedHolding(); if (ObjectUtils.isNull(nonAppliedHolding)) { return true; } if (StringUtils.isNotEmpty(nonAppliedHolding.getCustomerNumber())) { KualiDecimal nonAppliedAmount = nonAppliedHolding.getFinancialDocumentLineAmount(); if (null == nonAppliedAmount) { nonAppliedAmount = KualiDecimal.ZERO; } boolean isValid = totalFromControl.isGreaterEqual(nonAppliedAmount); if (!isValid) { String propertyName = ArPropertyConstants.PaymentApplicationDocumentFields.UNAPPLIED_AMOUNT; String errorKey = ArKeyConstants.PaymentApplicationDocumentErrors .UNAPPLIED_AMOUNT_CANNOT_EXCEED_AVAILABLE_AMOUNT; GlobalVariables.getMessageMap().putError(propertyName, errorKey); } // The amount of the unapplied can't exceed the remaining balance to be applied KualiDecimal totalBalanceToBeApplied = applicationDocument.getUnallocatedBalance(); isValid = KualiDecimal.ZERO.isLessEqual(totalBalanceToBeApplied); if (!isValid) { String propertyName = ArPropertyConstants.PaymentApplicationDocumentFields.UNAPPLIED_AMOUNT; String errorKey = ArKeyConstants.PaymentApplicationDocumentErrors .UNAPPLIED_AMOUNT_CANNOT_EXCEED_BALANCE_TO_BE_APPLIED; GlobalVariables.getMessageMap().putError(propertyName, errorKey); } // the unapplied amount cannot be negative isValid = nonAppliedAmount.isPositive() || nonAppliedAmount.isZero(); if (!isValid) { String propertyName = ArPropertyConstants.PaymentApplicationDocumentFields.UNAPPLIED_AMOUNT; String errorKey = ArKeyConstants.PaymentApplicationDocumentErrors.AMOUNT_TO_BE_APPLIED_MUST_BE_POSTIIVE; GlobalVariables.getMessageMap().putError(propertyName, errorKey); } return isValid; } else { if (ObjectUtils.isNull(nonAppliedHolding.getFinancialDocumentLineAmount()) || KualiDecimal.ZERO.equals(nonAppliedHolding.getFinancialDocumentLineAmount())) { // All's OK. Both customer number and amount are empty/null. return true; } else { // Error. Customer number is empty but amount wasn't. String propertyName = ArPropertyConstants.PaymentApplicationDocumentFields.UNAPPLIED_CUSTOMER_NUMBER; String errorKey = ArKeyConstants.PaymentApplicationDocumentErrors .UNAPPLIED_AMOUNT_CANNOT_BE_EMPTY_OR_ZERO; GlobalVariables.getMessageMap().putError(propertyName, errorKey); return false; } } }
public final void testThreshold_InvalidDescription() { MaintenanceDocumentBase doc = getMaintenanceDocument(ThresholdFixture.CHARTCODE); doc.getDocumentHeader().setDocumentDescription(null); assertFalse(thresholdRule.processSaveDocument(doc)); assertTrue(GlobalVariables.getMessageMap().hasErrors()); assertTrue( GlobalVariables.getMessageMap() .getErrorMessages() .containsKey("document.documentHeader.documentDescription")); }
/** * This method is used to return back to expenses tab * * @param mapping * @param form * @param request * @param response * @return mapping forward * @throws Exception */ public ActionForward returnToExpenses( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { BudgetForm budgetForm = (BudgetForm) form; BudgetDocument budgetDocument = budgetForm.getBudgetDocument(); Budget budget = budgetDocument.getBudget(); int selectedBudgetPeriodIndex = budgetForm.getViewBudgetPeriod() - 1; int selectedBudgetLineItemIndex = budgetForm.getSelectedBudgetLineItemIndex(); BudgetLineItem selectedBudgetLineItem = budget .getBudgetPeriod(selectedBudgetPeriodIndex) .getBudgetLineItem(selectedBudgetLineItemIndex); int k = 0; boolean errorFound = false; GlobalVariables.getMessageMap().addToErrorPath("document"); for (BudgetPersonnelDetails budgetPersonnelDetails : selectedBudgetLineItem.getBudgetPersonnelDetailsList()) { errorFound = errorFound || personnelDatesCheck( selectedBudgetLineItem, budgetPersonnelDetails, selectedBudgetPeriodIndex, selectedBudgetLineItemIndex, k); k++; } GlobalVariables.getMessageMap().removeFromErrorPath("document"); if (errorFound) { return mapping.findForward(Constants.MAPPING_BASIC); } else { getCalculationService().calculateBudgetLineItem(budget, selectedBudgetLineItem); BudgetCategoryTypeValuesFinder budgetCategoryTypeValuesFinder = new BudgetCategoryTypeValuesFinder(); List<KeyValue> budgetCategoryTypes = new ArrayList<KeyValue>(); budgetCategoryTypes = budgetCategoryTypeValuesFinder.getKeyValues(); for (int i = 0; i < budgetCategoryTypes.size(); i++) { budgetForm.getNewBudgetLineItems().add(budget.getNewBudgetLineItem()); } budget.setBudgetCategoryTypeCodes(budgetCategoryTypes); request.setAttribute( "fromPersonnelBudget" + budgetForm.getViewBudgetPeriod() + "" + selectedBudgetLineItemIndex, true); return mapping.findForward("expenses"); } }
public final void testThreshold_ChartOfAccount_Invalid() { MaintenanceDocumentBase doc = getMaintenanceDocument(ThresholdFixture.CHARTCODE_INVALID); assertTrue(thresholdRule.processSaveDocument(doc)); assertTrue(thresholdRule.processRouteDocument(doc)); assertTrue(GlobalVariables.getMessageMap().hasErrors()); assertEquals(1, GlobalVariables.getMessageMap().getErrorCount()); assertTrue( GlobalVariables.getMessageMap() .getErrorMessages() .containsKey("document.newMaintainableObject.chartOfAccountsCode")); }
/** * Refresh and set server messages * * @param form * @param result * @param request * @param response * @return */ @RequestMapping(method = RequestMethod.POST, params = "methodToCall=refreshWithServerMessages") public ModelAndView refreshWithServerMessages( @ModelAttribute("KualiForm") UifFormBase form, BindingResult result, HttpServletRequest request, HttpServletResponse response) { GlobalVariables.getMessageMap().putError("inputField4", "serverTestError"); GlobalVariables.getMessageMap().putWarning("inputField4", "serverTestWarning"); GlobalVariables.getMessageMap().putInfo("inputField4", "serverTestInfo"); return getUIFModelAndView(form); }
protected boolean checkDelegationMember(RoleDocumentDelegationMember newMember) { if (StringUtils.isBlank(newMember.getMemberTypeCode()) || StringUtils.isBlank(newMember.getMemberId())) { GlobalVariables.getMessageMap() .putError( "document.delegationMember.memberId", RiceKeyConstants.ERROR_EMPTY_ENTRY, new String[] {"Member Type Code and Member ID"}); return false; } if (MemberType.PRINCIPAL.getCode().equals(newMember.getMemberTypeCode())) { Principal principalInfo = getIdentityService().getPrincipal(newMember.getMemberId()); if (principalInfo == null) { GlobalVariables.getMessageMap() .putError( "document.delegationMember.memberId", RiceKeyConstants.ERROR_MEMBERID_MEMBERTYPE_MISMATCH, new String[] {newMember.getMemberId()}); return false; } else { newMember.setMemberName(principalInfo.getPrincipalName()); } } else if (MemberType.GROUP.getCode().equals(newMember.getMemberTypeCode())) { Group groupInfo = null; groupInfo = getGroupService().getGroup(newMember.getMemberId()); if (groupInfo == null) { GlobalVariables.getMessageMap() .putError( "document.delegationMember.memberId", RiceKeyConstants.ERROR_MEMBERID_MEMBERTYPE_MISMATCH, new String[] {newMember.getMemberId()}); return false; } else { newMember.setMemberName(groupInfo.getName()); newMember.setMemberNamespaceCode(groupInfo.getNamespaceCode()); } } else if (MemberType.ROLE.getCode().equals(newMember.getMemberTypeCode())) { Role roleInfo = KimApiServiceLocator.getRoleService().getRole(newMember.getMemberId()); if (roleInfo == null) { GlobalVariables.getMessageMap() .putError( "document.delegationMember.memberId", RiceKeyConstants.ERROR_MEMBERID_MEMBERTYPE_MISMATCH, new String[] {newMember.getMemberId()}); return false; } else { newMember.setMemberName(roleInfo.getName()); newMember.setMemberNamespaceCode(roleInfo.getNamespaceCode()); } } return true; }
protected boolean checkKimDocumentRoleMember(KimDocumentRoleMember newMember) { boolean memberExists = false; String memberName = null; String memberNamespace = null; if (StringUtils.isBlank(newMember.getMemberId())) { GlobalVariables.getMessageMap() .putError( "document.member.memberId", RiceKeyConstants.ERROR_EMPTY_ENTRY, new String[] {"Member ID"}); return false; } if (MemberType.PRINCIPAL.getCode().equals(newMember.getMemberTypeCode())) { Principal pi = this.getIdentityService().getPrincipal(newMember.getMemberId()); if (pi != null) { memberExists = true; memberName = pi.getPrincipalName(); memberNamespace = ""; } } else if (MemberType.GROUP.getCode().equals(newMember.getMemberTypeCode())) { Group gi = KimApiServiceLocator.getGroupService().getGroup(newMember.getMemberId()); if (gi != null) { memberExists = true; memberName = gi.getName(); memberNamespace = gi.getNamespaceCode(); } } else if (MemberType.ROLE.getCode().equals(newMember.getMemberTypeCode())) { Role ri = KimApiServiceLocator.getRoleService().getRole(newMember.getMemberId()); if (!validateRole(newMember.getMemberId(), ri, "document.member.memberId", "Role")) { return false; } else { memberExists = true; memberName = ri.getName(); memberNamespace = ri.getNamespaceCode(); } } if (!memberExists) { GlobalVariables.getMessageMap() .putError( "document.member.memberId", RiceKeyConstants.ERROR_MEMBERID_MEMBERTYPE_MISMATCH, new String[] {newMember.getMemberId()}); return false; } newMember.setMemberName(memberName); newMember.setMemberNamespaceCode(memberNamespace); return true; }
public boolean processAddBudgetVersion(AddBudgetVersionEvent event) throws WorkflowException { BudgetParent budgetParent = event.getBudgetParent(); boolean success = true; if (budgetParent.getRequestedStartDateInitial() == null) { GlobalVariables.getMessageMap() .putError(event.getErrorPath(), KeyConstants.ERROR_BUDGET_START_DATE_MISSING, "Name"); success &= false; } if (budgetParent.getRequestedEndDateInitial() == null) { GlobalVariables.getMessageMap() .putError(event.getErrorPath(), KeyConstants.ERROR_BUDGET_END_DATE_MISSING, "Name"); success &= false; } return success; }
private boolean checkForSelectedPerson(AwardUnitContact newContact) { boolean valid = true; if (StringUtils.isBlank(newContact.getPersonId())) { if (StringUtils.isBlank(newContact.getFullName())) { GlobalVariables.getMessageMap() .putError(PERSON_ERROR_KEY, KeyConstants.ERROR_MISSING_UNITCONTACT_PERSON); } else { GlobalVariables.getMessageMap() .putError(PERSON_ERROR_KEY, KeyConstants.ERROR_INVALID_UNITCONTACT_PERSON); } valid = false; } return valid; }
@Override public ActionForward approve( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { KualiAccountingDocumentFormBase tmpForm = (KualiAccountingDocumentFormBase) form; // KFSPTS-1735 ActionForward forward = super.approve(mapping, form, request, response); if (GlobalVariables.getMessageMap().hasNoErrors()) { // KFSPTS-1735 SpringContext.getBean(CUFinancialSystemDocumentService.class) .checkAccountingLinesForChanges((AccountingDocument) tmpForm.getFinancialDocument()); // KFSPTS-1735 } // need to check on sales tax for all the accounting lines checkSalesTaxRequiredAllLines( tmpForm, tmpForm.getFinancialDocument().getSourceAccountingLines()); checkSalesTaxRequiredAllLines( tmpForm, tmpForm.getFinancialDocument().getTargetAccountingLines()); return forward; }