1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.time.rules.graceperiod.validation;
17
18 import java.math.BigDecimal;
19
20 import org.kuali.kpme.tklm.time.rules.graceperiod.GracePeriodRule;
21 import org.kuali.rice.kns.document.MaintenanceDocument;
22 import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
23 import org.kuali.rice.krad.bo.PersistableBusinessObject;
24
25 @SuppressWarnings("deprecation")
26 public class GracePeriodRuleValidation extends MaintenanceDocumentRuleBase{
27 @Override
28 protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document){
29 boolean valid = false;
30 LOG.debug("entering custom validation for Grace Period Rule");
31 PersistableBusinessObject pbo = (PersistableBusinessObject) this.getNewBo();
32 if (pbo instanceof GracePeriodRule) {
33 GracePeriodRule gracePeriodRule = (GracePeriodRule)this.getNewBo();
34 if (gracePeriodRule != null) {
35 valid = true;
36
37 if(gracePeriodRule.getHourFactor() != null
38 && (gracePeriodRule.getHourFactor().compareTo(BigDecimal.ZERO) <= 0
39 || gracePeriodRule.getHourFactor().compareTo(new BigDecimal(60)) > 0)){
40 this.putFieldError("hourFactor", "graceperiod.hour.factor.invalid", gracePeriodRule.getHourFactor()+"");
41 valid = false;
42 }
43 }
44 }
45 return valid;
46 }
47 }