View Javadoc

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.pm.position;
17  
18  import java.util.ArrayList;
19  import java.util.Arrays;
20  import java.util.Collections;
21  import java.util.LinkedList;
22  import java.util.List;
23  import java.math.BigDecimal;
24  
25  import com.google.common.collect.ImmutableList;
26  import org.apache.commons.collections.CollectionUtils;
27  import org.apache.commons.lang.StringUtils;
28  import org.kuali.rice.location.impl.campus.CampusBo;
29  import org.kuali.kpme.core.position.PositionBase;
30  import org.kuali.kpme.core.util.HrConstants;
31  import org.kuali.kpme.pm.api.position.PositionContract;
32  import org.kuali.kpme.pm.classification.duty.ClassificationDuty;
33  import org.kuali.kpme.pm.classification.flag.ClassificationFlag;
34  import org.kuali.kpme.pm.classification.qual.ClassificationQualification;
35  import org.kuali.kpme.pm.position.funding.PositionFunding;
36  import org.kuali.kpme.pm.positionresponsibility.PositionResponsibility;
37  import org.kuali.kpme.pm.service.base.PmServiceLocator;
38  
39  public class Position extends PositionBase implements PositionContract {
40  	private static final long serialVersionUID = 1L;
41  	
42      public static final String CACHE_NAME = HrConstants.CacheNamespace.NAMESPACE_PREFIX + "Position";
43      public static final ImmutableList<String> CACHE_FLUSH = new ImmutableList.Builder<String>()
44              .add(PositionBase.CACHE_NAME)
45              .add(Position.CACHE_NAME)
46              .build();
47  	
48  	private List<PositionQualification> qualificationList = new LinkedList<PositionQualification>();
49      private List<PositionDuty> dutyList = new LinkedList<PositionDuty>();
50      private List<PstnFlag> flagList = new LinkedList<PstnFlag>();
51      private List<PositionResponsibility> positionResponsibilityList = new LinkedList<PositionResponsibility>();
52      private List<PositionFunding> fundingList = new ArrayList<PositionFunding>();
53  
54      private String institution;
55      private String campus;
56      private String salaryGroup;
57      private String pmPositionClassId;
58      private String classificationTitle;
59      private String workingPositionTitle;
60      private BigDecimal percentTime;
61      private int workMonths;
62      private String benefitsEligible;
63      private String leaveEligible;
64      private String leavePlan;
65      private String positionReportGroup;
66      private String positionType;
67      private String poolEligible;
68      private int maxPoolHeadCount;
69      private String tenureEligible;
70  
71      private CampusBo campusObj;
72      
73      private String category;		// used to determine what fields should show when editing an existing maint doc
74      
75      private List<ClassificationQualification> requiredQualList = new ArrayList<ClassificationQualification>(); 	// read only required qualifications that comes from assiciated Classification
76  
77      public List<PositionDuty> getDutyList() {
78      	if(CollectionUtils.isEmpty(dutyList) && StringUtils.isNotEmpty(this.getPmPositionClassId())) {
79      		List<ClassificationDuty> aList = PmServiceLocator.getClassificationDutyService().getDutyListForClassification(this.getPmPositionClassId());
80      		if(CollectionUtils.isNotEmpty(aList)) {
81      			List<PositionDuty> pDutyList = new ArrayList<PositionDuty>();
82      			// copy basic information from classificaton duty list
83      			for(ClassificationDuty aDuty : aList) {
84      				PositionDuty pDuty = new PositionDuty();
85      				pDuty.setName(aDuty.getName());
86      				pDuty.setDescription(aDuty.getDescription());
87      				pDuty.setPercentage(aDuty.getPercentage());
88      				pDuty.setPmDutyId(null);
89      				pDuty.setHrPositionId(this.getHrPositionId());
90      				pDutyList.add(pDuty);
91      			}
92      			this.setDutyList(pDutyList);
93      		}
94      	}
95  		return dutyList;
96  	}
97  
98  	public List<PositionResponsibility> getPositionResponsibilityList() {
99  		return positionResponsibilityList;
100 	}
101 
102 	public void setPositionResponsibilityList(
103 			List<PositionResponsibility> positionResponsibilityList) {
104 		this.positionResponsibilityList = positionResponsibilityList;
105 	}
106 	public void setDutyList(List<PositionDuty> dutyList) {
107 		this.dutyList = dutyList;
108 	}
109 
110 	public List<PositionQualification> getQualificationList() {
111 		return qualificationList;
112 	}
113 
114 	public void setQualificationList(List<PositionQualification> qualificationList) {
115 		this.qualificationList = qualificationList;
116 	}
117 
118 	public List<PstnFlag> getFlagList() {
119 		if(CollectionUtils.isEmpty(flagList) && StringUtils.isNotEmpty(this.getPmPositionClassId())) {
120     		List<ClassificationFlag> aList = PmServiceLocator.getClassificationFlagService().getFlagListForClassification(this.getPmPositionClassId());
121     		if(CollectionUtils.isNotEmpty(aList)) {
122     			List<PstnFlag> pFlagList = new ArrayList<PstnFlag>();
123     			// copy basic information from classificaton flag list
124     			for(ClassificationFlag aFlag : aList) {
125     				PstnFlag pFlag = new PstnFlag();
126     				pFlag.setCategory(aFlag.getCategory());
127     				pFlag.setNames(aFlag.getNames());
128     				pFlag.setPmFlagId(null);
129     				pFlag.setHrPositionId(this.getHrPositionId());
130     				pFlagList.add(pFlag);
131     			}
132     			this.setFlagList(pFlagList);
133     		}
134 		}
135 		return flagList;
136 	}
137 
138 	public void setFlagList(List<PstnFlag> flagList) {
139 		this.flagList = flagList;
140 	}
141 	
142 	public String getPmPositionClassId() {
143 		return pmPositionClassId;
144 	}
145 
146 	public void setPmPositionClassId(String id) {
147 		this.pmPositionClassId = id;
148 	}
149 	
150 	public List<ClassificationQualification> getRequiredQualList() {
151 		if(StringUtils.isNotEmpty(this.getPmPositionClassId())) {
152 			// when Position Classification Id is changed, change the requiredQualList with it
153 			if(CollectionUtils.isEmpty(requiredQualList) ||
154 					(CollectionUtils.isNotEmpty(requiredQualList) 
155 							&& !requiredQualList.get(0).getPmPositionClassId().equals(this.getPmPositionClassId()))) {
156 				List<ClassificationQualification> aList = PmServiceLocator.getClassificationQualService()
157 						.getQualListForClassification(this.getPmPositionClassId());
158 				if(CollectionUtils.isNotEmpty(aList))
159 					this.setRequiredQualList(aList);
160 			} else {
161 				
162 			}
163 		}
164  		return requiredQualList;
165 	}
166 	
167 	public void setRequiredQualList(List<ClassificationQualification> aList) {
168 			requiredQualList = aList;
169 	}
170 
171 	public List<PositionFunding> getFundingList() {
172 		return fundingList;
173 	}
174 
175 	public void setFundingList(List<PositionFunding> fundingList) {
176 		this.fundingList = fundingList;
177 	}
178 
179 	public String getCategory() {
180 		return category;
181 	}
182 
183 	public void setCategory(String category) {
184 		this.category = category;
185 	}
186     public String getInstitution() {
187         return institution;
188     }
189 
190     public void setInstitution(String institution) {
191         this.institution = institution;
192     }
193 
194     public String getCampus() {
195         return campus;
196     }
197 
198     public void setCampus(String campus) {
199         this.campus = campus;
200     }
201 
202     public CampusBo getCampusObj() {
203         return campusObj;
204     }
205 
206     public void setCampusObj(CampusBo campusObj) {
207         this.campusObj = campusObj;
208     }
209 
210     public String getSalaryGroup() {
211         return salaryGroup;
212     }
213 
214     public void setSalaryGroup(String salaryGroup) {
215         this.salaryGroup = salaryGroup;
216     }
217 
218     public String getClassificationTitle() {
219         return classificationTitle;
220     }
221 
222     public void setClassificationTitle(String classificationTitle) {
223         this.classificationTitle = classificationTitle;
224     }
225 
226     public String getWorkingPositionTitle() {
227         return workingPositionTitle;
228     }
229 
230     public void setWorkingPositionTitle(String workingPositionTitle) {
231         this.workingPositionTitle = workingPositionTitle;
232     }
233 
234     public BigDecimal getPercentTime() {
235         return percentTime;
236     }
237 
238     public void setPercentTime(BigDecimal percentTime) {
239         this.percentTime = percentTime;
240     }
241 
242     public String getBenefitsEligible() {
243         return benefitsEligible;
244     }
245 
246     public void setBenefitsEligible(String benefitsEligible) {
247         this.benefitsEligible = benefitsEligible;
248     }
249 
250     public String getLeaveEligible() {
251         return leaveEligible;
252     }
253 
254     public void setLeaveEligible(String leaveEligible) {
255         this.leaveEligible = leaveEligible;
256     }
257 
258     public String getLeavePlan() {
259         return leavePlan;
260     }
261 
262     public void setLeavePlan(String leavePlan) {
263         this.leavePlan = leavePlan;
264     }
265 
266     public String getPositionReportGroup() {
267         return positionReportGroup;
268     }
269 
270     public void setPositionReportGroup(String positionReportGroup) {
271         this.positionReportGroup = positionReportGroup;
272     }
273 
274     public String getPositionType() {
275         return positionType;
276     }
277 
278     public void setPositionType(String positionType) {
279         this.positionType = positionType;
280     }
281 
282     public String getPoolEligible() {
283         return poolEligible;
284     }
285 
286     public void setPoolEligible(String poolEligible) {
287         this.poolEligible = poolEligible;
288     }
289 
290     public int getMaxPoolHeadCount() {
291         return maxPoolHeadCount;
292     }
293 
294     public void setMaxPoolHeadCount(int maxPoolHeadCount) {
295         this.maxPoolHeadCount = maxPoolHeadCount;
296     }
297 
298     public String getTenureEligible() {
299         return tenureEligible;
300     }
301 
302     public void setTenureEligible(String tenureEligible) {
303         this.tenureEligible = tenureEligible;
304     }
305 
306     public int getWorkMonths() {
307         return workMonths;
308     }
309 
310     public void setWorkMonths(int workMonths) {
311         this.workMonths = workMonths;
312     }
313 }