View Javadoc
1   package org.kuali.ole.deliver.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.sql.Date;
14  import java.util.Collection;
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 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         private String title;
227         private String author;
228         private String shelvingLocation;
229         private String callNumber;
230         private String copyNumber;
231         private String volumeNumber;
232         private String patronName;
233         private String itemType;
234         private String itemStatus;
235         private String itemId;
236         private String requestId;
237         private Integer borrowerQueuePosition;
238         private Date createDate;
239         private OleDeliverRequestTypeDefinition.Builder oleDeliverRequestType;
240 
241 
242         private Builder() {
243         }
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.getTitle() != null) {
255                 builder.setTitle(contract.getTitle());
256             }
257             if (contract.getAuthor() != null) {
258                 builder.setAuthor(contract.getAuthor());
259             }
260             if (contract.getCallNumber() != null) {
261                 builder.setCallNumber(contract.getCallNumber());
262             }
263             if (contract.getCopyNumber() != null) {
264                 builder.setCopyNumber(contract.getCopyNumber());
265             }
266             if (contract.getItemStatus() != null) {
267                 builder.setItemStatus(contract.getItemStatus());
268             }
269             if (contract.getItemType() != null) {
270                 builder.setItemType(contract.getItemType());
271             }
272             if (contract.getShelvingLocation() != null) {
273                 builder.setShelvingLocation(contract.getShelvingLocation());
274             }
275             if (contract.getVolumeNumber() != null) {
276                 builder.setVolumeNumber(contract.getVolumeNumber());
277             }
278             if (contract.getItemId() != null) {
279                 builder.setItemId(contract.getItemId());
280             }
281             if (contract.getRequestId() != null) {
282                 builder.setRequestId(contract.getRequestId());
283             }
284             if (contract.getRequestId() != null) {
285                 builder.setRequestId(contract.getRequestId());
286             }
287             if (contract.getBorrowerQueuePosition() != null) {
288                 builder.setBorrowerQueuePosition(contract.getBorrowerQueuePosition());
289             }
290             if (contract.getCreateDate() != null) {
291                 builder.setCreateDate(contract.getCreateDate());
292             }
293             if (contract.getOleDeliverRequestType() != null) {
294                 builder.setOleDeliverRequestType(OleDeliverRequestTypeDefinition.Builder.create(contract.getOleDeliverRequestType()));
295             }
296 
297             builder.setId(contract.getId());
298             return builder;
299         }
300 
301 
302         public OleDeliverRequestDefinition build() {
303             return new OleDeliverRequestDefinition(this);
304         }
305 
306         public String getTitle() {
307             return title;
308         }
309 
310         public void setTitle(String title) {
311             this.title = title;
312         }
313 
314         public String getAuthor() {
315             return author;
316         }
317 
318         public void setAuthor(String author) {
319             this.author = author;
320         }
321 
322         public String getShelvingLocation() {
323             return shelvingLocation;
324         }
325 
326         public void setShelvingLocation(String shelvingLocation) {
327             this.shelvingLocation = shelvingLocation;
328         }
329 
330         public String getCallNumber() {
331             return callNumber;
332         }
333 
334         public void setCallNumber(String callNumber) {
335             this.callNumber = callNumber;
336         }
337 
338         public String getCopyNumber() {
339             return copyNumber;
340         }
341 
342         public void setCopyNumber(String copyNumber) {
343             this.copyNumber = copyNumber;
344         }
345 
346         public String getItemId() {
347             return itemId;
348         }
349 
350         public void setItemId(String itemId) {
351             this.itemId = itemId;
352         }
353 
354         public String getRequestId() {
355             return requestId;
356         }
357 
358         public void setRequestId(String requestId) {
359             this.requestId = requestId;
360         }
361 
362         public String getVolumeNumber() {
363             return volumeNumber;
364         }
365 
366         public void setBorrowerQueuePosition(Integer borrowerQueuePosition) {
367             this.borrowerQueuePosition = borrowerQueuePosition;
368         }
369 
370         public void setCreateDate(Date createDate) {
371             this.createDate = createDate;
372         }
373 
374         public OleDeliverRequestTypeDefinition.Builder getOleDeliverRequestType() {
375             return oleDeliverRequestType;
376         }
377 
378         public void setOleDeliverRequestType(OleDeliverRequestTypeDefinition.Builder oleDeliverRequestType) {
379             this.oleDeliverRequestType = oleDeliverRequestType;
380         }
381 
382         public void setVolumeNumber(String volumeNumber) {
383             this.volumeNumber = volumeNumber;
384         }
385 
386         public String getPatronName() {
387             return patronName;
388         }
389 
390         @Override
391         public Date getCreateDate() {
392             return this.createDate;
393         }
394 
395 
396         public void setPatronName(String patronName) {
397             this.patronName = patronName;
398         }
399 
400         public String getItemType() {
401             return itemType;
402         }
403 
404         @Override
405         public Integer getBorrowerQueuePosition() {
406             return this.borrowerQueuePosition;
407         }
408 
409         public void setItemType(String itemType) {
410             this.itemType = itemType;
411         }
412 
413         public String getItemStatus() {
414             return itemStatus;
415         }
416 
417         public void setItemStatus(String itemStatus) {
418             this.itemStatus = itemStatus;
419         }
420 
421         @Override
422         public String getId() {
423             return null;
424         }
425 
426         public void setId(String id) {
427         }
428 
429         @Override
430         public Long getVersionNumber() {
431             return null;  //To change body of implemented methods use File | Settings | File Templates.
432         }
433     }
434 
435     static class Constants {
436 
437         final static String ROOT_ELEMENT_NAME = "oleDeliverRequest";
438         final static String TYPE_NAME = "OleDeliverRequestType";
439         final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[]{CoreConstants.CommonElements.FUTURE_ELEMENTS};
440     }
441 
442     static class Elements {
443         final static String ITEM_ID = "itemId";
444         final static String REQUEST_ID = "requestId";
445         final static String TITLE = "title";
446         final static String ITEM_STATUS = "itemStatus";
447         final static String AUTHOR = "author";
448         final static String ITEM_TYPE = "itemType";
449         final static String SHELVING_LOCATION = "shelvingLocation";
450         final static String CALL_NUMBER = "callNumber";
451         final static String COPY_NUMBER = "copyNumber";
452         final static String VOLUME_NUMBER = "volumeNumber";
453         final static String PATRON_NAME = "patronName";
454         final static String CREATE_DATE = "createDate";
455         final static String BORR_QUEUE_POS = "borrowerQueuePosition";
456         final static String OLE_DLVR_REQ_TYPE = "oleDeliverRequestType";
457 
458 
459     }
460 
461     public static class Cache {
462         public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + Constants.TYPE_NAME;
463     }
464 }