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.sql.Date;
20  import java.sql.Timestamp;
21  import java.util.*;
22  
23  import org.kuali.hr.core.KPMEConstants;
24  import org.kuali.hr.time.accrual.AccrualCategory;
25  import org.kuali.hr.earncodesec.EarnCodeSecurity;
26  import org.kuali.hr.time.HrBusinessObject;
27  import org.kuali.hr.time.service.base.TkServiceLocator;
28  import org.kuali.rice.krad.service.KRADServiceLocator;
29  
30  public class EarnCode extends HrBusinessObject {
31      public static final String CACHE_NAME = KPMEConstants.APPLICATION_NAMESPACE_CODE + "/" + "EarnCode";
32      private static final String[] PRIVATE_CACHES_FOR_FLUSH = {EarnCodeSecurity.CACHE_NAME, EarnCode.CACHE_NAME};
33      public static final List<String> CACHE_FLUSH = Collections.unmodifiableList(Arrays.asList(PRIVATE_CACHES_FOR_FLUSH));
34  	/**
35       *
36       */
37  	private static final long serialVersionUID = 1L;
38  
39  	private String hrEarnCodeId;
40  	private String earnCode;
41  	private String description;
42  	
43      private Boolean ovtEarnCode;
44  	private String accrualCategory;
45  	private BigDecimal inflateMinHours;
46  	private BigDecimal inflateFactor;
47      private Long defaultAmountofTime;
48  	private boolean history;
49  
50  	private AccrualCategory accrualCategoryObj;
51  
52  	private String recordMethod;
53      
54  	public String getRecordMethod() {
55  		return recordMethod;
56  	}
57  
58  	public void setRecordMethod(String recordMethod) {
59  		this.recordMethod = recordMethod;
60  	}
61  
62  	public Long getDefaultAmountofTime() {
63  		return defaultAmountofTime;
64  	}
65  
66  	public void setDefaultAmountofTime(Long defaultAmountofTime) {
67  		this.defaultAmountofTime = defaultAmountofTime;
68  	}
69  
70  	public String getEarnCode() {
71  		return earnCode;
72  	}
73  
74  	public void setEarnCode(String earnCode) {
75  		this.earnCode = earnCode;
76  	}
77  
78  	public String getDescription() {
79  		return description;
80  	}
81  
82  	public void setDescription(String description) {
83  		this.description = description;
84  	}
85  
86  	public Date getEffectiveDate() {
87  		return effectiveDate;
88  	}
89  
90  	public void setEffectiveDate(Date effectiveDate) {
91  		this.effectiveDate = effectiveDate;
92  	}
93  
94  	public boolean isHistory() {
95  		return history;
96  	}
97  
98  	public void setHistory(boolean history) {
99  		this.history = history;
100 	}
101 
102 	public boolean isActive() {
103 		return active;
104 	}
105 
106 	public void setActive(boolean active) {
107 		this.active = active;
108 	}
109 
110 	public String getHrEarnCodeId() {
111 		return hrEarnCodeId;
112 	}
113 
114 	public void setHrEarnCodeId(String hrEarnCodeId) {
115 		this.hrEarnCodeId = hrEarnCodeId;
116 	}
117 
118 	public Timestamp getTimestamp() {
119 		return timestamp;
120 	}
121 
122 	public void setTimestamp(Timestamp timestamp) {
123 		this.timestamp = timestamp;
124 	}
125 
126 	public String getAccrualCategory() {
127 		return accrualCategory;
128 	}
129 
130 	public void setAccrualCategory(String accrualCategory) {
131 		this.accrualCategory = accrualCategory;
132 	}
133 
134 	public AccrualCategory getAccrualCategoryObj() {
135 		if(accrualCategoryObj == null && !this.getAccrualCategory().isEmpty()) {
136 			this.assingAccrualCategoryObj();
137 		}
138 		return accrualCategoryObj;
139 	}
140 	public void assingAccrualCategoryObj() {
141 		Map<String,Object> parameters = new HashMap<String,Object>();
142 		parameters.put("accrualCategory", getAccrualCategory());
143 		Collection c = KRADServiceLocator.getBusinessObjectService().findMatching(AccrualCategory.class, parameters);
144 		if(!c.isEmpty()) {
145 			this.setAccrualCategoryObj((AccrualCategory)c.toArray()[0]);
146 		}
147 	}
148 
149 	public void setAccrualCategoryObj(AccrualCategory accrualCategoryObj) {
150 		this.accrualCategoryObj = accrualCategoryObj;
151 	}
152 
153 	public BigDecimal getInflateMinHours() {
154 		return inflateMinHours;
155 	}
156 
157 	public void setInflateMinHours(BigDecimal inflateMinHours) {
158 		this.inflateMinHours = inflateMinHours;
159 	}
160 
161 	public BigDecimal getInflateFactor() {
162 		return inflateFactor;
163 	}
164 
165 	public void setInflateFactor(BigDecimal inflateFactor) {
166 		this.inflateFactor = inflateFactor;
167 	}
168 
169     public Boolean getOvtEarnCode() {
170         return ovtEarnCode;
171     }
172 
173     public void setOvtEarnCode(Boolean ovtEarnCode) {
174         this.ovtEarnCode = ovtEarnCode;
175     }
176 
177     /**
178 	 * This is used by the timeblock json object.
179 	 * 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
180 	 * @return String fieldType
181 	 */
182 	public String getEarnCodeType() {
183 //		if(getRecordHours()) {
184 //			return TkConstants.EARN_CODE_HOUR;
185 //		}
186 //		else if(getRecordTime()) {
187 //			return TkConstants.EARN_CODE_TIME;
188 //		}
189 //		else if(getRecordAmount()) {
190 //			return TkConstants.EARN_CODE_AMOUNT;
191 //		}
192 //		else {
193 //			return "";
194 //		}
195 		return this.recordMethod;
196 	}
197 
198 	@Override
199 	public String getUniqueKey() {
200 		return earnCode;
201 	}
202 
203 	@Override
204 	public String getId() {
205 		return getHrEarnCodeId();
206 	}
207 
208 	@Override
209 	public void setId(String id) {
210 		setHrEarnCodeId(id);
211 	}
212 	
213     public String getEarnCodeKeyForDisplay() {
214 //    	String unitTime = null;
215 //    	AccrualCategory acObj = null;
216 //    	if(this.accrualCategory != null) {
217 //    		acObj = TkServiceLocator.getAccrualCategoryService().getAccrualCategory(accrualCategory, this.effectiveDate);
218 //    	}
219 //    	unitTime = (acObj!= null ? acObj.getUnitOfTime() : this.recordMethod) ;
220 //        return hrEarnCodeId + ":" + unitTime;
221     	return hrEarnCodeId;
222     }
223     
224     public String getEarnCodeValueForDisplay() {
225         return earnCode + " : " + description;
226     }
227 }