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:quanlyhocvu.api.mongodb.DAO.NewsDAO.java

/**
 * get all data pagination/*from  ww  w .j av a2  s.  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.card.loop.xyz.dao.LearningObjectDAO.java

public List<LearningObject> getAllDownloadableLO() throws UnknownHostException {
    Query query = new Query();
    query.with(new Sort(new Sort.Order(Sort.Direction.DESC, "dateUploaded")));
    return (mongoOps.find(query(where("status").is(1)), LearningObject.class));
}

From source file:com.card.loop.xyz.dao.LearningObjectDAO.java

public List<LearningObject> getOldLO(String name) throws UnknownHostException {
    Query query = new Query();
    query.with(new Sort(new Sort.Order(Sort.Direction.DESC, "dateUploaded")));
    return (mongoOps.find(query(where("status").is(0)), LearningObject.class));
}

From source file:com.card.loop.xyz.dao.LearningObjectDAO.java

public List<LearningObject> getAllLO() throws UnknownHostException {
    Query query = new Query();
    query.with(new Sort(new Sort.Order(Sort.Direction.DESC, "dateUploaded")));
    return mongoOps.findAll(LearningObject.class);
}

From source file:com.card.loop.xyz.dao.LearningObjectDAO.java

public List<LearningObject> getAllLODev(String username) throws UnknownHostException {
    Query query = new Query();
    query.with(new Sort(new Sort.Order(Sort.Direction.DESC, "dateUploaded")));
    return mongoOps.find(query(where("uploadedBy").is(username)), LearningObject.class);
}

From source file:com.card.loop.xyz.dao.LearningObjectDAO.java

public List<LearningObject> getAllLORevLater(String user) throws UnknownHostException {
    Query query = new Query();
    query.with(new Sort(new Sort.Order(Sort.Direction.DESC, "dateUploaded")));
    return mongoOps.find(query(where("rating").lt(4).andOperator(where("rating").gt(0))
            .andOperator(where("status").is(2)).andOperator(where("rev").is(user))), LearningObject.class);
}

From source file:com.card.loop.xyz.dao.LearningObjectDAO.java

public List<LearningObject> getAllLORev() throws UnknownHostException {
    Query query = new Query();
    query.with(new Sort(new Sort.Order(Sort.Direction.DESC, "dateUploaded")));
    return mongoOps.find(
            query(where("rating").lt(4).andOperator(where("rating").gt(0)).andOperator(where("rev").is(""))),
            LearningObject.class);
}

From source file:com.pubkit.platform.persistence.impl.ApplicationDaoImpl.java

public List<Application> getUserApplications(User user) {
    Criteria criteria = Criteria.where("owner").is(user);

    Query query = Query.query(criteria);

    Sort sort = new Sort(new Order(Direction.ASC, "createdDate"));
    query = query.with(sort);

    return mongoTemplate.find(query, Application.class);
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.repository.mongo.impl.IAViewUpdateRepositoryImpl.java

@Override
public List<IAViewUpdate> findDocumentsCreatedFromDateAndCreatedBeforeDate(Date gtDate, Date ltDate,
        Integer limit) {//w w  w.  j  ava  2 s. c  om
    List<Criteria> listOfCriterias = new ArrayList<Criteria>();
    if (gtDate != null) {
        listOfCriterias.add(Criteria.where(IAViewUpdate.FIELD_CREATIONDATE).gte(gtDate));
    }
    if (ltDate != null) {
        listOfCriterias.add(Criteria.where(IAViewUpdate.FIELD_CREATIONDATE).lt(ltDate));
    }
    Query query = new Query(new Criteria().andOperator(listOfCriterias.toArray(new Criteria[0])));

    query.limit(limit + 1);
    query.with(new Sort(new Order(Sort.Direction.ASC, IAViewUpdate.FIELD_CREATIONDATE),
            new Order(Sort.Direction.ASC, IAViewUpdate.FIELD_DOCREFERENCE)));
    return mongoTemplate.find(query, IAViewUpdate.class);
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.repository.mongo.impl.IAViewUpdateRepositoryImpl.java

@Override
public List<IAViewUpdate> findDocumentsCreatedAfterDocumentAndCreatedBeforeDate(IAViewUpdate afterIAViewUpdate,
        Date ltDate, Integer limit) {
    List<Criteria> listOfCriterias = new ArrayList<Criteria>();
    listOfCriterias.add(new Criteria().orOperator(
            Criteria.where(IAViewUpdate.FIELD_CREATIONDATE).gt(afterIAViewUpdate.getCreationDate()),
            new Criteria().andOperator(
                    Criteria.where(IAViewUpdate.FIELD_CREATIONDATE).gte(afterIAViewUpdate.getCreationDate()),
                    Criteria.where(IAViewUpdate.FIELD_DOCREFERENCE).gt(afterIAViewUpdate.getDocReference()))));
    if (ltDate != null) {
        listOfCriterias.add(Criteria.where(IAViewUpdate.FIELD_CREATIONDATE).lt(ltDate));
    }/*  w w  w  .j  a  va  2s.  co m*/
    Query query = new Query(new Criteria().andOperator(listOfCriterias.toArray(new Criteria[0])));

    query.limit(limit + 1);
    query.with(new Sort(new Order(Sort.Direction.ASC, IAViewUpdate.FIELD_CREATIONDATE),
            new Order(Sort.Direction.ASC, IAViewUpdate.FIELD_DOCREFERENCE)));
    return mongoTemplate.find(query, IAViewUpdate.class);
}