DegreeCurricularPlan degreeCurricularPlan = studentCurricularPlan .getDegreeCurricularPlan(); List<ExecutionDegree> executionDegrees = degreeCurricularPlan.getExecutionDegrees();  ExecutionDegree executionDegree = (ExecutionDegree) Collections.min(executionDegrees, new Comparator() {  public int compare(Object o1, Object o2) { ExecutionDegree executionDegree1 = (ExecutionDegree) o1; ExecutionDegree executionDegree2 = (ExecutionDegree) o2;  return executionDegree1.getExecutionYear().getYear().compareTo( executionDegree2.getExecutionYear().getYear()); }  });  if (!executionDegree.getExecutionYear().equals(executionYear)) {
if (!getFirstExecutionDegree(studentCurricularPlan.getDegreeCurricularPlan()) .getExecutionYear().equals(executionYear)) {
    public Collection run(String executionYearName) throws ExcepcaoPersistencia {        final ISuportePersistente sp = PersistenceSupportFactory.getDefaultPersistenceSupport();        final ExecutionYear executionYear = sp.getIPersistentExecutionYear().readExecutionYearByName(                executionYearName);        final Collection<InfoStudentCurricularPlanWithFirstTimeEnrolment> infoStudentCurricularPlans = new ArrayList();        final Collection<StudentCurricularPlan> studentCurricularPlans = new ArrayList();        final Collection<DegreeCurricularPlan> masterDegreeCurricularPlans = sp                .getIPersistentDegreeCurricularPlan().readByDegreeTypeAndState(                        DegreeType.MASTER_DEGREE, DegreeCurricularPlanState.ACTIVE);        CollectionUtils.filter(masterDegreeCurricularPlans, new Predicate() {            public boolean evaluate(Object arg0) {                DegreeCurricularPlan degreeCurricularPlan = (DegreeCurricularPlan) arg0;                for (ExecutionDegree executionDegree : degreeCurricularPlan                        .getExecutionDegrees()) {                    if (executionDegree.getExecutionYear().equals(executionYear)) {                        return true;                    }                }                return false;            }        });        for (DegreeCurricularPlan degreeCurricularPlan : masterDegreeCurricularPlans) {            studentCurricularPlans.addAll(degreeCurricularPlan.getStudentCurricularPlans());        }        for (StudentCurricularPlan studentCurricularPlan : studentCurricularPlans) {            if (!studentCurricularPlan.getCurrentState().equals(StudentCurricularPlanState.ACTIVE)                    && !studentCurricularPlan.getCurrentState().equals(                            StudentCurricularPlanState.SCHOOLPARTCONCLUDED)) {                continue;            }            boolean firstTimeEnrolment = true;            if (studentCurricularPlan.getSpecialization().equals(Specialization.MASTER_DEGREE)) {                Collection<StudentCurricularPlan> previousStudentCurricularPlans = sp                        .getIStudentCurricularPlanPersistente().readAllByStudentNumberAndSpecialization(                                studentCurricularPlan.getStudent().getNumber(),                                DegreeType.MASTER_DEGREE, Specialization.MASTER_DEGREE);                previousStudentCurricularPlans.remove(studentCurricularPlan);                for (StudentCurricularPlan previousStudentCurricularPlan : previousStudentCurricularPlans) {                    if (previousStudentCurricularPlan.getDegreeCurricularPlan().getDegree().equals(                            studentCurricularPlan.getDegreeCurricularPlan().getDegree())) {                        firstTimeEnrolment = false;                        break;                    }                }            }                        if (firstTimeEnrolment) {                DegreeCurricularPlan degreeCurricularPlan = studentCurricularPlan                        .getDegreeCurricularPlan();                List<ExecutionDegree> executionDegrees = degreeCurricularPlan.getExecutionDegrees();                ExecutionDegree executionDegree = (ExecutionDegree) Collections.min(executionDegrees, new Comparator() {                    public int compare(Object o1, Object o2) {                        ExecutionDegree executionDegree1 = (ExecutionDegree) o1;                        ExecutionDegree executionDegree2 = (ExecutionDegree) o2;                        return executionDegree1.getExecutionYear().getYear().compareTo(                                executionDegree2.getExecutionYear().getYear());                    }                });                if (!executionDegree.getExecutionYear().equals(executionYear)) {                    firstTimeEnrolment = false;                }            }            InfoStudentCurricularPlanWithFirstTimeEnrolment infoStudentCurricularPlan = InfoStudentCurricularPlanWithFirstTimeEnrolment                    .newInfoFromDomain(studentCurricularPlan);            infoStudentCurricularPlan.setFirstTimeEnrolment(firstTimeEnrolment);            infoStudentCurricularPlans.add(infoStudentCurricularPlan);        }        return infoStudentCurricularPlans;    }