001/* 002 * Copyright 2007-2008 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.ole.pdp.document.validation.impl; 017 018import org.kuali.ole.pdp.PdpKeyConstants; 019import org.kuali.ole.pdp.PdpPropertyConstants; 020import org.kuali.ole.pdp.businessobject.DisbursementNumberRange; 021import org.kuali.rice.core.api.util.type.KualiInteger; 022import org.kuali.rice.kns.document.MaintenanceDocument; 023import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase; 024import org.kuali.rice.krad.util.GlobalVariables; 025 026/** 027 * Contains Business Rules for the Effort Certification Report Maintenance Document. 028 */ 029public class DisbursementNumberRangeRule extends MaintenanceDocumentRuleBase { 030 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DisbursementNumberRangeRule.class); 031 032 /** 033 * @see org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument) 034 */ 035 @Override 036 protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) { 037 LOG.debug("processCustomRouteDocumentBusinessRules() start"); 038 039 if (GlobalVariables.getMessageMap().hasErrors()) { 040 return false; 041 } 042 043 boolean isValid = true; 044 DisbursementNumberRange disbursementNumberRange = (DisbursementNumberRange) document.getNewMaintainableObject().getBusinessObject(); 045 046 KualiInteger beginNumber = disbursementNumberRange.getBeginDisbursementNbr(); 047 KualiInteger lastAssigned = disbursementNumberRange.getLastAssignedDisbNbr(); 048 KualiInteger end = disbursementNumberRange.getEndDisbursementNbr(); 049 if ( lastAssigned.isLessThan(beginNumber) || lastAssigned.isGreaterThan(end)) { 050 putFieldError(PdpPropertyConstants.LAST_ASSIGNED_DISBURSEMENT_NUMBER, PdpKeyConstants.DISBURSEMENT_NUMBER_OUT_OF_RANGE); 051 isValid = false; 052 } 053 054 return isValid; 055 } 056}