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