1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.api.common.attribute;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.joda.time.DateTime;
20 import org.kuali.rice.core.api.CoreConstants;
21 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
22 import org.kuali.rice.core.api.mo.ModelBuilder;
23 import org.kuali.rice.core.api.mo.common.active.InactivatableFromToUtils;
24 import org.kuali.rice.core.api.util.jaxb.DateTimeAdapter;
25 import org.kuali.rice.kim.api.type.KimType;
26 import org.w3c.dom.Element;
27
28 import javax.xml.bind.annotation.XmlAccessType;
29 import javax.xml.bind.annotation.XmlAccessorType;
30 import javax.xml.bind.annotation.XmlAnyElement;
31 import javax.xml.bind.annotation.XmlElement;
32 import javax.xml.bind.annotation.XmlRootElement;
33 import javax.xml.bind.annotation.XmlType;
34 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
35 import java.io.Serializable;
36 import java.util.Collection;
37
38 @XmlRootElement(name = KimAttributeDataHistory.Constants.ROOT_ELEMENT_NAME)
39 @XmlAccessorType(XmlAccessType.NONE)
40 @XmlType(name = KimAttributeDataHistory.Constants.TYPE_NAME, propOrder = {
41
42 KimAttributeDataHistory.Elements.ID,
43 KimAttributeDataHistory.Elements.ASSIGNED_TO_HISTORY_ID,
44 KimAttributeDataHistory.Elements.ASSIGNED_TO_ID,
45 KimAttributeDataHistory.Elements.KIM_TYPE_ID,
46 KimAttributeDataHistory.Elements.KIM_TYPE,
47 KimAttributeDataHistory.Elements.KIM_ATTRIBUTE,
48 KimAttributeDataHistory.Elements.ATTRIBUTE_VALUE,
49 CoreConstants.CommonElements.VERSION_NUMBER,
50 CoreConstants.CommonElements.OBJECT_ID,
51 CoreConstants.CommonElements.FUTURE_ELEMENTS
52 })
53 public final class KimAttributeDataHistory extends AbstractDataTransferObject implements KimAttributeDataHistoryContract {
54
55
56
57 @XmlElement(name = Elements.ID, required = false)
58 private final String id;
59
60 @XmlElement(name = Elements.ASSIGNED_TO_HISTORY_ID, required = true)
61 private final Long assignedToHistoryId;
62
63 @XmlElement(name = Elements.ASSIGNED_TO_ID, required = false)
64 private final String assignedToId;
65
66 @XmlElement(name = Elements.KIM_TYPE_ID, required = true)
67 private final String kimTypeId;
68
69 @XmlElement(name = Elements.KIM_TYPE, required = false)
70 private final KimType kimType;
71
72 @XmlElement(name = Elements.KIM_ATTRIBUTE, required = false)
73 private final KimAttribute kimAttribute;
74
75 @XmlElement(name = Elements.ATTRIBUTE_VALUE, required = false)
76 private final String attributeValue;
77
78 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
79 private final Long versionNumber;
80
81 @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
82 private final String objectId;
83
84 @SuppressWarnings("unused")
85 @XmlAnyElement
86 private final Collection<Element> _futureElements = null;
87
88 @SuppressWarnings("unused")
89 private KimAttributeDataHistory() {
90
91 this.id = null;
92 this.assignedToHistoryId = null;
93 this.assignedToId = null;
94 this.kimTypeId = null;
95 this.kimType = null;
96 this.kimAttribute = null;
97 this.attributeValue = null;
98 this.versionNumber = null;
99 this.objectId = null;
100 }
101
102 private KimAttributeDataHistory(Builder builder) {
103 this.id = builder.getId();
104 this.assignedToId = builder.getAssignedToId();
105 this.kimTypeId = builder.getKimTypeId();
106 this.kimType =
107 builder.getKimType() != null ? builder.getKimType().build() : null;
108 this.kimAttribute =
109 builder.getKimAttribute() != null ? builder.getKimAttribute().build() : null;
110 this.attributeValue = builder.getAttributeValue();
111 this.versionNumber = builder.getVersionNumber();
112 this.objectId = builder.getObjectId();
113
114 this.assignedToHistoryId = builder.getAssignedToHistoryId();
115 }
116
117
118
119
120
121
122 @Override
123 public String getId() {
124 return id;
125 }
126
127 @Override
128 public String getAssignedToId() {
129 return assignedToId;
130 }
131
132 @Override
133 public Long getAssignedToHistoryId() {
134 return assignedToHistoryId;
135 }
136
137 @Override
138 public String getKimTypeId() {
139 return kimTypeId;
140 }
141
142 @Override
143 public KimType getKimType() {
144 return kimType;
145 }
146
147 @Override
148 public KimAttribute getKimAttribute() {
149 return kimAttribute;
150 }
151
152 @Override
153 public String getAttributeValue() {
154 return attributeValue;
155 }
156
157 @Override
158 public Long getVersionNumber() {
159 return versionNumber;
160 }
161
162
163 @Override
164 public String getObjectId() {
165 return objectId;
166 }
167
168 public static final class Builder implements KimAttributeDataHistoryContract, ModelBuilder, Serializable {
169 private String id;
170 private String assignedToId;
171 private String kimTypeId;
172 private KimType.Builder kimType;
173 private KimAttribute.Builder kimAttribute;
174 private String attributeValue;
175 private Long versionNumber;
176 private String objectId;
177
178 private Long assignedToHistoryId;
179
180 private Builder(String kimTypeId) {
181 setKimTypeId(kimTypeId);
182 }
183
184
185
186
187 public static Builder create(String kimTypeId) {
188 return new Builder(kimTypeId);
189 }
190
191
192
193
194 public static Builder create(KimAttributeDataContract contract) {
195 Builder builder = new Builder(contract.getKimTypeId());
196 builder.setAssignedToId(contract.getAssignedToId());
197
198 builder.setId(contract.getId());
199 if (contract.getKimAttribute() != null) {
200 builder.setKimAttribute(KimAttribute.Builder.create(contract.getKimAttribute()));
201 }
202 if (contract.getKimType() != null) {
203 builder.setKimType(KimType.Builder.create(contract.getKimType()));
204 }
205 builder.setValue(contract.getAttributeValue());
206 builder.setVersionNumber(contract.getVersionNumber());
207 builder.setObjectId(contract.getObjectId());
208 return builder;
209 }
210
211 @Override
212 public String getId() {
213 return id;
214 }
215
216 public void setId(final String id) {
217 if (StringUtils.isWhitespace(id)) {
218 throw new IllegalArgumentException("id is whitespace");
219 }
220 this.id = id;
221 }
222
223 @Override
224 public String getAssignedToId() {
225 return assignedToId;
226 }
227
228 public void setAssignedToId(final String assignedToId) {
229 this.assignedToId = assignedToId;
230 }
231
232 @Override
233 public String getKimTypeId(){
234 return kimTypeId;
235 }
236
237 public void setKimTypeId(String kimTypeId) {
238 this.kimTypeId = kimTypeId;
239 }
240
241 @Override
242 public KimType.Builder getKimType() {
243 return kimType;
244 }
245
246 public void setKimType(final KimType.Builder kimType) {
247 this.kimType = kimType;
248 }
249
250 @Override
251 public KimAttribute.Builder getKimAttribute() {
252 return kimAttribute;
253 }
254
255 public void setKimAttribute(final KimAttribute.Builder kimAttribute) {
256 this.kimAttribute = kimAttribute;
257 }
258
259 @Override
260 public String getAttributeValue() {
261 return attributeValue;
262 }
263
264 public void setValue(final String attributeValue) {
265 this.attributeValue = attributeValue;
266 }
267
268 @Override
269 public Long getVersionNumber() {
270 return versionNumber;
271 }
272
273 public void setVersionNumber(Long versionNumber) {
274 this.versionNumber = versionNumber;
275 }
276
277 @Override
278 public String getObjectId() {
279 return objectId;
280 }
281
282 public void setObjectId(final String objectId) {
283 this.objectId = objectId;
284 }
285
286 @Override
287 public KimAttributeDataHistory build() {
288 return new KimAttributeDataHistory(this);
289 }
290
291
292
293
294
295
296
297
298
299
300 @Override
301 public Long getAssignedToHistoryId() {
302 return assignedToHistoryId;
303 }
304
305 public void setAssignedToHistoryId(Long assignedToHistoryId) {
306 this.assignedToHistoryId = assignedToHistoryId;
307 }
308 }
309
310
311
312
313 static class Constants {
314 final static String ROOT_ELEMENT_NAME = "kimAttributeDataHistory";
315 final static String TYPE_NAME = "KimAttributeDataHistoryType";
316 }
317
318
319
320
321
322 static class Elements {
323 final static String HISTORY_ID = "historyId";
324 final static String ID = "id";
325 final static String ASSIGNED_TO_HISTORY_ID = "assignedToHistoryId";
326 final static String ASSIGNED_TO_ID = "assignedToId";
327 final static String KIM_TYPE_ID = "kimTypeId";
328 final static String KIM_TYPE = "kimType";
329 final static String KIM_ATTRIBUTE = "kimAttribute";
330 final static String ATTRIBUTE_VALUE = "attributeValue";
331 }
332 }