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.api.departmentaffiliation.DepartmentAffiliationContract;
24 import org.kuali.kpme.core.api.paygrade.PayGrade;
25 import org.kuali.kpme.core.service.HrServiceLocator;
26 import org.kuali.kpme.core.util.ValidationUtils;
27 import org.kuali.kpme.pm.api.positionappointment.PositionAppointmentContract;
28 import org.kuali.kpme.pm.api.positionreportcat.PositionReportCategoryContract;
29 import org.kuali.kpme.pm.api.positionreportsubcat.PositionReportSubCategoryContract;
30 import org.kuali.kpme.pm.api.positionreporttype.PositionReportTypeContract;
31 import org.kuali.kpme.pm.api.positiontype.PositionTypeContract;
32 import org.kuali.kpme.pm.api.pstncontracttype.PstnContractTypeContract;
33 import org.kuali.kpme.pm.api.pstnqlfctnvl.PositionQualificationValueContract;
34 import org.kuali.kpme.pm.service.base.PmServiceLocator;
35 import org.kuali.rice.location.api.campus.Campus;
36 import org.kuali.rice.location.api.services.LocationApiServiceLocator;
37
38 public class PmValidationUtils {
39
40
41
42
43
44
45
46 public static boolean validateCampus(String campusCode) {
47 boolean valid = false;
48 if (ValidationUtils.isWildCard(campusCode)) {
49 valid = true;
50 } else {
51 Campus campusObj = LocationApiServiceLocator.getCampusService().getCampus(campusCode);
52 valid = (campusObj != null);
53 }
54 return valid;
55 }
56
57
58
59
60
61
62
63
64
65
66 public static boolean validatePositionReportType(String positionReportType, LocalDate asOfDate) {
67 boolean valid = false;
68 if (asOfDate != null) {
69 List<? extends PositionReportTypeContract> prtList = PmServiceLocator.getPositionReportTypeService().getPositionReportTypeList(positionReportType, asOfDate);
70 valid = (CollectionUtils.isNotEmpty(prtList));
71 }
72 return valid;
73 }
74
75 public static boolean validatePayGradeWithSalaryGroup(String salaryGroup, String payGrade, LocalDate asOfDate) {
76 if (asOfDate != null) {
77 PayGrade grade = HrServiceLocator.getPayGradeService().getPayGrade(payGrade, salaryGroup, asOfDate);
78 if(grade != null && StringUtils.isNotBlank(grade.getSalGroup()))
79 return StringUtils.equals(grade.getSalGroup(), salaryGroup);
80 }
81 return false;
82 }
83
84
85
86
87
88
89
90
91
92 public static boolean validatePositionReportCategory(String positionReportCat, String positionReportType, LocalDate asOfDate) {
93 if (StringUtils.isNotEmpty(positionReportCat) && asOfDate != null) {
94 List<? extends PositionReportCategoryContract> prcList = PmServiceLocator.getPositionReportCatService().getPositionReportCatList(positionReportCat, positionReportType, asOfDate);
95 return CollectionUtils.isNotEmpty(prcList);
96 }
97 return false;
98 }
99
100
101
102
103
104
105
106
107
108
109
110 public static boolean validatePositionReportSubCat(String pstnRptSubCat, LocalDate asOfDate) {
111 if(asOfDate != null) {
112 List<? extends PositionReportSubCategoryContract> prscList = PmServiceLocator.getPositionReportSubCatService().getPositionReportSubCat(pstnRptSubCat, asOfDate);
113 return CollectionUtils.isNotEmpty(prscList);
114 }
115 return false;
116 }
117
118 public static boolean validatePositionQualificationValue(String qValue) {
119 if(StringUtils.isNotEmpty(qValue)) {
120 PositionQualificationValueContract aPqv = PmServiceLocator.getPositionQualificationValueService().getPositionQualificationValueByValue(qValue);
121 if(aPqv != null) {
122 return true;
123 }
124 }
125 return false;
126 }
127
128 public static boolean validateAffiliation(String deptAffl, LocalDate asOfDate) {
129 if (asOfDate != null) {
130 List<? extends DepartmentAffiliationContract> pdaList = HrServiceLocator.getDepartmentAffiliationService().getDepartmentAffiliationList(deptAffl, asOfDate);
131 return CollectionUtils.isNotEmpty(pdaList);
132 }
133 return false;
134 }
135
136 public static boolean validatePositionType(String pType, LocalDate asOfDate) {
137 if(asOfDate != null) {
138 List<? extends PositionTypeContract> ptList = PmServiceLocator.getPositionTypeService().getPositionTypeList(pType, asOfDate);
139 return CollectionUtils.isNotEmpty(ptList);
140 }
141 return false;
142 }
143
144 public static boolean validatePositionAppointmentType(String positionAppointment, String groupKeyCode, LocalDate asOfDate) {
145 if (StringUtils.isNotEmpty(positionAppointment) && asOfDate != null) {
146 List<? extends PositionAppointmentContract> ptList = PmServiceLocator.getPositionAppointmentService().getPositionAppointmentList(positionAppointment, groupKeyCode, asOfDate);
147 return CollectionUtils.isNotEmpty(ptList);
148 }
149 return false;
150 }
151
152 public static boolean validatePositionContractType(String name, String groupKeyCode, LocalDate asOfDate) {
153 if (StringUtils.isNotEmpty(name) && asOfDate != null) {
154 List<? extends PstnContractTypeContract> ptList = PmServiceLocator.getPstnContractTypeService().getPstnContractTypeList(name, groupKeyCode, asOfDate);
155 return CollectionUtils.isNotEmpty(ptList);
156 }
157 return false;
158 }
159
160 }