1 package org.kuali.rice.kim.api.identity.citizenship;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.joda.time.DateTime;
5 import org.kuali.rice.core.api.CoreConstants;
6 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
7 import org.kuali.rice.core.api.mo.ModelBuilder;
8 import org.kuali.rice.core.api.util.jaxb.DateTimeAdapter;
9 import org.kuali.rice.kim.api.identity.CodedAttribute;
10 import org.w3c.dom.Element;
11
12 import javax.xml.bind.annotation.XmlAccessType;
13 import javax.xml.bind.annotation.XmlAccessorType;
14 import javax.xml.bind.annotation.XmlAnyElement;
15 import javax.xml.bind.annotation.XmlElement;
16 import javax.xml.bind.annotation.XmlRootElement;
17 import javax.xml.bind.annotation.XmlType;
18 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
19 import java.io.Serializable;
20 import java.util.Collection;
21
22 @XmlRootElement(name = EntityCitizenship.Constants.ROOT_ELEMENT_NAME)
23 @XmlAccessorType(XmlAccessType.NONE)
24 @XmlType(name = EntityCitizenship.Constants.TYPE_NAME, propOrder = {
25 EntityCitizenship.Elements.ID,
26 EntityCitizenship.Elements.ENTITY_ID,
27 EntityCitizenship.Elements.STATUS,
28 EntityCitizenship.Elements.COUNTRY_CODE,
29 EntityCitizenship.Elements.START_DATE,
30 EntityCitizenship.Elements.END_DATE,
31 CoreConstants.CommonElements.VERSION_NUMBER,
32 CoreConstants.CommonElements.OBJECT_ID,
33 EntityCitizenship.Elements.ACTIVE,
34 CoreConstants.CommonElements.FUTURE_ELEMENTS
35 })
36 public final class EntityCitizenship extends AbstractDataTransferObject
37 implements EntityCitizenshipContract
38 {
39 @XmlElement(name = Elements.ID, required = false)
40 private final String id;
41 @XmlElement(name = Elements.ENTITY_ID, required = false)
42 private final String entityId;
43 @XmlElement(name = Elements.STATUS, required = false)
44 private final CodedAttribute status;
45 @XmlElement(name = Elements.COUNTRY_CODE, required = false)
46 private final String countryCode;
47 @XmlJavaTypeAdapter(DateTimeAdapter.class)
48 @XmlElement(name = Elements.START_DATE, required = false)
49 private final DateTime startDate;
50 @XmlJavaTypeAdapter(DateTimeAdapter.class)
51 @XmlElement(name = Elements.END_DATE, required = false)
52 private final DateTime endDate;
53 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
54 private final Long versionNumber;
55 @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
56 private final String objectId;
57 @XmlElement(name = Elements.ACTIVE, required = false)
58 private final boolean active;
59 @SuppressWarnings("unused")
60 @XmlAnyElement
61 private final Collection<Element> _futureElements = null;
62
63
64
65
66
67 private EntityCitizenship() {
68 this.status = null;
69 this.countryCode = null;
70 this.startDate = null;
71 this.endDate = null;
72 this.versionNumber = null;
73 this.objectId = null;
74 this.active = false;
75 this.id = null;
76 this.entityId = null;
77 }
78
79 private EntityCitizenship(Builder builder) {
80 this.status = builder.getStatus() != null ? builder.getStatus().build() : null;
81 this.countryCode = builder.getCountryCode();
82 this.startDate = builder.getStartDate();
83 this.endDate = builder.getEndDate();
84 this.versionNumber = builder.getVersionNumber();
85 this.objectId = builder.getObjectId();
86 this.active = builder.isActive();
87 this.id = builder.getId();
88 this.entityId = builder.getEntityId();
89 }
90
91 @Override
92 public String getEntityId() {
93 return this.entityId;
94 }
95
96 @Override
97 public CodedAttribute getStatus() {
98 return this.status;
99 }
100
101 @Override
102 public String getCountryCode() {
103 return this.countryCode;
104 }
105
106 @Override
107 public DateTime getStartDate() {
108 return this.startDate;
109 }
110
111 @Override
112 public DateTime getEndDate() {
113 return this.endDate;
114 }
115
116 @Override
117 public Long getVersionNumber() {
118 return this.versionNumber;
119 }
120
121 @Override
122 public String getObjectId() {
123 return this.objectId;
124 }
125
126 @Override
127 public boolean isActive() {
128 return this.active;
129 }
130
131 @Override
132 public String getId() {
133 return this.id;
134 }
135
136
137
138
139
140 public final static class Builder
141 implements Serializable, ModelBuilder, EntityCitizenshipContract
142 {
143 private String entityId;
144 private CodedAttribute.Builder status;
145 private String countryCode;
146 private DateTime startDate;
147 private DateTime endDate;
148 private Long versionNumber;
149 private String objectId;
150 private boolean active;
151 private String id;
152
153 private Builder() {
154 }
155
156 public static Builder create() {
157 return new Builder();
158 }
159
160 public static Builder create(EntityCitizenshipContract contract) {
161 if (contract == null) {
162 throw new IllegalArgumentException("contract was null");
163 }
164 Builder builder = create();
165 builder.setEntityId(contract.getEntityId());
166 if (contract.getStatus() != null) {
167 builder.setStatus(CodedAttribute.Builder.create(contract.getStatus()));
168 }
169 builder.setCountryCode(contract.getCountryCode());
170 builder.setStartDate(contract.getStartDate());
171 builder.setEndDate(contract.getEndDate());
172 builder.setVersionNumber(contract.getVersionNumber());
173 builder.setObjectId(contract.getObjectId());
174 builder.setActive(contract.isActive());
175 builder.setId(contract.getId());
176 return builder;
177 }
178
179 public EntityCitizenship build() {
180 return new EntityCitizenship(this);
181 }
182
183 @Override
184 public String getEntityId() {
185 return this.entityId;
186 }
187
188 @Override
189 public CodedAttribute.Builder getStatus() {
190 return this.status;
191 }
192
193 @Override
194 public String getCountryCode() {
195 return this.countryCode;
196 }
197
198 @Override
199 public DateTime getStartDate() {
200 return this.startDate;
201 }
202
203 @Override
204 public DateTime getEndDate() {
205 return this.endDate;
206 }
207
208 @Override
209 public Long getVersionNumber() {
210 return this.versionNumber;
211 }
212
213 @Override
214 public String getObjectId() {
215 return this.objectId;
216 }
217
218 @Override
219 public boolean isActive() {
220 return this.active;
221 }
222
223 @Override
224 public String getId() {
225 return this.id;
226 }
227
228 public void setEntityId(String entityId) {
229 this.entityId = entityId;
230 }
231 public void setStatus(CodedAttribute.Builder status) {
232 this.status = status;
233 }
234
235 public void setCountryCode(String countryCode) {
236 this.countryCode = countryCode;
237 }
238
239 public void setStartDate(DateTime startDate) {
240 this.startDate = startDate;
241 }
242
243 public void setEndDate(DateTime endDate) {
244 this.endDate = endDate;
245 }
246
247 public void setVersionNumber(Long versionNumber) {
248 this.versionNumber = versionNumber;
249 }
250
251 public void setObjectId(String objectId) {
252 this.objectId = objectId;
253 }
254
255 public void setActive(boolean active) {
256 this.active = active;
257 }
258
259 public void setId(String id) {
260 if (StringUtils.isWhitespace(id)) {
261 throw new IllegalArgumentException("id is blank");
262 }
263 this.id = id;
264 }
265
266 }
267
268
269
270
271
272
273 static class Constants {
274
275 final static String ROOT_ELEMENT_NAME = "entityCitizenship";
276 final static String TYPE_NAME = "EntityCitizenshipType";
277 }
278
279
280
281
282
283
284 static class Elements {
285 final static String ENTITY_ID = "entityId";
286 final static String STATUS = "status";
287 final static String COUNTRY_CODE = "countryCode";
288 final static String START_DATE = "startDate";
289 final static String END_DATE = "endDate";
290 final static String ACTIVE = "active";
291 final static String ID = "id";
292
293 }
294
295 }