1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
package org.kuali.student.enrollment.class2.acal.form; |
16 | |
|
17 | |
import org.apache.commons.lang.StringUtils; |
18 | |
import org.kuali.rice.krad.web.form.UifFormBase; |
19 | |
import org.kuali.student.enrollment.acal.dto.AcademicCalendarInfo; |
20 | |
import org.kuali.student.enrollment.class2.acal.dto.AcademicTermWrapper; |
21 | |
import org.kuali.student.enrollment.class2.acal.dto.AcalEventWrapper; |
22 | |
import org.kuali.student.enrollment.class2.acal.dto.HolidayCalendarWrapper; |
23 | |
import org.kuali.student.enrollment.class2.acal.service.AcademicCalendarViewHelperService; |
24 | |
import org.kuali.student.enrollment.class2.acal.util.CalendarConstants; |
25 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
26 | |
|
27 | |
import java.text.SimpleDateFormat; |
28 | |
import java.util.ArrayList; |
29 | |
import java.util.Date; |
30 | |
import java.util.List; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
public class AcademicCalendarForm extends UifFormBase { |
39 | |
private static final long serialVersionUID = 4898118410378641665L; |
40 | |
|
41 | |
private AcademicCalendarInfo academicCalendarInfo; |
42 | |
private AcademicCalendarInfo orgAcalInfo; |
43 | |
private String adminOrgName; |
44 | |
private String updateTimeString; |
45 | |
|
46 | |
private List<AcalEventWrapper> events; |
47 | |
private List<HolidayCalendarWrapper> holidayCalendarList; |
48 | |
private List<AcademicTermWrapper> termWrapperList; |
49 | |
|
50 | |
|
51 | |
private boolean newCalendar; |
52 | |
private boolean officialCalendar; |
53 | |
|
54 | |
|
55 | |
private String defaultTabToShow; |
56 | |
|
57 | |
private List<AcalEventWrapper> eventsToDeleteOnSave; |
58 | |
private List<AcademicTermWrapper> termsToDeleteOnSave; |
59 | |
|
60 | |
public AcademicCalendarForm() { |
61 | 0 | super(); |
62 | 0 | academicCalendarInfo = new AcademicCalendarInfo(); |
63 | 0 | termWrapperList = new ArrayList<AcademicTermWrapper>(); |
64 | 0 | events = new ArrayList<AcalEventWrapper>(); |
65 | 0 | holidayCalendarList = new ArrayList<HolidayCalendarWrapper>(); |
66 | 0 | newCalendar = true; |
67 | 0 | officialCalendar = false; |
68 | 0 | defaultTabToShow = CalendarConstants.ACAL_INFO_TAB; |
69 | 0 | eventsToDeleteOnSave = new ArrayList<AcalEventWrapper>(); |
70 | 0 | termsToDeleteOnSave = new ArrayList<AcademicTermWrapper>(); |
71 | 0 | } |
72 | |
|
73 | |
public AcademicCalendarInfo getAcademicCalendarInfo() { |
74 | 0 | return academicCalendarInfo; |
75 | |
} |
76 | |
|
77 | |
public void setAcademicCalendarInfo(AcademicCalendarInfo academicCalendarInfo) { |
78 | 0 | this.academicCalendarInfo = academicCalendarInfo; |
79 | 0 | } |
80 | |
|
81 | |
public AcademicCalendarInfo getOrgAcalInfo() { |
82 | 0 | return orgAcalInfo; |
83 | |
} |
84 | |
|
85 | |
public void setOrgAcalInfo(AcademicCalendarInfo orgAcalInfo) { |
86 | 0 | this.orgAcalInfo = orgAcalInfo; |
87 | 0 | } |
88 | |
|
89 | |
public String getAdminOrgName() { |
90 | 0 | return adminOrgName; |
91 | |
} |
92 | |
|
93 | |
public void setAdminOrgName(String adminOrgName) { |
94 | 0 | this.adminOrgName = adminOrgName; |
95 | 0 | } |
96 | |
|
97 | |
public void setHolidayCalendarList(List<HolidayCalendarWrapper> holidayCalendarList) { |
98 | 0 | this.holidayCalendarList = holidayCalendarList; |
99 | 0 | } |
100 | |
|
101 | |
public List<HolidayCalendarWrapper> getHolidayCalendarList() { |
102 | 0 | return holidayCalendarList; |
103 | |
} |
104 | |
|
105 | |
public void setTermWrapperList(List<AcademicTermWrapper> termWrapperList) { |
106 | 0 | this.termWrapperList = termWrapperList; |
107 | 0 | } |
108 | |
|
109 | |
public List<AcademicTermWrapper> getTermWrapperList() { |
110 | 0 | return termWrapperList; |
111 | |
} |
112 | |
|
113 | |
public String getUpdateTimeString(){ |
114 | 0 | updateTimeString = new String(""); |
115 | 0 | if (getAcademicCalendarInfo() == null || |
116 | |
getAcademicCalendarInfo().getId()== null || |
117 | |
getAcademicCalendarInfo().getId().isEmpty()){ |
118 | 0 | return updateTimeString; |
119 | |
} |
120 | |
else { |
121 | 0 | Date updateTime = academicCalendarInfo.getMeta().getUpdateTime(); |
122 | 0 | if (updateTime != null){ |
123 | 0 | updateTimeString = "Last saved at "+new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(updateTime); |
124 | |
} |
125 | 0 | return updateTimeString; |
126 | |
} |
127 | |
} |
128 | |
|
129 | |
public List<AcalEventWrapper> getEvents() { |
130 | 0 | return events; |
131 | |
} |
132 | |
|
133 | |
public void setEvents(List<AcalEventWrapper> events) { |
134 | 0 | this.events = events; |
135 | 0 | } |
136 | |
|
137 | |
public boolean isNewCalendar() { |
138 | 0 | return newCalendar; |
139 | |
} |
140 | |
|
141 | |
public void setNewCalendar(boolean newCalendar) { |
142 | 0 | this.newCalendar = newCalendar; |
143 | 0 | } |
144 | |
|
145 | |
public boolean isOfficialCalendar() { |
146 | 0 | return officialCalendar; |
147 | |
} |
148 | |
|
149 | |
public void setOfficialCalendar(boolean officialCalendar) { |
150 | 0 | this.officialCalendar = officialCalendar; |
151 | 0 | } |
152 | |
|
153 | |
public String getDefaultTabToShow() { |
154 | 0 | return defaultTabToShow; |
155 | |
} |
156 | |
|
157 | |
public void setDefaultTabToShow(String defaultTabToShow) { |
158 | 0 | this.defaultTabToShow = defaultTabToShow; |
159 | 0 | } |
160 | |
|
161 | |
public List<AcalEventWrapper> getEventsToDeleteOnSave() { |
162 | 0 | return eventsToDeleteOnSave; |
163 | |
} |
164 | |
|
165 | |
public void setEventsToDeleteOnSave(List<AcalEventWrapper> eventsToDeleteOnSave) { |
166 | 0 | this.eventsToDeleteOnSave = eventsToDeleteOnSave; |
167 | 0 | } |
168 | |
|
169 | |
public List<AcademicTermWrapper> getTermsToDeleteOnSave() { |
170 | 0 | return termsToDeleteOnSave; |
171 | |
} |
172 | |
|
173 | |
public void setTermsToDeleteOnSave(List<AcademicTermWrapper> termsToDeleteOnSave) { |
174 | 0 | this.termsToDeleteOnSave = termsToDeleteOnSave; |
175 | 0 | } |
176 | |
|
177 | |
public int getDefaultSelectedTabIndex() { |
178 | 0 | if (StringUtils.equals(defaultTabToShow,CalendarConstants.ACAL_TERM_TAB)){ |
179 | 0 | return 1; |
180 | |
} |
181 | 0 | return 0; |
182 | |
} |
183 | |
|
184 | |
public void reset(){ |
185 | 0 | setAcademicCalendarInfo(new AcademicCalendarInfo()); |
186 | 0 | setOfficialCalendar(false); |
187 | 0 | getView().setReadOnly(false); |
188 | 0 | setEvents(new ArrayList<AcalEventWrapper>()); |
189 | 0 | setHolidayCalendarList(new ArrayList<HolidayCalendarWrapper>()); |
190 | 0 | setEventsToDeleteOnSave(new ArrayList<AcalEventWrapper>()); |
191 | 0 | setTermsToDeleteOnSave(new ArrayList<AcademicTermWrapper>()); |
192 | 0 | setTermWrapperList(new ArrayList<AcademicTermWrapper>()); |
193 | 0 | setNewCalendar(false); |
194 | 0 | } |
195 | |
|
196 | |
public AcademicCalendarViewHelperService getViewHelperService(){ |
197 | 0 | if (getView() != null && getView().getViewHelperServiceClass() != null){ |
198 | 0 | return (AcademicCalendarViewHelperService)getView().getViewHelperService(); |
199 | |
}else{ |
200 | 0 | return (AcademicCalendarViewHelperService)getPostedView().getViewHelperService(); |
201 | |
} |
202 | |
} |
203 | |
|
204 | |
public ContextInfo getContextInfo(){ |
205 | 0 | return getViewHelperService().getContextInfo(); |
206 | |
} |
207 | |
|
208 | |
} |