001 /**
002 * Copyright 2004-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.hr.lm.leavecode;
017
018 import org.apache.commons.lang.StringUtils;
019 import org.kuali.hr.core.KPMEConstants;
020 import org.kuali.hr.lm.accrual.AccrualCategory;
021 import org.kuali.hr.lm.leaveplan.LeavePlan;
022 import org.kuali.hr.time.HrBusinessObject;
023 import org.kuali.hr.time.earncode.EarnCode;
024 import org.kuali.hr.time.service.base.TkServiceLocator;
025
026 public class LeaveCode extends HrBusinessObject {
027
028 private static final long serialVersionUID = -759700327943760962L;
029
030 public static final String CACHE_NAME = KPMEConstants.APPLICATION_NAMESPACE_CODE + "/" + "LeaveCode";
031
032 private String lmLeaveCodeId;
033 private String leavePlan;
034 private String eligibleForAccrual;
035 private String affectPay; // kpme1464, chen
036 private String accrualCategory;
037 private String earnCode;
038 private String leaveCode;
039 private String displayName;
040 private String unitOfTime;
041 private String fractionalTimeAllowed;
042 private String roundingOption;
043 private String allowScheduledLeave;
044 private String fmla;
045 private String workmansComp;
046 private Long defaultAmountofTime;
047 private Boolean employee;
048 private Boolean approver;
049 private Boolean departmentAdmin;
050 private String allowNegativeAccrualBalance;
051 private Boolean history;
052
053 private LeavePlan leavePlanObj;
054 private EarnCode earnCodeObj;
055 private AccrualCategory accrualCategoryObj;
056
057 public String getAffectPay() {
058 return affectPay;
059 }
060
061 public void setAffectPay(String affectPay) {
062 this.affectPay = affectPay;
063 }
064
065 public EarnCode getEarnCodeObj() {
066 return earnCodeObj;
067 }
068
069 public void setEarnCodeObj(EarnCode earnCodeObj) {
070 this.earnCodeObj = earnCodeObj;
071 }
072
073 public AccrualCategory getAccrualCategoryObj() {
074 return accrualCategoryObj;
075 }
076
077 public void setAccrualCategoryObj(AccrualCategory accrualCategoryObj) {
078 this.accrualCategoryObj = accrualCategoryObj;
079 }
080
081 public LeavePlan getLeavePlanObj() {
082 return leavePlanObj;
083 }
084
085 public void setLeavePlanObj(LeavePlan leavePlanObj) {
086 this.leavePlanObj = leavePlanObj;
087 }
088
089 public String getLmLeaveCodeId() {
090 return lmLeaveCodeId;
091 }
092
093 public void setLmLeaveCodeId(String lmLeaveCodeId) {
094 this.lmLeaveCodeId = lmLeaveCodeId;
095 }
096
097 //KPME 1453 and 1541 moved pre-existing logic for getLeavePlan to else clause below and removed side effect of setting AccrualCategoryObj on BO
098 public String getLeavePlan() {
099 if (StringUtils.isNotEmpty(this.leavePlan)) {
100 return leavePlan;
101 }else{
102 AccrualCategory myAccrualCategoryObj = new AccrualCategory();
103 if (!StringUtils.isEmpty(this.accrualCategory) && getEffectiveDate() != null) {
104
105 myAccrualCategoryObj = TkServiceLocator.getAccrualCategoryService().getAccrualCategory(accrualCategory, getEffectiveDate());
106
107 }
108 return (myAccrualCategoryObj != null) ? myAccrualCategoryObj.getLeavePlan() : "";
109 }
110 }
111
112 public void setLeavePlan(String leavePlan) {
113 this.leavePlan = leavePlan;
114 }
115
116 public String getEligibleForAccrual() {
117 return eligibleForAccrual;
118 }
119
120 public void setEligibleForAccrual(String eligibleForAccrual) {
121 this.eligibleForAccrual = eligibleForAccrual;
122 }
123
124 public String getAccrualCategory() {
125 return accrualCategory;
126 }
127
128 public void setAccrualCategory(String accrualCategory) {
129 this.accrualCategory = accrualCategory;
130 }
131
132 public String getEarnCode() {
133 return earnCode;
134 }
135
136 public void setEarnCode(String earnCode) {
137 this.earnCode = earnCode;
138 }
139
140 public String getLeaveCode() {
141 return leaveCode;
142 }
143
144 public void setLeaveCode(String leaveCode) {
145 this.leaveCode = leaveCode;
146 }
147
148 public String getDisplayName() {
149 return displayName;
150 }
151
152 public void setDisplayName(String displayName) {
153 this.displayName = displayName;
154 }
155
156 public String getUnitOfTime() {
157 return unitOfTime;
158 }
159
160 public void setUnitOfTime(String unitOfTime) {
161 this.unitOfTime = unitOfTime;
162 }
163
164 public String getFractionalTimeAllowed() {
165 return fractionalTimeAllowed;
166 }
167
168 public void setFractionalTimeAllowed(String fractionalTimeAllowed) {
169 this.fractionalTimeAllowed = fractionalTimeAllowed;
170 }
171
172 public String getRoundingOption() {
173 return roundingOption;
174 }
175
176 public void setRoundingOption(String roundingOption) {
177 this.roundingOption = roundingOption;
178 }
179
180 public String getAllowScheduledLeave() {
181 return allowScheduledLeave;
182 }
183
184 public void setAllowScheduledLeave(String allowScheduledLeave) {
185 this.allowScheduledLeave = allowScheduledLeave;
186 }
187
188 public String getFmla() {
189 return fmla;
190 }
191
192 public void setFmla(String fmla) {
193 this.fmla = fmla;
194 }
195
196 public String getWorkmansComp() {
197 return workmansComp;
198 }
199
200 public void setWorkmansComp(String workmansComp) {
201 this.workmansComp = workmansComp;
202 }
203
204 public Long getDefaultAmountofTime() {
205 return defaultAmountofTime;
206 }
207
208 public void setDefaultAmountofTime(Long defaultAmountofTime) {
209 this.defaultAmountofTime = defaultAmountofTime;
210 }
211
212 public Boolean getEmployee() {
213 return employee;
214 }
215
216 public void setEmployee(Boolean employee) {
217 this.employee = employee;
218 }
219
220 public Boolean getApprover() {
221 return approver;
222 }
223
224 public void setApprover(Boolean approver) {
225 this.approver = approver;
226 }
227
228 public Boolean getDepartmentAdmin() {
229 return departmentAdmin;
230 }
231
232 public void setDepartmentAdmin(Boolean departmentAdmin) {
233 this.departmentAdmin = departmentAdmin;
234 }
235
236 public Boolean getHistory() {
237 return history;
238 }
239
240 public void setHistory(Boolean history) {
241 this.history = history;
242 }
243
244 @Override
245 protected String getUniqueKey() {
246 String leaveCodeKey = getLeaveCode() +"_"+ getLeavePlan() +"_"+ getAccrualCategory() +"_"+ getEarnCode();
247 return leaveCodeKey;
248 }
249
250 @Override
251 public String getId() {
252 return getLmLeaveCodeId();
253 }
254
255 public String getLeaveCodeKeyForDisplay() {
256 // String unitTime = null;
257 // AccrualCategory acObj = null;
258 // if(this.accrualCategory != null) {
259 // acObj = TkServiceLocator.getAccrualCategoryService().getAccrualCategory(accrualCategory, TKUtils.getCurrentDate());
260 // }
261 // unitTime = (acObj!= null ? acObj.getUnitOfTime() : unitOfTime) ;
262 // return lmLeaveCodeId + ":" +unitTime;
263 return lmLeaveCodeId;
264 }
265
266 public String getLeaveCodeValueForDisplay() {
267 return leaveCode + " : " + displayName;
268 }
269
270 @Override
271 public void setId(String id) {
272 setLmLeaveCodeId(id);
273 }
274
275 public String getAllowNegativeAccrualBalance() {
276 return allowNegativeAccrualBalance;
277 }
278
279 public void setAllowNegativeAccrualBalance(String allowNegativeAccrualBalance) {
280 this.allowNegativeAccrualBalance = allowNegativeAccrualBalance;
281 }
282 }