HttpServletResponse response) {
final IViewState viewState = RenderUtils.getViewState();
SummariesCalendarBean bean = (SummariesCalendarBean) viewState.getMetaObject().getObject();
ExecutionCourse executionCourse = bean.getExecutionCourse();
Shift shift = bean.getShift();
ShiftType shiftType = bean.getShiftType();
LessonCalendarViewType calendarViewType = bean.getCalendarViewType();
Set<NextPossibleSummaryLessonsAndDatesBean> summariesCalendar =
new TreeSet<NextPossibleSummaryLessonsAndDatesBean>(
NextPossibleSummaryLessonsAndDatesBean.COMPARATOR_BY_DATE_AND_HOUR);
for (Lesson lesson : executionCourse.getLessons()) {
boolean insert = true;
if ((shift != null && !shift.getAssociatedLessonsSet().contains(lesson))
|| (shiftType != null && !lesson.getShift().containsType(shiftType))) {
insert = false;
}
if (insert) {
for (YearMonthDay lessonDate : lesson.getAllLessonDates()) {
if ((calendarViewType.equals(LessonCalendarViewType.ALL_LESSONS))
|| (calendarViewType.equals(LessonCalendarViewType.PAST_LESSON) && lesson.isTimeValidToInsertSummary(
new HourMinuteSecond(), lessonDate))
|| (calendarViewType.equals(LessonCalendarViewType.PAST_LESSON_WITHOUT_SUMMARY) && lesson
.getSummaryByDate(lessonDate) == null)
&& lesson.isTimeValidToInsertSummary(new HourMinuteSecond(), lessonDate)) {
summariesCalendar.add(new NextPossibleSummaryLessonsAndDatesBean(lesson, lessonDate));
}
}
}
}
// Extra Summaries
if (shift != null) {
if (shiftType == null) {
addExtraSummariesToSummariesCalendar(summariesCalendar, shift, calendarViewType);
}
} else {
for (Shift executionCourseShift : executionCourse.getAssociatedShifts()) {
if (shiftType == null) {
addExtraSummariesToSummariesCalendar(summariesCalendar, executionCourseShift, calendarViewType);
}
}
}