Example usage for org.springframework.data.domain Sort Sort

List of usage examples for org.springframework.data.domain Sort Sort

Introduction

In this page you can find the example usage for org.springframework.data.domain Sort Sort.

Prototype

private Sort(Direction direction, List<String> properties) 

Source Link

Document

Creates a new Sort instance.

Usage

From source file:it.f2informatica.pagination.services.PageableFactoryImpl.java

@Override
public Optional<Sort> getSort(QueryParameters parameters) {
    final String sortColumn = parameters.getSortColumn();
    final String sortDirection = parameters.getSortDirection();

    return (StringUtils.hasText(sortColumn) && StringUtils.hasText(sortDirection))
            ? Optional.of(new Sort(getDirection(sortDirection), suppressUniquePrefixIfAny(sortColumn)))
            : Optional.<Sort>absent();
}

From source file:com.frank.search.solr.core.query.SolrPageRequest.java

/**
 * Creates a new {@link SolrPageRequest} with sort parameters applied.
 *
 * @param page zero-based page index./*from  www  .  jav  a2 s .com*/
 * @param size the size of the page to be returned.
 * @param direction the direction of the {@link org.springframework.data.domain.Sort} to be specified, can be {@literal null}.
 * @param properties the properties to sort by, must not be {@literal null} or empty.
 */
public SolrPageRequest(int page, int size, Direction direction, String... properties) {
    this(page, size, new Sort(direction, properties));
}

From source file:com.chevrier.legiondao.metier.Metier.java

@Override
public List<Terrain> getAllTerrain() {
    return Lists.newArrayList(terrainRepository.findAll(new Sort(Sort.Direction.ASC, "nom")));
}

From source file:org.kee.ssf.service.module.ModuleService.java

/**
 * ./* ww w .ja  va  2  s .c  o m*/
 */
private PageRequest buildPageRequest(int pageNumber, int pagzSize, String sortType) {
    Sort sort = null;
    if ("auto".equals(sortType)) {
        sort = new Sort(Sort.Direction.DESC, "id");
    } else if ("title".equals(sortType)) {
        sort = new Sort(Sort.Direction.ASC, "title");
    }

    return new PageRequest(pageNumber - 1, pagzSize, sort);
}

From source file:com.ninjas.movietime.repository.TheaterRepository.java

public Page<Theater> listByTheaterChain(Collection<TheaterChain> theaterChains, int page, int size) {
    Preconditions.checkArgument(theaterChains.size() > 0, "Theater Chain list cannot be empty");
    final Pageable pageable = new PageRequest(page, size, new Sort(Sort.Direction.ASC, "name"));
    final Query query = Query.query(Criteria.where("theaterChain").in(theaterChains));
    return findPaged(pageable, query, Theater.class);
}

From source file:com.capstone.giveout.controllers.GiftChainsController.java

@RequestMapping(value = Routes.GIFTS_CHAIN_PATH, method = RequestMethod.GET)
public @ResponseBody Collection<GiftChain> list(
        @RequestParam(value = Routes.PAGE_PARAMETER, required = false, defaultValue = "0") int page,
        @RequestParam(value = Routes.LIMIT_PARAMETER, required = false, defaultValue = Constants.DEFAULT_PAGE_SIZE) int limit) {
    PageRequest pageRequest = new PageRequest(page, limit, new Sort(Sort.Direction.DESC, "createdAt"));
    List<GiftChain> giftChainList = Lists.newArrayList(giftChains.findAll(pageRequest));
    for (GiftChain giftChain : giftChainList) {
        giftChain.allowAccessToGifts = true;
    }/*ww w  .ja  va2  s  . co m*/
    return giftChainList;
}

From source file:io.github.microcks.web.HealthController.java

@RequestMapping(value = "/health", method = RequestMethod.GET)
public ResponseEntity<String> health() {
    log.trace("Health check endpoint invoked");

    try {// www.jav a  2 s  .c  o m
        // Using a single selection query to ensure connection to MongoDB is ok.
        List<ImportJob> jobs = jobRepository
                .findAll(new PageRequest(0, 10, new Sort(Sort.Direction.ASC, "name"))).getContent();
    } catch (Exception e) {
        log.error("Health check caught an exception: " + e.getMessage(), e);
        return new ResponseEntity<String>(HttpStatus.SERVICE_UNAVAILABLE);
    }
    log.trace("Health check is OK");
    return new ResponseEntity<String>(HttpStatus.OK);
}

From source file:quanlyhocvu.api.mongodb.DAO.NewsDAO.java

/**
 * get pagination of news by catalogId//  w  ww.  j ava  2 s.  c o m
 * @param catalogId
 * @param limit
 * @param offset
 * @return 
 */
public List<NewsDTO> getNewsByCatalogIdAndPate(String catalogId, int limit, int offset) {
    Query query = Query.query(Criteria.where("catalogs.$id").is(new ObjectId(catalogId)));
    query.limit(limit);
    query.skip(offset);
    query.with(new Sort(Sort.Direction.DESC, "date"));
    return mongoOperation.find(query, NewsDTO.class);
}

From source file:jp.co.ctc_g.rack.connector.auth.WooreaAuthRepository.java

/**
 * {@inheritDoc}/*from   ww w .  j  av  a2s. co m*/
 */
@Override
public List<WooreaAuthentication> listWithPaginating() {

    return operations.find(new Query().with(new Sort(Direction.DESC, "_id")).limit(10),
            WooreaAuthentication.class);
}

From source file:com.appleframework.monitor.service.LogsService.java

public DBCursor findLogs(String projectName, LogQuery logQuery, int max) throws ParseException {
    Project project = projectService.findProject(projectName);
    MongoTemplate template = project.fetchMongoTemplate();

    Query query = new BasicQuery(logQuery.toQuery());
    query.limit(max);/* www .ja  v a 2  s  .  c  o  m*/

    //query.sort().on("timestamp", Order.DESCENDING);
    query.with(new Sort(Direction.DESC, "timestamp"));
    logger.debug("find logs from {}  by query {} by sort {}",
            new Object[] { project.getLogCollection(), query.getQueryObject(), query.getSortObject() });
    DBCursor cursor = template.getCollection(project.getLogCollection()).find(query.getQueryObject())
            .sort(query.getSortObject()).limit(max);
    return cursor;
}