String stringGrade = ie.getInfoEnrolmentEvaluation().getGrade();
String stringGrade; if (ie.getInfoEnrolmentEvaluation()!=null) {  stringGrade = ie.getInfoEnrolmentEvaluation().getGrade(); } else { stringGrade="NA"; }
    public ActionForward execute(        ActionMapping mapping,        ActionForm form,        HttpServletRequest request,        HttpServletResponse response)        throws FenixActionException    {        String document = DownloadCandidaciesTable.COLUMNS_HEADERS + "\n";        HttpSession session = this.getSession(request);        IUserView userView = (IUserView) session.getAttribute(SessionConstants.U_VIEW);        InfoClassification ic = null;        //        List candidacies = new LinkedList();        try        {            Object[] argsReadCandidacies = getReadCandidaciesArgs(request);            candidacies =                (List) ServiceManagerServiceFactory.executeService(                    userView,                    "Seminaries.ReadCandidacies",                    argsReadCandidacies);            for (Iterator iterator = candidacies.iterator(); iterator.hasNext();)            {                InfoStudent student = null;                InfoCurricularCourse curricularCourse = null;                InfoTheme theme = null;                InfoModality modality = null;                //String motivation= null;                InfoSeminary seminary = null;                List casesChoices = null;                InfoStudentCurricularPlan studentCurricularPlan = null;                List cases = new LinkedList();                InfoCandidacy candidacy = (InfoCandidacy) iterator.next();                Object[] argsReadStudent = { candidacy.getStudentIdInternal()};                Object[] argsReadCurricularCourse = { candidacy.getCurricularCourseIdInternal()};                Object[] argsReadTheme = { candidacy.getThemeIdInternal()};                Object[] argsReadModality = { candidacy.getModalityIdInternal()};                Object[] argsReadSeminary = { candidacy.getSeminaryIdInternal()};                student =                    (InfoStudent) ServiceManagerServiceFactory.executeService(                        userView,                        "student.ReadStudentById",                        argsReadStudent);                Object[] argsReadCurricularPlan = { student.getNumber(), student.getDegreeType()};                studentCurricularPlan =                    (InfoStudentCurricularPlan) ServiceManagerServiceFactory.executeService(                        userView,                        "student.ReadActiveStudentCurricularPlanByNumberAndDegreeType",                        argsReadCurricularPlan);                curricularCourse =                    (InfoCurricularCourse) ((SiteView) ServiceManagerServiceFactory                        .executeService(                            userView,                            "ReadCurricularCourseByOIdService",                            argsReadCurricularCourse))                        .getComponent();                theme =                    (InfoTheme) ServiceManagerServiceFactory.executeService(                        userView,                        "Seminaries.GetThemeById",                        argsReadTheme);                modality =                    (InfoModality) ServiceManagerServiceFactory.executeService(                        userView,                        "Seminaries.GetModalityById",                        argsReadModality);                seminary =                    (InfoSeminary) ServiceManagerServiceFactory.executeService(                        userView,                        "Seminaries.GetSeminary",                        argsReadSeminary);                //	motivation= candidacy.getMotivation();                casesChoices = candidacy.getCaseStudyChoices();                //                for (Iterator casesIterator = casesChoices.iterator(); casesIterator.hasNext();)                {                    InfoCaseStudyChoice choice = (InfoCaseStudyChoice) casesIterator.next();                    Object[] argsReadCaseStudy = { choice.getCaseStudyIdInternal()};                    InfoCaseStudy infoCaseStudy =                        (InfoCaseStudy) ServiceManagerServiceFactory.executeService(                            userView,                            "Seminaries.GetCaseStudyById",                            argsReadCaseStudy);                    cases.add(infoCaseStudy);                }                //                document += "\"" + student.getNumber() + "\"" + "\t";                document += "\"" + student.getInfoPerson().getNome() + "\"" + "\t";                //                //                //                //                //                //                Object argsReadStudentCurricularPlans[] =                    { new UserView(student.getInfoPerson().getUsername(), new LinkedList())};                InfoStudentCurricularPlan selectedSCP = null;                List cps =                    (ArrayList) ServiceManagerServiceFactory.executeService(                        userView,                        "ReadStudentCurricularPlansForSeminaries",                        argsReadStudentCurricularPlans);                long startDate = Long.MAX_VALUE;                for (Iterator iter = cps.iterator(); iter.hasNext();)                {                    InfoStudentCurricularPlan cp = (InfoStudentCurricularPlan) iter.next();                    if (cp.getStartDate().getTime() < startDate)                    {                        startDate = cp.getStartDate().getTime();                        selectedSCP = cp;                    }                }                Object getCurriculumArgs[] = { null, selectedSCP.getIdInternal()};                List enrollments =                    (ArrayList) ServiceManagerServiceFactory.executeService(                        userView,                        "ReadStudentCurriculum",                        getCurriculumArgs);                //                  //                ic = new InfoClassification();                int i = 0;                float acc = 0;                float grade = 0;                for (Iterator iter = enrollments.iterator(); iter.hasNext();)                {                    InfoEnrolment ie = (InfoEnrolment) iter.next();                    String stringGrade = ie.getInfoEnrolmentEvaluation().getGrade();                    if (stringGrade != null && !stringGrade.equals("RE") && !stringGrade.equals("NA"))                    {                        Float gradeObject = new Float(stringGrade);                        grade = gradeObject.floatValue();                        acc += grade;                        i++;                    }                }                if (i != 0)                {                    String value = new DecimalFormat("#0.0").format(acc / i);                    ic.setAritmeticClassification(value);                }                ic.setCompletedCourses(new Integer(i).toString());                document += "\"" + ic.getAritmeticClassification() + "\"" + "\t";                document += "\"" + ic.getCompletedCourses() + "\"" + "\t";                //                //                //                String friendlyBoolean;                if ((candidacy.getApproved() != null) && (candidacy.getApproved().booleanValue()))                    friendlyBoolean = "Sim";                else                    friendlyBoolean = "No";                document += "\"" + friendlyBoolean + "\"" + "\t";                document += "\"" + student.getInfoPerson().getEmail() + "\"" + "\t";                document += "\"" + seminary.getName() + "\"" + "\t";                document += "\""                    + curricularCourse.getInfoDegreeCurricularPlan().getInfoDegree().getSigla()                    + "\""                    + "\t";                document += "\"" + curricularCourse.getName() + "\"" + "\t";                document += "\"" + modality.getName() + "\"" + "\t";                if (theme != null)                    document += "\"" + theme.getName() + "\"" + "\t";                else                    document += "\"" + "N/A\"\t";                document += "\"" + candidacy.getMotivation() + "\"" + "\t";                for (Iterator casesIterator = cases.iterator(); casesIterator.hasNext();)                {                    InfoCaseStudy caseStudy = (InfoCaseStudy) casesIterator.next();                    document += "\"" + caseStudy.getName() + "\"" + "\t";                }                document += "\n";            }        } catch (Exception e)        {            e.printStackTrace();            throw new FenixActionException(e);        }        try        {            ServletOutputStream writer = response.getOutputStream();            response.setContentType("application/vnd.ms-excel");            writer.print(document);            writer.flush();            response.flushBuffer();        } catch (IOException e1)        {            throw new FenixActionException();        }        return null;    }