IEnrolment enrolment = (IEnrolment) iterEnrolment.next();
IEnrollment enrolment = (IEnrollment) iterEnrolment.next();
    public InfoSiteEnrolmentEvaluation run(Integer curricularCourseCode, String yearString)        throws FenixServiceException    {        List infoEnrolmentEvaluations = new ArrayList();        InfoTeacher infoTeacher = new InfoTeacher();        Date lastEvaluationDate = null;        try        {            ISuportePersistente sp = SuportePersistenteOJB.getInstance();            IPersistentCurricularCourse persistentCurricularCourse = sp.getIPersistentCurricularCourse();            IPersistentEnrolmentEvaluation persistentEnrolmentEvaluation =                sp.getIPersistentEnrolmentEvaluation();            IPersistentEnrolment persistentEnrolment = sp.getIPersistentEnrolment();            IPersistentTeacher persistentTeacher = sp.getIPersistentTeacher();            ICurricularCourse curricularCourse = new CurricularCourse();            curricularCourse.setIdInternal(curricularCourseCode);            curricularCourse =                (ICurricularCourse) persistentCurricularCourse.readByOId(curricularCourse, false);            List enrolments = null;            if (yearString != null)            {            	enrolments =            	persistentEnrolment.readByCurricularCourseAndYear(curricularCourse, yearString);            }            else            {            	enrolments =            	persistentEnrolment.readByCurricularCourse(curricularCourse);            }            List enrolmentEvaluations = new ArrayList();            Iterator iterEnrolment = enrolments.listIterator();            while (iterEnrolment.hasNext())            {                IEnrolment enrolment = (IEnrolment) iterEnrolment.next();                if (enrolment                    .getStudentCurricularPlan()                    .getDegreeCurricularPlan()                    .getDegree()                    .getTipoCurso()                    .equals(TipoCurso.MESTRADO_OBJ))                {                    List allEnrolmentEvaluations =                        persistentEnrolmentEvaluation.readEnrolmentEvaluationByEnrolment(enrolment);                    IEnrolmentEvaluation enrolmentEvaluation =                        (IEnrolmentEvaluation) allEnrolmentEvaluations.get(                            allEnrolmentEvaluations.size() - 1);                    enrolmentEvaluations.add(enrolmentEvaluation);                }            }            if (enrolmentEvaluations != null && enrolmentEvaluations.size() > 0)            {                //			in case we have evaluations they can be submitted only if they are temporary                List temporaryEnrolmentEvaluations =                    (List) CollectionUtils.select(enrolmentEvaluations, new Predicate()                {                    public boolean evaluate(Object arg0)                    {                        IEnrolmentEvaluation enrolmentEvaluation = (IEnrolmentEvaluation) arg0;                        if (enrolmentEvaluation                            .getEnrolmentEvaluationState()                            .equals(EnrolmentEvaluationState.TEMPORARY_OBJ))                            return true;                        return false;                    }                });                if (temporaryEnrolmentEvaluations == null || temporaryEnrolmentEvaluations.size() == 0)                {                    throw new ExistingServiceException();                }                //				if (((IEnrolmentEvaluation) enrolmentEvaluations.get(0))                //					.getEnrolmentEvaluationState()                //					.equals(EnrolmentEvaluationState.FINAL_OBJ)) {                //					throw new ExistingServiceException();                //				}                //				get teacher responsible for final evaluation - he is responsible for all evaluations for this                //				curricularCourse                List enrolmentEvaluationsWithResponsiblePerson =                    (List) CollectionUtils.select(enrolmentEvaluations, new Predicate()                {                    public boolean evaluate(Object arg0)                    {                        IEnrolmentEvaluation enrolEval = (IEnrolmentEvaluation) arg0;                        if (enrolEval.getPersonResponsibleForGrade() != null)                        {                            return true;                        }                        return false;                    }                });                if (enrolmentEvaluationsWithResponsiblePerson.size() > 0)                {                    IPessoa person =                        ((IEnrolmentEvaluation) enrolmentEvaluationsWithResponsiblePerson.get(0))                            .getPersonResponsibleForGrade();                    ITeacher teacher = persistentTeacher.readTeacherByUsername(person.getUsername());                    infoTeacher = Cloner.copyITeacher2InfoTeacher(teacher);                }                //				transform evaluations in databeans                ListIterator iter = temporaryEnrolmentEvaluations.listIterator();                while (iter.hasNext())                {                    IEnrolmentEvaluation elem = (IEnrolmentEvaluation) iter.next();                    InfoEnrolmentEvaluation infoEnrolmentEvaluation =                        Cloner.copyIEnrolmentEvaluation2InfoEnrolmentEvaluation(elem);                    infoEnrolmentEvaluation.setInfoEnrolment(                        Cloner.copyIEnrolment2InfoEnrolment(elem.getEnrolment()));                    infoEnrolmentEvaluations.add(infoEnrolmentEvaluation);                }            }            if (infoEnrolmentEvaluations.size() == 0)            {                throw new NonExistingServiceException();            }            //				get last evaluation date to show in interface            if (((InfoEnrolmentEvaluation) infoEnrolmentEvaluations.get(0)).getExamDate() == null)            {                lastEvaluationDate = getLastEvaluationDate(yearString, curricularCourse);            } else            {                lastEvaluationDate =                    ((InfoEnrolmentEvaluation) infoEnrolmentEvaluations.get(0)).getExamDate();            }        } catch (ExcepcaoPersistencia ex)        {            FenixServiceException newEx = new FenixServiceException("Persistence layer error");            newEx.fillInStackTrace();            throw newEx;        }        InfoSiteEnrolmentEvaluation infoSiteEnrolmentEvaluation = new InfoSiteEnrolmentEvaluation();        infoSiteEnrolmentEvaluation.setEnrolmentEvaluations(infoEnrolmentEvaluations);        infoSiteEnrolmentEvaluation.setInfoTeacher(infoTeacher);        infoSiteEnrolmentEvaluation.setLastEvaluationDate(lastEvaluationDate);        return infoSiteEnrolmentEvaluation;    }