1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.earncode;
17
18 import java.math.BigDecimal;
19 import java.sql.Timestamp;
20 import java.util.Collection;
21 import java.util.HashMap;
22 import java.util.Map;
23
24 import org.apache.commons.lang.StringUtils;
25 import org.kuali.kpme.core.accrualcategory.AccrualCategoryBo;
26 import org.kuali.kpme.core.api.earncode.EarnCode;
27 import org.kuali.kpme.core.api.earncode.EarnCodeContract;
28 import org.kuali.kpme.core.bo.HrBusinessObject;
29 import org.kuali.kpme.core.earncode.security.EarnCodeSecurityBo;
30 import org.kuali.kpme.core.leaveplan.LeavePlanBo;
31 import org.kuali.kpme.core.service.HrServiceLocator;
32 import org.kuali.kpme.core.util.HrConstants;
33 import org.kuali.rice.krad.service.KRADServiceLocator;
34
35 import com.google.common.collect.ImmutableList;
36 import com.google.common.collect.ImmutableMap;
37
38 public class EarnCodeBo extends HrBusinessObject implements EarnCodeContract {
39
40 private static final String EARN_CODE = "earnCode";
41
42 private static final long serialVersionUID = -1470603919624794932L;
43
44 public static final String CACHE_NAME = HrConstants.CacheNamespace.NAMESPACE_PREFIX + "EarnCode";
45 public static final ImmutableList<String> CACHE_FLUSH = new ImmutableList.Builder<String>()
46 .add(EarnCodeSecurityBo.CACHE_NAME)
47 .add(EarnCodeBo.CACHE_NAME)
48 .build();
49
50 public static final ImmutableList<String> BUSINESS_KEYS = new ImmutableList.Builder<String>()
51 .add(EARN_CODE)
52 .build();
53
54
55 private String hrEarnCodeId;
56 private String earnCode;
57 private String description;
58
59 private boolean ovtEarnCode;
60 private String accrualCategory;
61 private BigDecimal inflateMinHours;
62 private BigDecimal inflateFactor;
63
64 private boolean history;
65
66 private AccrualCategoryBo accrualCategoryObj;
67 private EarnCodeBo rollupToEarnCodeObj;
68 private LeavePlanBo leavePlanObj;
69
70 private String leavePlan;
71 private String accrualBalanceAction;
72 private String fractionalTimeAllowed;
73 private String roundingOption;
74 private String eligibleForAccrual;
75 private String affectPay;
76 private String allowScheduledLeave;
77 private String fmla;
78 private String workmansComp;
79 private Long defaultAmountofTime;
80 private String allowNegativeAccrualBalance;
81 private String rollupToEarnCode;
82 private String recordMethod;
83 private String usageLimit;
84 private String countsAsRegularPay;
85
86
87
88 @Override
89 public ImmutableMap<String, Object> getBusinessKeyValuesMap() {
90 return new ImmutableMap.Builder<String, Object>()
91 .put(EARN_CODE, this.getEarnCode())
92 .build();
93 }
94
95 public String getCountsAsRegularPay() {
96 return countsAsRegularPay;
97 }
98
99 public void setCountsAsRegularPay(String countsAsRegularPay) {
100 this.countsAsRegularPay = countsAsRegularPay;
101 }
102
103 public String getUsageLimit() {
104 return usageLimit;
105 }
106
107 public void setUsageLimit(String usageLimit) {
108 this.usageLimit = usageLimit;
109 }
110
111 public String getRecordMethod() {
112 return recordMethod;
113 }
114
115 public void setRecordMethod(String recordMethod) {
116 this.recordMethod = recordMethod;
117 }
118
119 public String getRollupToEarnCode() {
120 return rollupToEarnCode;
121 }
122
123 public void setRollupToEarnCode(String rollupToEarnCode) {
124 this.rollupToEarnCode = rollupToEarnCode;
125 }
126
127 public EarnCodeBo getRollupToEarnCodeObj() {
128 return rollupToEarnCodeObj;
129 }
130
131 public void setRollupToEarnCodeObj(EarnCodeBo rollupToEarnCodeObj) {
132 this.rollupToEarnCodeObj = rollupToEarnCodeObj;
133 }
134
135 public String getLeavePlan() {
136
137
138
139
140
141 return leavePlan;
142 }
143
144 public void setLeavePlan(String leavePlan) {
145 this.leavePlan = leavePlan;
146 }
147
148 public String getAccrualBalanceAction() {
149 return accrualBalanceAction;
150 }
151
152 public void setAccrualBalanceAction(String accrualBalanceAction) {
153 this.accrualBalanceAction = accrualBalanceAction;
154 }
155
156 public String getFractionalTimeAllowed() {
157 return fractionalTimeAllowed;
158 }
159
160 public void setFractionalTimeAllowed(String fractionalTimeAllowed) {
161 this.fractionalTimeAllowed = fractionalTimeAllowed;
162 }
163
164 public String getRoundingOption() {
165 return roundingOption;
166 }
167
168 public void setRoundingOption(String roundingOption) {
169 this.roundingOption = roundingOption;
170 }
171
172 public String getEligibleForAccrual() {
173 return eligibleForAccrual;
174 }
175
176 public void setEligibleForAccrual(String eligibleForAccrual) {
177 this.eligibleForAccrual = eligibleForAccrual;
178 }
179
180 public String getAffectPay() {
181 return affectPay;
182 }
183
184 public void setAffectPay(String affectPay) {
185 this.affectPay = affectPay;
186 }
187
188 public String getAllowScheduledLeave() {
189 return allowScheduledLeave;
190 }
191
192 public void setAllowScheduledLeave(String allowScheduledLeave) {
193 this.allowScheduledLeave = allowScheduledLeave;
194 }
195
196 public String getFmla() {
197 return fmla;
198 }
199
200 public void setFmla(String fmla) {
201 this.fmla = fmla;
202 }
203
204 public String getWorkmansComp() {
205 return workmansComp;
206 }
207
208 public void setWorkmansComp(String workmansComp) {
209 this.workmansComp = workmansComp;
210 }
211
212 public Long getDefaultAmountofTime() {
213 return defaultAmountofTime;
214 }
215
216 public void setDefaultAmountofTime(Long defaultAmountofTime) {
217 this.defaultAmountofTime = defaultAmountofTime;
218 }
219
220 public String getAllowNegativeAccrualBalance() {
221 return allowNegativeAccrualBalance;
222 }
223
224 public void setAllowNegativeAccrualBalance(String allowNegativeAccrualBalance) {
225 this.allowNegativeAccrualBalance = allowNegativeAccrualBalance;
226 }
227
228
229 public String getEarnCode() {
230 return earnCode;
231 }
232
233 public void setEarnCode(String earnCode) {
234 this.earnCode = earnCode;
235 }
236
237 public String getDescription() {
238 return description;
239 }
240
241 public void setDescription(String description) {
242 this.description = description;
243 }
244
245 public boolean isHistory() {
246 return history;
247 }
248
249 public void setHistory(boolean history) {
250 this.history = history;
251 }
252
253 public String getHrEarnCodeId() {
254 return hrEarnCodeId;
255 }
256
257 public void setHrEarnCodeId(String hrEarnCodeId) {
258 this.hrEarnCodeId = hrEarnCodeId;
259 }
260
261 public String getAccrualCategory() {
262 return accrualCategory;
263 }
264
265 public void setAccrualCategory(String accrualCategory) {
266 this.accrualCategory = accrualCategory;
267 }
268
269 public AccrualCategoryBo getAccrualCategoryObj() {
270 if(accrualCategoryObj == null && StringUtils.isNotEmpty(this.getAccrualCategory())) {
271 accrualCategoryObj = AccrualCategoryBo.from(HrServiceLocator.getAccrualCategoryService().getAccrualCategory(getAccrualCategory(), getEffectiveLocalDate()));
272 }
273 return accrualCategoryObj;
274 }
275
276 public void setAccrualCategoryObj(AccrualCategoryBo accrualCategoryObj) {
277 this.accrualCategoryObj = accrualCategoryObj;
278 }
279
280 public BigDecimal getInflateMinHours() {
281 return inflateMinHours;
282 }
283
284 public void setInflateMinHours(BigDecimal inflateMinHours) {
285 this.inflateMinHours = inflateMinHours;
286 }
287
288 public BigDecimal getInflateFactor() {
289 return inflateFactor;
290 }
291
292 public void setInflateFactor(BigDecimal inflateFactor) {
293 this.inflateFactor = inflateFactor;
294 }
295
296 public boolean isOvtEarnCode() {
297 return ovtEarnCode;
298 }
299
300 public void setOvtEarnCode(boolean ovtEarnCode) {
301 this.ovtEarnCode = ovtEarnCode;
302 }
303
304
305
306
307
308
309 public String getEarnCodeType() {
310
311
312
313
314
315
316
317
318
319
320
321
322 return this.recordMethod;
323 }
324
325 @Override
326 public String getUniqueKey() {
327 return earnCode;
328 }
329
330 @Override
331 public String getId() {
332 return getHrEarnCodeId();
333 }
334
335 @Override
336 public void setId(String id) {
337 setHrEarnCodeId(id);
338 }
339
340 public String getEarnCodeKeyForDisplay() {
341
342
343
344
345
346
347
348 return hrEarnCodeId;
349 }
350
351 public String getEarnCodeValueForDisplay() {
352 return earnCode + " : " + description;
353 }
354
355 public LeavePlanBo getLeavePlanObj() {
356 return leavePlanObj;
357 }
358
359 public void setLeavePlanObj(LeavePlanBo leavePlanObj) {
360 this.leavePlanObj = leavePlanObj;
361 }
362
363
364 public static EarnCodeBo from(EarnCode im) {
365 if (im == null) {
366 return null;
367 }
368 EarnCodeBo ec = new EarnCodeBo();
369
370 ec.setHrEarnCodeId(im.getHrEarnCodeId());
371 ec.setEarnCode(im.getEarnCode());
372 ec.setDescription(im.getDescription());
373
374 ec.setOvtEarnCode(im.isOvtEarnCode());
375 ec.setAccrualCategory(im.getAccrualCategory());
376 ec.setInflateMinHours(im.getInflateMinHours());
377 ec.setInflateFactor(im.getInflateFactor());
378
379 ec.setAccrualCategoryObj(im.getAccrualCategoryObj() == null ? null : AccrualCategoryBo.from(im.getAccrualCategoryObj()));
380 ec.setRollupToEarnCodeObj(im.getRollupToEarnCodeObj() == null ? null : EarnCodeBo.from(im.getRollupToEarnCodeObj()));
381
382 ec.setLeavePlan(im.getLeavePlan());
383 ec.setAccrualBalanceAction(im.getAccrualBalanceAction());
384 ec.setFractionalTimeAllowed(im.getFractionalTimeAllowed());
385 ec.setRoundingOption(im.getRoundingOption());
386 ec.setEligibleForAccrual(im.getEligibleForAccrual());
387 ec.setAffectPay(im.getAffectPay());
388 ec.setAllowScheduledLeave(im.getAllowScheduledLeave());
389 ec.setFmla(im.getFmla());
390 ec.setWorkmansComp(im.getWorkmansComp());
391 ec.setDefaultAmountofTime(im.getDefaultAmountofTime());
392 ec.setAllowNegativeAccrualBalance(im.getAllowNegativeAccrualBalance());
393 ec.setRollupToEarnCode(im.getRollupToEarnCode());
394 ec.setRecordMethod(im.getRecordMethod());
395 ec.setUsageLimit(im.getUsageLimit());
396 ec.setCountsAsRegularPay(im.getCountsAsRegularPay());
397
398 ec.setEffectiveDate(im.getEffectiveLocalDate() == null ? null : im.getEffectiveLocalDate().toDate());
399 ec.setActive(im.isActive());
400 if (im.getCreateTime() != null) {
401 ec.setTimestamp(new Timestamp(im.getCreateTime().getMillis()));
402 }
403 ec.setUserPrincipalId(im.getUserPrincipalId());
404 ec.setVersionNumber(im.getVersionNumber());
405 ec.setObjectId(im.getObjectId());
406
407 return ec;
408 }
409
410 public static EarnCode to(EarnCodeBo bo) {
411 if (bo == null) {
412 return null;
413 }
414
415 return EarnCode.Builder.create(bo).build();
416 }
417 }