1 package org.kuali.ole.patron.api;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.api.jaxb.DateAdapter;
5 import org.kuali.rice.core.api.CoreConstants;
6 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
7 import org.kuali.rice.core.api.mo.ModelBuilder;
8 import org.kuali.rice.kim.api.KimConstants;
9 import org.w3c.dom.Element;
10
11 import javax.xml.bind.annotation.*;
12 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
13 import java.io.Serializable;
14 import java.sql.Date;
15 import java.util.Collection;
16
17
18
19
20
21
22
23
24 @XmlRootElement(name = OleSourceDefinition.Constants.ROOT_ELEMENT_NAME)
25 @XmlAccessorType(XmlAccessType.NONE)
26 @XmlType(name = OleSourceDefinition.Constants.TYPE_NAME, propOrder = {
27 OleSourceDefinition.Elements.OLE_SOURCE_ID,
28 OleSourceDefinition.Elements.OLE_SOURCE_CODE,
29 OleSourceDefinition.Elements.OLE_SOURCE_NAME,
30 OleSourceDefinition.Elements.OLE_SOURCE_DESC,
31 OleSourceDefinition.Elements.ACTIVE_INDICATOR,
32
33 CoreConstants.CommonElements.VERSION_NUMBER,
34
35 CoreConstants.CommonElements.FUTURE_ELEMENTS
36 })
37 public final class OleSourceDefinition extends AbstractDataTransferObject implements OleSourceContract{
38
39 private static final long serialVersionUID = 1L;
40
41
42
43 @XmlElement(name = Elements.OLE_SOURCE_ID, required = false)
44 private final String oleSourceId;
45
46 @XmlElement(name = Elements.OLE_SOURCE_CODE, required = false)
47 private final String oleSourceCode;
48
49 @XmlElement(name = Elements.OLE_SOURCE_NAME, required = false)
50 private final String oleSourceName;
51
52 @XmlElement(name = Elements.OLE_SOURCE_DESC, required = false)
53 private final String oleSourceDesc;
54
55 @XmlElement(name = Elements.ACTIVE_INDICATOR, required = false)
56 private final boolean active;
57
58 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
59 private final Long versionNumber;
60
61
62
63 @SuppressWarnings("unused")
64 @XmlAnyElement
65 private final Collection<Element> _futureElements = null;
66
67 public OleSourceDefinition() {
68 this.oleSourceId = null;
69 this.oleSourceCode = null;
70 this.oleSourceName = null;
71 this.active = false;
72 this.oleSourceDesc = null;
73 this.versionNumber = null;
74
75 }
76
77
78 private OleSourceDefinition(Builder builder) {
79 this.oleSourceId = builder.getOleSourceId();
80 this.oleSourceCode = builder.getOleSourceCode();
81 this.oleSourceName = builder.getOleSourceName();
82 this.oleSourceDesc = builder.getOleSourceDesc();
83 this.active = builder.isActive();
84
85 this.versionNumber = builder.getVersionNumber();
86
87 }
88
89
90 @Override
91 public String getOleSourceId() {
92 return this.oleSourceId;
93 }
94
95 @Override
96 public String getOleSourceCode() {
97 return this.oleSourceCode;
98 }
99
100 @Override
101 public String getOleSourceName() {
102 return this.oleSourceName;
103 }
104
105 @Override
106 public String getOleSourceDesc() {
107 return this.oleSourceDesc;
108 }
109
110 @Override
111 public boolean isActive() {
112 return this.active;
113 };
114
115
116 @Override
117 public String getId() {
118 return this.oleSourceId;
119 }
120
121
122 @Override
123 public Long getVersionNumber() {
124 return this.versionNumber;
125 }
126
127
128
129
130
131
132
133 public static class Builder
134 implements Serializable, ModelBuilder, OleSourceContract
135 {
136
137 private String oleSourceId;
138 private String oleSourceCode;
139 private String oleSourceName;
140 private String oleSourceDesc;
141 private boolean active;
142
143 private Long versionNumber;
144 private String objectId;
145
146 private Builder() { }
147
148 public static Builder create() {
149 return new Builder();
150 }
151
152 public static Builder create(OleSourceContract contract) {
153 if(contract == null) {
154 throw new IllegalArgumentException("contract was null");
155 }
156 Builder builder = create();
157 if (contract.getOleSourceId() != null) {
158 builder.setOleSourceId(contract.getOleSourceId());
159 }
160 if(contract.getOleSourceCode() != null) {
161 builder.setOleSourceCode(contract.getOleSourceCode());
162 }
163 if(contract.getOleSourceName() != null) {
164 builder.setOleSourceName(contract.getOleSourceName());
165 }
166 if(contract.isActive()) {
167 builder.setActive(contract.isActive());
168 }
169 if(contract.getOleSourceDesc() != null) {
170 builder.setOleSourceDesc(contract.getOleSourceDesc());
171 }
172
173 builder.setVersionNumber(contract.getVersionNumber());
174
175
176 builder.setId(contract.getId());
177 return builder;
178 }
179
180
181 public OleSourceDefinition build() {
182 return new OleSourceDefinition(this);
183 }
184
185 public String getOleSourceId() {
186 return oleSourceId;
187 }
188
189 public void setOleSourceId(String oleSourceId) {
190 this.oleSourceId = oleSourceId;
191 }
192
193 public String getOleSourceCode() {
194 return oleSourceCode;
195 }
196
197 public void setOleSourceCode(String oleSourceCode) {
198 this.oleSourceCode = oleSourceCode;
199 }
200
201 public String getOleSourceName() {
202 return oleSourceName;
203 }
204
205 public void setOleSourceName(String oleSourceName) {
206 this.oleSourceName = oleSourceName;
207 }
208
209 public String getOleSourceDesc() {
210 return oleSourceDesc;
211 }
212
213 public void setOleSourceDesc(String oleSourceDesc) {
214 this.oleSourceDesc = oleSourceDesc;
215 }
216
217 public boolean isActive() {
218 return active;
219 }
220
221 public void setActive(boolean active) {
222 this.active = active;
223 }
224
225 @Override
226 public Long getVersionNumber() {
227 return versionNumber;
228 }
229
230 public void setVersionNumber(Long versionNumber) {
231 this.versionNumber = versionNumber;
232 }
233
234
235
236
237
238
239 public void setObjectId(String objectId) {
240 this.objectId = objectId;
241 }
242
243 @Override
244 public String getId() {
245 return this.oleSourceId;
246 }
247
248
249
250 public void setId(String id) {
251 if (StringUtils.isWhitespace(id)) {
252 throw new IllegalArgumentException("id is blank");
253 }
254 this.oleSourceId = id;
255 }
256 }
257
258 static class Constants {
259
260 final static String ROOT_ELEMENT_NAME = "oleSource";
261 final static String TYPE_NAME = "OleSourceType";
262 final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS };
263 }
264
265 static class Elements {
266 final static String OLE_SOURCE_ID = "oleSourceId";
267 final static String OLE_SOURCE_CODE = "oleSourceCode";
268 final static String OLE_SOURCE_NAME = "oleSourceName";
269 final static String OLE_SOURCE_DESC = "oleSourceDesc";
270 final static String ACTIVE_INDICATOR = "active";
271
272
273 }
274 public static class Cache {
275 public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + Constants.TYPE_NAME;
276 }
277 }