Search in sources :

Example 1 with Query

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

the class MongoDbTicketRegistry method deleteAll.

@Override
public long deleteAll() {
    final Query query = new Query(Criteria.where(TicketHolder.FIELD_NAME_ID).regex(".+"));
    final long count = this.mongoTemplate.count(query, this.collectionName);
    mongoTemplate.remove(query, this.collectionName);
    return count;
}
Also used : Query(org.springframework.data.mongodb.core.query.Query)

Example 2 with Query

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

the class MongoDbYubiKeyAccountRegistry method getAccount.

@Override
public Optional<YubiKeyAccount> getAccount(final String uid) {
    final Query query = new Query();
    query.addCriteria(Criteria.where("username").is(uid));
    final YubiKeyAccount account = this.mongoTemplate.findOne(query, YubiKeyAccount.class, this.collectionName);
    if (account != null) {
        return Optional.of(new YubiKeyAccount(account.getId(), getCipherExecutor().decode(account.getPublicId()), account.getUsername()));
    }
    return Optional.empty();
}
Also used : Query(org.springframework.data.mongodb.core.query.Query) YubiKeyAccount(org.apereo.cas.adaptors.yubikey.YubiKeyAccount)

Example 3 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 4 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 5 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)

Aggregations

Query (org.springframework.data.mongodb.core.query.Query)690 Test (org.junit.jupiter.api.Test)391 BasicQuery (org.springframework.data.mongodb.core.query.BasicQuery)259 NearQuery (org.springframework.data.mongodb.core.query.NearQuery)109 TextQuery (org.springframework.data.mongodb.core.query.TextQuery)91 Document (org.bson.Document)90 Update (org.springframework.data.mongodb.core.query.Update)83 Criteria (org.springframework.data.mongodb.core.query.Criteria)74 Test (org.junit.Test)72 lombok.val (lombok.val)50 ObjectId (org.bson.types.ObjectId)47 PartTree (org.springframework.data.repository.query.parser.PartTree)44 Sort (org.springframework.data.domain.Sort)41 StepVerifier (reactor.test.StepVerifier)39 Assertions (org.assertj.core.api.Assertions)30 Bson (org.bson.conversions.Bson)29 Mono (reactor.core.publisher.Mono)29 Point (org.springframework.data.geo.Point)28 Collation (org.springframework.data.mongodb.core.query.Collation)27 List (java.util.List)26