1 | |
package org.kuali.rice.kim.api.identity.employment; |
2 | |
|
3 | |
import org.apache.commons.lang.StringUtils; |
4 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
5 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
6 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
7 | |
import org.kuali.rice.core.api.CoreConstants; |
8 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
9 | |
import org.kuali.rice.core.api.mo.ModelObjectComplete; |
10 | |
import org.kuali.rice.core.util.jaxb.KualiDecimalAdapter; |
11 | |
import org.kuali.rice.core.util.type.KualiDecimal; |
12 | |
import org.kuali.rice.kim.api.identity.Type; |
13 | |
import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliation; |
14 | |
import org.w3c.dom.Element; |
15 | |
|
16 | |
import javax.xml.bind.annotation.XmlAccessType; |
17 | |
import javax.xml.bind.annotation.XmlAccessorType; |
18 | |
import javax.xml.bind.annotation.XmlAnyElement; |
19 | |
import javax.xml.bind.annotation.XmlElement; |
20 | |
import javax.xml.bind.annotation.XmlRootElement; |
21 | |
import javax.xml.bind.annotation.XmlType; |
22 | |
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
23 | |
import java.io.Serializable; |
24 | |
import java.util.Collection; |
25 | |
|
26 | 41 | @XmlRootElement(name = EntityEmployment.Constants.ROOT_ELEMENT_NAME) |
27 | |
@XmlAccessorType(XmlAccessType.NONE) |
28 | |
@XmlType(name = EntityEmployment.Constants.TYPE_NAME, propOrder = { |
29 | |
EntityEmployment.Elements.ID, |
30 | |
EntityEmployment.Elements.ENTITY_ID, |
31 | |
EntityEmployment.Elements.EMPLOYEE_ID, |
32 | |
EntityEmployment.Elements.EMPLOYMENT_RECORD_ID, |
33 | |
EntityEmployment.Elements.ENTITY_AFFILIATION, |
34 | |
EntityEmployment.Elements.EMPLOYEE_STATUS, |
35 | |
EntityEmployment.Elements.EMPLOYEE_TYPE, |
36 | |
EntityEmployment.Elements.PRIMARY_DEPARTMENT_CODE, |
37 | |
EntityEmployment.Elements.BASE_SALARY_AMOUNT, |
38 | |
EntityEmployment.Elements.PRIMARY, |
39 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
40 | |
CoreConstants.CommonElements.OBJECT_ID, |
41 | |
EntityEmployment.Elements.ACTIVE, |
42 | |
|
43 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
44 | |
}) |
45 | 6 | public final class EntityEmployment |
46 | |
implements ModelObjectComplete, EntityEmploymentContract |
47 | |
{ |
48 | |
@XmlElement(name = Elements.ID, required = false) |
49 | |
private final String id; |
50 | |
@XmlElement(name = Elements.ENTITY_ID, required = false) |
51 | |
private final String entityId; |
52 | |
@XmlElement(name = Elements.ENTITY_AFFILIATION, required = false) |
53 | |
private final EntityAffiliation entityAffiliation; |
54 | |
@XmlElement(name = Elements.EMPLOYEE_STATUS, required = false) |
55 | |
private final Type employeeStatus; |
56 | |
@XmlElement(name = Elements.EMPLOYEE_TYPE, required = false) |
57 | |
private final Type employeeType; |
58 | |
@XmlElement(name = Elements.PRIMARY_DEPARTMENT_CODE, required = false) |
59 | |
private final String primaryDepartmentCode; |
60 | |
@XmlElement(name = Elements.EMPLOYEE_ID, required = false) |
61 | |
private final String employeeId; |
62 | |
@XmlElement(name = Elements.EMPLOYMENT_RECORD_ID, required = false) |
63 | |
private final String employmentRecordId; |
64 | |
@XmlElement(name = Elements.BASE_SALARY_AMOUNT, required = false) |
65 | |
@XmlJavaTypeAdapter(KualiDecimalAdapter.class) |
66 | |
private final KualiDecimal baseSalaryAmount; |
67 | |
@XmlElement(name = Elements.PRIMARY, required = false) |
68 | |
private final boolean primary; |
69 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
70 | |
private final Long versionNumber; |
71 | |
@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) |
72 | |
private final String objectId; |
73 | |
@XmlElement(name = Elements.ACTIVE, required = false) |
74 | |
private final boolean active; |
75 | |
|
76 | 10 | @SuppressWarnings("unused") |
77 | |
@XmlAnyElement |
78 | |
private final Collection<Element> _futureElements = null; |
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | 4 | private EntityEmployment() { |
85 | 4 | this.entityAffiliation = null; |
86 | 4 | this.employeeStatus = null; |
87 | 4 | this.employeeType = null; |
88 | 4 | this.primaryDepartmentCode = null; |
89 | 4 | this.employeeId = null; |
90 | 4 | this.employmentRecordId = null; |
91 | 4 | this.baseSalaryAmount = null; |
92 | 4 | this.primary = false; |
93 | 4 | this.versionNumber = null; |
94 | 4 | this.objectId = null; |
95 | 4 | this.active = false; |
96 | 4 | this.entityId = null; |
97 | 4 | this.id = null; |
98 | 4 | } |
99 | |
|
100 | 6 | private EntityEmployment(Builder builder) { |
101 | 6 | this.entityAffiliation = builder.getEntityAffiliation() != null ? builder.getEntityAffiliation().build() : null; |
102 | 6 | this.employeeStatus = builder.getEmployeeStatus() != null ? builder.getEmployeeStatus().build() : null; |
103 | 6 | this.employeeType = builder.getEmployeeType() != null ? builder.getEmployeeType().build() : null; |
104 | 6 | this.primaryDepartmentCode = builder.getPrimaryDepartmentCode(); |
105 | 6 | this.employeeId = builder.getEmployeeId(); |
106 | 6 | this.employmentRecordId = builder.getEmploymentRecordId(); |
107 | 6 | this.baseSalaryAmount = builder.getBaseSalaryAmount(); |
108 | 6 | this.primary = builder.isPrimary(); |
109 | 6 | this.versionNumber = builder.getVersionNumber(); |
110 | 6 | this.objectId = builder.getObjectId(); |
111 | 6 | this.active = builder.isActive(); |
112 | 6 | this.id = builder.getId(); |
113 | 6 | this.entityId = builder.getEntityId(); |
114 | 6 | } |
115 | |
|
116 | |
@Override |
117 | |
public String getEntityId() { |
118 | 4 | return this.entityId; |
119 | |
} |
120 | |
@Override |
121 | |
public EntityAffiliation getEntityAffiliation() { |
122 | 19 | return this.entityAffiliation; |
123 | |
} |
124 | |
|
125 | |
@Override |
126 | |
public Type getEmployeeStatus() { |
127 | 11 | return this.employeeStatus; |
128 | |
} |
129 | |
|
130 | |
@Override |
131 | |
public Type getEmployeeType() { |
132 | 11 | return this.employeeType; |
133 | |
} |
134 | |
|
135 | |
@Override |
136 | |
public String getPrimaryDepartmentCode() { |
137 | 4 | return this.primaryDepartmentCode; |
138 | |
} |
139 | |
|
140 | |
@Override |
141 | |
public String getEmployeeId() { |
142 | 4 | return this.employeeId; |
143 | |
} |
144 | |
|
145 | |
@Override |
146 | |
public String getEmploymentRecordId() { |
147 | 4 | return this.employmentRecordId; |
148 | |
} |
149 | |
|
150 | |
@Override |
151 | |
public KualiDecimal getBaseSalaryAmount() { |
152 | 4 | return this.baseSalaryAmount; |
153 | |
} |
154 | |
|
155 | |
@Override |
156 | |
public boolean isPrimary() { |
157 | 4 | return this.primary; |
158 | |
} |
159 | |
|
160 | |
@Override |
161 | |
public Long getVersionNumber() { |
162 | 4 | return this.versionNumber; |
163 | |
} |
164 | |
|
165 | |
@Override |
166 | |
public String getObjectId() { |
167 | 4 | return this.objectId; |
168 | |
} |
169 | |
|
170 | |
@Override |
171 | |
public boolean isActive() { |
172 | 4 | return this.active; |
173 | |
} |
174 | |
|
175 | |
@Override |
176 | |
public String getId() { |
177 | 4 | return this.id; |
178 | |
} |
179 | |
|
180 | |
@Override |
181 | |
public int hashCode() { |
182 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
183 | |
} |
184 | |
|
185 | |
@Override |
186 | |
public boolean equals(Object object) { |
187 | 5 | return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
188 | |
} |
189 | |
|
190 | |
@Override |
191 | |
public String toString() { |
192 | 0 | return ToStringBuilder.reflectionToString(this); |
193 | |
} |
194 | |
|
195 | |
|
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | 4 | public final static class Builder |
201 | |
implements Serializable, ModelBuilder, EntityEmploymentContract |
202 | |
{ |
203 | |
private String entityId; |
204 | |
private EntityAffiliation.Builder entityAffiliation; |
205 | |
private Type.Builder employeeStatus; |
206 | |
private Type.Builder employeeType; |
207 | |
private String primaryDepartmentCode; |
208 | |
private String employeeId; |
209 | |
private String employmentRecordId; |
210 | |
private KualiDecimal baseSalaryAmount; |
211 | |
private boolean primary; |
212 | |
private Long versionNumber; |
213 | |
private String objectId; |
214 | |
private boolean active; |
215 | |
private String id; |
216 | |
|
217 | 8 | private Builder() { } |
218 | |
|
219 | |
public static Builder create() { |
220 | 8 | return new Builder(); |
221 | |
} |
222 | |
|
223 | |
public static Builder create(EntityEmploymentContract contract) { |
224 | 5 | if (contract == null) { |
225 | 0 | throw new IllegalArgumentException("contract was null"); |
226 | |
} |
227 | 5 | Builder builder = create(); |
228 | 5 | builder.setEntityId(contract.getEntityId()); |
229 | 5 | if (contract.getEntityAffiliation() != null) { |
230 | 4 | builder.setEntityAffiliation(EntityAffiliation.Builder.create(contract.getEntityAffiliation())); |
231 | |
} |
232 | 5 | if (contract.getEmployeeStatus() != null) { |
233 | 4 | builder.setEmployeeStatus(Type.Builder.create(contract.getEmployeeStatus())); |
234 | |
} |
235 | 5 | if (contract.getEmployeeType() != null) { |
236 | 4 | builder.setEmployeeType(Type.Builder.create(contract.getEmployeeType())); |
237 | |
} |
238 | 5 | builder.setPrimaryDepartmentCode(contract.getPrimaryDepartmentCode()); |
239 | 5 | builder.setEmployeeId(contract.getEmployeeId()); |
240 | 5 | builder.setEmploymentRecordId(contract.getEmploymentRecordId()); |
241 | 5 | builder.setBaseSalaryAmount(contract.getBaseSalaryAmount()); |
242 | 5 | builder.setPrimary(contract.isPrimary()); |
243 | 5 | builder.setVersionNumber(contract.getVersionNumber()); |
244 | 5 | builder.setObjectId(contract.getObjectId()); |
245 | 5 | builder.setActive(contract.isActive()); |
246 | 5 | builder.setId(contract.getId()); |
247 | 5 | return builder; |
248 | |
} |
249 | |
|
250 | |
public EntityEmployment build() { |
251 | 6 | return new EntityEmployment(this); |
252 | |
} |
253 | |
|
254 | |
@Override |
255 | |
public String getEntityId() { |
256 | 6 | return this.entityId; |
257 | |
} |
258 | |
@Override |
259 | |
public EntityAffiliation.Builder getEntityAffiliation() { |
260 | 10 | return this.entityAffiliation; |
261 | |
} |
262 | |
|
263 | |
@Override |
264 | |
public Type.Builder getEmployeeStatus() { |
265 | 10 | return this.employeeStatus; |
266 | |
} |
267 | |
|
268 | |
@Override |
269 | |
public Type.Builder getEmployeeType() { |
270 | 10 | return this.employeeType; |
271 | |
} |
272 | |
|
273 | |
@Override |
274 | |
public String getPrimaryDepartmentCode() { |
275 | 6 | return this.primaryDepartmentCode; |
276 | |
} |
277 | |
|
278 | |
@Override |
279 | |
public String getEmployeeId() { |
280 | 6 | return this.employeeId; |
281 | |
} |
282 | |
|
283 | |
@Override |
284 | |
public String getEmploymentRecordId() { |
285 | 6 | return this.employmentRecordId; |
286 | |
} |
287 | |
|
288 | |
@Override |
289 | |
public KualiDecimal getBaseSalaryAmount() { |
290 | 6 | return this.baseSalaryAmount; |
291 | |
} |
292 | |
|
293 | |
@Override |
294 | |
public boolean isPrimary() { |
295 | 8 | return this.primary; |
296 | |
} |
297 | |
|
298 | |
@Override |
299 | |
public Long getVersionNumber() { |
300 | 6 | return this.versionNumber; |
301 | |
} |
302 | |
|
303 | |
@Override |
304 | |
public String getObjectId() { |
305 | 6 | return this.objectId; |
306 | |
} |
307 | |
|
308 | |
@Override |
309 | |
public boolean isActive() { |
310 | 6 | return this.active; |
311 | |
} |
312 | |
|
313 | |
@Override |
314 | |
public String getId() { |
315 | 6 | return this.id; |
316 | |
} |
317 | |
|
318 | |
public void setEntityAffiliation(EntityAffiliation.Builder entityAffiliation) { |
319 | 4 | this.entityAffiliation = entityAffiliation; |
320 | 4 | } |
321 | |
|
322 | |
public void setEmployeeStatus(Type.Builder employeeStatus) { |
323 | 4 | this.employeeStatus = employeeStatus; |
324 | 4 | } |
325 | |
|
326 | |
public void setEmployeeType(Type.Builder employeeType) { |
327 | 4 | this.employeeType = employeeType; |
328 | 4 | } |
329 | |
|
330 | |
public void setEntityId(String entityId) { |
331 | 5 | this.entityId = entityId; |
332 | 5 | } |
333 | |
|
334 | |
public void setPrimaryDepartmentCode(String primaryDepartmentCode) { |
335 | 5 | this.primaryDepartmentCode = primaryDepartmentCode; |
336 | 5 | } |
337 | |
|
338 | |
public void setEmployeeId(String employeeId) { |
339 | 5 | this.employeeId = employeeId; |
340 | 5 | } |
341 | |
|
342 | |
public void setEmploymentRecordId(String employmentRecordId) { |
343 | 5 | this.employmentRecordId = employmentRecordId; |
344 | 5 | } |
345 | |
|
346 | |
public void setBaseSalaryAmount(KualiDecimal baseSalaryAmount) { |
347 | 5 | this.baseSalaryAmount = baseSalaryAmount; |
348 | 5 | } |
349 | |
|
350 | |
public void setPrimary(boolean primary) { |
351 | 5 | this.primary = primary; |
352 | 5 | } |
353 | |
|
354 | |
public void setVersionNumber(Long versionNumber) { |
355 | 5 | this.versionNumber = versionNumber; |
356 | 5 | } |
357 | |
|
358 | |
public void setObjectId(String objectId) { |
359 | 5 | this.objectId = objectId; |
360 | 5 | } |
361 | |
|
362 | |
public void setActive(boolean active) { |
363 | 5 | this.active = active; |
364 | 5 | } |
365 | |
|
366 | |
public void setId(String id) { |
367 | 6 | if (StringUtils.isWhitespace(id)) { |
368 | 1 | throw new IllegalArgumentException("id is blank"); |
369 | |
} |
370 | 5 | this.id = id; |
371 | 5 | } |
372 | |
|
373 | |
} |
374 | |
|
375 | |
|
376 | |
|
377 | |
|
378 | |
|
379 | |
|
380 | 0 | static class Constants { |
381 | |
|
382 | |
final static String ROOT_ELEMENT_NAME = "entityEmployment"; |
383 | |
final static String TYPE_NAME = "EntityEmploymentType"; |
384 | 1 | final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS }; |
385 | |
|
386 | |
} |
387 | |
|
388 | |
|
389 | |
|
390 | |
|
391 | |
|
392 | |
|
393 | 0 | static class Elements { |
394 | |
|
395 | |
final static String ENTITY_AFFILIATION = "entityAffiliation"; |
396 | |
final static String EMPLOYEE_STATUS = "employeeStatus"; |
397 | |
final static String EMPLOYEE_TYPE = "employeeType"; |
398 | |
final static String PRIMARY_DEPARTMENT_CODE = "primaryDepartmentCode"; |
399 | |
final static String EMPLOYEE_ID = "employeeId"; |
400 | |
final static String EMPLOYMENT_RECORD_ID = "employmentRecordId"; |
401 | |
final static String BASE_SALARY_AMOUNT = "baseSalaryAmount"; |
402 | |
final static String PRIMARY = "primary"; |
403 | |
final static String ACTIVE = "active"; |
404 | |
final static String ENTITY_ID = "entityId"; |
405 | |
final static String ID = "id"; |
406 | |
|
407 | |
} |
408 | |
|
409 | |
} |