1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.leave.timeoff;
17
18 import java.math.BigDecimal;
19 import java.util.Date;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.joda.time.LocalDate;
23 import org.kuali.kpme.core.accrualcategory.AccrualCategoryBo;
24 import org.kuali.kpme.core.bo.HrBusinessObject;
25 import org.kuali.kpme.core.earncode.EarnCodeBo;
26 import org.kuali.kpme.core.leaveplan.LeavePlanBo;
27 import org.kuali.kpme.core.location.LocationBo;
28 import org.kuali.kpme.core.service.HrServiceLocator;
29 import org.kuali.kpme.core.util.HrConstants;
30 import org.kuali.kpme.tklm.api.leave.timeoff.SystemScheduledTimeOffContract;
31 import org.kuali.kpme.tklm.api.common.TkConstants;
32
33 import com.google.common.collect.ImmutableList;
34 import com.google.common.collect.ImmutableMap;
35
36 public class SystemScheduledTimeOff extends HrBusinessObject implements SystemScheduledTimeOffContract {
37
38 private static final String ACCRUED_DATE = "accruedDate";
39 private static final String ACCRUAL_CATEGORY = "accrualCategory";
40 private static final String LOCATION = "location";
41 private static final String LEAVE_PLAN = "leavePlan";
42 private static final String EARN_CODE = "earnCode";
43
44 private static final long serialVersionUID = 6660625335629574993L;
45
46 public static final String CACHE_NAME = TkConstants.Namespace.NAMESPACE_PREFIX + "SystemScheduledTimeOff";
47
48 public static final ImmutableList<String> fields = new ImmutableList.Builder<String>()
49 .add(EARN_CODE)
50 .add(LEAVE_PLAN)
51 .add(LOCATION)
52 .add(ACCRUAL_CATEGORY)
53 .add(ACCRUED_DATE)
54 .build();
55
56
57 private String lmSystemScheduledTimeOffId;
58 private String leavePlan;
59 private String accrualCategory;
60 private String earnCode;
61 private Date accruedDate;
62 private Date scheduledTimeOffDate;
63 private String location;
64 private String descr;
65 private BigDecimal amountofTime;
66 private String unusedTime;
67 private BigDecimal transferConversionFactor;
68 private String transfertoEarnCode;
69 private String premiumEarnCode;
70 private String premiumHoliday;
71
72 private LeavePlanBo leavePlanObj;
73 private AccrualCategoryBo accrualCategoryObj;
74 private EarnCodeBo earnCodeObj;
75 private EarnCodeBo transferToEarnCodeObj;
76 private EarnCodeBo premiumEarnCodeObj;
77 private LocationBo locationObj;
78
79
80 @Override
81 public ImmutableMap<String, Object> getBusinessKeyValuesMap() {
82 return new ImmutableMap.Builder<String, Object>()
83 .put(EARN_CODE, this.getEarnCode())
84 .put(LEAVE_PLAN, this.getLeavePlan())
85 .put(LOCATION, this.getLocation())
86 .put(ACCRUAL_CATEGORY, this.getAccrualCategory())
87 .put(ACCRUED_DATE, this.getAccruedDate())
88 .build();
89 }
90
91 public String getLmSystemScheduledTimeOffId() {
92 return lmSystemScheduledTimeOffId;
93 }
94
95 public void setLmSystemScheduledTimeOffId(String lmSystemScheduledTimeOffId) {
96 this.lmSystemScheduledTimeOffId = lmSystemScheduledTimeOffId;
97 }
98
99 public String getLeavePlan() {
100 if(StringUtils.isNotEmpty(leavePlan)) {
101 return leavePlan;
102 }
103 if (this.earnCodeObj == null &&
104 (!StringUtils.isEmpty(this.earnCode) && getEffectiveDate() != null)) {
105 earnCodeObj = EarnCodeBo.from(HrServiceLocator.getEarnCodeService().getEarnCode(earnCode, getEffectiveLocalDate()));
106 }
107 leavePlan = (earnCodeObj != null) ? earnCodeObj.getLeavePlan() : "";
108 return leavePlan;
109 }
110
111 public void setLeavePlan(String leavePlan) {
112 this.leavePlan = leavePlan;
113 }
114
115 public String getAccrualCategory() {
116 if(StringUtils.isNotEmpty(accrualCategory)) {
117 return accrualCategory;
118 }
119 if (this.earnCodeObj == null &&
120 (!StringUtils.isEmpty(this.earnCode) && getEffectiveDate() != null)) {
121 earnCodeObj = EarnCodeBo.from(HrServiceLocator.getEarnCodeService().getEarnCode(earnCode, getEffectiveLocalDate()));
122 }
123 accrualCategory = (earnCodeObj != null) ? earnCodeObj.getAccrualCategory() : "";
124 return accrualCategory;
125 }
126
127 public void setAccrualCategory(String accrualCategory) {
128 this.accrualCategory = accrualCategory;
129 }
130
131 public Date getAccruedDate() {
132 return accruedDate;
133 }
134
135 public void setAccruedDate(Date accruedDate) {
136 this.accruedDate = accruedDate;
137 }
138
139 public LocalDate getAccruedLocalDate() {
140 return accruedDate != null ? LocalDate.fromDateFields(accruedDate) : null;
141 }
142
143 public void setAccruedLocalDate(LocalDate accruedLocalDate) {
144 this.accruedDate = accruedLocalDate != null? accruedLocalDate.toDate() : null;
145 }
146
147 public Date getScheduledTimeOffDate() {
148 return scheduledTimeOffDate;
149 }
150
151 public void setScheduledTimeOffDate(Date scheduledTimeOffDate) {
152 this.scheduledTimeOffDate = scheduledTimeOffDate;
153 }
154
155 public LocalDate getScheduledTimeOffLocalDate() {
156 return scheduledTimeOffDate != null ? LocalDate.fromDateFields(scheduledTimeOffDate) : null;
157 }
158
159 public void setScheduledTimeOffLocalDate(LocalDate scheduledTimeOffLocalDate) {
160 this.scheduledTimeOffDate = scheduledTimeOffLocalDate != null? scheduledTimeOffLocalDate.toDate() : null;
161 }
162
163 public String getLocation() {
164 return location;
165 }
166
167 public void setLocation(String location) {
168 this.location = location;
169 }
170
171 public String getDescr() {
172 return descr;
173 }
174
175 public void setDescr(String descr) {
176 this.descr = descr;
177 }
178
179 public BigDecimal getAmountofTime() {
180 return amountofTime;
181 }
182
183 public void setAmountofTime(BigDecimal amountofTime) {
184 this.amountofTime = amountofTime;
185 }
186
187 public String getUnusedTime() {
188 return unusedTime;
189 }
190
191 public void setUnusedTime(String unusedTime) {
192 this.unusedTime = unusedTime;
193 }
194
195 public BigDecimal getTransferConversionFactor() {
196 return transferConversionFactor != null ? transferConversionFactor.setScale(HrConstants.BIG_DECIMAL_SCALE) : null;
197 }
198
199 public void setTransferConversionFactor(BigDecimal transferConversionFactor) {
200 this.transferConversionFactor = transferConversionFactor;
201 }
202
203 public String getPremiumHoliday() {
204 return premiumHoliday;
205 }
206
207 public void setPremiumHoliday(String premiumHoliday) {
208 this.premiumHoliday = premiumHoliday;
209 }
210
211 public LeavePlanBo getLeavePlanObj() {
212 return leavePlanObj;
213 }
214
215 public void setLeavePlanObj(LeavePlanBo leavePlanObj) {
216 this.leavePlanObj = leavePlanObj;
217 }
218
219 public AccrualCategoryBo getAccrualCategoryObj() {
220 return accrualCategoryObj;
221 }
222
223 public void setAccrualCategoryObj(AccrualCategoryBo accrualCategoryObj) {
224 this.accrualCategoryObj = accrualCategoryObj;
225 }
226
227 public String getEarnCode() {
228 return earnCode;
229 }
230
231 public void setEarnCode(String earnCode) {
232 this.earnCode = earnCode;
233 }
234
235 public String getTransfertoEarnCode() {
236 return transfertoEarnCode;
237 }
238
239 public void setTransfertoEarnCode(String transfertoEarnCode) {
240 this.transfertoEarnCode = transfertoEarnCode;
241 }
242
243 public EarnCodeBo getEarnCodeObj() {
244 return earnCodeObj;
245 }
246
247 public void setEarnCodeObj(EarnCodeBo earnCodeObj) {
248 this.earnCodeObj = earnCodeObj;
249 }
250
251 public LocationBo getLocationObj() {
252 return locationObj;
253 }
254
255 public void setLocationObj(LocationBo locationObj) {
256 this.locationObj = locationObj;
257 }
258
259 @Override
260 protected String getUniqueKey() {
261 String lmSystemScheduledTimeOffKey = getEarnCode() +"_"+ getLeavePlan() +"_"+ getAccrualCategory();
262 return lmSystemScheduledTimeOffKey;
263 }
264
265 @Override
266 public String getId() {
267 return getLmSystemScheduledTimeOffId();
268 }
269
270 @Override
271 public void setId(String id) {
272 setLmSystemScheduledTimeOffId(id);
273 }
274
275 public EarnCodeBo getTransferToEarnCodeObj() {
276 return transferToEarnCodeObj;
277 }
278
279 public void setTransferToEarnCodeObj(EarnCodeBo transferToEarnCodeObj) {
280 this.transferToEarnCodeObj = transferToEarnCodeObj;
281 }
282
283 @Override
284 public String getPremiumEarnCode() {
285 return premiumEarnCode;
286 }
287
288 public void setPremiumEarnCode(String premiumEarnCode) {
289 this.premiumEarnCode = premiumEarnCode;
290 }
291
292 public EarnCodeBo getPremiumEarnCodeObj() {
293 return premiumEarnCodeObj;
294 }
295
296 public void setPremiumEarnCodeObj(EarnCodeBo premiumEarnCodeObj) {
297 this.premiumEarnCodeObj = premiumEarnCodeObj;
298 }
299
300 }