List of usage examples for org.apache.commons.collections.comparators ReverseComparator ReverseComparator
public ReverseComparator(Comparator comparator)
From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.ThesisExecutionYearsProvider.java
@Override public Object provide(Object source, Object currentValue) { SortedSet<ExecutionYear> result = new TreeSet<ExecutionYear>( new ReverseComparator(ExecutionYear.COMPARATOR_BY_YEAR)); result.addAll(Bennu.getInstance().getExecutionYearsSet()); return result; }
From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.candidacy.ExecutionYearsForDegree.java
@Override public Object provide(Object source, Object currentValue) { final SortedSet<ExecutionYear> result = new TreeSet<ExecutionYear>( new ReverseComparator(ExecutionYear.COMPARATOR_BY_YEAR)); final DFACandidacyBean bean = (DFACandidacyBean) source; if (bean.getDegree() != null) { for (final DegreeCurricularPlan dcp : bean.getDegree().getDegreeCurricularPlansSet()) { result.addAll(dcp.getExecutionYears()); }// w w w . j av a 2 s .c om } else { bean.setExecutionYear(null); } return result; }
From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.executionDegree.ExecutionDegreesForDegreeCurricularPlan.java
@Override public Object provide(Object source, Object currentValue) { Set<ExecutionDegree> result = new TreeSet<ExecutionDegree>( new ReverseComparator(ExecutionDegree.EXECUTION_DEGREE_COMPARATORY_BY_YEAR)); ExecutionDegreeBean executionDegreeBean = (ExecutionDegreeBean) source; DegreeCurricularPlan degreeCurricularPlan = executionDegreeBean.getDegreeCurricularPlan(); if (degreeCurricularPlan != null) { result.addAll(degreeCurricularPlan.getExecutionDegreesSet()); }/*from w w w.j av a2s. c o m*/ return result; }
From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.AcademicIntervalProvider.java
@Override public Object provide(Object source, Object current) { List<AcademicInterval> result = AcademicInterval.readAcademicIntervals(AcademicPeriod.SEMESTER); Collections.sort(result, new ReverseComparator(AcademicInterval.COMPARATOR_BY_BEGIN_DATE)); return result; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.phd.coordinator.providers.PhdManageEnrolmentsExecutionSemestersProvider.java
@Override public Object provide(Object source, Object obj) { final ManageEnrolmentsBean bean = (ManageEnrolmentsBean) source; final List<ExecutionSemester> result = new ArrayList<ExecutionSemester>(); ExecutionSemester each = bean.getProcess().getExecutionYear().getFirstExecutionPeriod(); while (each != null) { result.add(each);/*from www. j a va 2 s. c o m*/ each = each.getNextExecutionPeriod(); } Collections.sort(result, new ReverseComparator(ExecutionSemester.COMPARATOR_BY_SEMESTER_AND_YEAR)); return result; }
From source file:gov.nih.nci.cabig.caaers.web.table.SortRowsCallbackImpl.java
public Collection sortRows(TableModel model, Collection rows) throws Exception { boolean sorted = model.getLimit().isSorted(); if (!sorted) { return rows; }// ww w.j a v a 2 s. c o m Sort sort = model.getLimit().getSort(); String property = sort.getProperty(); String sortOrder = sort.getSortOrder(); if (StringUtils.contains(property, ".")) { try { if (sortOrder.equals(TableConstants.SORT_ASC)) { Collections.sort((List) rows, new NullSafeBeanComparator(property, new NullStringComparator())); } else if (sortOrder.equals(TableConstants.SORT_DESC)) { NullSafeBeanComparator reversedNaturalOrderBeanComparator = new NullSafeBeanComparator(property, new ReverseComparator(new NullStringComparator())); Collections.sort((List) rows, reversedNaturalOrderBeanComparator); } } catch (NoClassDefFoundError e) { String msg = "The column property [" + property + "] is nested and requires BeanUtils 1.7 or greater for proper sorting."; logger.error(msg); throw new NoClassDefFoundError(msg); //just rethrow so it is not hidden } } else { if (sortOrder.equals(TableConstants.SORT_ASC)) { BeanComparator comparator = new BeanComparator(property, new NullStringComparator()); Collections.sort((List) rows, comparator); } else if (sortOrder.equals(TableConstants.SORT_DESC)) { BeanComparator reversedNaturalOrderBeanComparator = new BeanComparator(property, new ReverseComparator(new NullStringComparator())); Collections.sort((List) rows, reversedNaturalOrderBeanComparator); } } return rows; }
From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.ExecutionPeriodsForCandidacyRegistrationProvider.java
@Override public Object provide(Object source, Object currentValue) { final StudentCurricularPlan studentCurricularPlan = ((IStudentCurricularPlanBean) source) .getStudentCurricularPlan(); final List<ExecutionSemester> executionPeriodsInTimePeriod = ExecutionSemester .readExecutionPeriodsInTimePeriod(studentCurricularPlan.getStartDateYearMonthDay().toLocalDate(), getEndDate());// ww w.j a v a 2s . c om Collections.sort(executionPeriodsInTimePeriod, new ReverseComparator(ExecutionSemester.COMPARATOR_BY_SEMESTER_AND_YEAR)); return executionPeriodsInTimePeriod; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.credits.departmentMember.DepartmentMemberTeacherManagementFunctionsAction.java
@Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {//from ww w .j av a 2 s . c o m final User userView = Authenticate.getUser(); if (userView.getPerson().getTeacher() != null) { List<PersonFunction> personFunctions = new ArrayList<PersonFunction>( userView.getPerson().getPersonFunctions(AccountabilityTypeEnum.MANAGEMENT_FUNCTION)); Collections.sort(personFunctions, new ReverseComparator(new BeanComparator("beginDate"))); request.setAttribute("personFunctions", personFunctions); } return mapping.findForward("showTeacherCreditsManagementFunctions"); }
From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.ExecutionPeriodsForStudentCurricularPlanProvider.java
@Override public Object provide(Object source, Object currentValue) { // final List<ExecutionSemester> result = new // ArrayList<ExecutionSemester>(); final StudentCurricularPlan studentCurricularPlan = ((IStudentCurricularPlanBean) source) .getStudentCurricularPlan(); final List<ExecutionSemester> executionPeriodsInTimePeriod = ExecutionSemester .readExecutionPeriodsInTimePeriod(studentCurricularPlan.getStartDate(), getEndDate()); /*//from www . ja va 2s . c o m * 26/08/2009 - For curriculum validation we want execution semesters * since student curricular plan start date * * Without the code below we'll get all execution semesters since the * start date */ // final ExecutionSemester first = // studentCurricularPlan.getDegreeCurricularPlan().getFirstExecutionPeriodEnrolments(); // for (final ExecutionSemester executionSemester : // executionPeriodsInTimePeriod) { // if (first.isBeforeOrEquals(executionSemester) && // !executionSemester.isNotOpen()) { // result.add(executionSemester); // } // } /* * 26/08/2009 - We sort and return executionPeriodsInTimePeriod instead * of result */ Collections.sort(executionPeriodsInTimePeriod, new ReverseComparator(ExecutionSemester.COMPARATOR_BY_SEMESTER_AND_YEAR)); return executionPeriodsInTimePeriod; }
From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.EmployeesForGivenUnit.java
@Override public Object provide(Object source, Object currentValue) { VigilantGroupBean bean = (VigilantGroupBean) source; ExecutionYear currentYear = ExecutionYear.readCurrentExecutionYear(); Unit unit = bean.getSelectedUnit();//from w w w . ja va2 s. c o m List<Employee> employees = null; if (unit != null) { employees = unit.getAllWorkingEmployees(currentYear.getBeginDateYearMonthDay(), currentYear.getEndDateYearMonthDay()); } else { Department department = bean.getSelectedDepartment(); if (department != null) { employees = department.getAllWorkingEmployees(currentYear.getBeginDateYearMonthDay(), currentYear.getEndDateYearMonthDay()); } } VigilantGroup group = bean.getSelectedVigilantGroup(); if (group != null) { Collection<VigilantWrapper> vigilants = group.getVigilants(); for (VigilantWrapper vigilant : vigilants) { Employee employee = vigilant.getPerson().getEmployee(); if (employee != null) { employees.remove(employee); } } } ComparatorChain chain = new ComparatorChain(); chain.addComparator(new CategoryComparator()); chain.addComparator(new ReverseComparator(new BeanComparator("person.username"))); Collections.sort(employees, chain); return employees; }