/** * creates a sortedset of all hook implementations found for the given hook. Ordering is done through * {@link com.github.cherimojava.orchidae.hook.HookHandler.HookComparator} in reverse order * * @param hook to find all implementations from * @param url where to search for hook implementations * @param <H> Hook type * @return sortedset with all found hook implementation */ public static <H> SortedSet<? extends H> getHookOrdering( Class<H> hook, URL url ) { Configuration config = new ConfigurationBuilder().addUrls( url ) .addUrls( ClasspathHelper.forPackage( HookHandler.class.getPackage().getName() ) ) .setScanners( new SubTypesScanner() ); Reflections reflect = new Reflections( config ); SortedSet<H> hooks = Sets.newTreeSet( new ReverseComparator( comparator ) ); LOG.info( "Searching for hooks of {}", hook ); for ( Class<? extends H> c : reflect.getSubTypesOf( hook ) ) { try { LOG.info( "Found hook {}", c ); hooks.add( c.newInstance() ); } catch ( IllegalAccessException | InstantiationException e ) { LOG.error( "Failed to instantiate {} please make sure it has a no param Constructor. {}", c, e ); } } return hooks; }
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; }
public List<SelectItem> getExecutionYears() { if (selectedYears == null) { ExecutionYear year = null; if (getCompetenceCourse() != null) { final ExecutionSemester semester = getCompetenceCourse().getStartExecutionSemester(); year = semester != null ? semester.getExecutionYear() : null; } selectedYears = new ArrayList<SelectItem>(); for (ExecutionYear executionYear : ExecutionYear.readNotClosedExecutionYears()) { if (year == null || executionYear.isAfterOrEquals(year)) { selectedYears.add(new SelectItem(executionYear.getExternalId(), executionYear.getYear())); } } Collections.sort(selectedYears, new ReverseComparator(new BeanComparator("label"))); } return selectedYears; }
@Override public Object provide(Object source, Object currentValue) { /* * get executionPeriods after '1 Semestre 2006/2007' */ final ExecutionSemester currentExecutionPeriod = ExecutionSemester.readBySemesterAndExecutionYear(1, "2006/2007"); final List<ExecutionSemester> result = new ArrayList<ExecutionSemester>(); for (final ExecutionSemester executionSemester : ExecutionSemester.readNotClosedPublicExecutionPeriods()) { if (executionSemester.isAfterOrEquals(currentExecutionPeriod)) { result.add(executionSemester); } } Collections.sort(result, new ReverseComparator()); return result; }
@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); each = each.getNextExecutionPeriod(); } Collections.sort(result, new ReverseComparator(ExecutionSemester.COMPARATOR_BY_SEMESTER_AND_YEAR)); return result; }
private ExecutionYear getExecutionYear(HttpServletRequest request) { String id = request.getParameter("executionYearId"); if (id == null) { id = request.getParameter("executionYear"); } if (id == null) { TreeSet<ExecutionYear> executionYears = new TreeSet<ExecutionYear>(new ReverseComparator()); executionYears.addAll(getDegreeCurricularPlan(request).getExecutionYears()); if (executionYears.isEmpty()) { return ExecutionYear.readCurrentExecutionYear(); } else { return executionYears.first(); } } else { return FenixFramework.getDomainObject(id); } }
private ThesisContextBean getContextBean(HttpServletRequest request) { ThesisContextBean bean = getRenderedObject("contextBean"); RenderUtils.invalidateViewState("contextBean"); if (bean != null) { return bean; } else { ExecutionYear executionYear = getExecutionYear(request); if (executionYear == null) { executionYear = ExecutionYear.readCurrentExecutionYear(); } TreeSet<ExecutionYear> executionYears = new TreeSet<ExecutionYear>(new ReverseComparator()); executionYears.addAll(getDegreeCurricularPlan(request).getExecutionYears()); return new ThesisContextBean(executionYears, executionYear); } }
final private Collection<Coordinator> getCurrentCoordinators(final boolean responsible) { SortedSet<ExecutionYear> years = new TreeSet<ExecutionYear>(new ReverseComparator(ExecutionYear.COMPARATOR_BY_YEAR)); years.addAll(getDegreeCurricularPlansExecutionYears()); ExecutionYear current = ExecutionYear.readCurrentExecutionYear(); for (ExecutionYear year : years) { if (year.isAfter(current)) { continue; } Collection<Coordinator> coordinators = getCoordinators(year, responsible); if (!coordinators.isEmpty()) { return coordinators; } } return Collections.emptyList(); }
public int doStartTag() { if (drugOrders == null || drugOrders.isEmpty()) { log.error("ForEachDrugOrderTag skipping body due to drugOrders param being null or empty: " + drugOrders); return SKIP_BODY; } // First retrieve all encounters matching the passed concept id, if provided. // If not provided, return all encounters matchingDrugOrders = new ArrayList<DrugOrder>(); for (Iterator<DrugOrder> i = drugOrders.iterator(); i.hasNext();) { DrugOrder d = i.next(); if (d != null) { // TODO: eventually we might want to have criteria, but not yet matchingDrugOrders.add(d); } } log.debug("ForEachDrugOrderTag found " + matchingDrugOrders.size() + " drug orders"); // Next, sort the encounters if (StringUtils.isEmpty(sortBy)) { sortBy = defaultSortBy; } Comparator comp = new BeanComparator(sortBy, (descending ? new ReverseComparator(new ComparableComparator()) : new ComparableComparator())); try { Collections.sort(matchingDrugOrders, comp); } catch (ClassCastException cce) { log .error("ForEachDrugTag unable to compare the list of drug orders passed. Ensure they are compatible with Comparator used."); } // Return appropriate number of results if (matchingDrugOrders.isEmpty()) { return SKIP_BODY; } else { pageContext.setAttribute(var, matchingDrugOrders.get(count++)); return EVAL_BODY_BUFFERED; } }
@Override public int doStartTag() { if (visits == null || visits.isEmpty()) { log.debug("ForEachVisitTag skipping body due to 'visits' param = " + visits); return SKIP_BODY; } // First retrieve all visits matching the passed visit type id, if provided. // If not provided, return all visits matchingVisits = new ArrayList<Visit>(); for (Iterator<Visit> i = visits.iterator(); i.hasNext();) { Visit e = i.next(); if (type == null || e.getVisitType().getVisitTypeId().intValue() == type.intValue()) { matchingVisits.add(e); } } log.debug("ForEachVisitTag found " + matchingVisits.size() + " visits matching type = " + type); // Next, sort the visits if (StringUtils.isEmpty(sortBy)) { sortBy = "visitDatetime"; } Comparator comp = new BeanComparator(sortBy, (descending ? new ReverseComparator(new ComparableComparator()) : new ComparableComparator())); Collections.sort(matchingVisits, comp); // Return appropriate number of results if (matchingVisits.isEmpty()) { return SKIP_BODY; } else { pageContext.setAttribute(var, matchingVisits.get(count++)); return EVAL_BODY_BUFFERED; } }
public int doStartTag() { if (obs == null || obs.isEmpty()) { log.error("ForEachObsTag skipping body due to obs param = " + obs); return SKIP_BODY; } // First retrieve all observations matching the passed concept id, if provided. // If not provided, return all observations matchingObs = new ArrayList<Obs>(); for (Iterator<Obs> i = obs.iterator(); i.hasNext();) { Obs o = i.next(); if (conceptId == null || (o.getConcept() != null && o.getConcept().getConceptId().intValue() == conceptId.intValue())) { matchingObs.add(o); } } log.debug("ForEachObsTag found " + matchingObs.size() + " observations matching conceptId = " + conceptId); // Next, sort these observations if (StringUtils.isEmpty(sortBy)) { sortBy = "obsDatetime"; } Comparator comp = new BeanComparator(sortBy, (descending ? new ReverseComparator(new ComparableComparator()) : new ComparableComparator())); Collections.sort(matchingObs, comp); // Return appropriate number of results if (matchingObs.isEmpty()) { return SKIP_BODY; } else { pageContext.setAttribute(var, matchingObs.get(count++)); return EVAL_BODY_BUFFERED; } }
protected List<WorkflowInstanceSearchModel> sortSearchResult( List<WorkflowInstanceSearchModel> result, int column, String direction ){ List<WorkflowInstanceSearchModel> unorderedSource = new ArrayList<>( result ); String fieldName = DataTableColumnMapper.from( column ).getFieldName(); BeanComparator<WorkflowInstanceSearchModel> beanComparator; if( "asc".equalsIgnoreCase( direction ) ){ beanComparator = new BeanComparator<>( fieldName, new NullComparator() ); } else{ beanComparator = new BeanComparator<>( fieldName, new ReverseComparator( new NullComparator() ) ); } Collections.sort( unorderedSource, beanComparator ); return unorderedSource; }
private List<SelectItem> readPreBolonhaExecutionPeriodItems() { final List<ExecutionSemester> semesters = new ArrayList<ExecutionSemester>(rootDomainObject.getExecutionPeriodsSet()); Collections.sort(semesters, new ReverseComparator(ExecutionSemester.COMPARATOR_BY_SEMESTER_AND_YEAR)); final List<SelectItem> result = new ArrayList<SelectItem>(); for (final ExecutionSemester semester : semesters) { result.add(new SelectItem(semester.getExternalId(), semester.getQualifiedName())); } return result; }
public Collection<SelectItem> getAcademicIntervals() throws FenixServiceException { List<AcademicInterval> intervals = AcademicInterval.readAcademicIntervals(AcademicPeriod.SEMESTER); Collections.sort(intervals, new ReverseComparator(AcademicInterval.COMPARATOR_BY_BEGIN_DATE)); List<SelectItem> items = new ArrayList<>(); for (AcademicInterval interval : intervals) { items.add(new SelectItem(interval.getResumedRepresentationInStringFormat(), interval.getPathName())); } return items; }
@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()); } return result; }
@Override public Object provide(Object source, Object currentValue) { final StudentCurricularPlan studentCurricularPlan = ((IStudentCurricularPlanBean) source).getStudentCurricularPlan(); final List<ExecutionSemester> executionPeriodsInTimePeriod = ExecutionSemester.readExecutionPeriodsInTimePeriod( studentCurricularPlan.getStartDateYearMonthDay().toLocalDate(), getEndDate()); Collections.sort(executionPeriodsInTimePeriod, new ReverseComparator(ExecutionSemester.COMPARATOR_BY_SEMESTER_AND_YEAR)); return executionPeriodsInTimePeriod; }
@Override public Object provide(Object source, Object currentValue) { final List<ExecutionSemester> result = new ArrayList<ExecutionSemester>(); for (final ExecutionSemester executionSemester : Bennu.getInstance().getExecutionPeriodsSet()) { if (executionSemester.isBefore(ExecutionSemester.readMarkSheetManagmentExecutionPeriod())) { result.add(executionSemester); } } Collections.sort(result, new ReverseComparator()); return result; }
@Override public Object provide(Object source, Object currentValue) { final List<ExecutionSemester> result = new ArrayList<ExecutionSemester>(); for (final ExecutionSemester executionSemester : Bennu.getInstance().getExecutionPeriodsSet()) { if (executionSemester.isAfterOrEquals(ExecutionSemester.readMarkSheetManagmentExecutionPeriod())) { result.add(executionSemester); } } Collections.sort(result, new ReverseComparator()); return result; }
@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()); } } else { bean.setExecutionYear(null); } return result; }
@Override public Object provide(Object source, Object currentValue) { List<ExecutionSemester> executionSemesters = new ArrayList<ExecutionSemester>(Bennu.getInstance().getExecutionPeriodsSet()); Collections.sort(executionSemesters, new ReverseComparator()); return executionSemesters; }
@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()); /* * 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; }
@Override public Object provide(Object source, Object currentValue) { final List<ExecutionSemester> result = new ArrayList<ExecutionSemester>(); final StudentCurricularPlan studentCurricularPlan = ((IStudentCurricularPlanBean) source).getStudentCurricularPlan(); ExecutionSemester scpSemester = studentCurricularPlan.getStartExecutionPeriod(); ExecutionSemester lastExecutionSemester = ExecutionYear.readCurrentExecutionYear().getLastExecutionPeriod(); while (scpSemester != lastExecutionSemester) { result.add(scpSemester); scpSemester = scpSemester.getNextExecutionPeriod(); } result.add(lastExecutionSemester); Collections.sort(result, new ReverseComparator()); return result; }
public ActionForward showSummariesPostBack(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { final IViewState viewState = RenderUtils.getViewState(); ShowSummariesBean bean = (ShowSummariesBean) viewState.getMetaObject().getObject(); ExecutionCourse executionCourse = bean.getExecutionCourse(); ShiftType shiftType = bean.getShiftType(); Shift shift = bean.getShift(); SummaryTeacherBean summaryTeacher = bean.getSummaryTeacher(); Professorship teacher = (summaryTeacher != null) ? summaryTeacher.getProfessorship() : null; Boolean otherTeachers = (summaryTeacher != null) ? summaryTeacher.getOthers() : null; SummariesOrder summariesOrder = bean.getSummariesOrder(); Set<Summary> summariesToShow = summariesOrder == null || summariesOrder.equals(SummariesOrder.DECREASING) ? new TreeSet<Summary>( Summary.COMPARATOR_BY_DATE_AND_HOUR) : new TreeSet<Summary>(new ReverseComparator( Summary.COMPARATOR_BY_DATE_AND_HOUR)); for (Summary summary : executionCourse.getAssociatedSummariesSet()) { boolean insert = true; if ((shift != null && (summary.getShift() == null || !summary.getShift().equals(shift))) || (teacher != null && (summary.getProfessorship() == null || !summary.getProfessorship().equals(teacher))) || (shiftType != null && (summary.getSummaryType() == null || !summary.getSummaryType().equals(shiftType))) || (otherTeachers != null && otherTeachers && summary.getProfessorship() != null)) { insert = false; } if (insert) { summariesToShow.add(summary); } } readAndSaveNextPossibleSummaryLessonsAndDates(request, executionCourse); request.setAttribute("showSummariesBean", bean); request.setAttribute("summaries", summariesToShow); return mapping.findForward("prepareShowSummaries"); }
@Override public Object provide(Object source, Object currentValue) { final ManageEnrolmentsBean bean = (ManageEnrolmentsBean) source; final Collection<ExecutionSemester> result = new TreeSet<ExecutionSemester>(new ReverseComparator()); for (final ExecutionYear executionYear : bean.getCurricularCourse().getDegreeCurricularPlan().getExecutionYears()) { result.addAll(executionYear.getExecutionPeriodsSet()); } return result; }
private List<Registration> getAllRegistrations(final Student student) { final List<Registration> result = new ArrayList<Registration>(); result.addAll(student.getRegistrationsSet()); result.addAll(student.getTransitionRegistrations()); Collections.sort(result, new ReverseComparator(Registration.COMPARATOR_BY_START_DATE)); return result; }
/** * @param request * @param infoExecutionCourses */ private void sortList(HttpServletRequest request, List<InfoExecutionCourse> infoExecutionCourses) { String sortParameter = request.getParameter("sortBy"); if ((sortParameter != null) && (sortParameter.length() != 0)) { if (sortParameter.equals("occupancy")) { Collections.sort(infoExecutionCourses, new ReverseComparator(new BeanComparator(sortParameter))); } else { Collections.sort(infoExecutionCourses, new BeanComparator(sortParameter)); } } else { Collections.sort(infoExecutionCourses, new ReverseComparator(new BeanComparator("occupancy"))); } }
public ActionForward sort(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaValidatorForm roomSearchForm = (DynaValidatorForm) form; String[] availableRoomsId = (String[]) roomSearchForm.get("availableRoomsId"); String sortParameter = request.getParameter("sortParameter"); List<InfoRoom> availableRooms = new ArrayList<InfoRoom>(); for (String element : availableRoomsId) { final Space room = FenixFramework.getDomainObject(element); availableRooms.add(InfoRoom.newInfoFromDomain(room)); } if ((sortParameter != null) && (sortParameter.length() != 0)) { if (sortParameter.equals("name")) { Collections.sort(availableRooms, new BeanComparator("nome")); } else if (sortParameter.equals("type")) { Collections.sort(availableRooms, new BeanComparator("tipo")); } else if (sortParameter.equals("building")) { Collections.sort(availableRooms, new BeanComparator("edificio")); } else if (sortParameter.equals("floor")) { Collections.sort(availableRooms, new BeanComparator("piso")); } else if (sortParameter.equals("normal")) { Collections.sort(availableRooms, new ReverseComparator(new BeanComparator("capacidadeNormal"))); } else if (sortParameter.equals("exam")) { Collections.sort(availableRooms, new ReverseComparator(new BeanComparator("capacidadeExame"))); } } else { Collections.sort(availableRooms, new BeanComparator("nome")); } String sdate = roomSearchForm.get("day") + "/" + roomSearchForm.get("month") + "/" + roomSearchForm.get("year"); String startTime = roomSearchForm.get("beginningHour") + ":" + roomSearchForm.get("beginningMinute"); String endTime = roomSearchForm.get("endHour") + ":" + roomSearchForm.get("endMinute"); request.setAttribute(PresentationConstants.DATE, sdate); request.setAttribute(PresentationConstants.START_TIME, startTime); request.setAttribute(PresentationConstants.END_TIME, endTime); request.setAttribute(PresentationConstants.AVAILABLE_ROOMS, availableRooms); request.setAttribute(PresentationConstants.AVAILABLE_ROOMS_ID, availableRoomsId); return mapping.findForward("showRooms"); }
private void buildPeriods(HttpServletRequest request) { final List<ExecutionSemester> notClosedExecutionPeriods = ExecutionSemester.readNotClosedExecutionPeriods(); Collections.sort(notClosedExecutionPeriods, new ReverseComparator(ExecutionSemester.COMPARATOR_BY_SEMESTER_AND_YEAR)); final List<LabelValueBean> periods = new ArrayList<LabelValueBean>(); for (final ExecutionSemester period : notClosedExecutionPeriods) { periods.add(new LabelValueBean(period.getExecutionYear().getYear() + " - " + period.getName(), period.getExternalId() .toString())); } request.setAttribute("periods", periods); }
public ActionForward showRegimes(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { final Registration registration = getAndSetRegistration(request); final List<RegistrationRegime> regimes = new ArrayList<RegistrationRegime>(registration.getRegistrationRegimesSet()); Collections.sort(regimes, new ReverseComparator(RegistrationRegime.COMPARATOR_BY_EXECUTION_YEAR)); request.setAttribute("registrationRegimes", regimes); return mapping.findForward("showRegimes"); }
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; }
public AlumniIdentityCheckRequest getLastIdentityRequest() { Set<AlumniIdentityCheckRequest> orderedSet = new TreeSet<AlumniIdentityCheckRequest>(new ReverseComparator(new BeanComparator("creationDateTime"))); for (AlumniIdentityCheckRequest request : getIdentityRequestsSet()) { orderedSet.add(request); } return orderedSet.size() != 0 ? orderedSet.iterator().next() : null; }
public CycleCurriculumGroup getLastConcludedCycleCurriculumGroup() { final SortedSet<CycleCurriculumGroup> cycleCurriculumGroups = new TreeSet<CycleCurriculumGroup>(new ReverseComparator(CycleCurriculumGroup.COMPARATOR_BY_CYCLE_TYPE_AND_ID)); cycleCurriculumGroups.addAll(getInternalCycleCurriculumGroups()); for (final CycleCurriculumGroup curriculumGroup : cycleCurriculumGroups) { if (curriculumGroup.isConcluded()) { return curriculumGroup; } } return null; }
private Double countMaxEctsCredits(final Collection<DegreeModule> modulesByExecutionPeriod, final ExecutionSemester executionSemester, final Integer maximumLimit) { final List<Double> ectsCredits = new ArrayList<Double>(); for (final DegreeModule degreeModule : modulesByExecutionPeriod) { ectsCredits.add(degreeModule.getMaxEctsCredits(executionSemester)); } Collections.sort(ectsCredits, new ReverseComparator()); return sumEctsCredits(ectsCredits, maximumLimit.intValue()); }
public void createLessonPlanningsUsingSummariesFrom(Shift shift) { List<Summary> summaries = new ArrayList<Summary>(); summaries.addAll(shift.getAssociatedSummariesSet()); Collections.sort(summaries, new ReverseComparator(Summary.COMPARATOR_BY_DATE_AND_HOUR)); for (Summary summary : summaries) { for (ShiftType shiftType : shift.getTypes()) { new LessonPlanning(summary.getTitle(), summary.getSummaryText(), shiftType, this); } } }
private void speedTest(int length, int limit) { System.out.println( "sorting the max " + limit + " of " + length + " random Integers"); // random input, 3 copies // repeated keys Integer[] vec1 = newRandomIntegers(length, 0, length / 5); Integer[] vec2 = new Integer[length]; Integer[] vec3 = new Integer[length]; System.arraycopy(vec1, 0, vec2, 0, length); System.arraycopy(vec1, 0, vec3, 0, length); // full sort vec1 long now = System.currentTimeMillis(); Arrays.sort(vec1); long dt = System.currentTimeMillis() - now; System.out.println(" full mergesort took " + dt + " msecs"); // partial sort vec2 now = System.currentTimeMillis(); doPartialSort(vec2, true, limit); dt = System.currentTimeMillis() - now; System.out.println(" partial quicksort took " + dt + " msecs"); // stable partial sort vec3 Comparator comp = new ReverseComparator(ComparatorUtils.naturalComparator()); List<Integer> vec3List = Arrays.asList(vec3); now = System.currentTimeMillis(); FunUtil.stablePartialSort(vec3List, comp, limit); dt = System.currentTimeMillis() - now; System.out.println(" stable partial quicksort took " + dt + " msecs"); }
/** * @see javax.servlet.jsp.tagext.BodyTagSupport#doStartTag() * @should sort encounters by encounterDatetime in descending order * @should pass for a patient with no encounters */ @SuppressWarnings( { "rawtypes", "unchecked" }) @Override public int doStartTag() { if (encounters == null || encounters.isEmpty()) { log.debug("ForEachEncounterTag skipping body due to 'encounters' param = " + encounters); return SKIP_BODY; } //First, sort the encounters if (StringUtils.isEmpty(sortBy)) { sortBy = "encounterDatetime"; } Comparator comp = new BeanComparator(sortBy, (descending ? new ReverseComparator(new ComparableComparator()) : new ComparableComparator())); Collections.sort((List) encounters, comp); // Next, retrieve all encounters matching the passed encounter type id, if provided. // If not provided, return all encounters matchingEncs = new ArrayList<Encounter>(); for (Iterator<Encounter> i = encounters.iterator(); i.hasNext();) { if (getNum() != null && getNum() <= matchingEncs.size()) { break; } Encounter e = i.next(); if (type == null || e.getEncounterType().getEncounterTypeId().intValue() == type.intValue()) { matchingEncs.add(e); } } log.debug("ForEachEncounterTag found " + matchingEncs.size() + " encounters matching type = " + type); // Return appropriate number of results if (matchingEncs.isEmpty()) { return SKIP_BODY; } else { pageContext.setAttribute("count", count); pageContext.setAttribute(var, matchingEncs.get(count++)); return EVAL_BODY_BUFFERED; } }
private void speedTest(Logger logger, int length, int limit) { logger.debug( "sorting the max " + limit + " of " + length + " random Integers"); // random input, 3 copies // repeated keys Integer[] vec1 = newRandomIntegers(length, 0, length / 5); Integer[] vec2 = vec1.clone(); Integer[] vec3 = vec1.clone(); Integer[] vec4 = vec1.clone(); // full sort vec1 long now = System.currentTimeMillis(); Arrays.sort(vec1); long dt = System.currentTimeMillis() - now; logger.debug(" full mergesort took " + dt + " msecs"); // partial sort vec2 now = System.currentTimeMillis(); doPartialSort(vec2, true, limit); dt = System.currentTimeMillis() - now; logger.debug(" partial quicksort took " + dt + " msecs"); // marc's stable partial quicksort vec3 @SuppressWarnings({"unchecked"}) Comparator<Integer> comp = new ReverseComparator(ComparatorUtils.naturalComparator()); List<Integer> vec3List = Arrays.asList(vec3); now = System.currentTimeMillis(); FunUtil.stablePartialSort(vec3List, comp, limit, 2); dt = System.currentTimeMillis() - now; logger.debug(" marc's stable partial quicksort took " + dt + " msecs"); // julian's algorithm stable partial sort vec4 @SuppressWarnings({"unchecked"}) List<Integer> vec4List = Arrays.asList(vec4); now = System.currentTimeMillis(); FunUtil.stablePartialSort(vec4List, comp, limit, 4); dt = System.currentTimeMillis() - now; logger.debug(" julian's stable partial sort took " + dt + " msecs"); }
@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; }