View Javadoc

1   /*
2    * Copyright 2007-2008 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.pdp.document.validation.impl;
17  
18  import org.kuali.ole.pdp.PdpKeyConstants;
19  import org.kuali.ole.pdp.PdpPropertyConstants;
20  import org.kuali.ole.pdp.businessobject.DisbursementNumberRange;
21  import org.kuali.rice.core.api.util.type.KualiInteger;
22  import org.kuali.rice.kns.document.MaintenanceDocument;
23  import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
24  import org.kuali.rice.krad.util.GlobalVariables;
25  
26  /**
27   * Contains Business Rules for the Effort Certification Report Maintenance Document.
28   */
29  public class DisbursementNumberRangeRule extends MaintenanceDocumentRuleBase {
30      protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DisbursementNumberRangeRule.class);
31  
32      /**
33       * @see org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.rice.kns.document.MaintenanceDocument)
34       */
35      @Override
36      protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
37          LOG.debug("processCustomRouteDocumentBusinessRules() start");
38          
39          if (GlobalVariables.getMessageMap().hasErrors()) {
40              return false;
41          }
42          
43          boolean isValid = true;
44          DisbursementNumberRange disbursementNumberRange = (DisbursementNumberRange) document.getNewMaintainableObject().getBusinessObject();
45          
46          KualiInteger beginNumber = disbursementNumberRange.getBeginDisbursementNbr();
47          KualiInteger lastAssigned = disbursementNumberRange.getLastAssignedDisbNbr();
48          KualiInteger end = disbursementNumberRange.getEndDisbursementNbr();
49          if ( lastAssigned.isLessThan(beginNumber) || lastAssigned.isGreaterThan(end)) {
50              putFieldError(PdpPropertyConstants.LAST_ASSIGNED_DISBURSEMENT_NUMBER, PdpKeyConstants.DISBURSEMENT_NUMBER_OUT_OF_RANGE);
51              isValid = false;
52          }
53          
54          return isValid;
55      }
56  }