1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.api.location;
17
18 import java.io.Serializable;
19 import java.util.Collection;
20 import javax.xml.bind.annotation.XmlAccessType;
21 import javax.xml.bind.annotation.XmlAccessorType;
22 import javax.xml.bind.annotation.XmlAnyElement;
23 import javax.xml.bind.annotation.XmlElement;
24 import javax.xml.bind.annotation.XmlRootElement;
25 import javax.xml.bind.annotation.XmlType;
26 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
27
28 import org.apache.commons.lang.StringUtils;
29 import org.joda.time.DateTime;
30 import org.joda.time.LocalDate;
31 import org.kuali.rice.core.api.CoreConstants;
32 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
33 import org.kuali.rice.core.api.mo.ModelBuilder;
34 import org.kuali.rice.core.api.util.jaxb.DateTimeAdapter;
35 import org.kuali.rice.core.api.util.jaxb.LocalDateAdapter;
36 import org.w3c.dom.Element;
37
38 @XmlRootElement(name = Location.Constants.ROOT_ELEMENT_NAME)
39 @XmlAccessorType(XmlAccessType.NONE)
40 @XmlType(name = Location.Constants.TYPE_NAME, propOrder = {
41 Location.Elements.LOCATION,
42 Location.Elements.HR_LOCATION_ID,
43 Location.Elements.TIMEZONE,
44 Location.Elements.DESCRIPTION,
45 Location.Elements.USER_PRINCIPAL_ID,
46 Location.Elements.ACTIVE,
47 Location.Elements.ID,
48 Location.Elements.CREATE_TIME,
49 Location.Elements.EFFECTIVE_LOCAL_DATE,
50 CoreConstants.CommonElements.VERSION_NUMBER,
51 CoreConstants.CommonElements.OBJECT_ID,
52 CoreConstants.CommonElements.FUTURE_ELEMENTS
53 })
54 public final class Location
55 extends AbstractDataTransferObject
56 implements LocationContract
57 {
58
59 @XmlElement(name = Elements.LOCATION, required = false)
60 private final String location;
61 @XmlElement(name = Elements.HR_LOCATION_ID, required = false)
62 private final String hrLocationId;
63 @XmlElement(name = Elements.TIMEZONE, required = false)
64 private final String timezone;
65 @XmlElement(name = Elements.DESCRIPTION, required = false)
66 private final String description;
67 @XmlElement(name = Elements.USER_PRINCIPAL_ID, required = false)
68 private final String userPrincipalId;
69 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
70 private final Long versionNumber;
71 @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
72 private final String objectId;
73 @XmlElement(name = Elements.ACTIVE, required = false)
74 private final boolean active;
75 @XmlElement(name = Elements.ID, required = false)
76 private final String id;
77 @XmlElement(name = Elements.CREATE_TIME, required = false)
78 @XmlJavaTypeAdapter(DateTimeAdapter.class)
79 private final DateTime createTime;
80 @XmlElement(name = Elements.EFFECTIVE_LOCAL_DATE, required = false)
81 @XmlJavaTypeAdapter(LocalDateAdapter.class)
82 private final LocalDate effectiveLocalDate;
83 @SuppressWarnings("unused")
84 @XmlAnyElement
85 private final Collection<Element> _futureElements = null;
86
87
88
89
90
91 private Location() {
92 this.location = null;
93 this.hrLocationId = null;
94 this.timezone = null;
95 this.description = null;
96 this.userPrincipalId = null;
97 this.versionNumber = null;
98 this.objectId = null;
99 this.active = false;
100 this.id = null;
101 this.createTime = null;
102 this.effectiveLocalDate = null;
103 }
104
105 private Location(Builder builder) {
106 this.location = builder.getLocation();
107 this.hrLocationId = builder.getHrLocationId();
108 this.timezone = builder.getTimezone();
109 this.description = builder.getDescription();
110 this.userPrincipalId = builder.getUserPrincipalId();
111 this.versionNumber = builder.getVersionNumber();
112 this.objectId = builder.getObjectId();
113 this.active = builder.isActive();
114 this.id = builder.getId();
115 this.createTime = builder.getCreateTime();
116 this.effectiveLocalDate = builder.getEffectiveLocalDate();
117 }
118
119 @Override
120 public String getLocation() {
121 return this.location;
122 }
123
124 @Override
125 public String getHrLocationId() {
126 return this.hrLocationId;
127 }
128
129 @Override
130 public String getTimezone() {
131 return this.timezone;
132 }
133
134 @Override
135 public String getDescription() {
136 return this.description;
137 }
138
139 @Override
140 public String getUserPrincipalId() {
141 return this.userPrincipalId;
142 }
143
144 @Override
145 public Long getVersionNumber() {
146 return this.versionNumber;
147 }
148
149 @Override
150 public String getObjectId() {
151 return this.objectId;
152 }
153
154 @Override
155 public boolean isActive() {
156 return this.active;
157 }
158
159 @Override
160 public String getId() {
161 return this.id;
162 }
163
164 @Override
165 public DateTime getCreateTime() {
166 return this.createTime;
167 }
168
169 @Override
170 public LocalDate getEffectiveLocalDate() {
171 return this.effectiveLocalDate;
172 }
173
174
175
176
177
178
179 public final static class Builder
180 implements Serializable, LocationContract, ModelBuilder
181 {
182
183 private String location;
184 private String hrLocationId;
185 private String timezone;
186 private String description;
187 private String userPrincipalId;
188 private Long versionNumber;
189 private String objectId;
190 private boolean active;
191 private String id;
192 private DateTime createTime;
193 private LocalDate effectiveLocalDate;
194
195 private Builder(String location) {
196 setLocation(location);
197 }
198
199 public static Builder create(String location) {
200 return new Builder(location);
201 }
202
203 public static Builder create(LocationContract contract) {
204 if (contract == null) {
205 throw new IllegalArgumentException("contract was null");
206 }
207 Builder builder = create(contract.getLocation());
208 builder.setHrLocationId(contract.getHrLocationId());
209 builder.setTimezone(contract.getTimezone());
210 builder.setDescription(contract.getDescription());
211 builder.setUserPrincipalId(contract.getUserPrincipalId());
212 builder.setVersionNumber(contract.getVersionNumber());
213 builder.setObjectId(contract.getObjectId());
214 builder.setActive(contract.isActive());
215 builder.setId(contract.getId());
216 builder.setCreateTime(contract.getCreateTime());
217 builder.setEffectiveLocalDate(contract.getEffectiveLocalDate());
218 return builder;
219 }
220
221 public Location build() {
222 return new Location(this);
223 }
224
225 @Override
226 public String getLocation() {
227 return this.location;
228 }
229
230 @Override
231 public String getHrLocationId() {
232 return this.hrLocationId;
233 }
234
235 @Override
236 public String getTimezone() {
237 return this.timezone;
238 }
239
240 @Override
241 public String getDescription() {
242 return this.description;
243 }
244
245 @Override
246 public String getUserPrincipalId() {
247 return this.userPrincipalId;
248 }
249
250 @Override
251 public Long getVersionNumber() {
252 return this.versionNumber;
253 }
254
255 @Override
256 public String getObjectId() {
257 return this.objectId;
258 }
259
260 @Override
261 public boolean isActive() {
262 return this.active;
263 }
264
265 @Override
266 public String getId() {
267 return this.id;
268 }
269
270 @Override
271 public DateTime getCreateTime() {
272 return this.createTime;
273 }
274
275 @Override
276 public LocalDate getEffectiveLocalDate() {
277 return this.effectiveLocalDate;
278 }
279
280 public void setLocation(String location) {
281 if (StringUtils.isEmpty(location)) {
282 throw new IllegalArgumentException("location is blank");
283 }
284 this.location = location;
285 }
286
287 public void setHrLocationId(String hrLocationId) {
288 this.hrLocationId = hrLocationId;
289 }
290
291 public void setTimezone(String timezone) {
292 this.timezone = timezone;
293 }
294
295 public void setDescription(String description) {
296 this.description = description;
297 }
298
299 public void setUserPrincipalId(String userPrincipalId) {
300 this.userPrincipalId = userPrincipalId;
301 }
302
303 public void setVersionNumber(Long versionNumber) {
304 this.versionNumber = versionNumber;
305 }
306
307 public void setObjectId(String objectId) {
308 this.objectId = objectId;
309 }
310
311 public void setActive(boolean active) {
312 this.active = active;
313 }
314
315 public void setId(String id) {
316 this.id = id;
317 }
318
319 public void setCreateTime(DateTime createTime) {
320 this.createTime = createTime;
321 }
322
323 public void setEffectiveLocalDate(LocalDate effectiveLocalDate) {
324 this.effectiveLocalDate = effectiveLocalDate;
325 }
326
327 }
328
329
330
331
332
333
334 static class Constants {
335
336 final static String ROOT_ELEMENT_NAME = "location";
337 final static String TYPE_NAME = "LocationType";
338
339 }
340
341
342
343
344
345
346 static class Elements {
347
348 final static String LOCATION = "location";
349 final static String HR_LOCATION_ID = "hrLocationId";
350 final static String TIMEZONE = "timezone";
351 final static String DESCRIPTION = "description";
352 final static String USER_PRINCIPAL_ID = "userPrincipalId";
353 final static String ACTIVE = "active";
354 final static String ID = "id";
355 final static String CREATE_TIME = "createTime";
356 final static String EFFECTIVE_LOCAL_DATE = "effectiveLocalDate";
357
358 }
359
360 }