package net.sourceforge.fenixedu.applicationTier.Servico.department; import java.util.ArrayList; import java.util.List; import java.util.Map; import net.sourceforge.fenixedu.applicationTier.Servico.exceptions.FenixServiceException; import net.sourceforge.fenixedu.dataTransferObject.department.DegreeCourseStatisticsDTO; import net.sourceforge.fenixedu.domain.CompetenceCourse; import net.sourceforge.fenixedu.domain.CurricularCourse; import net.sourceforge.fenixedu.domain.Degree; import net.sourceforge.fenixedu.domain.Enrolment; import net.sourceforge.fenixedu.domain.ExecutionSemester; public class ComputeDegreeCourseStatistics extends ComputeCourseStatistics { public List run(Integer competenceCourseId, Integer executionPeriodId) throws FenixServiceException { CompetenceCourse competenceCourse = rootDomainObject.readCompetenceCourseByOID(competenceCourseId); ExecutionSemester executionSemester = rootDomainObject.readExecutionSemesterByOID(executionPeriodId); Map> groupedCourses = competenceCourse.getAssociatedCurricularCoursesGroupedByDegree(); List results = new ArrayList(); for (Degree degree : groupedCourses.keySet()) { List enrollments = new ArrayList(); List curricularCourses = groupedCourses.get(degree); for (CurricularCourse curricularCourse : curricularCourses) { enrollments.addAll(curricularCourse.getActiveEnrollments(executionSemester)); } DegreeCourseStatisticsDTO degreeCourseStatistics = new DegreeCourseStatisticsDTO(); degreeCourseStatistics.setIdInternal(degree.getIdInternal()); degreeCourseStatistics.setName(degree.getNameFor(executionSemester.getExecutionYear()).getContent()); createCourseStatistics(degreeCourseStatistics, enrollments); results.add(degreeCourseStatistics); } return results; } }