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.sql.Date;
015import java.util.Collection;
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 = OlePatronLostBarcodeDefinition.Constants.ROOT_ELEMENT_NAME)
025@XmlAccessorType(XmlAccessType.NONE)
026@XmlType(name = OlePatronLostBarcodeDefinition.Constants.TYPE_NAME, propOrder = {
027        OlePatronLostBarcodeDefinition.Elements.OLE_PTRN_LOST_BAR_ID,
028        OlePatronLostBarcodeDefinition.Elements.OLE_PTRN_ID,
029        OlePatronLostBarcodeDefinition.Elements.OLE_PTRN_LOST_BAR_EFF_DT,
030        OlePatronLostBarcodeDefinition.Elements.OLE_PTRN_LOST_BAR_NUM,
031        //OlePatronDefinition.Elements.OLE_BORROWER_TYPE,
032        //OlePatronDefinition.Elements.ENTITY,
033
034        CoreConstants.CommonElements.VERSION_NUMBER,
035        CoreConstants.CommonElements.OBJECT_ID,
036        CoreConstants.CommonElements.FUTURE_ELEMENTS
037})
038public class OlePatronLostBarcodeDefinition extends AbstractDataTransferObject implements OlePatronLostBarcodeContract {
039
040    private static final long serialVersionUID = 1L;
041
042
043    @XmlElement(name = Elements.OLE_PTRN_LOST_BAR_ID, required = false)
044    private final String olePatronLostBarcodeId;
045
046    @XmlElement(name = Elements.OLE_PTRN_ID, required = false)
047    private final String olePatronId;
048
049    @XmlElement(name = Elements.OLE_PTRN_LOST_BAR_EFF_DT, required = false)
050    @XmlJavaTypeAdapter(value = DateAdapter.class, type = Date.class)
051    private final Date invalidOrLostBarcodeEffDate;
052
053    @XmlElement(name = Elements.OLE_PTRN_LOST_BAR_NUM, required = false)
054    private final String invalidOrLostBarcodeNumber;
055
056    @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
057    private final Long versionNumber;
058
059
060    @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
061    private final String objectId;
062
063
064    @SuppressWarnings("unused")
065    @XmlAnyElement
066    private final Collection<Element> _futureElements = null;
067
068    public OlePatronLostBarcodeDefinition() {
069        this.olePatronLostBarcodeId = null;
070        this.olePatronId = null;
071        this.invalidOrLostBarcodeNumber = null;
072        this.invalidOrLostBarcodeEffDate = null;
073        this.versionNumber = null;
074
075        this.objectId = null;
076    }
077
078
079    private OlePatronLostBarcodeDefinition(Builder builder) {
080        this.olePatronLostBarcodeId = builder.getOlePatronLostBarcodeId();
081        this.olePatronId = builder.getOlePatronId();
082        this.invalidOrLostBarcodeEffDate = builder.getInvalidOrLostBarcodeEffDate();
083        this.invalidOrLostBarcodeNumber = builder.getInvalidOrLostBarcodeNumber();
084        this.versionNumber = builder.getVersionNumber();
085        this.objectId = builder.getObjectId();
086    }
087
088    public String getOlePatronLostBarcodeId() {
089        return this.olePatronLostBarcodeId;
090    }
091
092
093    public String getOlePatronId() {
094        return this.olePatronId;
095    }
096
097
098    public Date getInvalidOrLostBarcodeEffDate() {
099        return this.invalidOrLostBarcodeEffDate;
100    }
101
102    public String getInvalidOrLostBarcodeNumber() {
103        return this.invalidOrLostBarcodeNumber;
104    }
105
106    @Override
107    public String getObjectId() {
108        return this.objectId;
109    }
110
111    @Override
112    public Long getVersionNumber() {
113        return this.versionNumber;
114    }
115
116    @Override
117    public String getId() {
118        return this.olePatronLostBarcodeId;
119    }
120
121
122    //@Override
123    /*public OleBorrowerTypeDefinition getOleBorrowerType() {
124        return this.oleBorrowerType;
125    }*/
126
127    public static class Builder
128            implements Serializable, ModelBuilder, OlePatronLostBarcodeContract {
129        private String olePatronLostBarcodeId;
130        private String olePatronId;
131        private Date invalidOrLostBarcodeEffDate;
132        private String invalidOrLostBarcodeNumber;
133        private Long versionNumber;
134        private String objectId;
135
136        private Builder() {
137        }
138
139        public static Builder create() {
140            return new Builder();
141        }
142
143        public static Builder create(OlePatronLostBarcodeContract contract) {
144            if (contract == null) {
145                throw new IllegalArgumentException("contract was null");
146            }
147            Builder builder = create();
148            if (contract.getOlePatronLostBarcodeId() != null) {
149                builder.setOlePatronLostBarcodeId(contract.getOlePatronLostBarcodeId());
150            }
151            if (contract.getOlePatronId() != null) {
152                builder.setOlePatronId(contract.getOlePatronId());
153            }
154            if (contract.getInvalidOrLostBarcodeNumber() != null) {
155                builder.setInvalidOrLostBarcodeNumber(contract.getInvalidOrLostBarcodeNumber());
156            }
157            if (contract.getInvalidOrLostBarcodeEffDate() != null) {
158                builder.setInvalidOrLostBarcodeEffDate(new Date(contract.getInvalidOrLostBarcodeEffDate().getTime()));
159            }
160
161            builder.setObjectId(contract.getObjectId());
162            builder.setVersionNumber(contract.getVersionNumber());
163            builder.setId(contract.getId());
164            return builder;
165        }
166
167
168        public OlePatronLostBarcodeDefinition build() {
169            return new OlePatronLostBarcodeDefinition(this);
170        }
171
172        public String getOlePatronLostBarcodeId() {
173            return this.olePatronLostBarcodeId;
174        }
175
176        public void setOlePatronLostBarcodeId(String olePatronLostBarcodeId) {
177            this.olePatronLostBarcodeId = olePatronLostBarcodeId;
178        }
179
180        public String getOlePatronId() {
181            return this.olePatronId;
182        }
183
184        public void setOlePatronId(String olePatronId) {
185            this.olePatronId = olePatronId;
186        }
187
188        public Date getInvalidOrLostBarcodeEffDate() {
189            return this.invalidOrLostBarcodeEffDate;
190        }
191
192        public void setInvalidOrLostBarcodeEffDate(Date invalidOrLostBarcodeEffDate) {
193            this.invalidOrLostBarcodeEffDate = invalidOrLostBarcodeEffDate;
194        }
195
196        public String getInvalidOrLostBarcodeNumber() {
197            return this.invalidOrLostBarcodeNumber;
198        }
199
200        public void setInvalidOrLostBarcodeNumber(String invalidOrLostBarcodeNumber) {
201            this.invalidOrLostBarcodeNumber = invalidOrLostBarcodeNumber;
202        }
203
204        @Override
205        public String getId() {
206            return this.olePatronLostBarcodeId;
207        }
208
209
210        public void setId(String id) {
211            if (StringUtils.isWhitespace(id)) {
212                throw new IllegalArgumentException("id is blank");
213            }
214            this.olePatronLostBarcodeId = id;
215        }
216
217        public Long getVersionNumber() {
218            return this.versionNumber;
219        }
220
221        public void setVersionNumber(Long versionNumber) {
222            this.versionNumber = versionNumber;
223        }
224
225        public String getObjectId() {
226            return objectId;
227        }
228
229        public void setObjectId(String objectId) {
230            this.objectId = objectId;
231        }
232    }
233
234    static class Constants {
235
236        final static String ROOT_ELEMENT_NAME = "olePatronLostBarcode";
237        final static String TYPE_NAME = "OlePatronLostBarcodeType";
238        final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[]{CoreConstants.CommonElements.FUTURE_ELEMENTS};
239    }
240
241    static class Elements {
242        final static String OLE_PTRN_LOST_BAR_ID = "olePatronLostBarcodeId";
243        final static String OLE_PTRN_ID = "olePatronId";
244        final static String OLE_PTRN_LOST_BAR_EFF_DT = "invalidOrLostBarcodeEffDate";
245        final static String OLE_PTRN_LOST_BAR_NUM = "invalidOrLostBarcodeNumber";
246
247
248    }
249
250    public static class Cache {
251        public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + Constants.TYPE_NAME;
252    }
253}