1 package org.kuali.ole.deliver.bo; 2 3 4 import org.kuali.api.jaxb.DateAdapter; 5 import org.kuali.rice.core.api.mo.AbstractDataTransferObject; 6 import org.kuali.rice.core.api.mo.ModelBuilder; 7 8 import javax.xml.bind.annotation.*; 9 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 10 import java.io.Serializable; 11 import java.util.Date; 12 13 14 @XmlRootElement(name = OlePatronLoanDocument.Constants.ROOT_ELEMENT_NAME) 15 @XmlAccessorType(XmlAccessType.NONE) 16 @XmlType(name = "PatronLoanDocument", propOrder = { 17 OlePatronLoanDocument.Elements.ITEM_BAR_CODE, 18 OlePatronLoanDocument.Elements.TITLE, 19 OlePatronLoanDocument.Elements.AUTHOR, 20 OlePatronLoanDocument.Elements.LOCATION, 21 OlePatronLoanDocument.Elements.CALL_NUMBER, 22 OlePatronLoanDocument.Elements.DUE_DATE, 23 OlePatronLoanDocument.Elements.MESSAGE_INFO 24 25 26 }) 27 public class OlePatronLoanDocument extends AbstractDataTransferObject implements OlePatronLoanDocumentContract { 28 29 private static final long serialVersionUID = 1L; 30 31 @XmlElement(name = Elements.ITEM_BAR_CODE, required = false) 32 private final String itemBarcode; 33 34 @XmlElement(name = Elements.TITLE, required = false) 35 private final String title; 36 37 @XmlElement(name = Elements.AUTHOR, required = false) 38 private final String author; 39 40 @XmlElement(name = Elements.DUE_DATE, required = false) 41 @XmlJavaTypeAdapter(value = DateAdapter.class, type = Date.class) 42 private final Date dueDate; 43 44 @XmlElement(name = Elements.LOCATION, required = false) 45 private final String location; 46 47 @XmlElement(name = Elements.CALL_NUMBER, required = false) 48 private final String callNumber; 49 50 @XmlElement(name = Elements.MESSAGE_INFO, required = false) 51 private final String messageInfo; 52 53 54 public OlePatronLoanDocument() { 55 this.itemBarcode = null; 56 this.title = null; 57 this.author = null; 58 this.dueDate = null; 59 this.location = null; 60 this.callNumber = null; 61 this.messageInfo = null; 62 63 } 64 65 66 private OlePatronLoanDocument(Builder builder) { 67 this.itemBarcode = builder.getItemBarcode(); 68 this.title = builder.getTitle(); 69 this.author = builder.getAuthor(); 70 this.dueDate = builder.getDueDate(); 71 this.location = builder.getLocation(); 72 this.callNumber = builder.getCallNumber(); 73 this.messageInfo = builder.getMessageInfo(); 74 75 } 76 77 78 @Override 79 public String getMessageInfo() { 80 return messageInfo; 81 } 82 83 @Override 84 public String getItemBarcode() { 85 return itemBarcode; 86 } 87 88 @Override 89 public String getTitle() { 90 return title; 91 } 92 93 @Override 94 public String getAuthor() { 95 return author; 96 } 97 98 @Override 99 public Date getDueDate() { 100 return dueDate; 101 } 102 103 @Override 104 public String getLocation() { 105 return location; 106 } 107 108 @Override 109 public String getCallNumber() { 110 return callNumber; 111 } 112 113 @Override 114 public Long getVersionNumber() { 115 return null; 116 } 117 118 @Override 119 public String getId() { 120 return null; 121 } 122 123 124 public static class Builder 125 implements Serializable, ModelBuilder, OlePatronLoanDocumentContract { 126 private String itemBarcode; 127 private String title; 128 private String author; 129 private Date dueDate; 130 private String location; 131 private String callNumber; 132 private String id; 133 private Long versionNumber; 134 private String messageInfo; 135 private String patronBarcode; 136 137 138 private Builder() { 139 } 140 141 public static Builder create() { 142 return new Builder(); 143 } 144 145 public static Builder create(OlePatronLoanDocumentContract contract) { 146 if (contract == null) { 147 throw new IllegalArgumentException("contract was null"); 148 } 149 Builder builder = create(); 150 if (contract.getItemBarcode() != null) { 151 builder.setItemBarcode(contract.getItemBarcode()); 152 } 153 if (contract.getAuthor() != null) { 154 builder.setAuthor(contract.getAuthor()); 155 } 156 if (contract.getTitle() != null) { 157 builder.setTitle(contract.getTitle()); 158 } 159 if (contract.getCallNumber() != null) { 160 builder.setCallNumber(contract.getCallNumber()); 161 } 162 if (contract.getLocation() != null) { 163 builder.setLocation(contract.getLocation()); 164 } 165 if (contract.getDueDate() != null) { 166 builder.setDueDate(contract.getDueDate()); 167 } 168 if (contract.getMessageInfo() != null) { 169 builder.setMessageInfo(contract.getMessageInfo()); 170 } 171 return builder; 172 } 173 174 175 public void setPatronBarcode(String patronBarcode) { 176 this.patronBarcode = patronBarcode; 177 } 178 179 @Override 180 public Long getVersionNumber() { 181 return versionNumber; 182 } 183 184 public void setVersionNumber(Long versionNumber) { 185 this.versionNumber = versionNumber; 186 } 187 188 @Override 189 public String getId() { 190 return id; 191 } 192 193 public void setId(String id) { 194 this.id = id; 195 } 196 197 @Override 198 public OlePatronLoanDocument build() { 199 return new OlePatronLoanDocument(this); 200 } 201 202 @Override 203 public String getItemBarcode() { 204 return itemBarcode; 205 } 206 207 public void setItemBarcode(String itemBarcode) { 208 this.itemBarcode = itemBarcode; 209 } 210 211 @Override 212 public String getTitle() { 213 return title; 214 } 215 216 public void setTitle(String title) { 217 this.title = title; 218 } 219 220 @Override 221 public String getAuthor() { 222 return author; 223 } 224 225 public void setAuthor(String author) { 226 this.author = author; 227 } 228 229 @Override 230 public Date getDueDate() { 231 return dueDate; 232 } 233 234 public void setDueDate(Date dueDate) { 235 this.dueDate = dueDate; 236 } 237 238 @Override 239 public String getLocation() { 240 return location; 241 } 242 243 public void setLocation(String location) { 244 this.location = location; 245 } 246 247 @Override 248 public String getCallNumber() { 249 return callNumber; 250 } 251 252 @Override 253 public String getMessageInfo() { 254 return messageInfo; 255 } 256 257 public void setMessageInfo(String messageInfo) { 258 this.messageInfo = messageInfo; 259 } 260 261 public void setCallNumber(String callNumber) { 262 this.callNumber = callNumber; 263 } 264 } 265 266 static class Constants { 267 268 final static String ROOT_ELEMENT_NAME = "olePatronLoanItem"; 269 } 270 271 static class Elements { 272 final static String ITEM_BAR_CODE = "itemBarcode"; 273 final static String TITLE = "title"; 274 final static String AUTHOR = "author"; 275 final static String DUE_DATE = "dueDate"; 276 final static String LOCATION = "location"; 277 final static String CALL_NUMBER = "callNumber"; 278 final static String MESSAGE_INFO = "messageInfo"; 279 280 } 281 282 }