1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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
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 }