Map studentGroupsMap = getStudentGroupsMapFromGroupPropertiesList(groupProperties, persistentSupport);
Map studentGroupsMap = getStudentGroupsMapFromGroupPropertiesList(groupProperties);
    public Object run(Integer executionCourseCode, List curricularPlansIds, List enrollmentTypeFilters,            List shiftIds) throws FenixServiceException, ExcepcaoPersistencia {        final ExecutionCourse executionCourse = (ExecutionCourse) persistentObject                .readByOID(ExecutionCourse.class, executionCourseCode);        InfoExecutionCourse infoExecutionCourse = InfoExecutionCourseWithExecutionPeriod                .newInfoFromDomain(executionCourse);        final Site site = executionCourse.getSite();        List attends = executionCourse.getAttends();        List allDegreeCurricularPlans = getDegreeCurricularPlansFromAttends(attends);        List allShifts = executionCourse.getAssociatedShifts();        List groupProperties = executionCourse.getGroupings();        Map studentGroupsMap = getStudentGroupsMapFromGroupPropertiesList(groupProperties, persistentSupport);        InfoAttendsSummary infoAttendsSummary = new InfoAttendsSummary();        int[] enrollmentDistribution = new int[10];        // filter by Course        if (curricularPlansIds != null) {            final List dcpIds = new ArrayList();            dcpIds.addAll(curricularPlansIds);            Predicate pCourses = new Predicate() {                public boolean evaluate(Object o) {                    Attends attendance = (Attends) o;                    List scps = attendance.getAluno().getStudentCurricularPlans();                    if (scps != null && !scps.isEmpty()) {                        StudentCurricularPlan lastSCP = getStudentCurricularPlanFromAttends(attendance);                        final Integer lastDCPId = lastSCP.getDegreeCurricularPlan().getIdInternal();                        return dcpIds.contains(lastDCPId);                    }                    return false;                }            };            attends = (List) CollectionUtils.select(attends, pCourses);        }        // filter by Enrollment type        if (enrollmentTypeFilters != null) {            boolean enrolledFilter = enrollmentTypeFilters                    .contains(AttendacyStateSelectionType.ENROLLED);            boolean notEnrolledFilter = enrollmentTypeFilters                    .contains(AttendacyStateSelectionType.NOT_ENROLLED);            boolean improvementFilter = enrollmentTypeFilters                    .contains(AttendacyStateSelectionType.IMPROVEMENT);            boolean specialSeasonFilter = enrollmentTypeFilters            		.contains(AttendacyStateSelectionType.SPECIAL_SEASON);                        List newAttends = new ArrayList();            Iterator attendsIterator = attends.iterator();            while (attendsIterator.hasNext()) {                Attends attendacy = (Attends) attendsIterator.next();                // improvement student (he/she is enrolled)                if (improvementFilter                        && attendacy.getEnrolment() != null                        && (!attendacy.getEnrolment().getExecutionPeriod().equals(                                executionCourse.getExecutionPeriod()))) {                    newAttends.add(attendacy);                    // normal student (cannot be an improvement student)                } else if (enrolledFilter                        && attendacy.getEnrolment() != null                        && (attendacy.getEnrolment().getExecutionPeriod().equals(executionCourse                                .getExecutionPeriod())) && !hasSpecialSeasonEnrolmentEvaluation(attendacy.getEnrolment().getEvaluations())) {                    newAttends.add(attendacy);                    // not enrolled student                } else if (notEnrolledFilter && attendacy.getEnrolment() == null) {                    newAttends.add(attendacy);                    // persistentSupportecial season student                } else if (specialSeasonFilter && attendacy.getEnrolment() != null && (attendacy.getEnrolment().getExecutionPeriod().equals(executionCourse                        .getExecutionPeriod())) && hasSpecialSeasonEnrolmentEvaluation(attendacy.getEnrolment().getEvaluations())) {                		newAttends.add(attendacy);                }            }            attends = newAttends;        }        // filter by Shift        if (shiftIds != null) {            Iterator shiftIterator = shiftIds.iterator();            List collectedAttends = new ArrayList();            while (shiftIterator.hasNext()) {                Integer shiftId = (Integer) shiftIterator.next();                final Shift turno = rootDomainObject.readShiftByOID(shiftId);                Iterator attendsIterator = attends.iterator();                while (attendsIterator.hasNext()) {                    Attends attendance = (Attends) attendsIterator.next();                    // if an attendance is related to a Shift                    Student student = attendance.getAluno();                    if (turno.getStudents().contains(student)) {                        collectedAttends.add(attendance);                    }                }            }            attends = collectedAttends;        }        // building the info        InfoForReadStudentsWithAttendsByExecutionCourse infoDTO = new InfoForReadStudentsWithAttendsByExecutionCourse();        List shifts = executionCourse.getAssociatedShifts();        List infoCompositions = new ArrayList();        Iterator it = attends.iterator();        final Map<Integer, InfoShift> clonedShifts = new HashMap<Integer, InfoShift>();        while (it.hasNext()) {            Attends iFrequenta = (Attends) it.next();            InfoCompositionOfAttendAndDegreeCurricularPlanAndShiftsAndStudentGroups infoComposition = new InfoCompositionOfAttendAndDegreeCurricularPlanAndShiftsAndStudentGroups();            InfoFrequenta infoFrequenta = InfoAttendsWithInfoStudentAndPersonAndInfoEnrollment                    .newInfoFromDomain(iFrequenta);            infoComposition.setInfoAttends(infoFrequenta);            // determining the EnrolmentEvaluationType            if (iFrequenta.getEnrolment() != null) {                EnrolmentEvaluationType enrollmentEvaluationType = null;            	        		if (!iFrequenta.getEnrolment().getExecutionPeriod().equals(                        executionCourse.getExecutionPeriod())) {                    enrollmentEvaluationType = EnrolmentEvaluationType.IMPROVEMENT;        		} else {        			if(hasSpecialSeasonEnrolmentEvaluation(iFrequenta.getEnrolment().getEvaluations())) {        				enrollmentEvaluationType = EnrolmentEvaluationType.SPECIAL_SEASON;        			}        			else {        				enrollmentEvaluationType = EnrolmentEvaluationType.NORMAL;        			}        			        		}        		infoFrequenta.getInfoEnrolment().setEnrolmentEvaluationType(enrollmentEvaluationType);            }            StudentCurricularPlan studentCurricularPlan = getStudentCurricularPlanFromAttends(iFrequenta);            DegreeCurricularPlan degreeCP = studentCurricularPlan.getDegreeCurricularPlan();            InfoDegreeCurricularPlan infoDCP = InfoDegreeCurricularPlanWithDegree                    .newInfoFromDomain(degreeCP);            infoComposition.setAttendingStudentInfoDCP(infoDCP);            Map infoShifts = getShiftsByAttends(shifts, iFrequenta, persistentSupport, clonedShifts);            infoComposition.setInfoShifts(infoShifts);            Map infoStudentGroups = getInfoStudentGroupsByAttends(studentGroupsMap, iFrequenta);            infoComposition.setInfoStudentGroups(infoStudentGroups);            Enrolment enrollment = iFrequenta.getEnrolment();            int numberOfEnrollments = 0;            if (enrollment != null) {                numberOfEnrollments = countAllEnrolmentsForSameStudent(studentCurricularPlan, enrollment                        .getCurricularCourse().getName());            }            if (numberOfEnrollments >= enrollmentDistribution.length) {                int[] newDistribution = new int[Math.max(numberOfEnrollments + 1,                        enrollmentDistribution.length * 2)];                System.arraycopy(enrollmentDistribution, 0, newDistribution, 0,                        enrollmentDistribution.length);                enrollmentDistribution = newDistribution;            }                enrollmentDistribution[numberOfEnrollments]++;            infoComposition.setNumberOfEnrollments(numberOfEnrollments);            infoCompositions.add(infoComposition);        }        infoDTO.setInfoAttends(infoCompositions);        infoDTO.setInfoExecutionCourse(infoExecutionCourse);        List tipoAulas = getClassTypesFromExecutionCourse(executionCourse);        infoDTO.setClassTypes(tipoAulas);        infoDTO.setInfoShifts(getInfoShiftsFromList(allShifts));        infoDTO                .setInfoDegreeCurricularPlans(getInfoDegreeCurricularPlansFromList(allDegreeCurricularPlans));        List infoGroupProperties = getInfoGroupPropertiesFromList(groupProperties);        infoDTO.setInfoGroupProperties(infoGroupProperties);        List enrollmentDistributionKeys = new ArrayList(enrollmentDistribution.length);        Map enrollmentDistributionMap = new HashMap();        for (int i = 0; i < enrollmentDistribution.length; i++) {            if (enrollmentDistribution[i] != 0) {                Integer key = new Integer(i);                Integer value = new Integer(enrollmentDistribution[i]);                enrollmentDistributionKeys.add(key);                enrollmentDistributionMap.put(key, value);            }        }        infoAttendsSummary.setEnrollmentDistribution(enrollmentDistributionMap);        infoAttendsSummary.setNumberOfEnrollments(enrollmentDistributionKeys);        infoDTO.setInfoAttendsSummary(infoAttendsSummary);        TeacherAdministrationSiteView siteView = createSiteView(infoDTO, site);        return siteView;    }