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