1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.roles;
17
18 import java.sql.Date;
19
20 import org.apache.commons.lang.builder.HashCodeBuilder;
21 import org.kuali.hr.core.KPMEConstants;
22 import org.kuali.hr.location.Location;
23 import org.kuali.hr.time.HrBusinessObject;
24 import org.kuali.hr.time.department.Department;
25 import org.kuali.hr.time.position.Position;
26 import org.kuali.hr.time.service.base.TkServiceLocator;
27 import org.kuali.hr.time.util.TKUtils;
28 import org.kuali.hr.time.workarea.WorkArea;
29 import org.kuali.kfs.coa.businessobject.Chart;
30 import org.kuali.rice.kim.api.identity.Person;
31 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
32
33 public class TkRole extends HrBusinessObject {
34
35 private static final long serialVersionUID = -2123815189941339343L;
36
37 public static final String CACHE_NAME = KPMEConstants.APPLICATION_NAMESPACE_CODE + "/" + "TkRole";
38
39 private String hrRolesId;
40 private String principalId;
41 private String roleName;
42 private String userPrincipalId;
43 private Long workArea;
44 private String department;
45 private String chart;
46 private Long hrDeptId;
47 private String positionNumber;
48 private Date expirationDate;
49
50
51
52
53
54 private transient Person person;
55 private transient Department departmentObj;
56 private transient WorkArea workAreaObj;
57 private transient Chart chartObj;
58 private transient Position positionObj;
59
60 private Location locationObj;
61
62 public Chart getChartObj() {
63 return chartObj;
64 }
65
66 public void setChartObj(Chart chartObj) {
67 this.chartObj = chartObj;
68 }
69
70 public Department getDepartmentObj() {
71 return departmentObj;
72 }
73
74 public void setDepartmentObj(Department departmentObj) {
75 this.departmentObj = departmentObj;
76 if (departmentObj != null) {
77 this.department = departmentObj.getDept();
78 this.workAreaObj= null;
79 this.workArea = null;
80 }
81 }
82
83 public WorkArea getWorkAreaObj() {
84 return workAreaObj;
85 }
86
87 public void setWorkAreaObj(WorkArea workAreaObj) {
88 this.workAreaObj = workAreaObj;
89 if (workAreaObj != null) {
90 this.workArea = workAreaObj.getWorkArea();
91 this.departmentObj = TkServiceLocator.getDepartmentService().getDepartment(workAreaObj.getDept(), TKUtils.getCurrentDate());
92 this.department = workAreaObj.getDept();
93 }
94 }
95
96 public String getHrRolesId() {
97 return hrRolesId;
98 }
99
100 public void setHrRolesId(String hrRolesId) {
101 this.hrRolesId = hrRolesId;
102 }
103
104 public String getPrincipalId() {
105 return principalId;
106 }
107
108 public void setPrincipalId(String principalId) {
109 this.principalId = principalId;
110 setPerson(KimApiServiceLocator.getPersonService().getPerson(this.principalId));
111 }
112
113 public String getRoleName() {
114 return roleName;
115 }
116
117 public void setRoleName(String roleName) {
118 this.roleName = roleName;
119 }
120
121 public String getUserPrincipalId() {
122 return userPrincipalId;
123 }
124
125 public void setUserPrincipalId(String userPrincipalId) {
126 this.userPrincipalId = userPrincipalId;
127 }
128
129 public Long getWorkArea() {
130 return workArea;
131 }
132
133 public void setWorkArea(Long workArea) {
134 this.workArea = workArea;
135 }
136
137 public String getDepartment() {
138 return department;
139 }
140
141 public void setDepartment(String department) {
142 this.department = department;
143 }
144
145 public Person getPerson() {
146 return person;
147 }
148
149 public void setPerson(Person person) {
150 this.person = person;
151 }
152
153 public Long getHrDeptId() {
154 return hrDeptId;
155 }
156
157 public void setHrDeptId(Long hrDeptId) {
158 this.hrDeptId = hrDeptId;
159 }
160
161 public String getChart() {
162 return chart;
163 }
164
165 public void setChart(String chart) {
166 this.chart = chart;
167 }
168
169
170
171
172 public String getUserName() {
173 if (person == null) {
174 person = KimApiServiceLocator.getPersonService().getPerson(this.principalId);
175 }
176
177 return (person != null) ? person.getName() : "";
178 }
179
180 public void setPositionNumber(String positionNumber) {
181 this.positionNumber = positionNumber;
182 }
183
184 public String getPositionNumber() {
185 return positionNumber;
186 }
187
188 public Date getExpirationDate() {
189 return expirationDate;
190 }
191
192 public void setExpirationDate(Date expirationDate) {
193 this.expirationDate = expirationDate;
194 }
195
196 public void setPositionObj(Position positionObj) {
197 this.positionObj = positionObj;
198 }
199
200 public Position getPositionObj() {
201 return positionObj;
202 }
203
204 @Override
205 public String getUniqueKey() {
206 return principalId + "_" + positionNumber != null ? positionNumber.toString() : "" +"_"+
207 roleName + "_" + workArea != null ? workArea.toString() : "" + "_" +
208 department + "_" + chart;
209 }
210
211 @Override
212 public String getId() {
213 return getHrRolesId();
214 }
215
216 @Override
217 public void setId(String id) {
218 setHrRolesId(id);
219 }
220
221 public Location getLocationObj() {
222 return locationObj;
223 }
224
225 public void setLocationObj(Location locationObj) {
226 this.locationObj = locationObj;
227 }
228
229 @Override
230 public int hashCode() {
231 return HashCodeBuilder.reflectionHashCode(this);
232 }
233
234 @Override
235 public boolean equals(Object o) {
236 if (this == o) return true;
237 if (o == null || getClass() != o.getClass()) return false;
238
239 TkRole tkRole = (TkRole) o;
240
241 if (chart != null ? !chart.equals(tkRole.chart) : tkRole.chart != null) return false;
242 if (chartObj != null ? !chartObj.equals(tkRole.chartObj) : tkRole.chartObj != null) return false;
243 if (department != null ? !department.equals(tkRole.department) : tkRole.department != null) return false;
244 if (departmentObj != null ? !departmentObj.equals(tkRole.departmentObj) : tkRole.departmentObj != null)
245 return false;
246 if (expirationDate != null ? !expirationDate.equals(tkRole.expirationDate) : tkRole.expirationDate != null)
247 return false;
248 if (hrDeptId != null ? !hrDeptId.equals(tkRole.hrDeptId) : tkRole.hrDeptId != null) return false;
249 if (!hrRolesId.equals(tkRole.hrRolesId)) return false;
250 if (locationObj != null ? !locationObj.equals(tkRole.locationObj) : tkRole.locationObj != null) return false;
251 if (person != null ? !person.equals(tkRole.person) : tkRole.person != null) return false;
252 if (positionNumber != null ? !positionNumber.equals(tkRole.positionNumber) : tkRole.positionNumber != null)
253 return false;
254 if (positionObj != null ? !positionObj.equals(tkRole.positionObj) : tkRole.positionObj != null) return false;
255 if (principalId != null ? !principalId.equals(tkRole.principalId) : tkRole.principalId != null) return false;
256 if (roleName != null ? !roleName.equals(tkRole.roleName) : tkRole.roleName != null) return false;
257 if (userPrincipalId != null ? !userPrincipalId.equals(tkRole.userPrincipalId) : tkRole.userPrincipalId != null)
258 return false;
259 if (workArea != null ? !workArea.equals(tkRole.workArea) : tkRole.workArea != null) return false;
260 if (workAreaObj != null ? !workAreaObj.equals(tkRole.workAreaObj) : tkRole.workAreaObj != null) return false;
261
262 return true;
263 }
264 }