1 package org.kuali.rice.kim.api.identity.personal;
2
3 import java.io.Serializable;
4 import java.util.ArrayList;
5 import java.util.Collection;
6 import java.util.Collections;
7 import java.util.HashSet;
8 import java.util.List;
9 import java.util.Set;
10 import javax.xml.bind.annotation.XmlAccessType;
11 import javax.xml.bind.annotation.XmlAccessorType;
12 import javax.xml.bind.annotation.XmlAnyElement;
13 import javax.xml.bind.annotation.XmlElement;
14 import javax.xml.bind.annotation.XmlElementWrapper;
15 import javax.xml.bind.annotation.XmlRootElement;
16 import javax.xml.bind.annotation.XmlType;
17
18 import org.apache.commons.collections.CollectionUtils;
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.rice.core.api.CoreConstants;
21 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
22 import org.kuali.rice.core.api.mo.ModelBuilder;
23 import org.kuali.rice.kim.api.identity.CodedAttribute;
24 import org.kuali.rice.kim.api.identity.CodedAttributeContract;
25 import org.w3c.dom.Element;
26
27 @XmlRootElement(name = EntityDisability.Constants.ROOT_ELEMENT_NAME)
28 @XmlAccessorType(XmlAccessType.NONE)
29 @XmlType(name = EntityDisability.Constants.TYPE_NAME, propOrder = {
30 EntityDisability.Elements.ID,
31 EntityDisability.Elements.ENTITY_ID,
32 EntityDisability.Elements.STATUS_CODE,
33 EntityDisability.Elements.DETERMINATION_SOURCE_TYPE,
34 EntityDisability.Elements.ACCOMMODATIONS_NEEDED,
35 EntityDisability.Elements.CONDITION_TYPE,
36 CoreConstants.CommonElements.ACTIVE,
37 CoreConstants.CommonElements.VERSION_NUMBER,
38 CoreConstants.CommonElements.OBJECT_ID,
39 CoreConstants.CommonElements.FUTURE_ELEMENTS
40 })
41 public final class EntityDisability
42 extends AbstractDataTransferObject
43 implements EntityDisabilityContract
44 {
45
46 @XmlElement(name = Elements.STATUS_CODE, required = false)
47 private final String statusCode;
48 @XmlElement(name = Elements.DETERMINATION_SOURCE_TYPE, required = false)
49 private final CodedAttribute determinationSourceType;
50 @XmlElementWrapper(name = Elements.ACCOMMODATIONS_NEEDED, required = false)
51 @XmlElement(name = Elements.ACCOMMODATION_NEEDED, required = false)
52 private final List<CodedAttribute> accommodationsNeeded;
53 @XmlElement(name = Elements.CONDITION_TYPE, required = false)
54 private final CodedAttribute conditionType;
55 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
56 private final Long versionNumber;
57 @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
58 private final String objectId;
59 @XmlElement(name = Elements.ACTIVE, required = false)
60 private final boolean active;
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 @SuppressWarnings("unused")
66 @XmlAnyElement
67 private final Collection<Element> _futureElements = null;
68
69
70
71
72
73 private EntityDisability() {
74 this.statusCode = null;
75 this.determinationSourceType = null;
76 this.accommodationsNeeded = null;
77 this.conditionType = null;
78 this.versionNumber = null;
79 this.objectId = null;
80 this.active = false;
81 this.id = null;
82 this.entityId = null;
83 }
84
85 private EntityDisability(Builder builder) {
86 this.statusCode = builder.getStatusCode();
87 this.determinationSourceType = builder.getDeterminationSourceType() != null ? builder.getDeterminationSourceType().build() : null;
88 this.accommodationsNeeded = new ArrayList<CodedAttribute>();
89 if (CollectionUtils.isNotEmpty(builder.getAccommodationsNeeded())) {
90 for (CodedAttribute.Builder accommodations : builder.getAccommodationsNeeded()) {
91 this.accommodationsNeeded.add(accommodations.build());
92 }
93 }
94 this.conditionType = builder.getConditionType() != null ? builder.getConditionType().build() : null;
95 this.versionNumber = builder.getVersionNumber();
96 this.objectId = builder.getObjectId();
97 this.active = builder.isActive();
98 this.id = builder.getId();
99 this.entityId = builder.getEntityId();
100 }
101
102 @Override
103 public String getStatusCode() {
104 return this.statusCode;
105 }
106
107 @Override
108 public CodedAttribute getDeterminationSourceType() {
109 return this.determinationSourceType;
110 }
111
112 @Override
113 public List<CodedAttribute> getAccommodationsNeeded() {
114 return Collections.unmodifiableList(this.accommodationsNeeded);
115 }
116
117 @Override
118 public CodedAttribute getConditionType() {
119 return this.conditionType;
120 }
121
122 @Override
123 public Long getVersionNumber() {
124 return this.versionNumber;
125 }
126
127 @Override
128 public String getObjectId() {
129 return this.objectId;
130 }
131
132 @Override
133 public boolean isActive() {
134 return this.active;
135 }
136
137 @Override
138 public String getId() {
139 return this.id;
140 }
141
142 @Override
143 public String getEntityId() {
144 return this.entityId;
145 }
146
147
148
149
150
151
152 public final static class Builder
153 implements Serializable, ModelBuilder, EntityDisabilityContract
154 {
155
156 private String statusCode;
157 private CodedAttribute.Builder determinationSourceType;
158 private List<CodedAttribute.Builder> accommodationsNeeded;
159 private CodedAttribute.Builder conditionType;
160 private Long versionNumber;
161 private String objectId;
162 private boolean active;
163 private String id;
164 private String entityId;
165
166 private Builder() {
167 }
168
169 public static Builder create() {
170 return new Builder();
171 }
172
173 public static Builder create(EntityDisabilityContract contract) {
174 if (contract == null) {
175 throw new IllegalArgumentException("contract was null");
176 }
177 Builder builder = create();
178 builder.setEntityId(contract.getEntityId());
179 builder.setStatusCode(contract.getStatusCode());
180 if (contract.getDeterminationSourceType() != null) {
181 builder.setDeterminationSourceType(CodedAttribute.Builder.create(contract.getDeterminationSourceType()));
182 }
183 if (contract.getAccommodationsNeeded() != null) {
184 List<CodedAttribute.Builder> accommodations = new ArrayList<CodedAttribute.Builder>();
185 for (CodedAttributeContract accommodation : contract.getAccommodationsNeeded()) {
186 accommodations.add(CodedAttribute.Builder.create(accommodation));
187 }
188 builder.setAccommodationsNeeded(accommodations);
189 }
190 if (contract.getConditionType() != null) {
191 builder.setConditionType(CodedAttribute.Builder.create(contract.getConditionType()));
192 }
193 builder.setVersionNumber(contract.getVersionNumber());
194 builder.setObjectId(contract.getObjectId());
195 builder.setActive(contract.isActive());
196 builder.setId(contract.getId());
197 return builder;
198 }
199
200 public EntityDisability build() {
201 return new EntityDisability(this);
202 }
203
204 @Override
205 public String getStatusCode() {
206 return this.statusCode;
207 }
208
209 @Override
210 public String getEntityId() {
211 return this.entityId;
212 }
213
214 @Override
215 public CodedAttribute.Builder getDeterminationSourceType() {
216 return this.determinationSourceType;
217 }
218
219 @Override
220 public List<CodedAttribute.Builder> getAccommodationsNeeded() {
221 return this.accommodationsNeeded;
222 }
223
224 @Override
225 public CodedAttribute.Builder getConditionType() {
226 return this.conditionType;
227 }
228
229 @Override
230 public Long getVersionNumber() {
231 return this.versionNumber;
232 }
233
234 @Override
235 public String getObjectId() {
236 return this.objectId;
237 }
238
239 @Override
240 public boolean isActive() {
241 return this.active;
242 }
243
244 @Override
245 public String getId() {
246 return this.id;
247 }
248
249 public void setEntityId(String entityId) {
250 this.entityId = entityId;
251 }
252
253 public void setStatusCode(String statusCode) {
254 this.statusCode = statusCode;
255 }
256
257 public void setDeterminationSourceType(CodedAttribute.Builder determinationSourceType) {
258 this.determinationSourceType = determinationSourceType;
259 }
260
261 public void setAccommodationsNeeded(List<CodedAttribute.Builder> accommodationsNeeded) {
262 this.accommodationsNeeded = Collections.unmodifiableList(accommodationsNeeded);
263 }
264
265 public void setConditionType(CodedAttribute.Builder conditionType) {
266 this.conditionType = conditionType;
267 }
268
269 public void setVersionNumber(Long versionNumber) {
270 this.versionNumber = versionNumber;
271 }
272
273 public void setObjectId(String objectId) {
274 this.objectId = objectId;
275 }
276
277 public void setActive(boolean active) {
278 this.active = active;
279 }
280
281 public void setId(String id) {
282 if (StringUtils.isWhitespace(id)) {
283 throw new IllegalArgumentException("id is blank");
284 }
285 this.id = id;
286 }
287
288 }
289
290
291
292
293
294
295 static class Constants {
296
297 final static String ROOT_ELEMENT_NAME = "entityDisability";
298 final static String TYPE_NAME = "EntityDisabilityType";
299
300 }
301
302
303
304
305
306
307 static class Elements {
308
309 final static String STATUS_CODE = "statusCode";
310 final static String DETERMINATION_SOURCE_TYPE = "determinationSourceType";
311 final static String ACCOMMODATIONS_NEEDED = "accommodationsNeeded";
312 final static String ACCOMMODATION_NEEDED = "accommodationNeeded";
313 final static String CONDITION_TYPE = "conditionType";
314 final static String ACTIVE = "active";
315 final static String ID = "id";
316 final static String ENTITY_ID = "entityId";
317
318 }
319
320 }