1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.pm.positionreportgroup.validation;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.kpme.core.util.ValidationUtils;
20 import org.kuali.kpme.pm.positionreportgroup.PositionReportGroup;
21 import org.kuali.rice.kns.document.MaintenanceDocument;
22 import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
23
24 @SuppressWarnings("deprecation")
25 public class PositionReportGroupValidation extends MaintenanceDocumentRuleBase {
26 @Override
27 protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
28 boolean valid = false;
29 LOG.debug("entering custom validation for Position Report Group");
30 PositionReportGroup prg = (PositionReportGroup) this.getNewBo();
31
32 if (prg != null) {
33 valid = true;
34 valid &= this.validateInstitution(prg);
35 valid &= this.validateLocation(prg);
36 }
37 return valid;
38 }
39
40 private boolean validateInstitution(PositionReportGroup prg) {
41 if (StringUtils.isNotEmpty(prg.getInstitution())
42 && !ValidationUtils.validateInstitution(prg.getInstitution(), prg.getEffectiveLocalDate())) {
43 this.putFieldError("institution", "error.existence", "Instituion '"
44 + prg.getInstitution() + "'");
45 return false;
46 } else {
47 return true;
48 }
49 }
50
51 private boolean validateLocation(PositionReportGroup prg) {
52 if (StringUtils.isNotEmpty(prg.getLocation())
53 && !ValidationUtils.validateLocation(prg.getLocation(), prg.getEffectiveLocalDate())) {
54 this.putFieldError("location", "error.existence", "Location '"
55 + prg.getLocation() + "'");
56 return false;
57 } else {
58 return true;
59 }
60 }
61 }