if (newEnrolmentList != null && newEnrolmentList.size() > 1) {
if (newEnrolmentList != null && newEnrolmentList.size() > 0) {
    public ActionForward chooseFinal(ActionMapping mapping, ActionForm form, HttpServletRequest request,            HttpServletResponse response) throws Exception {        HttpSession session = request.getSession(false);        if (session != null) {            IUserView userView = (IUserView) session.getAttribute(SessionConstants.U_VIEW);            session.removeAttribute(SessionConstants.INFO_STUDENT_CURRICULAR_PLAN);            session.removeAttribute(SessionConstants.DATE);            session.removeAttribute(SessionConstants.INFO_FINAL_RESULT);            session.removeAttribute(SessionConstants.ENROLMENT_LIST);            session.removeAttribute(SessionConstants.INFO_EXECUTION_YEAR);            session.removeAttribute(SessionConstants.CONCLUSION_DATE);            session.removeAttribute(SessionConstants.INFO_BRANCH);            session.removeAttribute("total");            session.removeAttribute("givenCredits");            Integer studentCurricularPlanID = (Integer) request.getAttribute("studentCurricularPlanID");            if (studentCurricularPlanID == null) {                studentCurricularPlanID = Integer.valueOf(request                        .getParameter("studentCurricularPlanID"));            }            InfoStudentCurricularPlan infoStudentCurricularPlan = null;            Object args[] = { studentCurricularPlanID };            try {                infoStudentCurricularPlan = (InfoStudentCurricularPlan) ServiceManagerServiceFactory                        .executeService(userView, "ReadStudentCurricularPlan", args);            } catch (NonExistingServiceException e) {                throw new NonExistingActionException("O aluno");            }            List enrolmentList = null;            InfoFinalResult infoFinalResult = null;            try {                Object argsFinalResult[] = { infoStudentCurricularPlan };                infoFinalResult = (InfoFinalResult) ServiceManagerServiceFactory.executeService(                        userView, "FinalResult", argsFinalResult);            } catch (FenixServiceException e) {                throw new FenixServiceException("");            }            if (infoFinalResult == null) {                throw new FinalResulUnreachedActionException("");            }            try {                Object argsEnrolmentList[] = { infoStudentCurricularPlan.getIdInternal(),                        EnrollmentState.APROVED };                enrolmentList = (List) ServiceManagerServiceFactory.executeService(userView,                        "GetEnrolmentList", argsEnrolmentList);            } catch (NonExistingServiceException e) {                throw new NonExistingActionException("Inscrio", e);            }            if (enrolmentList.size() == 0) {                throw new NonExistingActionException("Inscrio em Disciplinas");            }            //check the last exam date            //                        InfoEnrolmentEvaluation infoEnrolmentEvaluation = new            // InfoEnrolmentEvaluation();            String conclusionDate = null;            Date endOfScholarshipDate = null;            try {                Object argsTemp[] = { studentCurricularPlanID };                endOfScholarshipDate = (Date) ServiceManagerServiceFactory.executeService(userView,                        "GetEndOfScholarshipDate", argsTemp);            } catch (FenixServiceException e) {                throw new FenixActionException(e);            }            conclusionDate = Data.format2DayMonthYear(endOfScholarshipDate, "/");            Date dateConclusion = Data.convertStringDate(conclusionDate, "/");            conclusionDate = DateFormat.getDateInstance().format(dateConclusion);            //String dataAux = null;            Object result = null;            //                        Iterator iterator = enrolmentList.iterator();            //                        int i = 0;            //                        while (iterator.hasNext())            //                        {            //                            result = iterator.next();            //                            infoEnrolmentEvaluation = (InfoEnrolmentEvaluation)            // (((InfoEnrolment) result)            //                                            .getInfoEvaluations().get(i));            //                            // dataAux =            //                            // DateFormat.getDateInstance().format(            //                            // infoEnrolmentEvaluation.getExamDate());            //                            /*            //                             * if (conclusionDate.compareTo(dataAux) == -1) {            //                             * conclusionDate = dataAux;            //                             */            //                        }            List newEnrolmentList = new ArrayList();            //get the last enrolmentEvaluation            Iterator iterator1 = enrolmentList.iterator();            double sum = 0;            while (iterator1.hasNext()) {                result = iterator1.next();                InfoEnrolment infoEnrolment2 = (InfoEnrolment) result;                //                            InfoCurricularCourseScope infoCurricularCourseScope =                // infoEnrolment2                //                                            .getInfoCurricularCourseScope();                //                            sum = sum                //                                            + Double.parseDouble(String                //                                                            .valueOf(infoCurricularCourseScope                //                                                                            .getInfoCurricularCourse()                //                                                                            .getCredits()));                InfoCurricularCourse infoCurricularCourse = infoEnrolment2.getInfoCurricularCourse();                sum = sum + Double.parseDouble(String.valueOf(infoCurricularCourse.getCredits()));                List aux = infoEnrolment2.getInfoEvaluations();                if (aux != null && aux.size() > 0) {                    if (aux.size() > 1) {                        BeanComparator dateComparator = new BeanComparator("when");                        Collections.sort(aux, dateComparator);                        Collections.reverse(aux);                    }                    InfoEnrolmentEvaluation latestEvaluation = (InfoEnrolmentEvaluation) aux.get(0);                    infoEnrolment2.setInfoEnrolmentEvaluation(latestEvaluation);                    newEnrolmentList.add(infoEnrolment2);                }            }            if ((infoStudentCurricularPlan.getGivenCredits() != null)                    && !infoStudentCurricularPlan.getGivenCredits().equals(new Double(0))) {                sum = sum                        + Double                                .parseDouble(String.valueOf(infoStudentCurricularPlan.getGivenCredits()));                session.setAttribute("givenCredits", "POR ATRIBUIO DE CRDITOS");            }            BigDecimal roundedSum = new BigDecimal(sum);            session.setAttribute("total", roundedSum.setScale(1, BigDecimal.ROUND_HALF_UP));//.toBigInteger());            session.setAttribute(SessionConstants.CONCLUSION_DATE, conclusionDate);            try {                ServiceManagerServiceFactory.executeService(userView, "ReadCurrentExecutionYear", null);            } catch (RuntimeException e) {                throw new RuntimeException("Error", e);            }            Locale locale = new Locale("pt", "PT");            Date date = new Date();            String anoLectivo = "";            if (newEnrolmentList != null && newEnrolmentList.size() > 1) {                anoLectivo = ((InfoEnrolment) newEnrolmentList.get(0)).getInfoExecutionPeriod()                        .getInfoExecutionYear().getYear();            }            String formatedDate = "Lisboa, "                    + DateFormat.getDateInstance(DateFormat.LONG, locale).format(date);            session.setAttribute(SessionConstants.INFO_STUDENT_CURRICULAR_PLAN,                    infoStudentCurricularPlan);            session.setAttribute(SessionConstants.DATE, formatedDate);            if (infoStudentCurricularPlan.getInfoBranch() != null                    && infoStudentCurricularPlan.getInfoBranch().getName().length() != 0)                session.setAttribute(SessionConstants.INFO_BRANCH, infoStudentCurricularPlan                        .getInfoBranch().getName());            session.setAttribute(SessionConstants.INFO_EXECUTION_YEAR, anoLectivo);            session.setAttribute(SessionConstants.ENROLMENT_LIST, newEnrolmentList);            session.setAttribute(SessionConstants.INFO_FINAL_RESULT, infoFinalResult);            return mapping.findForward("ChooseSuccess");        }        throw new Exception();    }