View Javadoc

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