Java Code Examples for org.apache.commons.collections.comparators.ComparatorChain#addComparator()
The following examples show how to use
org.apache.commons.collections.comparators.ComparatorChain#addComparator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReadActiveCurricularCourseScopeByDegreeCurricularPlanAndExecutionYear.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 6 votes |
@Atomic public static SortedSet<DegreeModuleScope> run(String degreeCurricularPlanID, AcademicInterval academicInterval) throws FenixServiceException { final DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID); 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.isActiveForAcademicInterval(academicInterval)) { scopes.add(degreeModuleScope); } } return scopes; }
Example 2
Source File: DisplayEvaluationsForStudentToEnrol.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 6 votes |
public List<SelectItem> getExecutionPeriodsLabels() { if (this.executionPeriodsLabels == null) { this.executionPeriodsLabels = new ArrayList(); final List<InfoExecutionPeriod> infoExecutionPeriods = getExecutionPeriods(); final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(new ReverseComparator(new BeanComparator("infoExecutionYear.year"))); comparatorChain.addComparator(new ReverseComparator(new BeanComparator("semester"))); Collections.sort(infoExecutionPeriods, comparatorChain); for (final InfoExecutionPeriod infoExecutionPeriod : infoExecutionPeriods) { final SelectItem selectItem = new SelectItem(); selectItem.setValue(infoExecutionPeriod.getExternalId()); selectItem.setLabel(infoExecutionPeriod.getName() + " - " + infoExecutionPeriod.getInfoExecutionYear().getYear()); this.executionPeriodsLabels.add(selectItem); } } return this.executionPeriodsLabels; }
Example 3
Source File: CoordinatorEvaluationManagementBackingBean.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 6 votes |
public List<SelectItem> getExecutionPeriodsLabels() { if (this.executionPeriodsLabels == null) { this.executionPeriodsLabels = new ArrayList(); final List<InfoExecutionPeriod> infoExecutionPeriods = getExecutionPeriods(); final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(new ReverseComparator(new BeanComparator("infoExecutionYear.year"))); comparatorChain.addComparator(new ReverseComparator(new BeanComparator("semester"))); Collections.sort(infoExecutionPeriods, comparatorChain); for (final InfoExecutionPeriod infoExecutionPeriod : infoExecutionPeriods) { final SelectItem selectItem = new SelectItem(); selectItem.setValue(infoExecutionPeriod.getExternalId()); selectItem.setLabel(infoExecutionPeriod.getName() + " - " + infoExecutionPeriod.getInfoExecutionYear().getYear()); this.executionPeriodsLabels.add(selectItem); } } return this.executionPeriodsLabels; }
Example 4
Source File: Party.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public int compare(final Party o1, final Party o2) { final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(Party.COMPARATOR_BY_NAME); comparatorChain.addComparator(DomainObjectUtil.COMPARATOR_BY_ID); return comparatorChain.compare(o1, o2); }
Example 5
Source File: ExecutionDegree.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public int compare(ExecutionDegree o1, ExecutionDegree o2) { final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(EXECUTION_DEGREE_COMPARATORY_BY_DEGREE_TYPE_AND_NAME); comparatorChain.addComparator(EXECUTION_DEGREE_COMPARATORY_BY_YEAR); return comparatorChain.compare(o1, o2); }
Example 6
Source File: MarkSheet.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
@Override final public int compare(MarkSheet o1, MarkSheet o2) { final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(MarkSheet.COMPARATOR_BY_EVALUATION_DATE); comparatorChain.addComparator(DomainObjectUtil.COMPARATOR_BY_ID); return comparatorChain.compare(o1, o2); }
Example 7
Source File: ExternalEnrolment.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public int compare(ExternalEnrolment o1, ExternalEnrolment o2) { final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(ExternalEnrolment.COMPARATOR_BY_EXECUTION_PERIOD_AND_ID); comparatorChain.addComparator(ExternalEnrolment.COMPARATOR_BY_APPROVEMENT_DATE); return comparatorChain.compare(o1, o2); }
Example 8
Source File: CycleCurriculumGroup.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
@Override final public int compare(final CycleCurriculumGroup o1, final CycleCurriculumGroup o2) { final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(CycleCurriculumGroup.COMPARATOR_BY_CYCLE_TYPE); comparatorChain.addComparator(DomainObjectUtil.COMPARATOR_BY_ID); return comparatorChain.compare(o1, o2); }
Example 9
Source File: ConclusionProcessVersion.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
@Override final public int compare(ConclusionProcessVersion o1, ConclusionProcessVersion o2) { final ComparatorChain chain = new ComparatorChain(); chain.addComparator(ConclusionProcessVersion.COMPARATOR_BY_CREATION_DATE_TIME); chain.addComparator(DomainObjectUtil.COMPARATOR_BY_ID); return chain.compare(o1, o2); }
Example 10
Source File: ICurriculumEntry.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
@Override final public int compare(ICurriculumEntry o1, ICurriculumEntry o2) { final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(ICurriculumEntry.COMPARATOR_BY_EXECUTION_YEAR_AND_NAME); comparatorChain.addComparator(ICurriculumEntry.COMPARATOR_BY_ID); return comparatorChain.compare(o1, o2); }
Example 11
Source File: ICurriculumEntry.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
@Override final public int compare(ICurriculumEntry o1, ICurriculumEntry o2) { final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(ICurriculumEntry.COMPARATOR_BY_REVERSE_EXECUTION_PERIOD_AND_NAME); comparatorChain.addComparator(ICurriculumEntry.COMPARATOR_BY_ID); return comparatorChain.compare(o1, o2); }
Example 12
Source File: ICurriculumEntry.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
@Override final public int compare(ICurriculumEntry o1, ICurriculumEntry o2) { final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(ICurriculumEntry.COMPARATOR_BY_EXECUTION_PERIOD_AND_NAME); comparatorChain.addComparator(ICurriculumEntry.COMPARATOR_BY_ID); return comparatorChain.compare(o1, o2); }
Example 13
Source File: ICurriculumEntry.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
@Override final public int compare(ICurriculumEntry o1, ICurriculumEntry o2) { final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(ICurriculumEntry.COMPARATOR_BY_EXECUTION_PERIOD); comparatorChain.addComparator(ICurriculumEntry.COMPARATOR_BY_ID); return comparatorChain.compare(o1, o2); }
Example 14
Source File: FunUtil.java From youkefu with Apache License 2.0 | 5 votes |
/** * Sorts a list of members according to a list of SortKeySpecs. * An in-place, Stable sort. * Helper function for MDX OrderSet function. * * <p>NOTE: Does not preserve the contents of the validator. */ static List<Member> sortMembers( Evaluator evaluator, Iterable<Member> memberIter, List<Member> memberList, List<SortKeySpec> keySpecList) { if ((memberList != null) && (memberList.size() <= 1)) { return memberList; } if (memberList == null) { memberList = new ArrayList<Member>(); for (Member member : memberIter) { memberList.add(member); } if (memberList.size() <= 1) { return memberList; } } ComparatorChain chain = new ComparatorChain(); for (SortKeySpec key : keySpecList) { boolean brk = key.direction.brk; MemberComparator comp; if (brk) { comp = new BreakMemberComparator( evaluator, key.key, key.direction.descending); } else { comp = new HierarchicalMemberComparator( evaluator, key.key, key.direction.descending); } comp.preloadValues(memberList); chain.addComparator(comp.wrap(), false); } Collections.sort(memberList, chain); return memberList; }
Example 15
Source File: AcademicServiceRequestsManagementDispatchAction.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
private Comparator getComparator(HttpServletRequest request) { final String orderParameter = request.getParameter(ORDER_PARAMETER); final String orderGetter = StringUtils.isEmpty(orderParameter) ? DEFAULT_ORDER_GETTER : orderParameter.substring(0, orderParameter.indexOf(ORDER_MARKER)); final String orderDir = StringUtils.isEmpty(orderParameter) ? DEFAULT_ORDER_DIR : orderParameter.substring( orderParameter.indexOf(ORDER_MARKER) + 1, orderParameter.length()); final boolean orderAsc = Arrays.asList(ASC_ORDER_DIR).contains(orderDir); if (orderGetter.equals(REQUEST_NUMBER_YEAR)) { return orderAsc ? AcademicServiceRequest.COMPARATOR_BY_NUMBER : new ReverseComparator( AcademicServiceRequest.COMPARATOR_BY_NUMBER); } else if (orderGetter.equals(EXECUTION_YEAR)) { return orderAsc ? AcademicServiceRequest.EXECUTION_YEAR_AND_OID_COMPARATOR : new ReverseComparator( AcademicServiceRequest.EXECUTION_YEAR_AND_OID_COMPARATOR); } else if (orderGetter.equals(REGISTRATION_NUMBER) || orderGetter.equals(DESCRIPTION) || orderGetter.equals(URGENT_REQUEST) || orderGetter.equals(REGISTRATION_NUMBER) || orderGetter.equals(REQUEST_DATE) || orderGetter.equals(ACTIVE_SITUATION_DATE)) { final ComparatorChain chain = new ComparatorChain(); chain.addComparator(orderAsc ? new BeanComparator(orderGetter) : new ReverseComparator( new BeanComparator(orderGetter))); chain.addComparator(DomainObjectUtil.COMPARATOR_BY_ID); return chain; } return null; }
Example 16
Source File: DisplayCurricularPlan.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
private void sortScopes(List<InfoCurricularCourseScope> scopes) { ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(new BeanComparator("infoCurricularSemester.infoCurricularYear.year")); comparatorChain.addComparator(new BeanComparator("infoBranch.name")); comparatorChain.addComparator(new BeanComparator("infoCurricularSemester.semester")); comparatorChain.addComparator(new BeanComparator("infoCurricularCourse.name")); Collections.sort(scopes, comparatorChain); }
Example 17
Source File: Party.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public int compare(final Party o1, final Party o2) { final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(Party.COMPARATOR_BY_SUBPARTY); comparatorChain.addComparator(Party.COMPARATOR_BY_NAME); comparatorChain.addComparator(DomainObjectUtil.COMPARATOR_BY_ID); return comparatorChain.compare(o1, o2); }
Example 18
Source File: InfoStudentCurricularPlan.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
public List getInfoEnrolmentsSorted() { final List<InfoEnrolment> infoEnrolments = getInfoEnrolments(); ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(new BeanComparator("infoExecutionPeriod.infoExecutionYear.year")); comparatorChain.addComparator(new BeanComparator("infoExecutionPeriod.semester")); comparatorChain.addComparator(new BeanComparator("infoCurricularCourse.name", Collator.getInstance())); Collections.sort(infoEnrolments, comparatorChain); return infoEnrolments; }
Example 19
Source File: ComparatorUtils.java From Penetration_Testing_POC with Apache License 2.0 | 5 votes |
/** * Gets a comparator that compares using an array of {@link Comparator}s, applied * in sequence until one returns not equal or the array is exhausted. * * @param comparators the comparators to use, not null or empty or containing nulls * @return a {@link ComparatorChain} formed from the input comparators * @throws NullPointerException if comparators array is null or contains a null * @see ComparatorChain */ public static Comparator chainedComparator(Comparator[] comparators) { ComparatorChain chain = new ComparatorChain(); for (int i = 0; i < comparators.length; i++) { if (comparators[i] == null) { throw new NullPointerException("Comparator cannot be null"); } chain.addComparator(comparators[i]); } return chain; }
Example 20
Source File: CurricularCourseEquivalenciesDA.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 4 votes |
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); }