List of usage examples for org.apache.commons.collections.comparators ComparatorChain addComparator
public void addComparator(Comparator comparator)
From source file:net.sourceforge.fenixedu.applicationTier.Servico.commons.curriculumHistoric.ReadActiveCurricularCourseScopeByDegreeCurricularPlanAndExecutionYear.java
@Deprecated public SortedSet<DegreeModuleScope> run(String degreeCurricularPlanID, String executioYearID) throws FenixServiceException { final DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID); final ExecutionYear executionYear = FenixFramework.getDomainObject(executioYearID); final ComparatorChain comparator = new ComparatorChain(); comparator.addComparator(new BeanComparator("curricularYear")); comparator.addComparator(new BeanComparator("curricularSemester")); comparator.addComparator(new BeanComparator("curricularCourse.externalId")); comparator.addComparator(new BeanComparator("branch")); final SortedSet<DegreeModuleScope> scopes = new TreeSet<DegreeModuleScope>(comparator); for (DegreeModuleScope degreeModuleScope : degreeCurricularPlan.getDegreeModuleScopes()) { if (degreeModuleScope.isActiveForExecutionYear(executionYear)) { scopes.add(degreeModuleScope); }//from w ww. j av a 2s . co m } return scopes; }
From source file:com.safetys.framework.jmesa.core.sort.MultiColumnSort.java
@SuppressWarnings("unchecked") public Collection<?> sortItems(Collection<?> items, Limit limit) { ComparatorChain chain = new ComparatorChain(); SortSet sortSet = limit.getSortSet(); for (Sort sort : sortSet.getSorts()) { if (sort.getOrder() == Order.ASC) { chain.addComparator(new BeanComparator(sort.getProperty(), new NullComparator())); } else if (sort.getOrder() == Order.DESC) { chain.addComparator(new BeanComparator(sort.getProperty(), new NullComparator()), true); }/*from w ww. j av a 2s.c o m*/ } if (chain.size() > 0) { Collections.sort((List<?>) items, chain); } return items; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.gep.TeachingStaffDispatchAction.java
@EntryPoint public ActionForward selectExecutionYear(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws FenixServiceException { final ExecutionYear executionYear = ExecutionYear.readCurrentExecutionYear(); String executionYearID = executionYear.getExternalId(); List degreeCurricularPlans = ReadActiveDegreeCurricularPlansByExecutionYear .runReadActiveDegreeCurricularPlansByExecutionYear(executionYearID); final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(new BeanComparator("infoDegree.tipoCurso")); comparatorChain.addComparator(new BeanComparator("infoDegree.nome")); Collections.sort(degreeCurricularPlans, comparatorChain); request.setAttribute("degreeCurricularPlans", degreeCurricularPlans); request.setAttribute("executionYears", ReadNotClosedExecutionYears.run()); request.setAttribute("executionYear", executionYear); return mapping.findForward("chooseExecutionYearAndDegreeCurricularPlan"); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.academicAdministration.student.equivalencies.CurricularCourseEquivalenciesDA.java
private void sortInfoCurricularCourseEquivalences(final List<CurricularCourseEquivalence> equivalences) { final ComparatorChain chain = new ComparatorChain(); chain.addComparator(CurricularCourseEquivalence.COMPARATOR_BY_EQUIVALENT_COURSE_NAME); chain.addComparator(CurricularCourseEquivalence.COMPARATOR_BY_EQUIVALENT_COURSE_CODE); Collections.sort(equivalences, chain); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.manager.ManageStudentCurricularPlanDA.java
protected void putDegreeCurricularPlansInRequest(final HttpServletRequest request, final List infoDegreeCurricularPlans) { final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(new BeanComparator("infoDegree.nome")); comparatorChain.addComparator(new BeanComparator("initialDate")); Collections.sort(infoDegreeCurricularPlans, comparatorChain); request.setAttribute("degreeCurricularPlans", infoDegreeCurricularPlans); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.ViewClassesActionNew.java
@Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixActionException { final ActionErrors errors = new ActionErrors(); try {//from w w w . j a va2 s . c o m super.execute(mapping, form, request, response); } catch (Exception e) { logger.error(e.getMessage(), e); } Boolean inEnglish = (Boolean) request.getAttribute("inEnglish"); if (inEnglish == null) { inEnglish = getLocale(request).getLanguage().equals(Locale.ENGLISH.getLanguage()); } request.setAttribute("inEnglish", inEnglish); // index Integer index = (Integer) request.getAttribute("index"); request.setAttribute("index", index); // degreeID String degreeId = (String) request.getAttribute("degreeID"); request.setAttribute("degreeID", degreeId); // degreeCurricularPlanID String degreeCurricularPlanId = (String) request.getAttribute("degreeCurricularPlanID"); request.setAttribute("degreeCurricularPlanID", degreeCurricularPlanId); final DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanId); if (!degreeCurricularPlan.getDegree().getExternalId().equals(degreeId)) { throw new FenixActionException(); } else { request.setAttribute("degree", degreeCurricularPlan.getDegree()); } // lista List<LabelValueBean> executionPeriodsLabelValueList = buildExecutionPeriodsLabelValueList( degreeCurricularPlanId); if (executionPeriodsLabelValueList.size() > 1) { request.setAttribute("lista", executionPeriodsLabelValueList); } else { request.removeAttribute("lista"); } // indice final DynaActionForm escolherContextoForm = (DynaActionForm) form; String indice = (String) escolherContextoForm.get("indice"); escolherContextoForm.set("indice", indice); request.setAttribute("indice", indice); InfoExecutionPeriod infoExecutionPeriod = (InfoExecutionPeriod) request .getAttribute(PresentationConstants.EXECUTION_PERIOD); request.setAttribute(PresentationConstants.EXECUTION_PERIOD, infoExecutionPeriod); request.setAttribute(PresentationConstants.EXECUTION_PERIOD_OID, infoExecutionPeriod.getExternalId().toString()); final ExecutionSemester executionSemester = FenixFramework .getDomainObject(infoExecutionPeriod.getExternalId()); ExecutionDegree executionDegree = degreeCurricularPlan .getExecutionDegreeByYear(executionSemester.getExecutionYear()); if (executionDegree != null) { // infoExecutionDegree InfoExecutionDegree infoExecutionDegree = InfoExecutionDegree.newInfoFromDomain(executionDegree); RequestUtils.setExecutionDegreeToRequest(request, infoExecutionDegree); request.setAttribute(PresentationConstants.INFO_DEGREE_CURRICULAR_PLAN, infoExecutionDegree.getInfoDegreeCurricularPlan()); List<InfoClass> classList = LerTurmas.run(infoExecutionDegree, infoExecutionPeriod, null); if (!classList.isEmpty()) { ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(new BeanComparator("anoCurricular")); comparatorChain.addComparator(new BeanComparator("nome")); Collections.sort(classList, comparatorChain); request.setAttribute("classList", classList); } } return mapping.findForward("Sucess"); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.teacher.professorship.CreateProfessorshipDispatchAction.java
private List getExecutionDegrees(HttpServletRequest request) throws FenixServiceException { InfoExecutionPeriod infoExecutionPeriod = (InfoExecutionPeriod) request.getAttribute("infoExecutionPeriod"); List<InfoExecutionDegree> executionDegrees = ReadExecutionDegreesByExecutionYearAndDegreeType .run(infoExecutionPeriod.getInfoExecutionYear().getYear(), null); ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(new BeanComparator("infoDegreeCurricularPlan.infoDegree.tipoCurso")); comparatorChain.addComparator(new BeanComparator("infoDegreeCurricularPlan.infoDegree.nome")); Collections.sort(executionDegrees, comparatorChain); MessageResources messageResources = this.getResources(request, "ENUMERATION_RESOURCES"); executionDegrees = InfoExecutionDegree.buildLabelValueBeansForList(executionDegrees, messageResources); return executionDegrees; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.vigilancy.VigilantGroupBean.java
public List<VigilantWrapper> getVigilantWrappersForGroupsInBean() { Set<VigilantWrapper> vigilantWrappers = new HashSet<VigilantWrapper>(); Collection<VigilantGroup> groups = this.getVigilantGroups(); for (VigilantGroup group : groups) { vigilantWrappers.addAll(group.getVigilantWrappersSet()); }//from w ww. j a v a 2 s . c om ComparatorChain chain = new ComparatorChain(); chain.addComparator(VigilantWrapper.POINTS_COMPARATOR); chain.addComparator(VigilantWrapper.CATEGORY_COMPARATOR); chain.addComparator(VigilantWrapper.USERNAME_COMPARATOR); List<VigilantWrapper> vigilantWrappersList = new ArrayList<VigilantWrapper>(vigilantWrappers); Collections.sort(vigilantWrappersList, chain); return vigilantWrappersList; }
From source file:net.sourceforge.fenixedu.presentationTier.backBeans.departmentMember.ViewDepartmentTeachers.java
public List<Teacher> getDepartmentTeachers() throws FenixServiceException { String executionYearID = getSelectedExecutionYearID(); List<Teacher> result = new ArrayList<Teacher>(ReadDepartmentTeachersByDepartmentIDAndExecutionYearID .runReadDepartmentTeachersByDepartmentIDAndExecutionYearID(getDepartment().getExternalId(), executionYearID));//from w w w .j ava 2 s.c o m ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(new BeanComparator("teacherId")); Collections.sort(result, comparatorChain); return result; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.credits.ShowTeacherCreditsDispatchAction.java
private void setInstitutionWorkTimes(HttpServletRequest request, TeacherService teacherService) { if (!teacherService.getInstitutionWorkTimes().isEmpty()) { ComparatorChain comparatorChain = new ComparatorChain(); BeanComparator weekDayComparator = new BeanComparator("weekDay"); BeanComparator startTimeComparator = new BeanComparator("startTime"); comparatorChain.addComparator(weekDayComparator); comparatorChain.addComparator(startTimeComparator); List<InstitutionWorkTime> institutionWorkingTimes = new ArrayList( teacherService.getInstitutionWorkTimes()); Collections.sort(institutionWorkingTimes, comparatorChain); request.setAttribute("institutionWorkTimeList", institutionWorkingTimes); }//from ww w . j av a2 s . c o m }