1 package org.kuali.ole.deliver.bo;
2
3 import org.apache.commons.lang3.StringUtils;
4 import org.kuali.ole.deliver.api.OleAddressContract;
5 import org.kuali.ole.deliver.api.OleAddressDefinition;
6 import org.kuali.rice.kim.impl.identity.address.EntityAddressBo;
7 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
8 import org.kuali.rice.krad.service.KRADServiceLocator;
9
10 import java.util.Date;
11 import java.util.HashMap;
12 import java.util.Map;
13
14
15
16
17 public class OleAddressBo extends PersistableBusinessObjectBase implements OleAddressContract {
18
19 private String oleAddressId;
20 private String olePatronId;
21 private String id;
22 private boolean addressVerified;
23 private Date addressValidFrom;
24 private Date addressValidTo;
25 private String addressSource;
26 private String oleAddressSourceName;
27 private OleAddressSourceBo addressSourceBo = new OleAddressSourceBo();
28 private EntityAddressBo entityAddress;
29 private OlePatronDocument olePatronDocument;
30 private boolean deliverAddress;
31
32 public OleAddressBo() {
33 this.setAddressVerified(true);
34 }
35
36
37
38
39
40
41 public OlePatronDocument getOlePatronDocument() {
42 if (null == olePatronDocument) {
43 String patronId = getOlePatronId();
44 if (StringUtils.isNotEmpty(patronId)) {
45 Map<String, String> parameterMap = new HashMap<>();
46 parameterMap.put("olePatronId", patronId);
47 olePatronDocument = KRADServiceLocator.getBusinessObjectService().findByPrimaryKey(OlePatronDocument.class, parameterMap);
48 }
49 }
50 return olePatronDocument;
51 }
52
53
54
55
56
57
58 public void setOlePatronDocument(OlePatronDocument olePatronDocument) {
59 this.olePatronDocument = olePatronDocument;
60 }
61
62
63
64
65
66
67 public String getOleAddressId() {
68 return oleAddressId;
69 }
70
71
72
73
74
75
76 public void setOleAddressId(String oleAddressId) {
77 this.oleAddressId = oleAddressId;
78 }
79
80
81
82
83
84
85 public boolean isAddressVerified() {
86 return addressVerified;
87 }
88
89
90
91
92
93
94 public void setAddressVerified(boolean addressVerified) {
95 this.addressVerified = addressVerified;
96 }
97
98
99
100
101
102
103 public String getOlePatronId() {
104 return olePatronId;
105 }
106
107
108
109
110
111
112 public void setOlePatronId(String olePatronId) {
113 this.olePatronId = olePatronId;
114 }
115
116
117
118
119
120
121 public Date getAddressValidFrom() {
122 return addressValidFrom;
123 }
124
125
126
127
128
129
130 public void setAddressValidFrom(Date addressValidFrom) {
131 this.addressValidFrom = addressValidFrom;
132 }
133
134
135
136
137
138
139 public Date getAddressValidTo() {
140 return addressValidTo;
141 }
142
143
144
145
146
147
148 public void setAddressValidTo(Date addressValidTo) {
149 this.addressValidTo = addressValidTo;
150 }
151
152
153
154
155
156
157 public String getAddressSource() {
158 return addressSource;
159 }
160
161
162
163
164
165
166 public void setAddressSource(String addressSource) {
167 this.addressSource = addressSource;
168 }
169
170
171
172
173
174
175 public OleAddressSourceBo getAddressSourceBo() {
176 return addressSourceBo;
177 }
178
179
180
181
182
183
184 public void setAddressSourceBo(OleAddressSourceBo addressSourceBo) {
185 this.addressSourceBo = addressSourceBo;
186 }
187
188
189
190
191
192
193 public EntityAddressBo getEntityAddress() {
194 return entityAddress;
195 }
196
197
198
199
200
201
202 public void setEntityAddress(EntityAddressBo entityAddress) {
203 this.entityAddress = entityAddress;
204 }
205
206
207
208
209
210
211 public String getOleAddressSourceName() {
212 if (addressSourceBo != null) {
213 return addressSourceBo.getOleAddressSourceName();
214 }
215 return null;
216
217 }
218
219
220
221
222
223
224
225 public static OleAddressDefinition to(org.kuali.ole.deliver.bo.OleAddressBo bo) {
226 if (bo == null) {
227 return null;
228 }
229 return OleAddressDefinition.Builder.create(bo).build();
230 }
231
232
233
234
235
236
237
238 public static org.kuali.ole.deliver.bo.OleAddressBo from(OleAddressDefinition imOleAddressDefinition) {
239 if (imOleAddressDefinition == null) {
240 return null;
241 }
242
243 org.kuali.ole.deliver.bo.OleAddressBo bo = new org.kuali.ole.deliver.bo.OleAddressBo();
244 bo.oleAddressId = imOleAddressDefinition.getOleAddressId();
245 bo.olePatronId = imOleAddressDefinition.getOlePatronId();
246
247 bo.id = imOleAddressDefinition.getId();
248 bo.addressVerified = imOleAddressDefinition.isAddressVerified();
249 bo.addressValidFrom = imOleAddressDefinition.getAddressValidFrom();
250 bo.addressValidTo = imOleAddressDefinition.getAddressValidTo();
251 bo.addressSource = imOleAddressDefinition.getAddressSource();
252 bo.versionNumber = imOleAddressDefinition.getVersionNumber();
253 bo.deliverAddress = imOleAddressDefinition.isDeliverAddress();
254
255
256
257 if (imOleAddressDefinition.getAddressSourceBo() != null) {
258 bo.addressSourceBo = OleAddressSourceBo.from(imOleAddressDefinition.getAddressSourceBo());
259 }
260
261 return bo;
262 }
263
264
265
266
267
268
269 public String getId() {
270 return id;
271 }
272
273
274
275
276
277
278 public void setId(String id) {
279 this.id = id;
280 }
281
282 public boolean isDeliverAddress() {
283 return deliverAddress;
284 }
285
286 public void setDeliverAddress(boolean deliverAddress) {
287 this.deliverAddress = deliverAddress;
288 }
289 }