1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.api.calendar;
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.joda.time.DateTimeConstants;
29 import org.joda.time.LocalTime;
30 import org.kuali.kpme.core.api.util.jaxb.LocalTimeAdapter;
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.w3c.dom.Element;
35
36 @XmlRootElement(name = Calendar.Constants.ROOT_ELEMENT_NAME)
37 @XmlAccessorType(XmlAccessType.NONE)
38 @XmlType(name = Calendar.Constants.TYPE_NAME, propOrder = {
39 Calendar.Elements.CALENDAR_DESCRIPTIONS,
40 Calendar.Elements.CALENDAR_NAME,
41 Calendar.Elements.CALENDAR_TYPES,
42 Calendar.Elements.FLSA_BEGIN_DAY,
43 Calendar.Elements.FLSA_BEGIN_LOCAL_TIME,
44 Calendar.Elements.FLSA_BEGIN_DAY_CONSTANT,
45 Calendar.Elements.HR_CALENDAR_ID,
46 CoreConstants.CommonElements.VERSION_NUMBER,
47 CoreConstants.CommonElements.OBJECT_ID,
48 CoreConstants.CommonElements.FUTURE_ELEMENTS
49 })
50 public final class Calendar
51 extends AbstractDataTransferObject
52 implements CalendarContract
53 {
54
55 private static final long serialVersionUID = 8004629702037414752L;
56 @XmlElement(name = Elements.CALENDAR_DESCRIPTIONS, required = false)
57 private final String calendarDescriptions;
58 @XmlElement(name = Elements.CALENDAR_NAME, required = false)
59 private final String calendarName;
60 @XmlElement(name = Elements.CALENDAR_TYPES, required = false)
61 private final String calendarTypes;
62 @XmlElement(name = Elements.FLSA_BEGIN_DAY, required = false)
63 private final String flsaBeginDay;
64 @XmlElement(name = Elements.FLSA_BEGIN_LOCAL_TIME, required = false)
65 @XmlJavaTypeAdapter(LocalTimeAdapter.class)
66 private final LocalTime flsaBeginLocalTime;
67 @XmlElement(name = Elements.FLSA_BEGIN_DAY_CONSTANT, required = false)
68 private final int flsaBeginDayConstant;
69 @XmlElement(name = Elements.HR_CALENDAR_ID, required = false)
70 private final String hrCalendarId;
71 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
72 private final Long versionNumber;
73 @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
74 private final String objectId;
75 @SuppressWarnings("unused")
76 @XmlAnyElement
77 private final Collection<Element> _futureElements = null;
78
79
80
81
82
83 private Calendar() {
84 this.calendarDescriptions = null;
85 this.calendarName = null;
86 this.calendarTypes = null;
87 this.flsaBeginDay = null;
88 this.flsaBeginLocalTime = null;
89 this.flsaBeginDayConstant = 0;
90 this.hrCalendarId = null;
91 this.versionNumber = null;
92 this.objectId = null;
93 }
94
95 private Calendar(Builder builder) {
96 this.calendarDescriptions = builder.getCalendarDescriptions();
97 this.calendarName = builder.getCalendarName();
98 this.calendarTypes = builder.getCalendarTypes();
99 this.flsaBeginDay = builder.getFlsaBeginDay();
100 this.flsaBeginLocalTime = builder.getFlsaBeginLocalTime();
101 this.flsaBeginDayConstant = builder.getFlsaBeginDayConstant();
102 this.hrCalendarId = builder.getHrCalendarId();
103 this.versionNumber = builder.getVersionNumber();
104 this.objectId = builder.getObjectId();
105 }
106
107 @Override
108 public String getCalendarDescriptions() {
109 return this.calendarDescriptions;
110 }
111
112 @Override
113 public String getCalendarName() {
114 return this.calendarName;
115 }
116
117 @Override
118 public String getCalendarTypes() {
119 return this.calendarTypes;
120 }
121
122 @Override
123 public String getFlsaBeginDay() {
124 return this.flsaBeginDay;
125 }
126
127 @Override
128 public LocalTime getFlsaBeginLocalTime() {
129 return this.flsaBeginLocalTime;
130 }
131
132 @Override
133 public int getFlsaBeginDayConstant() {
134 return this.flsaBeginDayConstant;
135 }
136
137 @Override
138 public String getHrCalendarId() {
139 return this.hrCalendarId;
140 }
141
142 @Override
143 public Long getVersionNumber() {
144 return this.versionNumber;
145 }
146
147 @Override
148 public String getObjectId() {
149 return this.objectId;
150 }
151
152 public int getFlsaEndDayConstant() {
153 if (this.getFlsaBeginDayConstant() == DateTimeConstants.MONDAY) {
154 return DateTimeConstants.SUNDAY;
155 } else if (this.getFlsaBeginDayConstant() == DateTimeConstants.TUESDAY) {
156 return DateTimeConstants.MONDAY;
157 } else if (this.getFlsaBeginDayConstant() == DateTimeConstants.WEDNESDAY) {
158 return DateTimeConstants.TUESDAY;
159 } else if (this.getFlsaBeginDayConstant() == DateTimeConstants.THURSDAY) {
160 return DateTimeConstants.WEDNESDAY;
161 } else if (this.getFlsaBeginDayConstant() == DateTimeConstants.FRIDAY) {
162 return DateTimeConstants.THURSDAY;
163 } else if (this.getFlsaBeginDayConstant() == DateTimeConstants.SATURDAY) {
164 return DateTimeConstants.FRIDAY;
165 } else if (this.getFlsaBeginDayConstant() == DateTimeConstants.SUNDAY) {
166 return DateTimeConstants.SATURDAY;
167 }
168 return 0;
169 }
170
171
172
173
174
175
176 public final static class Builder
177 implements Serializable, CalendarContract, ModelBuilder
178 {
179
180 private String calendarDescriptions;
181 private String calendarName;
182 private String calendarTypes;
183 private String flsaBeginDay;
184 private LocalTime flsaBeginLocalTime;
185 private int flsaBeginDayConstant;
186 private String hrCalendarId;
187 private Long versionNumber;
188 private String objectId;
189
190 private Builder() {
191 }
192
193 public static Builder create() {
194 return new Builder();
195 }
196
197 public static Builder create(CalendarContract contract) {
198 if (contract == null) {
199 throw new IllegalArgumentException("contract was null");
200 }
201 Builder builder = create();
202 builder.setCalendarDescriptions(contract.getCalendarDescriptions());
203 builder.setCalendarName(contract.getCalendarName());
204 builder.setCalendarTypes(contract.getCalendarTypes());
205 builder.setFlsaBeginDay(contract.getFlsaBeginDay());
206 builder.setFlsaBeginLocalTime(contract.getFlsaBeginLocalTime());
207 builder.setFlsaBeginDayConstant(contract.getFlsaBeginDayConstant());
208 builder.setHrCalendarId(contract.getHrCalendarId());
209 builder.setVersionNumber(contract.getVersionNumber());
210 builder.setObjectId(contract.getObjectId());
211 return builder;
212 }
213
214 public Calendar build() {
215 return new Calendar(this);
216 }
217
218 @Override
219 public String getCalendarDescriptions() {
220 return this.calendarDescriptions;
221 }
222
223 @Override
224 public String getCalendarName() {
225 return this.calendarName;
226 }
227
228 @Override
229 public String getCalendarTypes() {
230 return this.calendarTypes;
231 }
232
233 @Override
234 public String getFlsaBeginDay() {
235 return this.flsaBeginDay;
236 }
237
238 @Override
239 public LocalTime getFlsaBeginLocalTime() {
240 return this.flsaBeginLocalTime;
241 }
242
243 @Override
244 public int getFlsaBeginDayConstant() {
245 return this.flsaBeginDayConstant;
246 }
247
248 @Override
249 public String getHrCalendarId() {
250 return this.hrCalendarId;
251 }
252
253 @Override
254 public Long getVersionNumber() {
255 return this.versionNumber;
256 }
257
258 @Override
259 public String getObjectId() {
260 return this.objectId;
261 }
262
263 public void setCalendarDescriptions(String calendarDescriptions) {
264 this.calendarDescriptions = calendarDescriptions;
265 }
266
267 public void setCalendarName(String calendarName) {
268 this.calendarName = calendarName;
269 }
270
271 public void setCalendarTypes(String calendarTypes) {
272 this.calendarTypes = calendarTypes;
273 }
274
275 public void setFlsaBeginDay(String flsaBeginDay) {
276 this.flsaBeginDay = flsaBeginDay;
277 }
278
279 public void setFlsaBeginLocalTime(LocalTime flsaBeginLocalTime) {
280 this.flsaBeginLocalTime = flsaBeginLocalTime;
281 }
282
283 public void setFlsaBeginDayConstant(int flsaBeginDayConstant) {
284 this.flsaBeginDayConstant = flsaBeginDayConstant;
285 }
286
287 public void setHrCalendarId(String hrCalendarId) {
288 this.hrCalendarId = hrCalendarId;
289 }
290
291 public void setVersionNumber(Long versionNumber) {
292 this.versionNumber = versionNumber;
293 }
294
295 public void setObjectId(String objectId) {
296 this.objectId = objectId;
297 }
298
299 }
300
301
302
303
304
305
306 static class Constants {
307
308 final static String ROOT_ELEMENT_NAME = "calendar";
309 final static String TYPE_NAME = "CalendarType";
310
311 }
312
313
314
315
316
317
318 static class Elements {
319
320 final static String CALENDAR_DESCRIPTIONS = "calendarDescriptions";
321 final static String CALENDAR_NAME = "calendarName";
322 final static String CALENDAR_TYPES = "calendarTypes";
323 final static String FLSA_BEGIN_DAY = "flsaBeginDay";
324 final static String FLSA_BEGIN_LOCAL_TIME = "flsaBeginLocalTime";
325 final static String FLSA_BEGIN_DAY_CONSTANT = "flsaBeginDayConstant";
326 final static String HR_CALENDAR_ID = "hrCalendarId";
327
328 }
329
330 }