Search in sources :

Example 11 with Query

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

the class GoogleAuthenticatorMongoDbTokenRepository method get.

@Override
public GoogleAuthenticatorToken get(final String uid, final Integer otp) {
    try {
        final Query query = new Query();
        query.addCriteria(Criteria.where("userId").is(uid).and("token").is(otp));
        final GoogleAuthenticatorToken r = this.mongoTemplate.findOne(query, GoogleAuthenticatorToken.class, this.collectionName);
        return r;
    } catch (final NoResultException e) {
        LOGGER.debug("No record could be found for google authenticator id [{}]", uid);
    }
    return null;
}
Also used : Query(org.springframework.data.mongodb.core.query.Query) GoogleAuthenticatorToken(org.apereo.cas.adaptors.gauth.token.GoogleAuthenticatorToken) NoResultException(javax.persistence.NoResultException)

Example 12 with Query

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

the class MongoDbGoogleAuthenticatorTokenCredentialRepository method get.

@Override
public OneTimeTokenAccount get(final String username) {
    try {
        final Query query = new Query();
        query.addCriteria(Criteria.where("username").is(username));
        final GoogleAuthenticatorAccount r = this.mongoTemplate.findOne(query, GoogleAuthenticatorAccount.class, this.collectionName);
        if (r != null) {
            return decode(r);
        }
    } catch (final NoResultException e) {
        LOGGER.debug("No record could be found for google authenticator id [{}]", username);
    }
    return null;
}
Also used : GoogleAuthenticatorAccount(org.apereo.cas.adaptors.gauth.repository.credentials.GoogleAuthenticatorAccount) Query(org.springframework.data.mongodb.core.query.Query) NoResultException(javax.persistence.NoResultException)

Example 13 with Query

use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.

the class LaunchRepositoryCustomImpl method findIdsByFilter.

@Override
public List<Launch> findIdsByFilter(Filter filter, int limit) {
    Query query = QueryBuilder.newBuilder().with(filter).with(limit).build();
    query.fields().include(ID_REFERENCE);
    return mongoTemplate.find(query, Launch.class);
}
Also used : Query(org.springframework.data.mongodb.core.query.Query)

Example 14 with Query

use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.

the class LaunchRepositoryCustomImpl method findIdsByFilter.

@Override
public List<Launch> findIdsByFilter(Filter filter, Sort sort, int quantity) {
    Query query = QueryBuilder.newBuilder().with(filter).with(sort).with(quantity).build();
    query.fields().include(NAME);
    query.fields().include(ID_REFERENCE);
    query.fields().include(NUMBER);
    query.fields().include(START_TIME);
    query.fields().include(STATUS);
    return mongoTemplate.find(query, Launch.class);
}
Also used : Query(org.springframework.data.mongodb.core.query.Query)

Example 15 with Query

use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.

the class LogRepositoryCustomImpl method deleteByPeriodAndItemsRef.

@Override
public void deleteByPeriodAndItemsRef(Duration time, List<String> itemsRef) {
    Query query = findModifiedLaterThanPeriod(time).addCriteria(where(ITEM_REFERENCE).in(itemsRef));
    mongoTemplate.remove(query, Log.class);
}
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