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