1 /**
2 * Copyright 2004-2014 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.kpme.core.salarygroup.validation;
17
18
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.kpme.core.bo.validation.HrKeyedSetBusinessObjectValidation;
21 import org.kuali.kpme.core.salarygroup.SalaryGroupBo;
22 import org.kuali.kpme.core.salarygroup.SalaryGroupKeyBo;
23 import org.kuali.kpme.core.util.ValidationUtils;
24 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
25 import org.kuali.rice.krad.rules.MaintenanceDocumentRuleBase;
26
27 public class SalaryGroupValidation extends HrKeyedSetBusinessObjectValidation<SalaryGroupBo, SalaryGroupKeyBo>{
28 @Override
29 protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
30 boolean valid = false;
31 LOG.debug("entering custom validation for Salary Group");
32 SalaryGroupBo sg = (SalaryGroupBo) this.getNewDataObject();
33
34 if (sg != null) {
35 valid = true;
36 // valid &= this.validateInstitution(sg);
37 // valid &= this.validateLocation(sg);
38 valid &= this.validateLeavePlan(sg);
39 }
40 return valid;
41 }
42
43 // private boolean validateInstitution(SalaryGroupBo sg) {
44 // if (StringUtils.isNotEmpty(sg.getInstitution())
45 // && !ValidationUtils.validateInstitution(sg.getInstitution(), sg.getEffectiveLocalDate())) {
46 // this.putFieldError("dataObject.institution", "error.existence", "Instituion '"
47 // + sg.getInstitution() + "'");
48 // return false;
49 // } else {
50 // return true;
51 // }
52 // }
53 //
54 // private boolean validateLocation(SalaryGroupBo sg) {
55 // if (StringUtils.isNotEmpty(sg.getLocation())
56 // && !ValidationUtils.validateLocation(sg.getLocation(), sg.getEffectiveLocalDate())) {
57 // this.putFieldError("dataObject.location", "error.existence", "Location '"
58 // + sg.getLocation() + "'");
59 // return false;
60 // } else {
61 // return true;
62 // }
63 // }
64
65 private boolean validateLeavePlan(SalaryGroupBo sg) {
66 if (StringUtils.isNotEmpty(sg.getLeavePlan())
67 && !ValidationUtils.validateLeavePlan(sg.getLeavePlan(), sg.getEffectiveLocalDate())) {
68 this.putFieldError("dataObject.leavePlan", "error.existence", "Leave Plan '"
69 + sg.getLeavePlan() + "'");
70 return false;
71 } else {
72 return true;
73 }
74 }
75
76
77 }