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.time.earncode;
017
018 import java.math.BigDecimal;
019 import java.util.Arrays;
020 import java.util.Collection;
021 import java.util.Collections;
022 import java.util.HashMap;
023 import java.util.List;
024 import java.util.Map;
025
026 import org.kuali.hr.core.KPMEConstants;
027 import org.kuali.hr.lm.accrual.AccrualCategory;
028 import org.kuali.hr.lm.earncodesec.EarnCodeSecurity;
029 import org.kuali.hr.lm.leaveplan.LeavePlan;
030 import org.kuali.hr.time.HrBusinessObject;
031 import org.kuali.rice.krad.service.KRADServiceLocator;
032
033 public class EarnCode extends HrBusinessObject {
034
035 private static final long serialVersionUID = -1470603919624794932L;
036
037 public static final String CACHE_NAME = KPMEConstants.APPLICATION_NAMESPACE_CODE + "/" + "EarnCode";
038 private static final String[] PRIVATE_CACHES_FOR_FLUSH = {EarnCodeSecurity.CACHE_NAME, EarnCode.CACHE_NAME};
039 public static final List<String> CACHE_FLUSH = Collections.unmodifiableList(Arrays.asList(PRIVATE_CACHES_FOR_FLUSH));
040
041 private String hrEarnCodeId;
042 private String earnCode;
043 private String description;
044
045 private Boolean ovtEarnCode;
046 private String accrualCategory;
047 private BigDecimal inflateMinHours;
048 private BigDecimal inflateFactor;
049
050 private boolean history;
051
052 private AccrualCategory accrualCategoryObj;
053 private EarnCode rollupToEarnCodeObj;
054 private LeavePlan leavePlanObj;
055
056 private String leavePlan;
057 private String accrualBalanceAction;
058 private String fractionalTimeAllowed;
059 private String roundingOption;
060 private String eligibleForAccrual;
061 private String affectPay;
062 private String allowScheduledLeave;
063 private String fmla;
064 private String workmansComp;
065 private Long defaultAmountofTime;
066 private String allowNegativeAccrualBalance;
067 private String rollupToEarnCode;
068 private String recordMethod;
069 private String usageLimit;
070
071 public String getUsageLimit() {
072 return usageLimit;
073 }
074
075 public void setUsageLimit(String usageLimit) {
076 this.usageLimit = usageLimit;
077 }
078
079 public String getRecordMethod() {
080 return recordMethod;
081 }
082
083 public void setRecordMethod(String recordMethod) {
084 this.recordMethod = recordMethod;
085 }
086
087 public String getRollupToEarnCode() {
088 return rollupToEarnCode;
089 }
090
091 public void setRollupToEarnCode(String rollupToEarnCode) {
092 this.rollupToEarnCode = rollupToEarnCode;
093 }
094
095 public EarnCode getRollupToEarnCodeObj() {
096 return rollupToEarnCodeObj;
097 }
098
099 public void setRollupToEarnCodeObj(EarnCode rollupToEarnCodeObj) {
100 this.rollupToEarnCodeObj = rollupToEarnCodeObj;
101 }
102
103 public String getLeavePlan() {
104 // AccrualCategory myAccrualCategoryObj = new AccrualCategory();
105 // if(this.accrualCategory != null) {
106 // myAccrualCategoryObj = TkServiceLocator.getAccrualCategoryService().getAccrualCategory(accrualCategory, getEffectiveDate());
107 // }
108 // this.leavePlan =(myAccrualCategoryObj != null) ? myAccrualCategoryObj.getLeavePlan() : "";
109 return leavePlan;
110 }
111
112 public void setLeavePlan(String leavePlan) {
113 this.leavePlan = leavePlan;
114 }
115
116 public String getAccrualBalanceAction() {
117 return accrualBalanceAction;
118 }
119
120 public void setAccrualBalanceAction(String accrualBalanceAction) {
121 this.accrualBalanceAction = accrualBalanceAction;
122 }
123
124 public String getFractionalTimeAllowed() {
125 return fractionalTimeAllowed;
126 }
127
128 public void setFractionalTimeAllowed(String fractionalTimeAllowed) {
129 this.fractionalTimeAllowed = fractionalTimeAllowed;
130 }
131
132 public String getRoundingOption() {
133 return roundingOption;
134 }
135
136 public void setRoundingOption(String roundingOption) {
137 this.roundingOption = roundingOption;
138 }
139
140 public String getEligibleForAccrual() {
141 return eligibleForAccrual;
142 }
143
144 public void setEligibleForAccrual(String eligibleForAccrual) {
145 this.eligibleForAccrual = eligibleForAccrual;
146 }
147
148 public String getAffectPay() {
149 return affectPay;
150 }
151
152 public void setAffectPay(String affectPay) {
153 this.affectPay = affectPay;
154 }
155
156 public String getAllowScheduledLeave() {
157 return allowScheduledLeave;
158 }
159
160 public void setAllowScheduledLeave(String allowScheduledLeave) {
161 this.allowScheduledLeave = allowScheduledLeave;
162 }
163
164 public String getFmla() {
165 return fmla;
166 }
167
168 public void setFmla(String fmla) {
169 this.fmla = fmla;
170 }
171
172 public String getWorkmansComp() {
173 return workmansComp;
174 }
175
176 public void setWorkmansComp(String workmansComp) {
177 this.workmansComp = workmansComp;
178 }
179
180 public Long getDefaultAmountofTime() {
181 return defaultAmountofTime;
182 }
183
184 public void setDefaultAmountofTime(Long defaultAmountofTime) {
185 this.defaultAmountofTime = defaultAmountofTime;
186 }
187
188 public String getAllowNegativeAccrualBalance() {
189 return allowNegativeAccrualBalance;
190 }
191
192 public void setAllowNegativeAccrualBalance(String allowNegativeAccrualBalance) {
193 this.allowNegativeAccrualBalance = allowNegativeAccrualBalance;
194 }
195
196
197 public String getEarnCode() {
198 return earnCode;
199 }
200
201 public void setEarnCode(String earnCode) {
202 this.earnCode = earnCode;
203 }
204
205 public String getDescription() {
206 return description;
207 }
208
209 public void setDescription(String description) {
210 this.description = description;
211 }
212
213 public boolean isHistory() {
214 return history;
215 }
216
217 public void setHistory(boolean history) {
218 this.history = history;
219 }
220
221 public String getHrEarnCodeId() {
222 return hrEarnCodeId;
223 }
224
225 public void setHrEarnCodeId(String hrEarnCodeId) {
226 this.hrEarnCodeId = hrEarnCodeId;
227 }
228
229 public String getAccrualCategory() {
230 return accrualCategory;
231 }
232
233 public void setAccrualCategory(String accrualCategory) {
234 this.accrualCategory = accrualCategory;
235 }
236
237 public AccrualCategory getAccrualCategoryObj() {
238 if(accrualCategoryObj == null && !this.getAccrualCategory().isEmpty()) {
239 this.assingAccrualCategoryObj();
240 }
241 return accrualCategoryObj;
242 }
243 public void assingAccrualCategoryObj() {
244 Map<String,Object> parameters = new HashMap<String,Object>();
245 parameters.put("accrualCategory", getAccrualCategory());
246 Collection c = KRADServiceLocator.getBusinessObjectService().findMatching(AccrualCategory.class, parameters);
247 if(!c.isEmpty()) {
248 this.setAccrualCategoryObj((AccrualCategory)c.toArray()[0]);
249 }
250 }
251
252 public void setAccrualCategoryObj(AccrualCategory accrualCategoryObj) {
253 this.accrualCategoryObj = accrualCategoryObj;
254 }
255
256 public BigDecimal getInflateMinHours() {
257 return inflateMinHours;
258 }
259
260 public void setInflateMinHours(BigDecimal inflateMinHours) {
261 this.inflateMinHours = inflateMinHours;
262 }
263
264 public BigDecimal getInflateFactor() {
265 return inflateFactor;
266 }
267
268 public void setInflateFactor(BigDecimal inflateFactor) {
269 this.inflateFactor = inflateFactor;
270 }
271
272 public Boolean getOvtEarnCode() {
273 return ovtEarnCode;
274 }
275
276 public void setOvtEarnCode(Boolean ovtEarnCode) {
277 this.ovtEarnCode = ovtEarnCode;
278 }
279
280 /**
281 * This is used by the timeblock json object.
282 * The purpose of this function is to create a string based on the record_* fields which can be used to render hour / begin(end) time input box
283 * @return String fieldType
284 */
285 public String getEarnCodeType() {
286 // if(getRecordHours()) {
287 // return TkConstants.EARN_CODE_HOUR;
288 // }
289 // else if(getRecordTime()) {
290 // return TkConstants.EARN_CODE_TIME;
291 // }
292 // else if(getRecordAmount()) {
293 // return TkConstants.EARN_CODE_AMOUNT;
294 // }
295 // else {
296 // return "";
297 // }
298 return this.recordMethod;
299 }
300
301 @Override
302 public String getUniqueKey() {
303 return earnCode;
304 }
305
306 @Override
307 public String getId() {
308 return getHrEarnCodeId();
309 }
310
311 @Override
312 public void setId(String id) {
313 setHrEarnCodeId(id);
314 }
315
316 public String getEarnCodeKeyForDisplay() {
317 // String unitTime = null;
318 // AccrualCategory acObj = null;
319 // if(this.accrualCategory != null) {
320 // acObj = TkServiceLocator.getAccrualCategoryService().getAccrualCategory(accrualCategory, this.effectiveDate);
321 // }
322 // unitTime = (acObj!= null ? acObj.getUnitOfTime() : this.recordMethod) ;
323 // return hrEarnCodeId + ":" + unitTime;
324 return hrEarnCodeId;
325 }
326
327 public String getEarnCodeValueForDisplay() {
328 return earnCode + " : " + description;
329 }
330
331 public LeavePlan getLeavePlanObj() {
332 return leavePlanObj;
333 }
334
335 public void setLeavePlanObj(LeavePlan leavePlanObj) {
336 this.leavePlanObj = leavePlanObj;
337 }
338
339 }