if (getStudentCurricularPlansSet().isEmpty()) {
return Curriculum.createEmpty(executionYear);
}
if (getDegreeType().isBolonhaType()) {
final StudentCurricularPlan studentCurricularPlan = getLastStudentCurricularPlan();
if (studentCurricularPlan == null) {
return Curriculum.createEmpty(executionYear);
}
if (cycleType == null) {
return studentCurricularPlan.getCurriculum(when, executionYear);
}
final CycleCurriculumGroup cycleCurriculumGroup = studentCurricularPlan.getCycle(cycleType);
if (cycleCurriculumGroup == null) {
return Curriculum.createEmpty(executionYear);
}
return cycleCurriculumGroup.getCurriculum(when, executionYear);
} else {
final List<StudentCurricularPlan> sortedSCPs = getSortedStudentCurricularPlans();
final ListIterator<StudentCurricularPlan> sortedSCPsIterator = sortedSCPs.listIterator(sortedSCPs.size());
final StudentCurricularPlan lastStudentCurricularPlan = sortedSCPsIterator.previous();
final ICurriculum curriculum;
if (lastStudentCurricularPlan.isBoxStructure()) {
curriculum = lastStudentCurricularPlan.getCurriculum(when, executionYear);
for (; sortedSCPsIterator.hasPrevious();) {
final StudentCurricularPlan studentCurricularPlan = sortedSCPsIterator.previous();
if (executionYear == null || studentCurricularPlan.getStartExecutionYear().isBeforeOrEquals(executionYear)) {
((Curriculum) curriculum).add(studentCurricularPlan.getCurriculum(when, executionYear));
}
}
return curriculum;