@Override public Object provide(Object source, Object currentValue) { final ExecutionYear currentYear = ExecutionYear.readCurrentExecutionYear(); final ExecutionYear previousYear = currentYear.getPreviousExecutionYear(); final List<ExecutionSemester> executionSemesters = new ArrayList<ExecutionSemester>(); SpecialSeasonStudentEnrollmentBean bean = (SpecialSeasonStudentEnrollmentBean) source; if (bean.getScp() .getDegreeCurricularPlan() .hasOpenSpecialSeasonEnrolmentPeriod(currentYear.getLastExecutionPeriod())) { executionSemesters.add(currentYear.getLastExecutionPeriod()); } if (bean.getScp() .getDegreeCurricularPlan() .hasOpenSpecialSeasonEnrolmentPeriod(currentYear.getFirstExecutionPeriod())) { executionSemesters.add(currentYear.getFirstExecutionPeriod()); } if (bean.getScp() .getDegreeCurricularPlan() .hasOpenSpecialSeasonEnrolmentPeriod(previousYear.getLastExecutionPeriod())) { executionSemesters.add(previousYear.getLastExecutionPeriod()); } if (bean.getScp() .getDegreeCurricularPlan() .hasOpenSpecialSeasonEnrolmentPeriod(previousYear.getFirstExecutionPeriod())) { executionSemesters.add(previousYear.getFirstExecutionPeriod()); } Collections.sort(executionSemesters, ExecutionSemester.COMPARATOR_BY_SEMESTER_AND_YEAR); Collections.reverse(executionSemesters); return executionSemesters; }
public static ExecutionYear getExecutionYearFourYearsBack(final ExecutionYear executionYear) { ExecutionYear executionYearFourYearsBack = executionYear; if (executionYear != null) { for (int i = 5; i > 1; i--) { final ExecutionYear previousExecutionYear = executionYearFourYearsBack.getPreviousExecutionYear(); if (previousExecutionYear != null) { executionYearFourYearsBack = previousExecutionYear; } } } return executionYearFourYearsBack; }