Search in sources :

Example 6 with Query

use of org.springframework.data.mongodb.core.query.Query in project cas by apereo.

the class MongoDbCasEventRepository method getEventsOfTypeForPrincipal.

@Override
public Collection<CasEvent> getEventsOfTypeForPrincipal(final String type, final String principal, final ZonedDateTime dateTime) {
    final Query query = new Query();
    query.addCriteria(Criteria.where(TYPE_PARAM).is(type).and(PRINCIPAL_ID_PARAM).is(principal).and(CREATION_TIME_PARAM).gte(dateTime.toString()));
    return this.mongoTemplate.find(query, CasEvent.class, this.collectionName);
}
Also used : Query(org.springframework.data.mongodb.core.query.Query)

Example 7 with Query

use of org.springframework.data.mongodb.core.query.Query in project cas by apereo.

the class MongoDbCasEventRepository method getEventsForPrincipal.

@Override
public Collection<CasEvent> getEventsForPrincipal(final String principal, final ZonedDateTime dateTime) {
    final Query query = new Query();
    query.addCriteria(Criteria.where(PRINCIPAL_ID_PARAM).is(principal).and(CREATION_TIME_PARAM).gte(dateTime.toString()));
    return this.mongoTemplate.find(query, CasEvent.class, this.collectionName);
}
Also used : Query(org.springframework.data.mongodb.core.query.Query)

Example 8 with Query

use of org.springframework.data.mongodb.core.query.Query in project cas by apereo.

the class MongoDbCasEventRepository method getEventsOfTypeForPrincipal.

@Override
public Collection<CasEvent> getEventsOfTypeForPrincipal(final String type, final String principal) {
    final Query query = new Query();
    query.addCriteria(Criteria.where(TYPE_PARAM).is(type).and(PRINCIPAL_ID_PARAM).is(principal));
    return this.mongoTemplate.find(query, CasEvent.class, this.collectionName);
}
Also used : Query(org.springframework.data.mongodb.core.query.Query)

Example 9 with Query

use of org.springframework.data.mongodb.core.query.Query in project cas by apereo.

the class MongoDbCasEventRepository method getEventsForPrincipal.

@Override
public Collection<CasEvent> getEventsForPrincipal(final String id) {
    final Query query = new Query();
    query.addCriteria(Criteria.where(PRINCIPAL_ID_PARAM).is(id));
    return this.mongoTemplate.find(query, CasEvent.class, this.collectionName);
}
Also used : Query(org.springframework.data.mongodb.core.query.Query)

Example 10 with Query

use of org.springframework.data.mongodb.core.query.Query in project cas by apereo.

the class MongoDbConsentRepository method deleteConsentDecision.

@Override
public boolean deleteConsentDecision(final long decisionId, final String principal) {
    final Query query = new Query(Criteria.where("id").is(decisionId));
    this.mongoTemplate.remove(query, this.collectionName);
    return true;
}
Also used : Query(org.springframework.data.mongodb.core.query.Query)

Aggregations

Query (org.springframework.data.mongodb.core.query.Query)488 Test (org.junit.Test)312 BasicQuery (org.springframework.data.mongodb.core.query.BasicQuery)156 Update (org.springframework.data.mongodb.core.query.Update)79 NearQuery (org.springframework.data.mongodb.core.query.NearQuery)66 Document (org.bson.Document)56 Criteria (org.springframework.data.mongodb.core.query.Criteria)47 PartTree (org.springframework.data.repository.query.parser.PartTree)44 Sort (org.springframework.data.domain.Sort)30 ObjectId (org.bson.types.ObjectId)27 BasicDBObject (com.mongodb.BasicDBObject)22 DBObject (com.mongodb.DBObject)20 Before (org.junit.Before)18 List (java.util.List)17 Autowired (org.springframework.beans.factory.annotation.Autowired)17 GeoJsonPoint (org.springframework.data.mongodb.core.geo.GeoJsonPoint)17 Collectors (java.util.stream.Collectors)16 ArrayList (java.util.ArrayList)15 OptimisticLockingFailureException (org.springframework.dao.OptimisticLockingFailureException)15 MappingException (org.springframework.data.mapping.MappingException)15