List allCurricularCourseScopes = new ArrayList(); Iterator iter = infoDegreeCurricularPlan.getCurricularCourses().listIterator(); while (iter.hasNext()) { InfoCurricularCourse infoCurricularCourse = (InfoCurricularCourse) iter.next(); allCurricularCourseScopes.addAll(infoCurricularCourse.getInfoScopes()); } ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(new BeanComparator( "infoCurricularSemester.infoCurricularYear.year")); comparatorChain.addComparator(new BeanComparator("infoCurricularSemester.semester")); comparatorChain.addComparator(new BeanComparator("infoCurricularCourse.name")); comparatorChain.addComparator(new BeanComparator("beginDate.time")); Collections.sort(allCurricularCourseScopes, comparatorChain);
List allCurricularCourseScopes = new ArrayList(); Iterator iter = infoDegreeCurricularPlan.getCurricularCourses().listIterator(); while (iter.hasNext()) { InfoCurricularCourse infoCurricularCourse = (InfoCurricularCourse) iter.next(); allCurricularCourseScopes.addAll(getInfoCurricularCourseScopes(infoCurricularCourse)); } ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(new BeanComparator( "infoCurricularSemester.infoCurricularYear.year")); comparatorChain.addComparator(new BeanComparator("infoCurricularSemester.semester")); comparatorChain.addComparator(new BeanComparator("infoCurricularCourse.name")); comparatorChain.addComparator(new BeanComparator("beginDate.time")); Collections.sort(allCurricularCourseScopes, comparatorChain);
    public ActionForward showCurricularCoursesHistory(ActionMapping mapping, ActionForm form,            HttpServletRequest request, HttpServletResponse response) throws FenixActionException, FenixFilterException {        HttpSession session = request.getSession(false);        IUserView userView = getUserView(request);        Integer degreeCurricularPlanID = getAndSetIntegerToRequest("degreeCurricularPlanID", request);               InfoDegreeCurricularPlan infoDegreeCurricularPlan = null;        ActionErrors errors = new ActionErrors();        Object[] args = { degreeCurricularPlanID };        try {            infoDegreeCurricularPlan = (InfoDegreeCurricularPlan) ServiceUtils.executeService(userView,                    "ReadDegreeCurricularPlanHistoryByDegreeCurricularPlanID", args);        } catch (NonExistingServiceException e) {            errors.add("chosenDegree", new ActionError("error.coordinator.noExecutionDegree"));            saveErrors(request, errors);        } catch (FenixServiceException e) {            if (e.getMessage().equals("nullDegree")) {                errors.add("nullCode", new ActionError("error.coordinator.noExecutionDegree"));                saveErrors(request, errors);            } else {                throw new FenixActionException(e);            }        }        if (infoDegreeCurricularPlan == null) {            errors.add("noDegreeCurricularPlan", new ActionError(                    "error.nonExisting.AssociatedCurricularCourses"));            saveErrors(request, errors);        }        if (infoDegreeCurricularPlan != null && infoDegreeCurricularPlan.getCurricularCourses() != null) {            //order list by year, next semester, next course            List allCurricularCourseScopes = new ArrayList();            Iterator iter = infoDegreeCurricularPlan.getCurricularCourses().listIterator();            while (iter.hasNext()) {                InfoCurricularCourse infoCurricularCourse = (InfoCurricularCourse) iter.next();                allCurricularCourseScopes.addAll(infoCurricularCourse.getInfoScopes());            }            ComparatorChain comparatorChain = new ComparatorChain();            comparatorChain.addComparator(new BeanComparator(                    "infoCurricularSemester.infoCurricularYear.year"));            comparatorChain.addComparator(new BeanComparator("infoCurricularSemester.semester"));            comparatorChain.addComparator(new BeanComparator("infoCurricularCourse.name"));            comparatorChain.addComparator(new BeanComparator("beginDate.time"));            Collections.sort(allCurricularCourseScopes, comparatorChain);            // build hashmap for jsp            HashMap curricularCourseScopesHashMap = new HashMap();            Integer lastKey = new Integer(0);            Iterator iterCurricularCourseScopes = allCurricularCourseScopes.iterator();            while (iterCurricularCourseScopes.hasNext()) {                InfoCurricularCourseScope curricularCourseScope = (InfoCurricularCourseScope) iterCurricularCourseScopes                        .next();                List equalCurricularCourseScopes = null;                if (lastKey.intValue() != 0) {                    InfoCurricularCourseScope lastIntroduced = (InfoCurricularCourseScope) ((List) curricularCourseScopesHashMap                            .get(lastKey)).get(0);                    if (scopesAreEqual(curricularCourseScope, lastIntroduced)) {                        equalCurricularCourseScopes = (List) curricularCourseScopesHashMap.get(lastKey);                        equalCurricularCourseScopes.add(curricularCourseScope);                        curricularCourseScopesHashMap.put(lastKey, equalCurricularCourseScopes);                        continue;                    }                }                equalCurricularCourseScopes = new ArrayList();                equalCurricularCourseScopes.add(curricularCourseScope);                curricularCourseScopesHashMap.put(curricularCourseScope.getIdInternal(),                        equalCurricularCourseScopes);                lastKey = curricularCourseScope.getIdInternal();            }            request.setAttribute("allCurricularCourseScopes", allCurricularCourseScopes);            request.setAttribute("curricularCourseScopesHashMap", curricularCourseScopesHashMap);        }        return mapping.findForward("showCurricularCoursesHistory");    }