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.lm.employeeoverride;
17  
18  import java.util.LinkedHashMap;
19  
20  import org.apache.commons.lang.StringUtils;
21  import org.kuali.hr.lm.accrual.AccrualCategory;
22  import org.kuali.hr.time.HrBusinessObject;
23  import org.kuali.hr.time.principal.PrincipalHRAttributes;
24  import org.kuali.hr.time.service.base.TkServiceLocator;
25  import org.kuali.rice.kim.api.identity.Person;
26  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
27  
28  public class EmployeeOverride extends HrBusinessObject {
29  
30  	private static final long serialVersionUID = 1L;
31  	
32  	private String lmEmployeeOverrideId;
33  	private String principalId;
34  	private String accrualCategory;
35  	private String leavePlan;
36  	private transient Person principal;
37  	private transient PrincipalHRAttributes principalHRAttrObj;
38  	private transient AccrualCategory accrualCategoryObj;
39  	private String overrideType;
40  	private Long overrideValue;
41  	private String description;
42  
43  	@Override
44  	public String getId() {
45  		return getLmEmployeeOverrideId();
46  	}
47  
48  	@Override
49  	protected String getUniqueKey() {
50  		return getLmEmployeeOverrideId();
51  	}
52  
53  	@Override
54  	public void setId(String id) {
55  		setLmEmployeeOverrideId(id);		
56  	}
57  
58  //	@SuppressWarnings("unchecked")
59  //	@Override
60  //	protected LinkedHashMap toStringMapper() {
61  //		LinkedHashMap<String, Object> toStringMap = new LinkedHashMap<String, Object>();
62  //		toStringMap.put("lmEmployeeOverrideId", lmEmployeeOverrideId);
63  //		toStringMap.put("principalId", principalId);
64  //		toStringMap.put("overrideType", overrideType);
65  //		toStringMap.put("accrualCategory", accrualCategory);
66  //	
67  //		return toStringMap;
68  //	}
69  
70  	public String getLmEmployeeOverrideId() {
71  		return lmEmployeeOverrideId;
72  	}
73  
74  	public void setLmEmployeeOverrideId(String lmEmployeeOverrideId) {
75  		this.lmEmployeeOverrideId = lmEmployeeOverrideId;
76  	}
77  
78  	public String getPrincipalId() {
79  		return principalId;
80  	}
81  
82  	public void setPrincipalId(String principalId) {
83  		this.principalId = principalId;
84  		this.setPrincipal(KimApiServiceLocator.getPersonService().getPerson(this.principalId));
85  	}
86  	
87  	public String getName() {
88  		if (principal == null) {
89          principal = KimApiServiceLocator.getPersonService().getPerson(this.principalId);
90  		}
91  		return (principal != null) ? principal.getName() : "";
92  	}
93  
94  	public AccrualCategory getAccrualCategoryObj() {
95  		return accrualCategoryObj;
96  	}
97  
98  	public void setAccrualCategoryObj(AccrualCategory accrualCategoryObj) {
99  		this.accrualCategoryObj = accrualCategoryObj;
100 	}
101 
102 	public String getOverrideType() {
103 		return overrideType;
104 	}
105 
106 	public void setOverrideType(String overrideType) {
107 		this.overrideType = overrideType;
108 	}
109 
110 	public String getDescription() {
111 		return description;
112 	}
113 
114 	public void setDescription(String description) {
115 		this.description = description;
116 	}
117 
118 	public String getAccrualCategory() {
119 		return accrualCategory;
120 	}
121 
122 	public void setAccrualCategory(String accrualCategory) {
123 		this.accrualCategory = accrualCategory;
124 	}
125 
126 	public String getLeavePlan() {
127         if (leavePlan != null) {
128             return leavePlan;
129         }
130 		if (this.principalHRAttrObj == null && !StringUtils.isEmpty(this.principalId)) {
131 			principalHRAttrObj = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalCalendar(principalId, this.getEffectiveDate());
132 		}
133         leavePlan = principalHRAttrObj == null ? null : principalHRAttrObj.getLeavePlan();
134 		return leavePlan;
135 	}
136 
137 	public void setLeavePlan(String leavePlan) {
138 		this.leavePlan = leavePlan;
139 	}
140 
141 	public Long getOverrideValue() {
142 		return overrideValue;
143 	}
144 
145 	public void setOverrideValue(Long overrideValue) {
146 		this.overrideValue = overrideValue;
147 	}
148 
149 	public Person getPrincipal() {
150 		return principal;
151 	}
152 
153 	public void setPrincipal(Person principal) {
154 		this.principal = principal;
155 	}
156 
157 	public PrincipalHRAttributes getPrincipalHRAttrObj() {
158 		return principalHRAttrObj;
159 	}
160 
161 	public void setPrincipalHRAttrObj(PrincipalHRAttributes principalHRAttrObj) {
162 		this.principalHRAttrObj = principalHRAttrObj;
163 	}
164 
165 }