1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.accrual.validation;
17
18 import org.kuali.hr.time.accrual.TimeOffAccrual;
19 import org.kuali.hr.time.util.ValidationUtils;
20 import org.kuali.rice.kns.document.MaintenanceDocument;
21 import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
22 import org.kuali.rice.krad.bo.PersistableBusinessObject;
23
24 public class TimeOffAccrualRule extends MaintenanceDocumentRuleBase {
25
26
27
28
29
30 @Override
31 protected boolean processCustomRouteDocumentBusinessRules(
32 MaintenanceDocument document) {
33 boolean valid = false;
34
35 LOG.debug("entering custom validation for ClockLocationRule");
36 PersistableBusinessObject pbo = (PersistableBusinessObject) this.getNewBo();
37 if (pbo instanceof TimeOffAccrual) {
38 TimeOffAccrual tof = (TimeOffAccrual) pbo;
39 if (tof != null) {
40 valid = true;
41 valid &= this.validatePrincipalId(tof);
42 valid &= this.validateAccrualCategory(tof);
43 }
44 }
45
46 return valid;
47 }
48
49 private boolean validatePrincipalId(TimeOffAccrual tof) {
50 if (tof.getPrincipalId() != null
51 && !ValidationUtils.validatePrincipalId(tof.getPrincipalId())) {
52 this.putFieldError("principalId", "error.existence",
53 "principalId '" + tof.getPrincipalId() + "'");
54 return false;
55 } else {
56 return true;
57 }
58 }
59
60 private boolean validateAccrualCategory(TimeOffAccrual tof) {
61 if (tof.getAccrualCategory() != null
62 && !ValidationUtils.validateAccrualCategory(tof
63 .getAccrualCategory(), tof.getEffectiveDate())) {
64 this.putFieldError("accrualCategory", "error.existence",
65 "accrualCategory '" + tof.getAccrualCategory() + "'");
66 return false;
67 } else {
68 return true;
69 }
70 }
71
72 }