1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.enrollment.class2.acal.dto; |
17 | |
|
18 | |
import org.apache.commons.lang.BooleanUtils; |
19 | |
import org.apache.commons.lang.StringUtils; |
20 | |
import org.kuali.student.enrollment.acal.dto.HolidayInfo; |
21 | |
|
22 | |
import java.util.Date; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | 0 | public class HolidayWrapper extends TimeSetWrapper implements Comparable<HolidayWrapper> { |
28 | |
|
29 | |
private String typeName; |
30 | |
private HolidayInfo holidayInfo; |
31 | |
private boolean instructional; |
32 | |
private String typeKey; |
33 | |
|
34 | 0 | public HolidayWrapper(){ |
35 | 0 | holidayInfo = new HolidayInfo(); |
36 | 0 | setAllDay(true); |
37 | 0 | setInstructional(false); |
38 | 0 | setDateRange(false); |
39 | 0 | } |
40 | |
|
41 | 0 | public HolidayWrapper(HolidayInfo holidayInfo){ |
42 | 0 | this.setHolidayInfo(holidayInfo); |
43 | 0 | this.setStartDate(holidayInfo.getStartDate()); |
44 | 0 | this.setEndDate(holidayInfo.getEndDate()); |
45 | 0 | this.setAllDay(holidayInfo.getIsAllDay()); |
46 | 0 | this.setDateRange(holidayInfo.getIsDateRange()); |
47 | 0 | this.setTypeKey(holidayInfo.getTypeKey()); |
48 | 0 | this.setInstructional(holidayInfo.getIsInstructionalDay()); |
49 | 0 | buildDateAndTime(); |
50 | 0 | } |
51 | |
|
52 | |
public String getTypeName() { |
53 | 0 | return typeName; |
54 | |
} |
55 | |
|
56 | |
public void setTypeName(String typeName) { |
57 | 0 | this.typeName = typeName; |
58 | 0 | } |
59 | |
|
60 | |
public HolidayInfo getHolidayInfo() { |
61 | 0 | return holidayInfo; |
62 | |
} |
63 | |
|
64 | |
public void setHolidayInfo(HolidayInfo holidayInfo) { |
65 | |
|
66 | |
|
67 | 0 | this.setAllDay(holidayInfo.getIsAllDay()); |
68 | 0 | this.setDateRange(holidayInfo.getIsDateRange()); |
69 | 0 | this.setInstructional(holidayInfo.getIsInstructionalDay()); |
70 | |
|
71 | 0 | this.holidayInfo = holidayInfo; |
72 | 0 | } |
73 | |
|
74 | |
|
75 | |
public String getIsNonInstructional(){ |
76 | 0 | if (holidayInfo != null){ |
77 | 0 | return StringUtils.capitalize(BooleanUtils.toStringYesNo(!holidayInfo.getIsInstructionalDay())); |
78 | |
} |
79 | 0 | return StringUtils.capitalize(BooleanUtils.toStringYesNo(true)); |
80 | |
} |
81 | |
|
82 | |
public boolean isInstructional() { |
83 | 0 | return instructional; |
84 | |
} |
85 | |
|
86 | |
public void setInstructional(boolean instructional) { |
87 | 0 | this.instructional = instructional; |
88 | 0 | } |
89 | |
|
90 | |
public String getTypeKey() { |
91 | 0 | return typeKey; |
92 | |
} |
93 | |
|
94 | |
public void setTypeKey(String typeKey) { |
95 | 0 | this.typeKey = typeKey; |
96 | 0 | } |
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
public int compareTo(HolidayWrapper holidayToCompare) { |
103 | 0 | int compareValue = compareDates(this.getStartDate(), holidayToCompare.getStartDate()); |
104 | 0 | if (compareValue == 0) { |
105 | |
|
106 | 0 | compareValue = compareDates(this.getEndDate(), holidayToCompare.getEndDate()); |
107 | |
} |
108 | 0 | return compareValue; |
109 | |
} |
110 | |
|
111 | |
private int compareDates(Date thisDate, Date compareToDate) { |
112 | |
|
113 | |
|
114 | 0 | if (null == thisDate) { |
115 | 0 | if (null == compareToDate) { |
116 | 0 | return 0; |
117 | |
} |
118 | 0 | return -1; |
119 | |
} |
120 | |
|
121 | 0 | if (null == compareToDate) { |
122 | 0 | return 1; |
123 | |
} |
124 | |
|
125 | |
|
126 | 0 | if (thisDate.before(compareToDate)) { |
127 | 0 | return -1; |
128 | |
} |
129 | 0 | if (thisDate.after(compareToDate)) { |
130 | 0 | return 1; |
131 | |
} |
132 | 0 | return 0; |
133 | |
} |
134 | |
|
135 | |
|
136 | |
public String getStartDateUI(){ |
137 | 0 | return formatStartDateUI(holidayInfo.getStartDate()); |
138 | |
} |
139 | |
|
140 | |
|
141 | |
public String getEndDateUI(){ |
142 | 0 | return formatEndDateUI(holidayInfo.getEndDate()); |
143 | |
} |
144 | |
|
145 | |
} |