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.kpme.tklm.leave.override;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.kpme.core.accrualcategory.AccrualCategory;
20  import org.kuali.kpme.core.bo.HrBusinessObject;
21  import org.kuali.kpme.core.principal.PrincipalHRAttributes;
22  import org.kuali.kpme.core.service.HrServiceLocator;
23  import org.kuali.kpme.tklm.api.leave.override.EmployeeOverrideContract;
24  import org.kuali.rice.kim.api.identity.Person;
25  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
26  
27  import com.google.common.collect.ImmutableList;
28  
29  public class EmployeeOverride extends HrBusinessObject implements EmployeeOverrideContract {
30  
31  	private static final long serialVersionUID = 1L;
32  	//KPME-2273/1965 Primary Business Keys List. Will be using this from now on instead.	
33  	public static final ImmutableList<String> EQUAL_TO_FIELDS = new ImmutableList.Builder<String>()
34              .add("principalId")
35              .add("leavePlan")
36              .add("accrualCategory")
37              .add("overrideType")
38              .build();
39  	
40  	private String lmEmployeeOverrideId;
41  	private String principalId;
42  	private String accrualCategory;
43  	private String leavePlan;
44  	private transient Person principal;
45  	private transient PrincipalHRAttributes principalHRAttrObj;
46  	private transient AccrualCategory accrualCategoryObj;
47  	private String overrideType;
48  	private Long overrideValue;
49  	private String description;
50  
51  	@Override
52  	public String getId() {
53  		return getLmEmployeeOverrideId();
54  	}
55  
56  	@Override
57  	protected String getUniqueKey() {
58  		return getLmEmployeeOverrideId();
59  	}
60  
61  	@Override
62  	public void setId(String id) {
63  		setLmEmployeeOverrideId(id);		
64  	}
65  
66  //	@SuppressWarnings("unchecked")
67  //	@Override
68  //	protected LinkedHashMap toStringMapper() {
69  //		LinkedHashMap<String, Object> toStringMap = new LinkedHashMap<String, Object>();
70  //		toStringMap.put("lmEmployeeOverrideId", lmEmployeeOverrideId);
71  //		toStringMap.put("principalId", principalId);
72  //		toStringMap.put("overrideType", overrideType);
73  //		toStringMap.put("accrualCategory", accrualCategory);
74  //	
75  //		return toStringMap;
76  //	}
77  
78  	public String getLmEmployeeOverrideId() {
79  		return lmEmployeeOverrideId;
80  	}
81  
82  	public void setLmEmployeeOverrideId(String lmEmployeeOverrideId) {
83  		this.lmEmployeeOverrideId = lmEmployeeOverrideId;
84  	}
85  
86  	public String getPrincipalId() {
87  		return principalId;
88  	}
89  
90  	public void setPrincipalId(String principalId) {
91  		this.principalId = principalId;
92  		this.setPrincipal(KimApiServiceLocator.getPersonService().getPerson(this.principalId));
93  	}
94  	
95  	public String getName() {
96  		if (principal == null) {
97          principal = KimApiServiceLocator.getPersonService().getPerson(this.principalId);
98  		}
99  		return (principal != null) ? principal.getName() : "";
100 	}
101 
102 	public AccrualCategory getAccrualCategoryObj() {
103 		return accrualCategoryObj;
104 	}
105 
106 	public void setAccrualCategoryObj(AccrualCategory accrualCategoryObj) {
107 		this.accrualCategoryObj = accrualCategoryObj;
108 	}
109 
110 	public String getOverrideType() {
111 		return overrideType;
112 	}
113 
114 	public void setOverrideType(String overrideType) {
115 		this.overrideType = overrideType;
116 	}
117 
118 	public String getDescription() {
119 		return description;
120 	}
121 
122 	public void setDescription(String description) {
123 		this.description = description;
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 String getLeavePlan() {
135         if (leavePlan != null) {
136             return leavePlan;
137         }
138 		if (this.principalHRAttrObj == null && !StringUtils.isEmpty(this.principalId)) {
139 			principalHRAttrObj = HrServiceLocator.getPrincipalHRAttributeService().getPrincipalCalendar(principalId, this.getEffectiveLocalDate());
140 		}
141         leavePlan = principalHRAttrObj == null ? null : principalHRAttrObj.getLeavePlan();
142 		return leavePlan;
143 	}
144 
145 	public void setLeavePlan(String leavePlan) {
146 		this.leavePlan = leavePlan;
147 	}
148 
149 	public Long getOverrideValue() {
150 		return overrideValue;
151 	}
152 
153 	public void setOverrideValue(Long overrideValue) {
154 		this.overrideValue = overrideValue;
155 	}
156 
157 	public Person getPrincipal() {
158 		return principal;
159 	}
160 
161 	public void setPrincipal(Person principal) {
162 		this.principal = principal;
163 	}
164 
165 	public PrincipalHRAttributes getPrincipalHRAttrObj() {
166 		return principalHRAttrObj;
167 	}
168 
169 	public void setPrincipalHRAttrObj(PrincipalHRAttributes principalHRAttrObj) {
170 		this.principalHRAttrObj = principalHRAttrObj;
171 	}
172 
173 }