List of usage examples for org.springframework.data.domain Sort Sort
private Sort(Direction direction, List<String> properties)
From source file:com.monkeyk.sos.infrastructure.mongo.UserRepositoryMongo.java
@Override public List<User> findAllUsers() { Query query = new Query().with(new Sort(Sort.Direction.DESC, "createTime")); return mongoTemplate().find(query, User.class); }
From source file:quanlyhocvu.api.mongodb.DAO.NewsDAO.java
/** * get all data pagination//from w w w . j av a2s . c o m * @param limit * @param offset * @return */ public List<NewsDTO> getAllNewsByPage(int limit, int offset) { Query query = Query.query(Criteria.where("id").exists(true)); query.limit(limit); query.skip(offset); query.with(new Sort(Sort.Direction.DESC, "date")); return mongoOperation.find(query, NewsDTO.class); }
From source file:com.github.camellabs.iot.cloudlet.webcam.service.DefaultWebcamService.java
@Override public WebcamImage latestImage(String deviceId, String webcamName) { Query query = new Query(); query.limit(1);//from w w w .ja va 2 s . co m query.with(new Sort(Sort.Direction.DESC, "timestamp")); query.addCriteria(where("deleted").is(null)).addCriteria(where("deviceId").is(deviceId)); return mongoTemplate.findOne(query, WebcamImage.class); }
From source file:cn.edu.zjnu.acm.judge.mapper.UserMapperTest.java
/** * Test of findAll method, of class UserMapper. *///from w ww .j a v a 2s .com @Test public void testFindAll() { log.info("findAll"); Pageable pageable = new PageRequest(0, 50); List<User> result = instance.findAll(pageable); log.debug("{}", result); pageable = new PageRequest(0, 50, new Sort(new Sort.Order(Sort.Direction.DESC, "solved"), new Sort.Order(Sort.Direction.ASC, "submit"))); result = instance.findAll(pageable); log.debug("{}", result); Sort.Order order = new Sort.Order(Sort.Direction.DESC, "solved"); ArrayList<Sort.Order> list = new ArrayList<>(1); list.add(order); pageable = new PageRequest(0, 50, new Sort(list)); list.clear(); result = instance.findAll(pageable); log.debug("{}", result); }
From source file:com.luna.common.entity.search.SearchableTest.java
@Test public void testNewSearchable() { Map<String, Object> searchParams1 = Maps.newHashMap(); searchParams1.put("name_like", "123"); searchParams1.put("name_like", "234"); searchParams1.put("age_eq", 1); Searchable searchable1 = Searchable.newSearchable(searchParams1); Assert.assertTrue(searchable1.containsSearchKey("name_like")); Assert.assertTrue(searchable1.containsSearchKey("age_eq")); Assert.assertEquals("234", searchable1.getValue("name_like")); Assert.assertEquals(1, searchable1.getValue("age_eq")); Assert.assertEquals(2, searchable1.getSearchFilters().size()); Searchable searchable2 = Searchable.newSearchable(null, new PageRequest(0, 1), new Sort(Sort.Direction.DESC, "uuid")); Assert.assertTrue(searchable2.hasPageable()); Assert.assertTrue(searchable2.hashSort()); Searchable searchable3 = Searchable.newSearchable(null, new PageRequest(0, 1, new Sort(Sort.Direction.DESC, "uuid"))); Assert.assertTrue(searchable3.hasPageable()); Assert.assertTrue(searchable3.hashSort()); }
From source file:org.openmhealth.shim.AccessParameterClientTokenServices.java
@Override public void saveAccessToken(OAuth2ProtectedResourceDetails resource, Authentication authentication, OAuth2AccessToken accessToken) { String username = authentication.getPrincipal().toString(); String shimKey = authentication.getDetails().toString(); AccessParameters accessParameters = accessParametersRepo.findByUsernameAndShimKey(username, shimKey, new Sort(Sort.Direction.DESC, "dateCreated")); if (accessParameters == null) { accessParameters = new AccessParameters(); accessParameters.setUsername(username); accessParameters.setShimKey(shimKey); }//ww w. j ava 2 s .co m accessParameters.setSerializedToken(SerializationUtils.serialize(accessToken)); accessParametersRepo.save(accessParameters); }
From source file:strat.mining.multipool.stats.persistence.dao.coinshift.impl.TransactionDAOMongo.java
@Override public Transaction getLastTransaction(Integer addressId) { Query query = new Query(Criteria.where("addressId").is(addressId)); query.with(new Sort(Sort.Direction.DESC, "date")); return mongoOperation.findOne(query, Transaction.class); }
From source file:org.davidmendoza.esu.web.BaseController.java
protected Map<String, Object> preparaPaginacion(Integer pagina, String ordena, String direccion, String filtro) {/*from w w w. j a v a 2 s . c om*/ Map<String, Object> params = new HashMap<>(); String direccionContraria; if (pagina == null) { pagina = 0; } if (StringUtils.isBlank(ordena)) { ordena = "lastUpdated"; direccion = "desc"; } if (StringUtils.isBlank(direccion)) { direccion = "asc"; } Sort sort; switch (direccion) { case "desc": sort = new Sort(Sort.Direction.DESC, ordena); direccionContraria = "asc"; break; default: sort = new Sort(Sort.Direction.ASC, ordena); direccionContraria = "desc"; } params.put(Constants.PAGINA, pagina); params.put(Constants.ORDENA, ordena); params.put(Constants.DIRECCION, direccion); params.put(Constants.DIRECCION_CONTRARIA, direccionContraria); params.put(Constants.FILTRO, filtro); PageRequest pageRequest = new PageRequest(pagina, 20, sort); params.put(Constants.PAGE_REQUEST, pageRequest); return params; }
From source file:org.devgateway.toolkit.forms.wicket.providers.SortableJpaRepositoryDataProvider.java
/** * Translates from a {@link SortParam} to a Spring {@link Sort} * * @return/* ww w.ja v a 2s . c o m*/ */ protected Sort translateSort() { if (getSort() == null) { return null; } return new Sort(getSort().isAscending() ? Direction.ASC : Direction.DESC, getSort().getProperty()); }
From source file:com.dm.estore.search.services.impl.CatalogSearchServiceImpl.java
@Override public List<CategoryDto> findHomeCategories() { List<CatalogItemDto> catalogItems = catalogSearchRepository .findByActiveTrue(new Sort(Sort.Direction.ASC, CatalogItemDto.FIELD_POPULARITY)); List<CategoryDto> homeCategories = new ArrayList<CategoryDto>(); for (CatalogItemDto item : catalogItems) { if (CatalogItemType.category.equals(item.getDocumentType())) { homeCategories.add(categoryConverter.convert(item)); }// w w w . ja va 2 s. co m } return homeCategories; }