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