List of usage examples for org.springframework.data.domain Sort Sort
private Sort(Direction direction, List<String> properties)
From source file:com.appleframework.monitor.model.Project.java
public List<MetricValue> findMetricData(String metricName) { Query query = fetchTimeQuery(); query.addCriteria(Criteria.where("name").is(metricName)); //query.sort().on(Constants.TIME_STAMP_FIELD_NAME, Order.ASCENDING); query.with(new Sort(Direction.ASC, Constants.TIME_STAMP_FIELD_NAME)); logger.debug("find metric value by {} ,mongo={}", query.getQueryObject(), mongoUri); return fetchMongoTemplate().find(query, MetricValue.class, metricCollection); }
From source file:cn.guoyukun.spring.jpa.plugin.serivce.BaseMovableService.java
public M findPreByWeight(Integer weight) { Pageable pageable = new PageRequest(0, 1); Map<String, Object> searchParams = Maps.newHashMap(); searchParams.put("weight_lt", weight); Sort sort = new Sort(Sort.Direction.DESC, "weight"); Page<M> page = findAll(Searchable.newSearchable(searchParams).addSort(sort).setPage(pageable)); if (page.hasContent()) { return page.getContent().get(0); }/*from ww w .j a v a 2s .c o m*/ return null; }
From source file:com.gamewin.weixin.service.account.AccountService.java
/** * ./* w ww . j a v a 2s. co m*/ */ private PageRequest buildPageRequest(int pageNumber, int pagzSize, String sortType) { Sort sort = null; if ("auto".equals(sortType)) { sort = new Sort(Direction.DESC, "id"); } else if ("title".equals(sortType)) { sort = new Sort(Direction.ASC, "registerDate"); } return new PageRequest(pageNumber - 1, pagzSize, sort); }
From source file:com.pkrete.locationservice.endpoint.solr.service.impl.LocationIndexServiceImpl.java
/** * Returns a Sort object that sorts the results in descending order by * location code.//from w w w .j a v a2 s . co m * * @return Sort object that sorts the results in descending order by call * number */ private Sort sortByLocationCodeDesc() { return new Sort(Sort.Direction.DESC, RepositoryConstants.FIELD_LOCATION_CODE); }
From source file:com.luna.common.plugin.service.MoveServiceIT.java
@Test public void testReweight() { for (int i = 0; i < 20; i++) { Move move = createMove();/*from w w w . j a v a 2s . c o m*/ move.setWeight(i); } flush(); moveService.reweight(); List<Move> moves = moveService.findAll(new Sort(Sort.Direction.ASC, "weight")); assertEquals(moveService.getStepLength(), moves.get(0).getWeight()); assertEquals(Integer.valueOf(moveService.getStepLength() * 2), moves.get(1).getWeight()); assertEquals(Integer.valueOf(moveService.getStepLength() * moves.size()), moves.get(moves.size() - 1).getWeight()); }
From source file:cn.guoyukun.spring.jpa.plugin.serivce.BaseMovableService.java
public M findNextByWeight(Integer weight) { Pageable pageable = new PageRequest(0, 1); Map<String, Object> searchParams = Maps.newHashMap(); searchParams.put("weight_gt", weight); Sort sort = new Sort(Sort.Direction.ASC, "weight"); Page<M> page = findAll(Searchable.newSearchable(searchParams).addSort(sort).setPage(pageable)); if (page.hasContent()) { return page.getContent().get(0); }// w w w . j a v a 2 s. com return null; }
From source file:com.appleframework.monitor.model.Project.java
/** * //from www . jav a 2 s .c om * * @param metricName * @return */ public MetricValue findLastMetric(String metricName) { Query query = BasicQuery.query(Criteria.where("name").is(metricName)); //query.sort().on(Constants.TIME_STAMP_FIELD_NAME, Order.DESCENDING); query.with(new Sort(Direction.DESC, Constants.TIME_STAMP_FIELD_NAME)); return fetchMongoTemplate().findOne(query, MetricValue.class, metricCollection); }
From source file:com.traffitruck.service.MongoDAO.java
public List<Load> getLoadsForUser(String username) { Query findByUsername = new Query().addCriteria(Criteria.where("username").is(username)); findByUsername.with(new Sort(Direction.DESC, "creationDate")); return mongoTemplate.find(findByUsername, Load.class); }
From source file:com.luna.common.web.bind.method.annotation.SearchableMethodArgumentResolverTest.java
@Test public void testMethodDefaultSearchable() throws Exception { int pn = 1;/*w w w . j av a2s. c o m*/ int pageSize = 10; request.setParameter("page.pn", String.valueOf(pn)); request.setParameter("page.size", String.valueOf(pageSize)); request.setParameter("sort1.baseInfo.realname", "asc"); request.setParameter("sort2.id", "desc"); MethodParameter parameter = new MethodParameter(methodDefaultSearchable, 0); NativeWebRequest webRequest = new ServletWebRequest(request); Searchable searchable = (Searchable) new SearchableMethodArgumentResolver().resolveArgument(parameter, null, webRequest, null); //-10 assertEquals(pn - 1, searchable.getPage().getPageNumber()); assertEquals(pageSize, searchable.getPage().getPageSize()); Sort expectedSort = new Sort(Sort.Direction.ASC, "baseInfo.realname") .and(new Sort(Sort.Direction.DESC, "id")); assertEquals(expectedSort, searchable.getSort()); assertContainsSearchFilter( SearchFilterHelper.newCondition("baseInfo.realname", SearchOperator.like, "zhang"), searchable); assertContainsSearchFilter(SearchFilterHelper.newCondition("id", SearchOperator.eq, "1"), searchable); }
From source file:com.github.fauu.natrank.service.MatchDataImportServiceImpl.java
@Override public List<Country> findAllCountriesSortedByName() throws DataAccessException { return countryRepository.findAll(new Sort(Sort.Direction.ASC, "name")); }