View Javadoc
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   * OleAddressBo provides OleAddressBo information through getter and setter.
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       * Gets the value of olePatronDocument property
38       *
39       * @return olePatronDocument
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       * Sets the value for olePatronDocument property
55       *
56       * @param olePatronDocument
57       */
58      public void setOlePatronDocument(OlePatronDocument olePatronDocument) {
59          this.olePatronDocument = olePatronDocument;
60      }
61  
62      /**
63       * Gets the value of oleAddressId property
64       *
65       * @return oleAddressId
66       */
67      public String getOleAddressId() {
68          return oleAddressId;
69      }
70  
71      /**
72       * Sets the value for oleAddressId property
73       *
74       * @param oleAddressId
75       */
76      public void setOleAddressId(String oleAddressId) {
77          this.oleAddressId = oleAddressId;
78      }
79  
80      /**
81       * Gets the value of addressVerified property
82       *
83       * @return addressVerified
84       */
85      public boolean isAddressVerified() {
86          return addressVerified;
87      }
88  
89      /**
90       * Sets the value for addressVerified property
91       *
92       * @param addressVerified
93       */
94      public void setAddressVerified(boolean addressVerified) {
95          this.addressVerified = addressVerified;
96      }
97  
98      /**
99       * Gets the value of olePatronId property
100      *
101      * @return olePatronId
102      */
103     public String getOlePatronId() {
104         return olePatronId;
105     }
106 
107     /**
108      * Sets the value for olePatronId property
109      *
110      * @param olePatronId
111      */
112     public void setOlePatronId(String olePatronId) {
113         this.olePatronId = olePatronId;
114     }
115 
116     /**
117      * Gets the value of addressValidFrom property
118      *
119      * @return addressValidFrom
120      */
121     public Date getAddressValidFrom() {
122         return addressValidFrom;
123     }
124 
125     /**
126      * Sets the value for addressValidFrom property
127      *
128      * @param addressValidFrom
129      */
130     public void setAddressValidFrom(Date addressValidFrom) {
131         this.addressValidFrom = addressValidFrom;
132     }
133 
134     /**
135      * Gets the value of addressValidTo property
136      *
137      * @return addressValidTo
138      */
139     public Date getAddressValidTo() {
140         return addressValidTo;
141     }
142 
143     /**
144      * Sets the value for addressValidTo property
145      *
146      * @param addressValidTo
147      */
148     public void setAddressValidTo(Date addressValidTo) {
149         this.addressValidTo = addressValidTo;
150     }
151 
152     /**
153      * Gets the value of addressSource property
154      *
155      * @return addressSource
156      */
157     public String getAddressSource() {
158         return addressSource;
159     }
160 
161     /**
162      * Sets the value for addressSource property
163      *
164      * @param addressSource
165      */
166     public void setAddressSource(String addressSource) {
167         this.addressSource = addressSource;
168     }
169 
170     /**
171      * Gets the value of addressSourceBo property
172      *
173      * @return addressSourceBo
174      */
175     public OleAddressSourceBo getAddressSourceBo() {
176         return addressSourceBo;
177     }
178 
179     /**
180      * Sets the value for addressSourceBo property
181      *
182      * @param addressSourceBo
183      */
184     public void setAddressSourceBo(OleAddressSourceBo addressSourceBo) {
185         this.addressSourceBo = addressSourceBo;
186     }
187 
188     /**
189      * Gets the value of entityAddress property
190      *
191      * @return entityAddress
192      */
193     public EntityAddressBo getEntityAddress() {
194         return entityAddress;
195     }
196 
197     /**
198      * Sets the value for entityAddress property
199      *
200      * @param entityAddress
201      */
202     public void setEntityAddress(EntityAddressBo entityAddress) {
203         this.entityAddress = entityAddress;
204     }
205 
206     /**
207      * Gets the value of addressSourceBo property
208      *
209      * @return addressSourceBo
210      */
211     public String getOleAddressSourceName() {
212         if (addressSourceBo != null) {
213             return addressSourceBo.getOleAddressSourceName();
214         }
215         return null;
216 
217     }
218 
219     /**
220      * This method converts the PersistableBusinessObjectBase OleAddressBo into immutable object OleAddressDefinition
221      *
222      * @param bo
223      * @return OleAddressDefinition
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      * This method converts the immutable object OleAddressDefinition into PersistableBusinessObjectBase OleAddressBo
234      *
235      * @param imOleAddressDefinition
236      * @return bo
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         //bo.olePatron = OlePatronDocument.from(im.getOlePatron());
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         /*if (im.getEntityAddress() != null) {
255             bo.entityAddress = EntityAddressBo.from(im.getEntityAddress());
256         }*/
257         if (imOleAddressDefinition.getAddressSourceBo() != null) {
258             bo.addressSourceBo = OleAddressSourceBo.from(imOleAddressDefinition.getAddressSourceBo());
259         }
260 
261         return bo;
262     }
263 
264     /**
265      * Gets the value of id property
266      *
267      * @return id
268      */
269     public String getId() {
270         return id;
271     }
272 
273     /**
274      * Sets the value for id property
275      *
276      * @param id
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 }