Integer executionDegree = (Integer) request.getAttribute("executionDegreeID"); if (executionDegree == null) { executionDegree = Integer.valueOf((String) request.getAttribute(SessionConstants.EXECUTION_DEGREE));
Integer executionDegree = Integer.valueOf (getFromRequest("executionDegreeID",request)); if (executionDegree == null) { executionDegree = Integer.valueOf((String) request.getAttribute(SessionConstants.EXECUTION_DEGREE));
    public ActionForward prepareSelectCandidates(ActionMapping mapping, ActionForm form,            HttpServletRequest request, HttpServletResponse response) throws Exception {        DynaActionForm approvalForm = (DynaActionForm) form;        IUserView userView = getUserView(request);        String executionYear = (String) request.getAttribute("executionYear");        String degree = (String) request.getAttribute("degree");        Integer executionDegree = (Integer) request.getAttribute("executionDegreeID");        if (executionDegree == null) {            executionDegree = Integer.valueOf((String) request.getAttribute(SessionConstants.EXECUTION_DEGREE));        }        request.setAttribute(SessionConstants.EXECUTION_DEGREE, executionDegree);        Integer degreeCurricularPlanID = Integer.valueOf(request.getParameter("degreeCurricularPlanID"));        if (executionYear == null) {            executionYear = (String) approvalForm.get("executionYear");        }        if (degree == null) {            degree = (String) approvalForm.get("degree");        }        // Get Numerus Clausus        Integer numerusClausus = null;        try {            Object args[] = { degreeCurricularPlanID };            numerusClausus = (Integer) ServiceManagerServiceFactory.executeService(userView,                    "ReadNumerusClausus", args);        } catch (NonExistingServiceException e) {            throw new NonExistingActionException(e);        }        if (numerusClausus == null) {            ActionErrors errors = new ActionErrors();            errors.add("numerusClaususNotDefined", new ActionError("error.numerusClausus.notDefined"));            saveErrors(request, errors);            return mapping.findForward("NumerusClaususNotDefined");        }        request.setAttribute(SessionConstants.NUMERUS_CLAUSUS, numerusClausus);        //Create the Candidate Situation List        List situationsList = new ArrayList();        situationsList.add(new LabelValueBean(SituationName.ADMITIDO_STRING,                SituationName.ADMITIDO_STRING));        situationsList.add(new LabelValueBean(SituationName.ADMITED_SPECIALIZATION_STRING,                SituationName.ADMITED_SPECIALIZATION_STRING));        situationsList.add(new LabelValueBean(SituationName.ADMITED_CONDICIONAL_CURRICULAR_STRING,                SituationName.ADMITED_CONDICIONAL_CURRICULAR_STRING));        situationsList.add(new LabelValueBean(SituationName.ADMITED_CONDICIONAL_FINALIST_STRING,                SituationName.ADMITED_CONDICIONAL_FINALIST_STRING));        situationsList.add(new LabelValueBean(SituationName.ADMITED_CONDICIONAL_OTHER_STRING,                SituationName.ADMITED_CONDICIONAL_OTHER_STRING));        situationsList.add(new LabelValueBean(SituationName.NAO_ACEITE_STRING,                SituationName.NAO_ACEITE_STRING));        situationsList.add(new LabelValueBean(SituationName.PENDENTE_CONFIRMADO_STRING,                SituationName.PENDENTE_CONFIRMADO_STRING));        situationsList.add(new LabelValueBean(SituationName.SUPLENTE_STRING,                SituationName.SUPLENTE_STRING));        situationsList.add(new LabelValueBean(SituationName.SUBSTITUTE_CONDICIONAL_CURRICULAR_STRING,                SituationName.SUBSTITUTE_CONDICIONAL_CURRICULAR_STRING));        situationsList.add(new LabelValueBean(SituationName.SUBSTITUTE_CONDICIONAL_FINALIST_STRING,                SituationName.SUBSTITUTE_CONDICIONAL_FINALIST_STRING));        situationsList.add(new LabelValueBean(SituationName.SUBSTITUTE_CONDICIONAL_OTHER_STRING,                SituationName.SUBSTITUTE_CONDICIONAL_OTHER_STRING));        request.setAttribute(SessionConstants.CANDIDATE_SITUATION_LIST, situationsList);        List candidateList = null;        List activeSituations = new ArrayList();        activeSituations.add(new SituationName(SituationName.PENDENT_CONFIRMADO));        activeSituations.add(new SituationName(SituationName.FALTA_CERTIFICADO));        Object args[] = { executionDegree, activeSituations };        try {            candidateList = (ArrayList) ServiceManagerServiceFactory.executeService(userView,                    "ReadCandidatesForSelection", args);        } catch (NonExistingServiceException e) {            ActionErrors errors = new ActionErrors();            errors.add("nonExisting", new ActionError(                    "error.masterDegree.administrativeOffice.nonExistingCandidates"));            saveErrors(request, errors);            return mapping.getInputForward();        } catch (ExistingServiceException e) {            throw new ExistingActionException(e);        }        BeanComparator nameComparator = new BeanComparator("infoPerson.nome");        Collections.sort(candidateList, nameComparator);        String ids[] = new String[candidateList.size()];        String situations[] = new String[candidateList.size()];        String remarks[] = new String[candidateList.size()];        String substitutes[] = new String[candidateList.size()];        Iterator iterator = candidateList.iterator();        int i = 0;        while (iterator.hasNext()) {            ids[i++] = ((InfoMasterDegreeCandidate) iterator.next()).getIdInternal().toString();        }        approvalForm.set("candidatesID", ids);        approvalForm.set("situations", situations);        approvalForm.set("remarks", remarks);        approvalForm.set("substitutes", substitutes);        approvalForm.set("executionYear", executionYear);        approvalForm.set("degree", degree);        generateToken(request);        saveToken(request);        request.setAttribute(SessionConstants.EXECUTION_DEGREE, executionDegree);        request.setAttribute("candidateList", candidateList);        request.setAttribute("degreeCurricularPlanID", degreeCurricularPlanID);        return mapping.findForward("PrepareSuccess");    }