IEnrolment enrolment = iEnrolmentEvaluation.getEnrolment();
IEnrollment enrolment = iEnrolmentEvaluation.getEnrolment();
    public List run(        Integer curricularCourseCode,        Integer enrolmentEvaluationCode,        InfoEnrolmentEvaluation infoEnrolmentEvaluation,        Integer teacherNumber,        IUserView userView)        throws FenixServiceException    {        List infoEvaluationsWithError = null;        try        {			Calendar calendario = Calendar.getInstance();            ISuportePersistente sp = SuportePersistenteOJB.getInstance();            IPersistentCurricularCourse persistentCurricularCourse = sp.getIPersistentCurricularCourse();            IPersistentEnrolmentEvaluation persistentEnrolmentEvaluation =                sp.getIPersistentEnrolmentEvaluation();            IPessoaPersistente persistentPerson = sp.getIPessoaPersistente();            IPersistentTeacher persistentTeacher = sp.getIPersistentTeacher();            IPersistentEnrolment persistentEnrolment = sp.getIPersistentEnrolment();			if ( (infoEnrolmentEvaluation.getGrade().equals("0")) || (infoEnrolmentEvaluation.getGrade().equals("")) || (infoEnrolmentEvaluation.getGrade().length() < -1)){//				new enrolment evaluation				IEnrolmentEvaluation enrolmentEvaluationCopy = new EnrolmentEvaluation();				enrolmentEvaluationCopy.setIdInternal(enrolmentEvaluationCode);				enrolmentEvaluationCopy =								   (IEnrolmentEvaluation) persistentEnrolmentEvaluation.readByOId(								enrolmentEvaluationCopy,									   false);				IEnrolment enrolment=enrolmentEvaluationCopy.getEnrolment();				 				persistentEnrolment.simpleLockWrite(enrolment);								enrolment.setEnrolmentState(EnrolmentState.ENROLED);				enrolment.setCurricularCourse(						enrolmentEvaluationCopy.getEnrolment().getCurricularCourse());				enrolment.setEnrolmentEvaluationType(						enrolmentEvaluationCopy.getEnrolment().getEnrolmentEvaluationType());				enrolment.setExecutionPeriod(						enrolmentEvaluationCopy.getEnrolment().getExecutionPeriod());				enrolment.setStudentCurricularPlan(						enrolmentEvaluationCopy.getEnrolment().getStudentCurricularPlan());				enrolment.setIdInternal(enrolmentEvaluationCopy.getEnrolment().getIdInternal());						IEnrolmentEvaluation enrolmentEvaluation = new EnrolmentEvaluation();				enrolmentEvaluation.setEnrolment(enrolment);					enrolmentEvaluation.setEnrolmentEvaluationState(EnrolmentEvaluationState.FINAL_OBJ );				enrolmentEvaluation.setEnrolmentEvaluationType(enrolmentEvaluationCopy.getEnrolmentEvaluationType());				enrolmentEvaluation.setCheckSum(null);				//		employee			    IPessoa person = persistentPerson.lerPessoaPorUsername(userView.getUtilizador());			    IEmployee employee = readEmployee(person);				enrolmentEvaluation.setEmployee(employee);				enrolmentEvaluation.setExamDate(null);				enrolmentEvaluation.setGrade(null);				enrolmentEvaluation.setGradeAvailableDate(null);				enrolmentEvaluation.setObservation(infoEnrolmentEvaluation.getObservation());				enrolmentEvaluation.setPersonResponsibleForGrade(null);				enrolmentEvaluation.setWhen(calendario.getTime());				enrolmentEvaluation.setAckOptLock(new Integer(1));				persistentEnrolmentEvaluation.lockWrite(enrolmentEvaluation);															}else{            //	responsible teacher            ITeacher teacher = persistentTeacher.readByNumber(teacherNumber);            if (teacher == null)            {                throw new NonExistingServiceException();            }            //		employee            IPessoa person = persistentPerson.lerPessoaPorUsername(userView.getUtilizador());            IEmployee employee = readEmployee(person);            //	curricular Course Scope            ICurricularCourse curricularCourse = new CurricularCourse();            curricularCourse.setIdInternal(curricularCourseCode);            curricularCourse =                (ICurricularCourse) persistentCurricularCourse.readByOId(curricularCourse, false);            infoEnrolmentEvaluation = completeEnrolmentEvaluation(infoEnrolmentEvaluation);            infoEvaluationsWithError = new ArrayList();                       if (!isValidEvaluation(infoEnrolmentEvaluation))            {                infoEvaluationsWithError.add(infoEnrolmentEvaluation);            } else            {                // read enrolmentEvaluation to change                IEnrolmentEvaluation iEnrolmentEvaluation = new EnrolmentEvaluation();                iEnrolmentEvaluation.setIdInternal(enrolmentEvaluationCode);                iEnrolmentEvaluation =                    (IEnrolmentEvaluation) persistentEnrolmentEvaluation.readByOId(                        iEnrolmentEvaluation,                        false);                // new enrolment evaluation                IEnrolmentEvaluation enrolmentEvaluation = new EnrolmentEvaluation();                enrolmentEvaluation =                    Cloner.copyInfoEnrolmentEvaluation2IEnrolmentEvaluation(infoEnrolmentEvaluation);                //check for an alteration                if (!enrolmentEvaluation.getGrade().equals(iEnrolmentEvaluation.getGrade()))                {					IEnrolment enrolment = iEnrolmentEvaluation.getEnrolment();					persistentEnrolment.simpleLockWrite(enrolment);                    try                    {                    	new Integer(enrolmentEvaluation.getGrade());                        enrolment.setEnrolmentState(EnrolmentState.APROVED);                    } catch (NumberFormatException e)                    {                    	String grade = null;                    	grade = enrolmentEvaluation.getGrade().toUpperCase();                        if (grade.equals("RE") ) 							enrolment.setEnrolmentState(EnrolmentState.NOT_APROVED);                        if (grade.equals("NA"))							enrolment.setEnrolmentState(EnrolmentState.NOT_EVALUATED);                    }                                        iEnrolmentEvaluation.setEnrolment(enrolment);                }                enrolmentEvaluation.setEnrolment(iEnrolmentEvaluation.getEnrolment());                enrolmentEvaluation.setWhen(calendario.getTime());                if (infoEnrolmentEvaluation.getExamDate() != null)                {                    enrolmentEvaluation.setExamDate(infoEnrolmentEvaluation.getExamDate());                } else                {                    enrolmentEvaluation.setExamDate(calendario.getTime());                }                if (infoEnrolmentEvaluation.getGradeAvailableDate() != null)                {                    enrolmentEvaluation.setGradeAvailableDate(                        infoEnrolmentEvaluation.getGradeAvailableDate());                } else                {                    enrolmentEvaluation.setGradeAvailableDate(calendario.getTime());                }                enrolmentEvaluation.setGrade(infoEnrolmentEvaluation.getGrade());                EnrolmentEvaluationState enrolmentEvaluationState = EnrolmentEvaluationState.FINAL_OBJ;                enrolmentEvaluation.setPersonResponsibleForGrade(teacher.getPerson());                enrolmentEvaluation.setEnrolmentEvaluationType(                    infoEnrolmentEvaluation.getEnrolmentEvaluationType());                enrolmentEvaluation.setEnrolmentEvaluationState(enrolmentEvaluationState);                enrolmentEvaluation.setEmployee(employee);                enrolmentEvaluation.setObservation(infoEnrolmentEvaluation.getObservation());                enrolmentEvaluation.setCheckSum("");                persistentEnrolmentEvaluation.lockWrite(enrolmentEvaluation);            }		}        } catch (ExcepcaoPersistencia ex)        {            ex.printStackTrace();            FenixServiceException newEx = new FenixServiceException("");            newEx.fillInStackTrace();            throw newEx;        }        return infoEvaluationsWithError;    }