View Javadoc

1   /**
2    * Copyright 2004-2013 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.hr.time.earncode;
17  
18  import java.math.BigDecimal;
19  import java.util.Arrays;
20  import java.util.Collection;
21  import java.util.Collections;
22  import java.util.HashMap;
23  import java.util.List;
24  import java.util.Map;
25  
26  import org.kuali.hr.core.KPMEConstants;
27  import org.kuali.hr.lm.accrual.AccrualCategory;
28  import org.kuali.hr.lm.earncodesec.EarnCodeSecurity;
29  import org.kuali.hr.lm.leaveplan.LeavePlan;
30  import org.kuali.hr.time.HrBusinessObject;
31  import org.kuali.rice.krad.service.KRADServiceLocator;
32  
33  public class EarnCode extends HrBusinessObject {
34  
35  	private static final long serialVersionUID = -1470603919624794932L;
36  	
37  	public static final String CACHE_NAME = KPMEConstants.APPLICATION_NAMESPACE_CODE + "/" + "EarnCode";
38      private static final String[] PRIVATE_CACHES_FOR_FLUSH = {EarnCodeSecurity.CACHE_NAME, EarnCode.CACHE_NAME};
39      public static final List<String> CACHE_FLUSH = Collections.unmodifiableList(Arrays.asList(PRIVATE_CACHES_FOR_FLUSH));
40  
41  	private String hrEarnCodeId;
42  	private String earnCode;
43  	private String description;
44  	
45      private Boolean ovtEarnCode;
46  	private String accrualCategory;
47  	private BigDecimal inflateMinHours;
48  	private BigDecimal inflateFactor;
49  
50  	private boolean history;
51  
52  	private AccrualCategory accrualCategoryObj;
53  	private EarnCode rollupToEarnCodeObj;
54  	private LeavePlan leavePlanObj;
55  	
56  	private String leavePlan;
57  	private String accrualBalanceAction;
58  	private String fractionalTimeAllowed;
59  	private String roundingOption;
60  	private String eligibleForAccrual;
61  	private String affectPay;
62  	private String allowScheduledLeave;
63  	private String fmla;
64  	private String workmansComp;
65  	private Long defaultAmountofTime;
66  	private String allowNegativeAccrualBalance;
67  	private String rollupToEarnCode;
68  	private String recordMethod;
69  	private String usageLimit;
70  	
71  	public String getUsageLimit() {
72  		return usageLimit;
73  	}
74  
75  	public void setUsageLimit(String usageLimit) {
76  		this.usageLimit = usageLimit;
77  	}
78  
79  	public String getRecordMethod() {
80  		return recordMethod;
81  	}
82  
83  	public void setRecordMethod(String recordMethod) {
84  		this.recordMethod = recordMethod;
85  	}
86  
87  	public String getRollupToEarnCode() {
88  		return rollupToEarnCode;
89  	}
90  
91  	public void setRollupToEarnCode(String rollupToEarnCode) {
92  		this.rollupToEarnCode = rollupToEarnCode;
93  	}
94  
95  	public EarnCode getRollupToEarnCodeObj() {
96  		return rollupToEarnCodeObj;
97  	}
98  
99  	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 }