1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.pm.util;
17
18 import java.util.List;
19
20 import org.apache.commons.collections.CollectionUtils;
21 import org.apache.commons.lang.StringUtils;
22 import org.joda.time.LocalDate;
23 import org.kuali.kpme.core.paygrade.PayGrade;
24 import org.kuali.kpme.core.service.HrServiceLocator;
25 import org.kuali.kpme.core.util.HrConstants;
26 import org.kuali.kpme.core.util.ValidationUtils;
27 import org.kuali.kpme.pm.PMConstants;
28 import org.kuali.kpme.pm.positiondepartmentaffiliation.PositionDepartmentAffiliation;
29 import org.kuali.kpme.pm.positionreportcat.PositionReportCategory;
30 import org.kuali.kpme.pm.positionreportgroup.PositionReportGroup;
31 import org.kuali.kpme.pm.positionreportsubcat.PositionReportSubCategory;
32 import org.kuali.kpme.pm.positionreporttype.PositionReportType;
33 import org.kuali.kpme.pm.positiontype.PositionType;
34 import org.kuali.kpme.pm.pstnqlfctnvl.PositionQualificationValue;
35 import org.kuali.kpme.pm.service.base.PmServiceLocator;
36 import org.kuali.rice.location.api.campus.Campus;
37 import org.kuali.rice.location.api.services.LocationApiServiceLocator;
38
39 public class PmValidationUtils {
40
41
42
43
44
45
46
47 public static boolean validateCampus(String campusCode) {
48 boolean valid = false;
49 if (ValidationUtils.isWildCard(campusCode)) {
50 valid = true;
51 } else {
52 Campus campusObj = LocationApiServiceLocator.getCampusService().getCampus(campusCode);
53 valid = (campusObj != null);
54 }
55 return valid;
56 }
57
58
59
60
61
62
63
64
65
66
67 public static boolean validatePositionReportType(String positionReportType, String institution, String location, LocalDate asOfDate) {
68 boolean valid = false;
69 if (asOfDate != null) {
70 List<PositionReportType> prtList = PmServiceLocator.getPositionReportTypeService().getPositionReportTypeList(positionReportType, institution, location, asOfDate);
71 valid = (CollectionUtils.isNotEmpty(prtList));
72 }
73 return valid;
74 }
75
76
77
78
79
80
81
82
83
84 public static boolean validateInstitutionWithPRT(String positionReportType, String institutionCode, LocalDate asOfDate) {
85 if (asOfDate != null) {
86 List<PositionReportType> prtList = PmServiceLocator.getPositionReportTypeService()
87 .getPositionReportTypeList(positionReportType, institutionCode, PMConstants.WILDCARD_CHARACTER, asOfDate);
88 return CollectionUtils.isNotEmpty(prtList);
89 }
90 return false;
91 }
92
93
94
95
96
97
98
99
100
101 public static boolean validateCampusWithPRT(String positionReportType, String campus, LocalDate asOfDate) {
102 if (asOfDate != null) {
103 List<PositionReportType> prtList = PmServiceLocator.getPositionReportTypeService()
104 .getPositionReportTypeList(positionReportType, HrConstants.WILDCARD_CHARACTER, campus, asOfDate);
105 return CollectionUtils.isNotEmpty(prtList);
106 }
107 return false;
108 }
109
110 public static boolean validatePayGradeWithSalaryGroup(String salaryGroup, String payGrade, LocalDate asOfDate) {
111 if (asOfDate != null) {
112 PayGrade grade = HrServiceLocator.getPayGradeService().getPayGrade(payGrade, salaryGroup, asOfDate);
113 if(grade != null && StringUtils.isNotBlank(grade.getSalGroup()))
114 return StringUtils.equals(grade.getSalGroup(), salaryGroup);
115 }
116 return false;
117 }
118
119
120
121
122
123
124
125
126
127
128 public static boolean validatePositionReportCategory(String positionReportCat, String positionReportType, String institution, String campus, LocalDate asOfDate) {
129 if (StringUtils.isNotEmpty(positionReportCat) && asOfDate != null) {
130 List<PositionReportCategory> prcList = PmServiceLocator.getPositionReportCatService().getPositionReportCatList(positionReportCat, positionReportType, institution, campus, asOfDate);
131 return CollectionUtils.isNotEmpty(prcList);
132 }
133 return false;
134 }
135
136
137
138
139
140
141
142
143
144
145
146 public static boolean validatePositionReportSubCat(String pstnRptSubCat, String institution, String location, LocalDate asOfDate) {
147 if(asOfDate != null) {
148 List<PositionReportSubCategory> prscList = PmServiceLocator.getPositionReportSubCatService().getPositionReportSubCat(pstnRptSubCat, institution, location, asOfDate);
149 return CollectionUtils.isNotEmpty(prscList);
150 }
151 return false;
152 }
153
154 public static boolean validatePstnRptGrp(String PstnRptGrp, String institution, String location, LocalDate asOfDate) {
155 if(asOfDate != null) {
156 List<PositionReportGroup> prgList = PmServiceLocator.getPositionReportGroupService().getPositionReportGroupList(PstnRptGrp, institution, location, asOfDate);
157 return CollectionUtils.isNotEmpty(prgList);
158 }
159 return false;
160 }
161
162 public static boolean validatePositionQualificationValue(String qValue) {
163 if(StringUtils.isNotEmpty(qValue)) {
164 PositionQualificationValue aPqv = PmServiceLocator.getPositionQualificationValueService().getPositionQualificationValueByValue(qValue);
165 if(aPqv != null) {
166 return true;
167 }
168 }
169 return false;
170 }
171
172 public static boolean validateAffiliation(String positionDeptAffl, LocalDate asOfDate) {
173 if (asOfDate != null) {
174 List<PositionDepartmentAffiliation> pdaList = PmServiceLocator.getPositionDepartmentAffiliationService().getPositionDepartmentAffiliationList(positionDeptAffl, asOfDate);
175 return CollectionUtils.isNotEmpty(pdaList);
176 }
177 return false;
178 }
179
180 public static boolean validatePositionType(String pType, String institution, String campus, LocalDate asOfDate) {
181 if(asOfDate != null) {
182 List<PositionType> ptList = PmServiceLocator.getPositionTypeService().getPositionTypeList(pType, institution, campus, asOfDate);
183 return CollectionUtils.isNotEmpty(ptList);
184 }
185 return false;
186 }
187
188 }