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