private List<InfoExam> obtainInfoExams(ExecutionDegree executionDegree, String executionPeriodId,
Integer wantedCurricularYear, ExecutionCourse executionCourse) {
List<InfoExam> result = new ArrayList<InfoExam>();
for (Exam exam : executionCourse.getAssociatedExams()) {
InfoExam infoExam =
InfoExamWithRoomOccupationsAndScopesWithCurricularCoursesWithDegreeAndSemesterAndYear.newInfoFromDomain(exam);
int numberOfStudentsForExam = 0;
Set<CurricularCourse> checkedCurricularCourses = new HashSet<CurricularCourse>();
for (DegreeModuleScope degreeModuleScope : exam.getDegreeModuleScopes()) {
CurricularCourse curricularCourse = degreeModuleScope.getCurricularCourse();
if (!checkedCurricularCourses.contains(curricularCourse)) {
checkedCurricularCourses.add(curricularCourse);
ExecutionSemester executionSemester = FenixFramework.getDomainObject(executionPeriodId);
int numberEnroledStudentsInCurricularCourse =
curricularCourse.countEnrolmentsByExecutionPeriod(executionSemester);
numberOfStudentsForExam += numberEnroledStudentsInCurricularCourse;
}
boolean isCurricularYearEqual = degreeModuleScope.getCurricularYear().equals(wantedCurricularYear);
DegreeCurricularPlan degreeCurricularPlanFromScope =
degreeModuleScope.getCurricularCourse().getDegreeCurricularPlan();
DegreeCurricularPlan degreeCurricularPlanFromExecutionDegree = executionDegree.getDegreeCurricularPlan();
boolean isCurricularPlanEqual = degreeCurricularPlanFromScope.equals(degreeCurricularPlanFromExecutionDegree);
if (isCurricularYearEqual && isCurricularPlanEqual && !result.contains(infoExam)) {
result.add(infoExam);
break;
}
}
infoExam.setEnrolledStudents(Integer.valueOf(numberOfStudentsForExam));
}
return result;
}