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