001 package org.kuali.ole.patron.api; 002 003 import org.apache.commons.lang.StringUtils; 004 import org.kuali.api.jaxb.DateAdapter; 005 import org.kuali.rice.core.api.CoreConstants; 006 import org.kuali.rice.core.api.mo.AbstractDataTransferObject; 007 import org.kuali.rice.core.api.mo.ModelBuilder; 008 import org.kuali.rice.kim.api.KimConstants; 009 import org.w3c.dom.Element; 010 011 import javax.xml.bind.annotation.*; 012 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 013 import java.io.Serializable; 014 import java.util.Collection; 015 import java.util.Date; 016 017 /** 018 * Created with IntelliJ IDEA. 019 * User: ? 020 * Date: 5/24/12 021 * Time: 8:26 PM 022 * To change this template use File | Settings | File Templates. 023 */ 024 @XmlRootElement(name = OleProxyPatronDefinition.Constants.ROOT_ELEMENT_NAME) 025 @XmlAccessorType(XmlAccessType.NONE) 026 @XmlType(name = OleProxyPatronDefinition.Constants.TYPE_NAME, propOrder = { 027 OleProxyPatronDefinition.Elements.OLE_PROXY_PATRON_DOC_ID, 028 OleProxyPatronDefinition.Elements.OLE_PROXY_PATRON_ID, 029 OleProxyPatronDefinition.Elements.OLE_PATRON_ID, 030 OleProxyPatronDefinition.Elements.OLE_PROXY_PATRON_EXP_DT, 031 OleProxyPatronDefinition.Elements.OLE_PROXY_PATRON_ACT_DT, 032 //OleProxyPatronDefinition.Elements.OLE_PATRON_DOC, 033 OleProxyPatronDefinition.Elements.ACTIVE_INDICATOR, 034 035 CoreConstants.CommonElements.VERSION_NUMBER, 036 //CoreConstants.CommonElements.OBJECT_ID, 037 CoreConstants.CommonElements.FUTURE_ELEMENTS 038 }) 039 public final class OleProxyPatronDefinition extends AbstractDataTransferObject implements OleProxyPatronContract{ 040 041 private static final long serialVersionUID = 1L; 042 043 044 045 @XmlElement(name = Elements.OLE_PROXY_PATRON_DOC_ID, required = false) 046 private final String oleProxyPatronDocumentId; 047 048 @XmlElement(name = Elements.OLE_PROXY_PATRON_ID, required = false) 049 private final String proxyPatronId; 050 051 @XmlElement(name = Elements.OLE_PATRON_ID, required = false) 052 private final String olePatronId; 053 054 @XmlElement(name = Elements.ACTIVE_INDICATOR, required = false) 055 private final boolean active; 056 057 @XmlElement(name = Elements.OLE_PROXY_PATRON_EXP_DT, required = false) 058 @XmlJavaTypeAdapter(value=DateAdapter.class, type=Date.class) 059 private final Date proxyPatronExpirationDate; 060 061 @XmlElement(name = Elements.OLE_PROXY_PATRON_ACT_DT, required = false) 062 @XmlJavaTypeAdapter(value=DateAdapter.class, type=Date.class) 063 private final Date proxyPatronActivationDate; 064 /* 065 066 @XmlElement(name = Elements.OLE_PATRON_DOC, required = false) 067 private final OlePatronDefinition olePatronDocument; 068 */ 069 070 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) 071 private final Long versionNumber; 072 073 /*@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) 074 private final String objectId;*/ 075 @SuppressWarnings("unused") 076 @XmlAnyElement 077 private final Collection<Element> _futureElements = null; 078 079 public OleProxyPatronDefinition() { 080 this.olePatronId = null; 081 this.oleProxyPatronDocumentId = null; 082 this.proxyPatronId = null; 083 this.active = false; 084 this.proxyPatronExpirationDate = null; 085 this.proxyPatronActivationDate = null; 086 // this.olePatronDocument = null; 087 this.versionNumber = null; 088 //this.objectId = null; 089 } 090 091 092 private OleProxyPatronDefinition(Builder builder) { 093 this.oleProxyPatronDocumentId = builder.getOleProxyPatronDocumentId(); 094 this.proxyPatronId = builder.getProxyPatronId(); 095 this.olePatronId = builder.getOlePatronId(); 096 this.proxyPatronExpirationDate = builder.getProxyPatronExpirationDate(); 097 this.proxyPatronActivationDate =builder.getProxyPatronActivationDate(); 098 this.active = builder.isActive(); 099 100 // this.olePatronDocument = builder.getOlePatronDocument().build(); 101 102 this.versionNumber = builder.getVersionNumber(); 103 //this.objectId = builder.getObjectId(); 104 } 105 106 @Override 107 public String getOlePatronId() { 108 return this.olePatronId; 109 } 110 @Override 111 public String getOleProxyPatronDocumentId(){ 112 return this.oleProxyPatronDocumentId; 113 }; 114 @Override 115 public String getProxyPatronId(){ 116 return this.proxyPatronId; 117 }; 118 119 /* @Override 120 public OlePatronDefinition getOlePatronDocument(){ 121 return this.olePatronDocument; 122 };*/ 123 @Override 124 public Date getProxyPatronExpirationDate(){ 125 return this.proxyPatronExpirationDate; 126 }; 127 @Override 128 public Date getProxyPatronActivationDate(){ 129 return this.proxyPatronActivationDate; 130 }; 131 @Override 132 public boolean isActive() { 133 return this.active; 134 }; 135 136 137 @Override 138 public String getId() { 139 return this.oleProxyPatronDocumentId; 140 } 141 142 143 @Override 144 public Long getVersionNumber() { 145 return this.versionNumber; 146 } 147 148 149 //@Override 150 /*public OleBorrowerTypeDefinition getOleBorrowerType() { 151 return this.oleBorrowerType; 152 }*/ 153 154 public static class Builder 155 implements Serializable, ModelBuilder, OleProxyPatronContract 156 { 157 private String oleProxyPatronDocumentId; 158 private String proxyPatronId; 159 private String olePatronId; 160 private Date proxyPatronExpirationDate; 161 private Date proxyPatronActivationDate; 162 private boolean active; 163 //private OlePatronDocument proxyPatron; 164 //private OlePatronDefinition.Builder olePatronDocument; 165 private Long versionNumber; 166 private String objectId; 167 168 private Builder() { } 169 170 public static Builder create() { 171 return new Builder(); 172 } 173 174 public static Builder create(OleProxyPatronContract contract) { 175 if(contract == null) { 176 throw new IllegalArgumentException("contract was null"); 177 } 178 Builder builder = create(); 179 if (contract.getOlePatronId() != null) { 180 builder.setOlePatronId(contract.getOlePatronId()); 181 } 182 if(contract.getOleProxyPatronDocumentId() != null) { 183 builder.setOleProxyPatronDocumentId(contract.getOleProxyPatronDocumentId()); 184 } 185 if(contract.getProxyPatronId() != null) { 186 builder.setProxyPatronId(contract.getProxyPatronId()); 187 } 188 if(contract.isActive()) { 189 builder.setActive(contract.isActive()); 190 } 191 if(contract.getProxyPatronExpirationDate() != null) { 192 builder.setProxyPatronExpirationDate(contract.getProxyPatronExpirationDate()); 193 } 194 195 if(contract.getProxyPatronActivationDate() != null) { 196 builder.setProxyPatronActivationDate(contract.getProxyPatronActivationDate()); 197 } 198 199 /* if (contract.getOlePatronDocument() != null) { 200 builder.setOlePatronDocument(OlePatronDefinition.Builder.create(contract.getOlePatronDocument())); 201 } 202 */ 203 builder.setVersionNumber(contract.getVersionNumber()); 204 /*builder.setObjectId(contract.getObjectId()); 205 builder.setActive(contract.isActive());*/ 206 builder.setId(contract.getId()); 207 return builder; 208 } 209 210 211 public OleProxyPatronDefinition build() { 212 return new OleProxyPatronDefinition(this); 213 } 214 215 public String getOleProxyPatronDocumentId() { 216 return oleProxyPatronDocumentId; 217 } 218 219 public void setOleProxyPatronDocumentId(String oleProxyPatronDocumentId) { 220 this.oleProxyPatronDocumentId = oleProxyPatronDocumentId; 221 } 222 223 public String getProxyPatronId() { 224 return proxyPatronId; 225 } 226 227 public void setProxyPatronId(String proxyPatronId) { 228 this.proxyPatronId = proxyPatronId; 229 } 230 231 public String getOlePatronId() { 232 return olePatronId; 233 } 234 235 public void setOlePatronId(String olePatronId) { 236 this.olePatronId = olePatronId; 237 } 238 239 public Date getProxyPatronExpirationDate() { 240 return proxyPatronExpirationDate; 241 } 242 243 public void setProxyPatronExpirationDate(Date proxyPatronExpirationDate) { 244 this.proxyPatronExpirationDate = proxyPatronExpirationDate; 245 } 246 247 public Date getProxyPatronActivationDate() { 248 return proxyPatronActivationDate; 249 } 250 251 public void setProxyPatronActivationDate(Date proxyPatronActivationDate) { 252 this.proxyPatronActivationDate = proxyPatronActivationDate; 253 } 254 255 public boolean isActive() { 256 return active; 257 } 258 259 public void setActive(boolean active) { 260 this.active = active; 261 } 262 263 /* public OlePatronDefinition.Builder getOlePatronDocument() { 264 return olePatronDocument; 265 } 266 267 public void setOlePatronDocument(OlePatronDefinition.Builder olePatronDocument) { 268 this.olePatronDocument = olePatronDocument; 269 }*/ 270 271 @Override 272 public Long getVersionNumber() { 273 return versionNumber; 274 } 275 276 public void setVersionNumber(Long versionNumber) { 277 this.versionNumber = versionNumber; 278 } 279 280 /*@Override 281 public String getObjectId() { 282 return objectId; 283 }*/ 284 285 public void setObjectId(String objectId) { 286 this.objectId = objectId; 287 } 288 289 @Override 290 public String getId() { 291 return this.oleProxyPatronDocumentId; 292 } 293 294 295 296 public void setId(String id) { 297 if (StringUtils.isWhitespace(id)) { 298 throw new IllegalArgumentException("id is blank"); 299 } 300 this.oleProxyPatronDocumentId = id; 301 } 302 } 303 304 static class Constants { 305 306 final static String ROOT_ELEMENT_NAME = "oleProxyPatron"; 307 final static String TYPE_NAME = "OleProxyPatronType"; 308 final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS }; 309 } 310 311 static class Elements { 312 final static String OLE_PROXY_PATRON_DOC_ID = "oleProxyPatronDocumentId"; 313 final static String OLE_PROXY_PATRON_ID = "proxyPatronId"; 314 final static String OLE_PATRON_ID = "olePatronId"; 315 final static String OLE_PROXY_PATRON_EXP_DT = "proxyPatronExpirationDate"; 316 final static String OLE_PROXY_PATRON_ACT_DT = "proxyPatronActivationDate"; 317 //final static String OLE_PATRON_DOC = "olePatronDocument"; 318 final static String ACTIVE_INDICATOR = "active"; 319 //final static String ENTITY_ID = "entityId"; 320 321 322 } 323 public static class Cache { 324 public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + OleProxyPatronDefinition.Constants.TYPE_NAME; 325 } 326 }