1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.pm.api.positionreportgroup;
17
18 import java.io.Serializable;
19 import java.util.ArrayList;
20 import java.util.Collection;
21 import java.util.Collections;
22 import java.util.List;
23 import java.util.Set;
24 import javax.xml.bind.annotation.XmlAccessType;
25 import javax.xml.bind.annotation.XmlAccessorType;
26 import javax.xml.bind.annotation.XmlAnyElement;
27 import javax.xml.bind.annotation.XmlElement;
28 import javax.xml.bind.annotation.XmlRootElement;
29 import javax.xml.bind.annotation.XmlType;
30
31 import org.apache.commons.collections.CollectionUtils;
32 import org.apache.commons.lang.StringUtils;
33 import org.joda.time.DateTime;
34 import org.joda.time.LocalDate;
35 import org.kuali.kpme.core.api.groupkey.HrGroupKey;
36 import org.kuali.kpme.core.api.groupkey.HrGroupKeyContract;
37 import org.kuali.kpme.core.api.mo.EffectiveKey;
38 import org.kuali.kpme.core.api.mo.EffectiveKeyContract;
39 import org.kuali.rice.core.api.CoreConstants;
40 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
41 import org.kuali.rice.core.api.mo.ModelBuilder;
42 import org.kuali.rice.core.api.mo.ModelObjectUtils;
43 import org.w3c.dom.Element;
44
45 @XmlRootElement(name = PositionReportGroup.Constants.ROOT_ELEMENT_NAME)
46 @XmlAccessorType(XmlAccessType.NONE)
47 @XmlType(name = PositionReportGroup.Constants.TYPE_NAME, propOrder = {
48 PositionReportGroup.Elements.PM_POSITION_REPORT_GROUP_ID,
49 PositionReportGroup.Elements.EFFECTIVE_KEY_SET,
50 PositionReportGroup.Elements.DESCRIPTION,
51 PositionReportGroup.Elements.POSITION_REPORT_GROUP,
52 CoreConstants.CommonElements.VERSION_NUMBER,
53 CoreConstants.CommonElements.OBJECT_ID,
54 PositionReportGroup.Elements.ACTIVE,
55 PositionReportGroup.Elements.ID,
56 PositionReportGroup.Elements.EFFECTIVE_LOCAL_DATE,
57 PositionReportGroup.Elements.CREATE_TIME,
58 PositionReportGroup.Elements.USER_PRINCIPAL_ID,
59 PositionReportGroup.Elements.GROUP_KEY_CODE_SET,
60 PositionReportGroup.Elements.GROUP_KEY_SET,
61 CoreConstants.CommonElements.FUTURE_ELEMENTS
62 })
63 public final class PositionReportGroup extends AbstractDataTransferObject implements PositionReportGroupContract {
64
65 private static final long serialVersionUID = -41287964136831033L;
66
67 @XmlElement(name = Elements.PM_POSITION_REPORT_GROUP_ID, required = false)
68 private final String pmPositionReportGroupId;
69 @XmlElement(name = Elements.EFFECTIVE_KEY_SET, required = false)
70 private final Set<EffectiveKey> effectiveKeySet;
71 @XmlElement(name = Elements.DESCRIPTION, required = false)
72 private final String description;
73 @XmlElement(name = Elements.POSITION_REPORT_GROUP, required = false)
74 private final String positionReportGroup;
75 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
76 private final Long versionNumber;
77 @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
78 private final String objectId;
79 @XmlElement(name = Elements.ACTIVE, required = false)
80 private final boolean active;
81 @XmlElement(name = Elements.ID, required = false)
82 private final String id;
83 @XmlElement(name = Elements.EFFECTIVE_LOCAL_DATE, required = false)
84 private final LocalDate effectiveLocalDate;
85 @XmlElement(name = Elements.CREATE_TIME, required = false)
86 private final DateTime createTime;
87 @XmlElement(name = Elements.USER_PRINCIPAL_ID, required = false)
88 private final String userPrincipalId;
89 @XmlElement(name = Elements.GROUP_KEY_CODE_SET, required = false)
90 private final Set<String> groupKeyCodeSet;
91 @XmlElement(name = Elements.GROUP_KEY_SET, required = false)
92 private final Set<HrGroupKey> groupKeySet;
93 @XmlAnyElement
94 private final Collection<Element> _futureElements = null;
95
96
97
98
99
100 private PositionReportGroup() {
101 this.pmPositionReportGroupId = null;
102 this.effectiveKeySet = null;
103 this.description = null;
104 this.positionReportGroup = null;
105 this.versionNumber = null;
106 this.objectId = null;
107 this.active = false;
108 this.id = null;
109 this.effectiveLocalDate = null;
110 this.createTime = null;
111 this.userPrincipalId = null;
112 this.groupKeyCodeSet = null;
113 this.groupKeySet = null;
114 }
115
116 private PositionReportGroup(Builder builder) {
117 this.pmPositionReportGroupId = builder.getPmPositionReportGroupId();
118 this.effectiveKeySet = ModelObjectUtils.<EffectiveKey>buildImmutableCopy(builder.getEffectiveKeySet());
119 this.description = builder.getDescription();
120 this.positionReportGroup = builder.getPositionReportGroup();
121 this.versionNumber = builder.getVersionNumber();
122 this.objectId = builder.getObjectId();
123 this.active = builder.isActive();
124 this.id = builder.getId();
125 this.effectiveLocalDate = builder.getEffectiveLocalDate();
126 this.createTime = builder.getCreateTime();
127 this.userPrincipalId = builder.getUserPrincipalId();
128 this.groupKeyCodeSet = builder.getGroupKeyCodeSet();
129 this.groupKeySet = ModelObjectUtils.<HrGroupKey>buildImmutableCopy(builder.getGroupKeySet());
130 }
131
132 @Override
133 public String getPmPositionReportGroupId() {
134 return this.pmPositionReportGroupId;
135 }
136
137 @Override
138 public Set<EffectiveKey> getEffectiveKeySet() {
139 return this.effectiveKeySet;
140 }
141
142
143 public List<EffectiveKey> getEffectiveKeyList() {
144 if (CollectionUtils.isEmpty(this.effectiveKeySet)) {
145 return Collections.emptyList();
146 }
147 List<EffectiveKey> copy = new ArrayList<EffectiveKey>();
148 for (EffectiveKey key : this.effectiveKeySet) {
149 copy.add(key);
150 }
151 return Collections.unmodifiableList(copy);
152 }
153
154 @Override
155 public String getDescription() {
156 return this.description;
157 }
158
159 @Override
160 public String getPositionReportGroup() {
161 return this.positionReportGroup;
162 }
163
164 @Override
165 public Long getVersionNumber() {
166 return this.versionNumber;
167 }
168
169 @Override
170 public String getObjectId() {
171 return this.objectId;
172 }
173
174 @Override
175 public boolean isActive() {
176 return this.active;
177 }
178
179 @Override
180 public String getId() {
181 return this.id;
182 }
183
184 @Override
185 public LocalDate getEffectiveLocalDate() {
186 return this.effectiveLocalDate;
187 }
188
189 @Override
190 public DateTime getCreateTime() {
191 return this.createTime;
192 }
193
194 @Override
195 public String getUserPrincipalId() {
196 return this.userPrincipalId;
197 }
198
199 @Override
200 public Set<String> getGroupKeyCodeSet() {
201 return this.groupKeyCodeSet;
202 }
203
204 @Override
205 public Set<HrGroupKey> getGroupKeySet() {
206 return this.groupKeySet;
207 }
208
209
210
211
212
213
214 public final static class Builder implements Serializable, PositionReportGroupContract, ModelBuilder {
215
216 private static final long serialVersionUID = 6845448497862211410L;
217
218 private String pmPositionReportGroupId;
219 private Set<EffectiveKey.Builder> effectiveKeySet;
220 private String description;
221 private String positionReportGroup;
222 private Long versionNumber;
223 private String objectId;
224 private boolean active;
225 private String id;
226 private LocalDate effectiveLocalDate;
227 private DateTime createTime;
228 private String userPrincipalId;
229 private Set<String> groupKeyCodeSet;
230 private Set<HrGroupKey.Builder> groupKeySet;
231
232 private static final ModelObjectUtils.Transformer<EffectiveKeyContract, EffectiveKey.Builder> toEffectiveKeyBuilder
233 = new ModelObjectUtils.Transformer<EffectiveKeyContract, EffectiveKey.Builder>() {
234 public EffectiveKey.Builder transform(EffectiveKeyContract input) {
235 return EffectiveKey.Builder.create(input);
236 }
237 };
238
239 private static final ModelObjectUtils.Transformer<HrGroupKeyContract, HrGroupKey.Builder> toHrGroupKeyBuilder
240 = new ModelObjectUtils.Transformer<HrGroupKeyContract, HrGroupKey.Builder>() {
241 public HrGroupKey.Builder transform(HrGroupKeyContract input) {
242 return HrGroupKey.Builder.create(input);
243 }
244 };
245
246 private Builder(String positionReportGroup) {
247
248 setPositionReportGroup(positionReportGroup);
249 }
250
251 public static Builder create(String positionReportGroup) {
252
253 return new Builder(positionReportGroup);
254 }
255
256 public static Builder create(PositionReportGroupContract contract) {
257 if (contract == null) {
258 throw new IllegalArgumentException("contract was null");
259 }
260
261 Builder builder = create(contract.getPositionReportGroup());
262 builder.setPmPositionReportGroupId(contract.getPmPositionReportGroupId());
263 builder.setEffectiveKeySet(ModelObjectUtils.transformSet(contract.getEffectiveKeySet(), toEffectiveKeyBuilder));
264 builder.setDescription(contract.getDescription());
265 builder.setVersionNumber(contract.getVersionNumber());
266 builder.setObjectId(contract.getObjectId());
267 builder.setActive(contract.isActive());
268 builder.setId(contract.getId());
269 builder.setEffectiveLocalDate(contract.getEffectiveLocalDate());
270 builder.setCreateTime(contract.getCreateTime());
271 builder.setUserPrincipalId(contract.getUserPrincipalId());
272 builder.setGroupKeyCodeSet(contract.getGroupKeyCodeSet());
273 builder.setGroupKeySet(ModelObjectUtils.transformSet(contract.getGroupKeySet(), toHrGroupKeyBuilder));
274 return builder;
275 }
276
277 public PositionReportGroup build() {
278 return new PositionReportGroup(this);
279 }
280
281 @Override
282 public String getPmPositionReportGroupId() {
283 return this.pmPositionReportGroupId;
284 }
285
286 @Override
287 public Set<EffectiveKey.Builder> getEffectiveKeySet() {
288 return this.effectiveKeySet;
289 }
290
291 @Override
292 public String getDescription() {
293 return this.description;
294 }
295
296 @Override
297 public String getPositionReportGroup() {
298 return this.positionReportGroup;
299 }
300
301 @Override
302 public Long getVersionNumber() {
303 return this.versionNumber;
304 }
305
306 @Override
307 public String getObjectId() {
308 return this.objectId;
309 }
310
311 @Override
312 public boolean isActive() {
313 return this.active;
314 }
315
316 @Override
317 public String getId() {
318 return this.id;
319 }
320
321 @Override
322 public LocalDate getEffectiveLocalDate() {
323 return this.effectiveLocalDate;
324 }
325
326 @Override
327 public DateTime getCreateTime() {
328 return this.createTime;
329 }
330
331 @Override
332 public String getUserPrincipalId() {
333 return this.userPrincipalId;
334 }
335
336 @Override
337 public Set<String> getGroupKeyCodeSet() {
338 return this.groupKeyCodeSet;
339 }
340
341 @Override
342 public Set<HrGroupKey.Builder> getGroupKeySet() {
343 return this.groupKeySet;
344 }
345
346 public void setPmPositionReportGroupId(String pmPositionReportGroupId) {
347
348 this.pmPositionReportGroupId = pmPositionReportGroupId;
349 }
350
351 public void setEffectiveKeySet(Set<EffectiveKey.Builder> effectiveKeySet) {
352
353 this.effectiveKeySet = effectiveKeySet;
354 }
355
356 public void setDescription(String description) {
357
358 this.description = description;
359 }
360
361 public void setPositionReportGroup(String positionReportGroup) {
362
363 if (StringUtils.isWhitespace(positionReportGroup) || (positionReportGroup == null)) {
364 throw new IllegalArgumentException("positionReportGroup is blank");
365 }
366 this.positionReportGroup = positionReportGroup;
367 }
368
369 public void setVersionNumber(Long versionNumber) {
370
371 this.versionNumber = versionNumber;
372 }
373
374 public void setObjectId(String objectId) {
375
376 this.objectId = objectId;
377 }
378
379 public void setActive(boolean active) {
380
381 this.active = active;
382 }
383
384 public void setId(String id) {
385
386 this.id = id;
387 }
388
389 public void setEffectiveLocalDate(LocalDate effectiveLocalDate) {
390
391 this.effectiveLocalDate = effectiveLocalDate;
392 }
393
394 public void setCreateTime(DateTime createTime) {
395
396 this.createTime = createTime;
397 }
398
399 public void setUserPrincipalId(String userPrincipalId) {
400
401 this.userPrincipalId = userPrincipalId;
402 }
403
404 public void setGroupKeyCodeSet(Set<String> groupKeyCodeSet) {
405
406 this.groupKeyCodeSet = groupKeyCodeSet;
407 }
408
409 public void setGroupKeySet(Set<HrGroupKey.Builder> groupKeySet) {
410
411 this.groupKeySet = groupKeySet;
412 }
413
414 }
415
416
417
418
419
420
421 static class Constants {
422
423 final static String ROOT_ELEMENT_NAME = "positionReportGroup";
424 final static String TYPE_NAME = "PositionReportGroupType";
425
426 }
427
428
429
430
431
432
433 static class Elements {
434
435 final static String PM_POSITION_REPORT_GROUP_ID = "pmPositionReportGroupId";
436 final static String EFFECTIVE_KEY_SET = "effectiveKeySet";
437 final static String DESCRIPTION = "description";
438 final static String POSITION_REPORT_GROUP = "positionReportGroup";
439 final static String ACTIVE = "active";
440 final static String ID = "id";
441 final static String EFFECTIVE_LOCAL_DATE = "effectiveLocalDate";
442 final static String CREATE_TIME = "createTime";
443 final static String USER_PRINCIPAL_ID = "userPrincipalId";
444 final static String GROUP_KEY_CODE_SET = "groupKeyCodeSet";
445 final static String GROUP_KEY_SET = "groupKeySet";
446
447 }
448
449 }