View Javadoc

1   package org.kuali.ole.deliver.request.api;
2   
3   import org.kuali.api.jaxb.DateAdapter;
4   import org.kuali.rice.core.api.CoreConstants;
5   import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
6   import org.kuali.rice.core.api.mo.ModelBuilder;
7   import org.kuali.rice.kim.api.KimConstants;
8   import org.w3c.dom.Element;
9   
10  import javax.xml.bind.annotation.*;
11  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
12  import java.io.Serializable;
13  import java.util.Collection;
14  import java.sql.Date;
15  
16  /**
17   * Created with IntelliJ IDEA.
18   * User: ?
19   * Date: 5/24/12
20   * Time: 8:26 PM
21   * To change this template use File | Settings | File Templates.
22   */
23  @XmlRootElement(name = OleDeliverRequestDefinition.Constants.ROOT_ELEMENT_NAME)
24  @XmlAccessorType(XmlAccessType.NONE)
25  @XmlType(name = OleDeliverRequestDefinition.Constants.TYPE_NAME, propOrder = {
26          OleDeliverRequestDefinition.Elements.AUTHOR,
27          OleDeliverRequestDefinition.Elements.CALL_NUMBER,
28          OleDeliverRequestDefinition.Elements.COPY_NUMBER,
29          OleDeliverRequestDefinition.Elements.ITEM_STATUS,
30          OleDeliverRequestDefinition.Elements.ITEM_TYPE,
31          OleDeliverRequestDefinition.Elements.PATRON_NAME,
32          OleDeliverRequestDefinition.Elements.VOLUME_NUMBER,
33          OleDeliverRequestDefinition.Elements.SHELVING_LOCATION,
34          OleDeliverRequestDefinition.Elements.TITLE,
35          OleDeliverRequestDefinition.Elements.ITEM_ID,
36          OleDeliverRequestDefinition.Elements.REQUEST_ID,
37          OleDeliverRequestDefinition.Elements.BORR_QUEUE_POS,
38          OleDeliverRequestDefinition.Elements.CREATE_DATE,
39          OleDeliverRequestDefinition.Elements.OLE_DLVR_REQ_TYPE,
40  
41          CoreConstants.CommonElements.VERSION_NUMBER,
42          //CoreConstants.CommonElements.OBJECT_ID,
43          CoreConstants.CommonElements.FUTURE_ELEMENTS
44  })
45  public class OleDeliverRequestDefinition extends AbstractDataTransferObject implements OleDeliverRequestContract{
46  
47      private static final long serialVersionUID = 1L;
48  
49      @XmlElement(name = Elements.TITLE, required = false)
50      private final String title;
51  
52      @XmlElement(name = Elements.AUTHOR, required = false)
53      private final String author;
54  
55      @XmlElement(name = Elements.CALL_NUMBER, required = false)
56      private final String callNumber;
57  
58      @XmlElement(name = Elements.COPY_NUMBER, required = false)
59      private final String copyNumber;
60  
61      @XmlElement(name = Elements.VOLUME_NUMBER, required = false)
62      private final String volumeNumber;
63  
64      @XmlElement(name = Elements.ITEM_STATUS, required = false)
65      private final String itemStatus;
66  
67      @XmlElement(name = Elements.ITEM_ID, required = false)
68      private final String itemId;
69  
70      @XmlElement(name = Elements.REQUEST_ID, required = false)
71      private final String requestId;
72  
73      @XmlElement(name = Elements.ITEM_TYPE, required = false)
74      private final String itemType;
75  
76      @XmlElement(name = Elements.PATRON_NAME, required = false)
77      private final String patronName;
78  
79      @XmlElement(name = Elements.CREATE_DATE, required = false)
80      @XmlJavaTypeAdapter(value=DateAdapter.class, type=Date.class)
81      private final Date createDate;
82  
83      @XmlElement(name = Elements.BORR_QUEUE_POS, required = false)
84      private final Integer borrowerQueuePosition;
85  
86      @XmlElement(name = Elements.SHELVING_LOCATION, required = false)
87      private final String shelvingLocation;
88  
89      @XmlElement(name = Elements.OLE_DLVR_REQ_TYPE, required = false)
90      private final OleDeliverRequestTypeDefinition oleDeliverRequestType;
91  
92      @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
93      private final Long versionNumber;
94  
95      /*@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
96      private final String objectId;*/
97      @SuppressWarnings("unused")
98      @XmlAnyElement
99      private final Collection<Element> _futureElements = null;
100 
101     public OleDeliverRequestDefinition() {
102         this.title = null;
103         this.author = null;
104         this.itemStatus = null;
105         this.callNumber = null;
106         this.copyNumber = null;
107         this.volumeNumber = null;
108         this.shelvingLocation = null;
109         this.itemType = null;
110         this.patronName = null;
111         this.itemId = null;
112         this.requestId = null;
113         this.createDate = null;
114         this.borrowerQueuePosition = null;
115         this.oleDeliverRequestType = null;
116         this.versionNumber = null;
117 
118         //this.objectId = null;
119     }
120 
121 
122     private OleDeliverRequestDefinition(Builder builder) {
123         this.title = builder.getTitle();
124         this.author= builder.getAuthor();
125         this.callNumber= builder.getCallNumber();
126         this.copyNumber = builder.getCopyNumber();
127         this.itemType= builder.getItemType();
128         this.itemStatus= builder.getItemStatus();
129         this.shelvingLocation = builder.getShelvingLocation();
130         this.volumeNumber = builder.getVolumeNumber();
131         this.patronName = builder.getPatronName();
132         this.itemId = builder.getItemId();
133         this.requestId = builder.getRequestId();
134         this.borrowerQueuePosition = builder.getBorrowerQueuePosition();
135         this.createDate = builder.getCreateDate();
136         this.oleDeliverRequestType = builder.getOleDeliverRequestType().build();
137         this.versionNumber = builder.getVersionNumber();
138         //this.objectId = builder.getObjectId();
139     }
140 
141 
142     @Override
143     public Long getVersionNumber() {
144         return this.versionNumber;
145     }
146 
147     @Override
148     public String getId() {
149         return this.requestId;
150     }
151 
152     @Override
153     public String getItemId() {
154         return this.itemId;
155     }
156 
157     @Override
158     public String getRequestId() {
159         return this.requestId;
160     }
161 
162     @Override
163     public String getItemStatus() {
164         return this.itemStatus;
165     }
166 
167     @Override
168     public String getItemType() {
169         return this.itemType;
170     }
171 
172     @Override
173     public Integer getBorrowerQueuePosition() {
174         return this.borrowerQueuePosition;
175     }
176 
177     @Override
178     public String getTitle() {
179         return this.title;
180     }
181 
182     @Override
183     public String getAuthor() {
184         return this.author;
185     }
186 
187     @Override
188     public String getShelvingLocation() {
189         return this.shelvingLocation;
190     }
191 
192     @Override
193     public String getCallNumber() {
194         return this.callNumber;
195     }
196 
197     @Override
198     public String getCopyNumber() {
199         return this.copyNumber;
200     }
201 
202     @Override
203     public String getPatronName() {
204         return this.patronName;
205     }
206 
207     @Override
208     public java.sql.Date getCreateDate() {
209         return this.createDate;
210     }
211 
212 
213     @Override
214     public String getVolumeNumber() {
215         return this.volumeNumber;
216     }
217 
218     @Override
219     public OleDeliverRequestTypeDefinition getOleDeliverRequestType() {
220         return this.oleDeliverRequestType;
221     }
222 
223 
224     public static class Builder
225             implements Serializable, ModelBuilder, OleDeliverRequestContract
226     {
227         private String title;
228         private String author;
229         private String shelvingLocation;
230         private String callNumber;
231         private String copyNumber;
232         private String volumeNumber;
233         private String patronName;
234         private String itemType;
235         private String itemStatus;
236         private String itemId;
237         private String requestId;
238         private Integer borrowerQueuePosition;
239         private Date createDate;
240         private OleDeliverRequestTypeDefinition.Builder oleDeliverRequestType;
241 
242 
243         private Builder() { }
244 
245         public static Builder create() {
246             return new Builder();
247         }
248 
249         public static Builder create(OleDeliverRequestContract contract) {
250             if(contract == null) {
251                 throw new IllegalArgumentException("contract was null");
252             }
253             Builder builder = create();
254             if (contract.getAuthor() != null) {
255                 builder.setAuthor(contract.getAuthor());
256             }
257             if(contract.getCallNumber() != null) {
258                 builder.setCallNumber(contract.getCallNumber());
259             }
260             if(contract.getCopyNumber() != null) {
261                 builder.setCopyNumber(contract.getCopyNumber());
262             }
263             if(contract.getItemStatus() != null) {
264                 builder.setItemStatus(contract.getItemStatus());
265             }
266             if(contract.getItemType() != null) {
267                 builder.setItemType(contract.getItemType());
268             }
269             if(contract.getShelvingLocation() != null) {
270                 builder.setShelvingLocation(contract.getShelvingLocation());
271             }
272             if(contract.getVolumeNumber() != null) {
273                 builder.setVolumeNumber(contract.getVolumeNumber());
274             }
275             if(contract.getItemId() != null) {
276                 builder.setItemId(contract.getItemId());
277             }
278             if(contract.getRequestId() != null) {
279                 builder.setRequestId(contract.getRequestId());
280             }
281             if(contract.getRequestId() != null) {
282                 builder.setRequestId(contract.getRequestId());
283             }
284             if(contract.getBorrowerQueuePosition() != null) {
285                 builder.setBorrowerQueuePosition(contract.getBorrowerQueuePosition());
286             }
287             if(contract.getCreateDate() != null) {
288                 builder.setCreateDate(contract.getCreateDate());
289             }
290             if(contract.getOleDeliverRequestType() != null) {
291                 builder.setOleDeliverRequestType(OleDeliverRequestTypeDefinition.Builder.create(contract.getOleDeliverRequestType()));
292             }
293 
294             builder.setId(contract.getId());
295             return builder;
296         }
297 
298 
299         public OleDeliverRequestDefinition build() {
300             return new OleDeliverRequestDefinition(this);
301         }
302 
303         public String getTitle() {
304             return title;
305         }
306 
307         public void setTitle(String title) {
308             this.title = title;
309         }
310 
311         public String getAuthor() {
312             return author;
313         }
314 
315         public void setAuthor(String author) {
316             this.author = author;
317         }
318 
319         public String getShelvingLocation() {
320             return shelvingLocation;
321         }
322 
323         public void setShelvingLocation(String shelvingLocation) {
324             this.shelvingLocation = shelvingLocation;
325         }
326 
327         public String getCallNumber() {
328             return callNumber;
329         }
330 
331         public void setCallNumber(String callNumber) {
332             this.callNumber = callNumber;
333         }
334 
335         public String getCopyNumber() {
336             return copyNumber;
337         }
338 
339         public void setCopyNumber(String copyNumber) {
340             this.copyNumber = copyNumber;
341         }
342 
343         public String getItemId() {
344             return itemId;
345         }
346 
347         public void setItemId(String itemId) {
348             this.itemId = itemId;
349         }
350 
351         public String getRequestId() {
352             return requestId;
353         }
354 
355         public void setRequestId(String requestId) {
356             this.requestId = requestId;
357         }
358 
359         public String getVolumeNumber() {
360             return volumeNumber;
361         }
362 
363         public void setBorrowerQueuePosition(Integer borrowerQueuePosition) {
364             this.borrowerQueuePosition = borrowerQueuePosition;
365         }
366 
367         public void setCreateDate(Date createDate) {
368             this.createDate = createDate;
369         }
370 
371         public OleDeliverRequestTypeDefinition.Builder getOleDeliverRequestType() {
372             return oleDeliverRequestType;
373         }
374 
375         public void setOleDeliverRequestType(OleDeliverRequestTypeDefinition.Builder oleDeliverRequestType) {
376             this.oleDeliverRequestType = oleDeliverRequestType;
377         }
378 
379         public void setVolumeNumber(String volumeNumber) {
380             this.volumeNumber = volumeNumber;
381         }
382 
383         public String getPatronName() {
384             return patronName;
385         }
386 
387         @Override
388         public java.sql.Date getCreateDate() {
389             return this.createDate;
390         }
391 
392 
393         public void setPatronName(String patronName) {
394             this.patronName = patronName;
395         }
396 
397         public String getItemType() {
398             return itemType;
399         }
400 
401         @Override
402         public Integer getBorrowerQueuePosition() {
403             return this.borrowerQueuePosition;
404         }
405 
406         public void setItemType(String itemType) {
407             this.itemType = itemType;
408         }
409 
410         public String getItemStatus() {
411             return itemStatus;
412         }
413 
414         public void setItemStatus(String itemStatus) {
415             this.itemStatus = itemStatus;
416         }
417 
418         @Override
419         public String getId() {
420             return null;
421         }
422 
423         public void setId(String id) {
424         }
425 
426         @Override
427         public Long getVersionNumber() {
428             return null;  //To change body of implemented methods use File | Settings | File Templates.
429         }
430     }
431 
432     static class Constants {
433 
434         final static String ROOT_ELEMENT_NAME = "oleDeliverRequest";
435         final static String TYPE_NAME = "OleDeliverRequestType";
436         final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS };
437     }
438 
439     static class Elements {
440         final static String ITEM_ID= "itemId";
441         final static String REQUEST_ID= "requestId";
442         final static String TITLE = "title";
443         final static String ITEM_STATUS = "itemStatus";
444         final static String AUTHOR = "author";
445         final static String ITEM_TYPE = "itemType";
446         final static String SHELVING_LOCATION= "shelvingLocation";
447         final static String CALL_NUMBER= "callNumber";
448         final static String COPY_NUMBER = "copyNumber";
449         final static String VOLUME_NUMBER = "volumeNumber";
450         final static String PATRON_NAME = "patronName";
451         final static String CREATE_DATE = "createDate";
452         final static String BORR_QUEUE_POS = "borrowerQueuePosition";
453         final static String OLE_DLVR_REQ_TYPE="oleDeliverRequestType";
454 
455 
456     }
457     public static class Cache {
458         public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + OleDeliverRequestDefinition.Constants.TYPE_NAME;
459     }
460 }