View Javadoc
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.w3c.dom.Element;
10  
11  import javax.xml.bind.annotation.*;
12  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
13  import java.io.Serializable;
14  import java.util.Collection;
15  import java.util.Date;
16  
17  /**
18   * Created with IntelliJ IDEA.
19   * User: ?
20   * Date: 5/24/12
21   * Time: 8:26 PM
22   * To change this template use File | Settings | File Templates.
23   */
24  @XmlRootElement(name = OleProxyPatronDefinition.Constants.ROOT_ELEMENT_NAME)
25  @XmlAccessorType(XmlAccessType.NONE)
26  @XmlType(name = OleProxyPatronDefinition.Constants.TYPE_NAME, propOrder = {
27          OleProxyPatronDefinition.Elements.OLE_PROXY_PATRON_DOC_ID,
28          OleProxyPatronDefinition.Elements.OLE_PROXY_PATRON_ID,
29          OleProxyPatronDefinition.Elements.OLE_PATRON_ID,
30          OleProxyPatronDefinition.Elements.OLE_PROXY_PATRON_EXP_DT,
31          OleProxyPatronDefinition.Elements.OLE_PROXY_PATRON_ACT_DT,
32          //OleProxyPatronDefinition.Elements.OLE_PATRON_DOC,
33          OleProxyPatronDefinition.Elements.ACTIVE_INDICATOR,
34  
35          CoreConstants.CommonElements.VERSION_NUMBER,
36          //CoreConstants.CommonElements.OBJECT_ID,
37          CoreConstants.CommonElements.FUTURE_ELEMENTS
38  })
39  public final class OleProxyPatronDefinition extends AbstractDataTransferObject implements OleProxyPatronContract {
40  
41      private static final long serialVersionUID = 1L;
42  
43  
44      @XmlElement(name = Elements.OLE_PROXY_PATRON_DOC_ID, required = false)
45      private final String oleProxyPatronDocumentId;
46  
47      @XmlElement(name = Elements.OLE_PROXY_PATRON_ID, required = false)
48      private final String proxyPatronId;
49  
50      @XmlElement(name = Elements.OLE_PATRON_ID, required = false)
51      private final String olePatronId;
52  
53      @XmlElement(name = Elements.ACTIVE_INDICATOR, required = false)
54      private final boolean active;
55  
56      @XmlElement(name = Elements.OLE_PROXY_PATRON_EXP_DT, required = false)
57      @XmlJavaTypeAdapter(value = DateAdapter.class, type = Date.class)
58      private final Date proxyPatronExpirationDate;
59  
60      @XmlElement(name = Elements.OLE_PROXY_PATRON_ACT_DT, required = false)
61      @XmlJavaTypeAdapter(value = DateAdapter.class, type = Date.class)
62      private final Date proxyPatronActivationDate;
63  /*
64  
65      @XmlElement(name = Elements.OLE_PATRON_DOC, required = false)
66      private final OlePatronDefinition olePatronDocument;
67  */
68  
69      @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
70      private final Long versionNumber;
71  
72      /*@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
73      private final String objectId;*/
74      @SuppressWarnings("unused")
75      @XmlAnyElement
76      private final Collection<Element> _futureElements = null;
77  
78      public OleProxyPatronDefinition() {
79          this.olePatronId = null;
80          this.oleProxyPatronDocumentId = null;
81          this.proxyPatronId = null;
82          this.active = false;
83          this.proxyPatronExpirationDate = null;
84          this.proxyPatronActivationDate = null;
85          //  this.olePatronDocument = null;
86          this.versionNumber = null;
87          //this.objectId = null;
88      }
89  
90  
91      private OleProxyPatronDefinition(Builder builder) {
92          this.oleProxyPatronDocumentId = builder.getOleProxyPatronDocumentId();
93          this.proxyPatronId = builder.getProxyPatronId();
94          this.olePatronId = builder.getOlePatronId();
95          this.proxyPatronExpirationDate = builder.getProxyPatronExpirationDate();
96          this.proxyPatronActivationDate = builder.getProxyPatronActivationDate();
97          this.active = builder.isActive();
98  
99          // this.olePatronDocument = builder.getOlePatronDocument().build();
100 
101         this.versionNumber = builder.getVersionNumber();
102         //this.objectId = builder.getObjectId();
103     }
104 
105     @Override
106     public String getOlePatronId() {
107         return this.olePatronId;
108     }
109 
110     @Override
111     public String getOleProxyPatronDocumentId() {
112         return this.oleProxyPatronDocumentId;
113     }
114 
115     ;
116 
117     @Override
118     public String getProxyPatronId() {
119         return this.proxyPatronId;
120     }
121 
122     ;
123 
124     /* @Override
125      public OlePatronDefinition getOlePatronDocument(){
126          return this.olePatronDocument;
127      };*/
128     @Override
129     public Date getProxyPatronExpirationDate() {
130         return this.proxyPatronExpirationDate;
131     }
132 
133     ;
134 
135     @Override
136     public Date getProxyPatronActivationDate() {
137         return this.proxyPatronActivationDate;
138     }
139 
140     ;
141 
142     @Override
143     public boolean isActive() {
144         return this.active;
145     }
146 
147     ;
148 
149 
150     @Override
151     public String getId() {
152         return this.oleProxyPatronDocumentId;
153     }
154 
155 
156     @Override
157     public Long getVersionNumber() {
158         return this.versionNumber;
159     }
160 
161 
162     //@Override
163     /*public OleBorrowerTypeDefinition getOleBorrowerType() {
164         return this.oleBorrowerType;
165     }*/
166 
167     public static class Builder
168             implements Serializable, ModelBuilder, OleProxyPatronContract {
169         private String oleProxyPatronDocumentId;
170         private String proxyPatronId;
171         private String olePatronId;
172         private Date proxyPatronExpirationDate;
173         private Date proxyPatronActivationDate;
174         private boolean active;
175         //private OlePatronDocument proxyPatron;
176         //private OlePatronDefinition.Builder olePatronDocument;
177         private Long versionNumber;
178         private String objectId;
179 
180         private Builder() {
181         }
182 
183         public static Builder create() {
184             return new Builder();
185         }
186 
187         public static Builder create(OleProxyPatronContract contract) {
188             if (contract == null) {
189                 throw new IllegalArgumentException("contract was null");
190             }
191             Builder builder = create();
192             if (contract.getOlePatronId() != null) {
193                 builder.setOlePatronId(contract.getOlePatronId());
194             }
195             if (contract.getOleProxyPatronDocumentId() != null) {
196                 builder.setOleProxyPatronDocumentId(contract.getOleProxyPatronDocumentId());
197             }
198             if (contract.getProxyPatronId() != null) {
199                 builder.setProxyPatronId(contract.getProxyPatronId());
200             }
201             if (contract.isActive()) {
202                 builder.setActive(contract.isActive());
203             }
204             if (contract.getProxyPatronExpirationDate() != null) {
205                 builder.setProxyPatronExpirationDate(contract.getProxyPatronExpirationDate());
206             }
207 
208             if (contract.getProxyPatronActivationDate() != null) {
209                 builder.setProxyPatronActivationDate(contract.getProxyPatronActivationDate());
210             }
211 
212            /* if (contract.getOlePatronDocument() != null) {
213                 builder.setOlePatronDocument(OlePatronDefinition.Builder.create(contract.getOlePatronDocument()));
214             }
215 */
216             builder.setVersionNumber(contract.getVersionNumber());
217             /*builder.setObjectId(contract.getObjectId());
218             builder.setActive(contract.isActive());*/
219             builder.setId(contract.getId());
220             return builder;
221         }
222 
223 
224         public OleProxyPatronDefinition build() {
225             return new OleProxyPatronDefinition(this);
226         }
227 
228         public String getOleProxyPatronDocumentId() {
229             return oleProxyPatronDocumentId;
230         }
231 
232         public void setOleProxyPatronDocumentId(String oleProxyPatronDocumentId) {
233             this.oleProxyPatronDocumentId = oleProxyPatronDocumentId;
234         }
235 
236         public String getProxyPatronId() {
237             return proxyPatronId;
238         }
239 
240         public void setProxyPatronId(String proxyPatronId) {
241             this.proxyPatronId = proxyPatronId;
242         }
243 
244         public String getOlePatronId() {
245             return olePatronId;
246         }
247 
248         public void setOlePatronId(String olePatronId) {
249             this.olePatronId = olePatronId;
250         }
251 
252         public Date getProxyPatronExpirationDate() {
253             return proxyPatronExpirationDate;
254         }
255 
256         public void setProxyPatronExpirationDate(Date proxyPatronExpirationDate) {
257             this.proxyPatronExpirationDate = proxyPatronExpirationDate;
258         }
259 
260         public Date getProxyPatronActivationDate() {
261             return proxyPatronActivationDate;
262         }
263 
264         public void setProxyPatronActivationDate(Date proxyPatronActivationDate) {
265             this.proxyPatronActivationDate = proxyPatronActivationDate;
266         }
267 
268         public boolean isActive() {
269             return active;
270         }
271 
272         public void setActive(boolean active) {
273             this.active = active;
274         }
275 
276        /* public OlePatronDefinition.Builder getOlePatronDocument() {
277             return olePatronDocument;
278         }
279 
280         public void setOlePatronDocument(OlePatronDefinition.Builder olePatronDocument) {
281             this.olePatronDocument = olePatronDocument;
282         }*/
283 
284         @Override
285         public Long getVersionNumber() {
286             return versionNumber;
287         }
288 
289         public void setVersionNumber(Long versionNumber) {
290             this.versionNumber = versionNumber;
291         }
292 
293         /*@Override
294         public String getObjectId() {
295             return objectId;
296         }*/
297 
298         public void setObjectId(String objectId) {
299             this.objectId = objectId;
300         }
301 
302         @Override
303         public String getId() {
304             return this.oleProxyPatronDocumentId;
305         }
306 
307 
308         public void setId(String id) {
309             if (StringUtils.isWhitespace(id)) {
310                 throw new IllegalArgumentException("id is blank");
311             }
312             this.oleProxyPatronDocumentId = id;
313         }
314     }
315 
316     static class Constants {
317 
318         final static String ROOT_ELEMENT_NAME = "oleProxyPatron";
319         final static String TYPE_NAME = "OleProxyPatronType";
320         final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[]{CoreConstants.CommonElements.FUTURE_ELEMENTS};
321     }
322 
323     static class Elements {
324         final static String OLE_PROXY_PATRON_DOC_ID = "oleProxyPatronDocumentId";
325         final static String OLE_PROXY_PATRON_ID = "proxyPatronId";
326         final static String OLE_PATRON_ID = "olePatronId";
327         final static String OLE_PROXY_PATRON_EXP_DT = "proxyPatronExpirationDate";
328         final static String OLE_PROXY_PATRON_ACT_DT = "proxyPatronActivationDate";
329         //final static String OLE_PATRON_DOC = "olePatronDocument";
330         final static String ACTIVE_INDICATOR = "active";
331         //final static String ENTITY_ID = "entityId";
332 
333 
334     }
335 
336     public static class Cache {
337         public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + Constants.TYPE_NAME;
338     }
339 }