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