1 package org.kuali.ole.deliver.api;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.api.jaxb.DateAdapter;
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.kim.api.KimConstants;
9 import org.kuali.rice.kim.api.identity.address.EntityAddress;
10 import org.w3c.dom.Element;
11
12 import javax.xml.bind.annotation.*;
13 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
14 import java.io.Serializable;
15 import java.util.Collection;
16 import java.util.Date;
17
18
19
20
21
22
23
24
25 @XmlRootElement(name = org.kuali.ole.deliver.api.OleAddressDefinition.Constants.ROOT_ELEMENT_NAME)
26 @XmlAccessorType(XmlAccessType.NONE)
27 @XmlType(name = org.kuali.ole.deliver.api.OleAddressDefinition.Constants.TYPE_NAME, propOrder = {
28 org.kuali.ole.deliver.api.OleAddressDefinition.Elements.OLE_ADDRESS_ID,
29 org.kuali.ole.deliver.api.OleAddressDefinition.Elements.OLE_PTRN_ID,
30 org.kuali.ole.deliver.api.OleAddressDefinition.Elements.ID,
31 org.kuali.ole.deliver.api.OleAddressDefinition.Elements.ADDRESS_VERIFIED,
32 org.kuali.ole.deliver.api.OleAddressDefinition.Elements.ADDRESS_VALID_FROM,
33 org.kuali.ole.deliver.api.OleAddressDefinition.Elements.ADDRESS_VALID_TO,
34
35 org.kuali.ole.deliver.api.OleAddressDefinition.Elements.ADDRESS_SOURCE,
36 org.kuali.ole.deliver.api.OleAddressDefinition.Elements.ADDRESS_SOURCE_BO,
37 org.kuali.ole.deliver.api.OleAddressDefinition.Elements.DELIVER_ADDRESS,
38
39
40
41 CoreConstants.CommonElements.VERSION_NUMBER,
42
43 CoreConstants.CommonElements.FUTURE_ELEMENTS
44 })
45 public class OleAddressDefinition extends AbstractDataTransferObject implements OleAddressContract {
46
47 private static final long serialVersionUID = 1L;
48
49 @XmlElement(name = Elements.OLE_ADDRESS_ID, required = false)
50 private final String oleAddressId;
51
52 @XmlElement(name = Elements.OLE_PTRN_ID, required = false)
53 private final String olePatronId;
54
55 @XmlElement(name = Elements.ID, required = false)
56 private final String id;
57
58 @XmlElement(name = Elements.ADDRESS_VALID_FROM, required = false)
59 @XmlJavaTypeAdapter(value = DateAdapter.class, type = Date.class)
60 private final Date addressValidFrom;
61
62 @XmlElement(name = Elements.ADDRESS_VALID_TO, required = false)
63 @XmlJavaTypeAdapter(value = DateAdapter.class, type = Date.class)
64 private final Date addressValidTo;
65
66 @XmlElement(name = Elements.ADDRESS_VERIFIED, required = false)
67 private final boolean addressVerified;
68
69
70
71
72 @XmlElement(name = Elements.ADDRESS_SOURCE, required = false)
73 private final String addressSource;
74
75 @XmlElement(name = Elements.ADDRESS_SOURCE_BO, required = false)
76 private final OleAddressSourceDefinition addressSourceBo;
77
78
79
80
81
82 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
83 private final Long versionNumber;
84
85 @XmlElement(name = Elements.DELIVER_ADDRESS, required = false)
86 private final boolean deliverAddress;
87
88
89
90
91
92 @SuppressWarnings("unused")
93 @XmlAnyElement
94 private final Collection<Element> _futureElements = null;
95
96 public OleAddressDefinition() {
97 this.oleAddressId = null;
98 this.addressVerified = false;
99 this.olePatronId = null;
100 this.id = null;
101 this.addressValidFrom = null;
102 this.addressValidTo = null;
103
104 this.addressSource = null;
105 this.addressSourceBo = null;
106 this.versionNumber = null;
107 this.deliverAddress=false;
108
109
110 }
111
112
113 private OleAddressDefinition(Builder builder) {
114 this.oleAddressId = builder.getOleAddressId();
115 this.addressVerified = builder.isAddressVerified();
116 this.olePatronId = builder.getOlePatronId();
117 this.id = builder.getId();
118 this.addressValidFrom = builder.getAddressValidFrom();
119 this.addressValidTo = builder.getAddressValidTo();
120
121 this.addressSource = builder.getAddressSource();
122 if (builder.getAddressSourceBo() != null)
123 this.addressSourceBo = builder.getAddressSourceBo().build();
124 else
125 this.addressSourceBo = new OleAddressSourceDefinition();
126 this.versionNumber = builder.getVersionNumber();
127 this.deliverAddress=builder.isDeliverAddress();
128
129 }
130
131 @Override
132 public String getOleAddressId() {
133 return oleAddressId;
134 }
135
136 @Override
137 public boolean isAddressVerified() {
138 return addressVerified;
139 }
140
141 public static long getSerialVersionUID() {
142 return serialVersionUID;
143 }
144
145 public String getOlePatronId() {
146 return olePatronId;
147 }
148
149 public Date getAddressValidFrom() {
150 return addressValidFrom;
151 }
152
153 public Date getAddressValidTo() {
154 return addressValidTo;
155 }
156
157
158
159
160
161 public String getAddressSource() {
162 return addressSource;
163 }
164
165 public OleAddressSourceDefinition getAddressSourceBo() {
166 return addressSourceBo;
167 }
168
169
170
171
172
173 @Override
174 public Long getVersionNumber() {
175 return this.versionNumber;
176 }
177
178 @Override
179 public String getId() {
180 return this.id;
181 }
182 @Override
183 public boolean isDeliverAddress() {
184 return deliverAddress;
185 }
186
187
188
189
190
191
192
193 public static class Builder
194 implements Serializable, ModelBuilder, OleAddressContract {
195 private String oleAddressId;
196 private String olePatronId;
197 private String id;
198 private boolean addressVerified;
199 private Date addressValidFrom;
200 private Date addressValidTo;
201 private String addressSource;
202 private OleAddressSourceDefinition.Builder addressSourceBo;
203 private EntityAddress.Builder entityAddress;
204 private Long versionNumber;
205 private String objectId;
206 private boolean deliverAddress;
207
208 private Builder() {
209 }
210
211 public static Builder create() {
212 return new Builder();
213 }
214
215 public static Builder create(OleAddressContract contract) {
216 if (contract == null) {
217 throw new IllegalArgumentException("contract was null");
218 }
219 Builder builder = create();
220 if (contract.getOleAddressId() != null) {
221 builder.setOleAddressId(contract.getOleAddressId());
222 }
223 if (contract.isAddressVerified()) {
224 builder.setAddressVerified(contract.isAddressVerified());
225 }
226 if (contract.getAddressValidFrom() != null) {
227 builder.setAddressValidFrom(contract.getAddressValidFrom());
228 }
229 if (contract.getAddressValidTo() != null) {
230 builder.setAddressValidTo(contract.getAddressValidTo());
231 }
232 if (contract.getOlePatronId() != null) {
233 builder.setOlePatronId(contract.getOlePatronId());
234 }
235 if (contract.getId() != null) {
236 builder.setId(contract.getId());
237 }
238 if (contract.getAddressSource() != null) {
239 builder.setAddressSource(contract.getAddressSource());
240 }
241 if (contract.getAddressSourceBo() != null) {
242 builder.setAddressSourceBo(OleAddressSourceDefinition.Builder.create(contract.getAddressSourceBo()));
243 }
244
245
246
247 builder.setDeliverAddress(contract.isDeliverAddress());
248 builder.setVersionNumber(contract.getVersionNumber());
249
250
251 builder.setId(contract.getId());
252 return builder;
253 }
254
255
256 public org.kuali.ole.deliver.api.OleAddressDefinition build() {
257 return new org.kuali.ole.deliver.api.OleAddressDefinition(this);
258 }
259
260 public String getOleAddressId() {
261 return oleAddressId;
262 }
263
264 public void setOleAddressId(String oleAddressId) {
265 this.oleAddressId = oleAddressId;
266 }
267
268 public String getOlePatronId() {
269 return olePatronId;
270 }
271
272 public void setOlePatronId(String olePatronId) {
273 this.olePatronId = olePatronId;
274 }
275
276 public Date getAddressValidFrom() {
277 return addressValidFrom;
278 }
279
280 public void setAddressValidFrom(Date addressValidFrom) {
281 this.addressValidFrom = addressValidFrom;
282 }
283
284 public Date getAddressValidTo() {
285 return addressValidTo;
286 }
287
288 public void setAddressValidTo(Date addressValidTo) {
289 this.addressValidTo = addressValidTo;
290 }
291
292 public boolean isAddressVerified() {
293 return addressVerified;
294 }
295
296 public void setAddressVerified(boolean addressVerified) {
297 this.addressVerified = addressVerified;
298 }
299
300 public EntityAddress.Builder getEntityAddress() {
301 return entityAddress;
302 }
303
304 public void setEntityAddress(EntityAddress.Builder entityAddress) {
305 this.entityAddress = entityAddress;
306 }
307
308 public String getAddressSource() {
309 return addressSource;
310 }
311
312 public void setAddressSource(String addressSource) {
313 this.addressSource = addressSource;
314 }
315
316 public OleAddressSourceDefinition.Builder getAddressSourceBo() {
317 return addressSourceBo;
318 }
319
320 public void setAddressSourceBo(OleAddressSourceDefinition.Builder addressSourceBo) {
321 this.addressSourceBo = addressSourceBo;
322 }
323
324 @Override
325 public Long getVersionNumber() {
326 return versionNumber;
327 }
328
329 public void setVersionNumber(Long versionNumber) {
330 this.versionNumber = versionNumber;
331 }
332
333
334
335
336
337
338 public void setObjectId(String objectId) {
339 this.objectId = objectId;
340 }
341
342 @Override
343 public String getId() {
344 return this.id;
345 }
346
347
348 public void setId(String id) {
349 if (StringUtils.isWhitespace(id)) {
350 throw new IllegalArgumentException("id is blank");
351 }
352 this.id = id;
353 }
354
355 public boolean isDeliverAddress() {
356 return deliverAddress;
357 }
358
359 public void setDeliverAddress(boolean deliverAddress) {
360 this.deliverAddress = deliverAddress;
361 }
362 }
363
364 static class Constants {
365
366 final static String ROOT_ELEMENT_NAME = "oleAddress";
367 final static String TYPE_NAME = "OleAddressType";
368 final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[]{CoreConstants.CommonElements.FUTURE_ELEMENTS};
369 }
370
371 static class Elements {
372 final static String OLE_ADDRESS_ID = "oleAddressId";
373
374 final static String OLE_PTRN_ID = "olePatronId";
375 final static String ID = "id";
376 final static String ADDRESS_VERIFIED = "addressVerified";
377 final static String ADDRESS_VALID_FROM = "addressValidFrom";
378 final static String ADDRESS_VALID_TO = "addressValidTo";
379 final static String ADDRESS_SOURCE = "addressSource";
380
381 final static String ADDRESS_SOURCE_BO = "addressSourceBo";
382 final static String DELIVER_ADDRESS = "deliverAddress";
383 }
384
385 public static class Cache {
386 public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + Constants.TYPE_NAME;
387 }
388 }