Example usage for org.springframework.data.mongodb.core.query Query with

List of usage examples for org.springframework.data.mongodb.core.query Query with

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.query Query with.

Prototype

public Query with(Sort sort) 

Source Link

Document

Adds a Sort to the Query instance.

Usage

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

public List<Project> findProjects() {
    Query query = new Query();
    //query.sort().on("name", Order.ASCENDING);
    query.with(new Sort(Direction.ASC, "name"));
    List<Project> projects = mongoTemplate.find(query, Project.class, collectionName);
    return projects;
}

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

/**
 * get pagination of news by catalogId/*from   w  w  w.jav a  2  s.c om*/
 * @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:com.trenako.repositories.mongo.WishListsRepositoryImpl.java

@Override
public Iterable<WishList> findByOwner(Account owner) {
    Query query = query(where("owner").is(owner.getSlug()));
    query.fields().exclude("items");
    query.with(NAME_SORT);
    return mongoTemplate.find(query, WishList.class);
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.service.impl.IAViewServiceImpl.java

public List<MongoInformationAssetView> findUntaggedDocumentsBySeriesMongo(String seriesIaid, Integer limit,
        Integer offset) {//from   w w  w .ja va2s .com
    Query query = Query.query(Criteria.where("series").is(seriesIaid).and("categories").size(0));
    query.limit(limit);
    query.skip(offset);
    query.with(new Sort(Sort.Direction.ASC, "_id"));
    return mongoTemplate.find(query, MongoInformationAssetView.class);
}

From source file:org.oncoblocks.centromere.mongodb.test.CentromereEntrezGeneRepositoryImpl.java

public List<EntrezGene> guessGene(String keyword) {
    Query query = new Query(Criteria.where("primaryGeneSymbol").is(keyword));
    Sort sort = new Sort(new Sort.Order(Sort.Direction.ASC, "entrezGeneId"));
    List<EntrezGene> genes = mongoOperations.find(query.with(sort), EntrezGene.class);
    if (genes != null && genes.size() > 0)
        return genes;
    query = new Query(Criteria.where("aliases").is(keyword));
    genes = mongoOperations.find(query.with(sort), EntrezGene.class);
    if (genes != null && genes.size() > 0)
        return genes;
    return null;/*from  w  ww .  ja  v a 2  s . c o  m*/
}

From source file:se.inera.axel.shs.broker.messagestore.internal.MongoMessageLogAdminService.java

@Override
public Iterable<ShsMessageEntry> findMessages(Filter filter) {

    Criteria criteria = buildCriteria(filter);
    Query query = Query.query(criteria);

    query.with(new Sort(Sort.Direction.DESC, "arrivalTimeStamp"));

    query = query.limit(filter.getLimit());
    query = query.skip(filter.getSkip());

    return mongoTemplate.find(query, ShsMessageEntry.class);

}

From source file:com.trenako.repositories.mongo.WishListsRepositoryImpl.java

@Override
public Iterable<WishList> findAllByOwner(Account owner, int maxNumberOfItems) {
    Query query = query(where("owner").is(owner.getSlug()));
    query.fields().slice("items", -1 * maxNumberOfItems);
    query.with(NAME_SORT);
    return mongoTemplate.find(query, WishList.class);
}

From source file:org.oncoblocks.centromere.mongodb.test.EntrezGeneRepository.java

public List<EntrezGene> guessGene(String keyword) {
    Query query = new Query(Criteria.where("primaryGeneSymbol").is(keyword));
    Sort sort = new Sort(new Sort.Order(Sort.Direction.ASC, "entrezGeneId"));
    List<EntrezGene> genes = getMongoOperations().find(query.with(sort), getModel());
    if (genes != null && genes.size() > 0)
        return genes;
    query = new Query(Criteria.where("aliases").is(keyword));
    genes = getMongoOperations().find(query.with(sort), getModel());
    if (genes != null && genes.size() > 0)
        return genes;
    return null;/*  ww  w  . ja  va 2  s .  c  o  m*/
}

From source file:org.starfishrespect.myconsumption.server.business.repositories.repositoriesimpl.ValuesRepositoryImpl.java

@Override
public List<SensorDataset> getSensor(Date startTime, Date endTime) throws DaoException {
    Query timeQuery = new Query(new Criteria().andOperator(Criteria.where("timestamp").gte(startTime),
            Criteria.where("timestamp").lte(endTime)));
    timeQuery.with(new Sort(Sort.Direction.ASC, "timestamp"));
    return mongoOperation.find(timeQuery, SensorDataset.class, collectionName);
}

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

public List<Alert> findAlerts(String projectName) {
    Query query = Query.query(Criteria.where("projectName").is(projectName)).limit(50);
    //query.sort().on("createTime", Order.DESCENDING);
    query.with(new Sort(Direction.DESC, "createTime"));
    return mongoTemplate.find(query, Alert.class, collectionName);
}