@Test public void testGetSortByNameAscendingAndUpdatesDescending() { List<ResourceSortCriterion> sortCrit = new ArrayList<ResourceSortCriterion>(); sortCrit.add(new ResourceSortCriterion(SortField.NAME, SortDirection.ASCENDING)); sortCrit.add(new ResourceSortCriterion(SortField.UPDATES_COUNT, SortDirection.DESCENDING)); ResourceSortCriteria criteria = new ResourceSortCriteria(sortCrit); Sort sort = sut.getSort(criteria); assertEquals(2, sort.getSort().length); assertEquals("byName", sort.getSort()[0].getField()); assertEquals(false, sort.getSort()[0].getReverse()); assertEquals("updatesCount", sort.getSort()[1].getField()); assertEquals(true, sort.getSort()[1].getReverse()); }
public Sort getSort(final ResourceSortCriteria inSortCriteria) { ResourceSortCriteria sortCriteria = overridingSortCriteria != null ? overridingSortCriteria : inSortCriteria; ArrayList<org.apache.lucene.search.SortField> sortFields = new ArrayList<org.apache.lucene.search.SortField>(); for (ResourceSortCriterion criterion : sortCriteria.getCriteria()) { boolean reverse = criterion.getSortDirection() == SortDirection.DESCENDING; switch (criterion.getSortField()) { case DATE_ADDED: sortFields.add(new org.apache.lucene.search.SortField("dateAdded", reverse)); break; case FOLLOWERS_COUNT: sortFields.add(new org.apache.lucene.search.SortField("followersCount", reverse)); break; case UPDATES_COUNT: sortFields.add(new org.apache.lucene.search.SortField("updatesCount", reverse)); break; default: sortFields.add(new org.apache.lucene.search.SortField("byName", reverse)); } } return new Sort(sortFields.toArray(new org.apache.lucene.search.SortField[sortFields.size()])); }
SortFieldBuilder { public Sort getSort(final ResourceSortCriteria inSortCriteria) { ResourceSortCriteria sortCriteria = overridingSortCriteria != null ? overridingSortCriteria : inSortCriteria; ArrayList<org.apache.lucene.search.SortField> sortFields = new ArrayList<org.apache.lucene.search.SortField>(); for (ResourceSortCriterion criterion : sortCriteria.getCriteria()) { boolean reverse = criterion.getSortDirection() == SortDirection.DESCENDING; switch (criterion.getSortField()) { case DATE_ADDED: sortFields.add(new org.apache.lucene.search.SortField("dateAdded", reverse)); break; case FOLLOWERS_COUNT: sortFields.add(new org.apache.lucene.search.SortField("followersCount", reverse)); break; case UPDATES_COUNT: sortFields.add(new org.apache.lucene.search.SortField("updatesCount", reverse)); break; default: sortFields.add(new org.apache.lucene.search.SortField("byName", reverse)); } } return new Sort(sortFields.toArray(new org.apache.lucene.search.SortField[sortFields.size()])); } }
SortFieldBuilder { public Sort getSort(final ResourceSortCriteria inSortCriteria) { ResourceSortCriteria sortCriteria = overridingSortCriteria != null ? overridingSortCriteria : inSortCriteria; ArrayList<org.apache.lucene.search.SortField> sortFields = new ArrayList<org.apache.lucene.search.SortField>(); for (ResourceSortCriterion criterion : sortCriteria.getCriteria()) { boolean reverse = criterion.getSortDirection() == SortDirection.DESCENDING; switch (criterion.getSortField()) { case DATE_ADDED: sortFields.add(new org.apache.lucene.search.SortField("dateAdded", reverse)); break; case FOLLOWERS_COUNT: sortFields.add(new org.apache.lucene.search.SortField("followersCount", reverse)); break; case UPDATES_COUNT: sortFields.add(new org.apache.lucene.search.SortField("updatesCount", reverse)); break; default: sortFields.add(new org.apache.lucene.search.SortField("byName", reverse)); } } return new Sort(sortFields.toArray(new org.apache.lucene.search.SortField[sortFields.size()])); }  }
SortFieldBuilder { public Sort getSort(final ResourceSortCriteria inSortCriteria) { ResourceSortCriteria sortCriteria = overridingSortCriteria != null ? overridingSortCriteria : inSortCriteria; ArrayList<org.apache.lucene.search.SortField> sortFields = new ArrayList<org.apache.lucene.search.SortField>(); for (ResourceSortCriterion criterion : sortCriteria.getCriteria()) { boolean reverse = criterion.getSortDirection() == SortDirection.DESCENDING; switch (criterion.getSortField()) { case DATE_ADDED: sortFields.add(new org.apache.lucene.search.SortField("dateAdded", reverse)); break; case FOLLOWERS_COUNT: sortFields.add(new org.apache.lucene.search.SortField("followersCount", reverse)); break; case UPDATES_COUNT: sortFields.add(new org.apache.lucene.search.SortField("updatesCount", reverse)); break; default: sortFields.add(new org.apache.lucene.search.SortField("byName", reverse)); } } return new Sort(sortFields.toArray(new org.apache.lucene.search.SortField[sortFields.size()])); }  Sort getSort(final ResourceSortCriteria inSortCriteria); void setOverridingSortCriteria(final ResourceSortCriteria inOverridingSortCriteria); }
SortFieldBuilder { public Sort getSort(final ResourceSortCriteria inSortCriteria) { ResourceSortCriteria sortCriteria = overridingSortCriteria != null ? overridingSortCriteria : inSortCriteria; ArrayList<org.apache.lucene.search.SortField> sortFields = new ArrayList<org.apache.lucene.search.SortField>(); for (ResourceSortCriterion criterion : sortCriteria.getCriteria()) { boolean reverse = criterion.getSortDirection() == SortDirection.DESCENDING; switch (criterion.getSortField()) { case DATE_ADDED: sortFields.add(new org.apache.lucene.search.SortField("dateAdded", reverse)); break; case FOLLOWERS_COUNT: sortFields.add(new org.apache.lucene.search.SortField("followersCount", reverse)); break; case UPDATES_COUNT: sortFields.add(new org.apache.lucene.search.SortField("updatesCount", reverse)); break; default: sortFields.add(new org.apache.lucene.search.SortField("byName", reverse)); } } return new Sort(sortFields.toArray(new org.apache.lucene.search.SortField[sortFields.size()])); }  Sort getSort(final ResourceSortCriteria inSortCriteria); void setOverridingSortCriteria(final ResourceSortCriteria inOverridingSortCriteria);  }