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.sql.Date;
15  import java.sql.Timestamp;
16  import java.util.Collection;
17  
18  /**
19   * Created with IntelliJ IDEA.
20   * User: ?
21   * Date: 5/24/12
22   * Time: 8:26 PM
23   * To change this template use File | Settings | File Templates.
24   */
25  @XmlRootElement(name = OlePatronLostBarcodeDefinition.Constants.ROOT_ELEMENT_NAME)
26  @XmlAccessorType(XmlAccessType.NONE)
27  @XmlType(name = OlePatronLostBarcodeDefinition.Constants.TYPE_NAME, propOrder = {
28          OlePatronLostBarcodeDefinition.Elements.OLE_PTRN_LOST_BAR_ID,
29          OlePatronLostBarcodeDefinition.Elements.OLE_PTRN_ID,
30          OlePatronLostBarcodeDefinition.Elements.OLE_PTRN_LOST_BAR_EFF_DT,
31          OlePatronLostBarcodeDefinition.Elements.OLE_PTRN_LOST_BAR_NUM,
32          //OlePatronDefinition.Elements.OLE_BORROWER_TYPE,
33          //OlePatronDefinition.Elements.ENTITY,
34  
35          CoreConstants.CommonElements.VERSION_NUMBER,
36          CoreConstants.CommonElements.OBJECT_ID,
37          CoreConstants.CommonElements.FUTURE_ELEMENTS
38  })
39  public class OlePatronLostBarcodeDefinition extends AbstractDataTransferObject implements OlePatronLostBarcodeContract {
40  
41      private static final long serialVersionUID = 1L;
42  
43  
44      @XmlElement(name = Elements.OLE_PTRN_LOST_BAR_ID, required = false)
45      private final String olePatronLostBarcodeId;
46  
47      @XmlElement(name = Elements.OLE_PTRN_ID, required = false)
48      private final String olePatronId;
49  
50      @XmlElement(name = Elements.OLE_PTRN_LOST_BAR_EFF_DT, required = false)
51      @XmlJavaTypeAdapter(value = DateAdapter.class, type = Timestamp.class)
52      private final Timestamp invalidOrLostBarcodeEffDate;
53  
54      @XmlElement(name = Elements.OLE_PTRN_LOST_BAR_NUM, required = false)
55      private final String invalidOrLostBarcodeNumber;
56  
57      @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
58      private final Long versionNumber;
59  
60  
61      @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
62      private final String objectId;
63  
64  
65      @SuppressWarnings("unused")
66      @XmlAnyElement
67      private final Collection<Element> _futureElements = null;
68  
69      public OlePatronLostBarcodeDefinition() {
70          this.olePatronLostBarcodeId = null;
71          this.olePatronId = null;
72          this.invalidOrLostBarcodeNumber = null;
73          this.invalidOrLostBarcodeEffDate = null;
74          this.versionNumber = null;
75  
76          this.objectId = null;
77      }
78  
79  
80      private OlePatronLostBarcodeDefinition(Builder builder) {
81          this.olePatronLostBarcodeId = builder.getOlePatronLostBarcodeId();
82          this.olePatronId = builder.getOlePatronId();
83          this.invalidOrLostBarcodeEffDate = builder.getInvalidOrLostBarcodeEffDate();
84          this.invalidOrLostBarcodeNumber = builder.getInvalidOrLostBarcodeNumber();
85          this.versionNumber = builder.getVersionNumber();
86          this.objectId = builder.getObjectId();
87      }
88  
89      public String getOlePatronLostBarcodeId() {
90          return this.olePatronLostBarcodeId;
91      }
92  
93  
94      public String getOlePatronId() {
95          return this.olePatronId;
96      }
97  
98  
99      public Timestamp getInvalidOrLostBarcodeEffDate() {
100         return this.invalidOrLostBarcodeEffDate;
101     }
102 
103     public String getInvalidOrLostBarcodeNumber() {
104         return this.invalidOrLostBarcodeNumber;
105     }
106 
107     @Override
108     public String getObjectId() {
109         return this.objectId;
110     }
111 
112     @Override
113     public Long getVersionNumber() {
114         return this.versionNumber;
115     }
116 
117     @Override
118     public String getId() {
119         return this.olePatronLostBarcodeId;
120     }
121 
122 
123     //@Override
124     /*public OleBorrowerTypeDefinition getOleBorrowerType() {
125         return this.oleBorrowerType;
126     }*/
127 
128     public static class Builder
129             implements Serializable, ModelBuilder, OlePatronLostBarcodeContract {
130         private String olePatronLostBarcodeId;
131         private String olePatronId;
132         private Timestamp invalidOrLostBarcodeEffDate;
133         private String invalidOrLostBarcodeNumber;
134         private Long versionNumber;
135         private String objectId;
136 
137         private Builder() {
138         }
139 
140         public static Builder create() {
141             return new Builder();
142         }
143 
144         public static Builder create(OlePatronLostBarcodeContract contract) {
145             if (contract == null) {
146                 throw new IllegalArgumentException("contract was null");
147             }
148             Builder builder = create();
149             if (contract.getOlePatronLostBarcodeId() != null) {
150                 builder.setOlePatronLostBarcodeId(contract.getOlePatronLostBarcodeId());
151             }
152             if (contract.getOlePatronId() != null) {
153                 builder.setOlePatronId(contract.getOlePatronId());
154             }
155             if (contract.getInvalidOrLostBarcodeNumber() != null) {
156                 builder.setInvalidOrLostBarcodeNumber(contract.getInvalidOrLostBarcodeNumber());
157             }
158             if (contract.getInvalidOrLostBarcodeEffDate() != null) {
159                 builder.setInvalidOrLostBarcodeEffDate(new Timestamp(contract.getInvalidOrLostBarcodeEffDate().getTime()));
160             }
161 
162             builder.setObjectId(contract.getObjectId());
163             builder.setVersionNumber(contract.getVersionNumber());
164             builder.setId(contract.getId());
165             return builder;
166         }
167 
168 
169         public OlePatronLostBarcodeDefinition build() {
170             return new OlePatronLostBarcodeDefinition(this);
171         }
172 
173         public String getOlePatronLostBarcodeId() {
174             return this.olePatronLostBarcodeId;
175         }
176 
177         public void setOlePatronLostBarcodeId(String olePatronLostBarcodeId) {
178             this.olePatronLostBarcodeId = olePatronLostBarcodeId;
179         }
180 
181         public String getOlePatronId() {
182             return this.olePatronId;
183         }
184 
185         public void setOlePatronId(String olePatronId) {
186             this.olePatronId = olePatronId;
187         }
188 
189         public Timestamp getInvalidOrLostBarcodeEffDate() {
190             return this.invalidOrLostBarcodeEffDate;
191         }
192 
193         public void setInvalidOrLostBarcodeEffDate(Timestamp invalidOrLostBarcodeEffDate) {
194             this.invalidOrLostBarcodeEffDate = invalidOrLostBarcodeEffDate;
195         }
196 
197         public String getInvalidOrLostBarcodeNumber() {
198             return this.invalidOrLostBarcodeNumber;
199         }
200 
201         public void setInvalidOrLostBarcodeNumber(String invalidOrLostBarcodeNumber) {
202             this.invalidOrLostBarcodeNumber = invalidOrLostBarcodeNumber;
203         }
204 
205         @Override
206         public String getId() {
207             return this.olePatronLostBarcodeId;
208         }
209 
210 
211         public void setId(String id) {
212             if (StringUtils.isWhitespace(id)) {
213                 throw new IllegalArgumentException("id is blank");
214             }
215             this.olePatronLostBarcodeId = id;
216         }
217 
218         public Long getVersionNumber() {
219             return this.versionNumber;
220         }
221 
222         public void setVersionNumber(Long versionNumber) {
223             this.versionNumber = versionNumber;
224         }
225 
226         public String getObjectId() {
227             return objectId;
228         }
229 
230         public void setObjectId(String objectId) {
231             this.objectId = objectId;
232         }
233     }
234 
235     static class Constants {
236 
237         final static String ROOT_ELEMENT_NAME = "olePatronLostBarcode";
238         final static String TYPE_NAME = "OlePatronLostBarcodeType";
239         final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[]{CoreConstants.CommonElements.FUTURE_ELEMENTS};
240     }
241 
242     static class Elements {
243         final static String OLE_PTRN_LOST_BAR_ID = "olePatronLostBarcodeId";
244         final static String OLE_PTRN_ID = "olePatronId";
245         final static String OLE_PTRN_LOST_BAR_EFF_DT = "invalidOrLostBarcodeEffDate";
246         final static String OLE_PTRN_LOST_BAR_NUM = "invalidOrLostBarcodeNumber";
247 
248 
249     }
250 
251     public static class Cache {
252         public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + Constants.TYPE_NAME;
253     }
254 }