comparatorChain.addComparator(new BeanComparator("state.degreeState"));
comparatorChain.addComparator(new BeanComparator("state"));
    private InfoDegreeCurricularPlan getInfoDegreeCurricularPlan(Integer executionDegreeId,            Integer degreeId, Integer degreeCurricularPlanId, ActionMapping mapping,            HttpServletRequest request, ActionErrors errors) {        // if came in the request a executionDegreeId that it is necessary        // find the correpond degree curricular plan        if (executionDegreeId != null) {            Object[] args = { executionDegreeId };            InfoExecutionDegree infoExecutionDegree = null;            try {                infoExecutionDegree = (InfoExecutionDegree) ServiceManagerServiceFactory.executeService(                        null, "ReadExecutionDegreeByOID", args);            } catch (FenixServiceException e) {                errors.add("impossibleDegreeSite", new ActionError("error.impossibleDegreeSite"));            } catch (FenixFilterException e) {                errors.add("impossibleDegreeSite", new ActionError("error.impossibleDegreeSite"));            }            if (infoExecutionDegree == null || infoExecutionDegree.getInfoDegreeCurricularPlan() == null) {                errors.add("impossibleDegreeSite", new ActionError("error.impossibleDegreeSite"));                return null;            }            request.setAttribute(SessionConstants.INFO_EXECUTION_DEGREE_KEY, infoExecutionDegree);            request.setAttribute("executionDegreeID", infoExecutionDegree.getIdInternal());            return infoExecutionDegree.getInfoDegreeCurricularPlan();        }        Object[] args = { degreeId };        List infoDegreeCurricularPlanList = null;        try {            infoDegreeCurricularPlanList = (List) ServiceManagerServiceFactory.executeService(null,                    "ReadPublicDegreeCurricularPlansByDegree", args);        } catch (FenixServiceException e) {            errors.add("impossibleDegreeSite", new ActionError("error.impossibleDegreeSite"));            return null;        } catch (FenixFilterException e) {            errors.add("impossibleDegreeSite", new ActionError("error.impossibleDegreeSite"));            return null;        }        // order the list by state and next by begin date        ComparatorChain comparatorChain = new ComparatorChain();        comparatorChain.addComparator(new BeanComparator("state.degreeState"));        comparatorChain.addComparator(new BeanComparator("initialDate"), true);        Collections.sort(infoDegreeCurricularPlanList, comparatorChain);        request.setAttribute("infoDegreeCurricularPlanList", infoDegreeCurricularPlanList);        InfoDegreeCurricularPlan infoDegreeCurricularPlan = (InfoDegreeCurricularPlan) infoDegreeCurricularPlanList                .get(0);        request.setAttribute("infoDegreeCurricularPlan", infoDegreeCurricularPlan);        // if came in the request a degreeCurricularPlanId that it is        // necessary        // find information about this degree curricular plan        if (degreeCurricularPlanId != null) {            Iterator iterator = infoDegreeCurricularPlanList.iterator();            while (iterator.hasNext()) {                InfoDegreeCurricularPlan infoDegreeCurricularPlanElem = (InfoDegreeCurricularPlan) iterator                        .next();                if (infoDegreeCurricularPlanElem.getIdInternal().equals(degreeCurricularPlanId)) {                    return infoDegreeCurricularPlanElem;                }            }        }        return infoDegreeCurricularPlan;    }