Example usage for org.springframework.data.mongodb.core.query Criteria where

List of usage examples for org.springframework.data.mongodb.core.query Criteria where

Introduction

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

Prototype

public static Criteria where(String key) 

Source Link

Document

Static factory method to create a Criteria using the provided key

Usage

From source file:io.cos.cas.adaptors.mongodb.OpenScienceFrameworkPersonalAccessTokenHandler.java

@Override
public PersonalAccessToken getToken(final String tokenId) {
    final OpenScienceFrameworkPersonalToken token = this.mongoTemplate
            .findOne(/*  ww  w . j a va2  s. co m*/
                    new Query(new Criteria().andOperator(Criteria.where("tokenId").is(tokenId),
                            Criteria.where("isActive").is(Boolean.TRUE))),
                    OpenScienceFrameworkPersonalToken.class);

    if (token == null) {
        return null;
    }

    final String scopes = token.scopes == null ? "" : token.scopes;
    return new PersonalAccessToken(token.tokenId, token.owner, new HashSet<>(Arrays.asList(scopes.split(" "))));
}

From source file:st.malike.service.mongo.DemographicSummaryService.java

public DemographicSummary getDemographicSummaryByEventAndDateForMin(String event, String dateCreated) {
    try {//from w  w  w . j  av  a  2  s  . c o  m
        Date startDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:00").parse(dateCreated);
        Date endDate = new DateTime(startDate).plusMinutes(1).toDate();
        Query query = new Query();
        query.addCriteria(Criteria.where("event").is(event));
        query.addCriteria(Criteria.where("dateCreated").gte(startDate).lte(endDate));
        return mongoTemplate.findOne(query, DemographicSummary.class, "demographic_summary");
    } catch (ParseException ex) {
        Logger.getLogger(DemographicSummaryService.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}

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);/*from   www . j a  v  a 2 s.  c om*/

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

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

public List<DeviceInfo> getDevices(String applicationId, String deviceType, int offset, int limit) {
    Criteria criteria = Criteria.where("applicationId").is(applicationId).and("deviceType").is(deviceType);
    Query query = Query.query(criteria).limit(limit).skip(offset);

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

From source file:com.telefonica.euro_iaas.sdc.puppetwrapper.services.impl.CatalogManagerMongoImpl.java

public void removeNode(String nodeName) {
    Query searchNodeQuery = new Query(Criteria.where("id").is(nodeName));
    mongoTemplate.remove(searchNodeQuery, Node.class);

}

From source file:strat.mining.multipool.stats.persistence.dao.coinshift.impl.AddressStatsDAOMongo.java

@Override
public AddressStats getLastAddressStats(Integer addressId) {
    Query query = new Query(Criteria.where("addressId").is(addressId));
    query.with(new Sort(Sort.Direction.DESC, "refreshTime"));
    return mongoOperation.findOne(query, AddressStats.class);
}

From source file:org.cbioportal.session_service.domain.internal.SessionRepositoryImpl.java

public Session findOneBySourceAndTypeAndData(String source, String type, Object data) {
    Query query = new Query(Criteria.where("source").is(source).and("type").is(type).and("data").is(data));
    return this.mongoTemplate.findOne(query, Session.class, type);
}

From source file:io.github.microcks.repository.DailyStatisticRepositoryImpl.java

@Override
public DailyStatistic aggregateDailyStatistics(String day) {

    // Build a query to pre-select the statistics that will be aggregated.
    Query query = new Query(Criteria.where("day").is(day));

    // Execute a MapReduce command.
    MapReduceResults<WrappedDailyStatistic> results = template.mapReduce(query, "dailyStatistic",
            "classpath:mapDailyStatisticForADay.js", "classpath:reduceDailyStatisticForADay.js",
            WrappedDailyStatistic.class);

    // Output some debug messages.
    if (log.isDebugEnabled()) {
        log.debug("aggregateDailyStatistics mapReduce for day " + day);
        log.debug("aggregateDailyStatistics mapReduce result counts: " + results.getCounts());
        for (WrappedDailyStatistic wdt : results) {
            log.debug("aggregateDailyStatistics mapReduce result value: " + wdt.getValue());
        }/*from  w  w  w. j  a v  a 2s . co  m*/
    }

    // We've got a result if we've got an output.
    if (results.getCounts().getOutputCount() > 0) {
        return results.iterator().next().getValue();
    }

    // Build and return an empty object otherwise?
    DailyStatistic statistic = new DailyStatistic();
    statistic.setDay(day);
    statistic.setDailyCount(0);
    return statistic;
}

From source file:com.tlantic.integration.authentication.service.security.TokenStoreService.java

@Override
public OAuth2AccessToken readAccessToken(String tokenId) {
    Query query = new Query();
    query.addCriteria(Criteria.where("tokenId").is(tokenId));
    OAuth2AuthenticationAccessToken token = mongoTemplate.findOne(query, OAuth2AuthenticationAccessToken.class,
            "oauth2_access_token");
    if (null == token) {
        throw new InvalidTokenException("Token not valid");
    }//w  w w . j ava2s  .  c  om
    return token.getoAuth2AccessToken();
}

From source file:strat.mining.multipool.stats.persistence.dao.donation.impl.AddressDAOMongo.java

@Override
public List<Address> getAllAddressesSince(Date afterDate) {
    Query query = new Query(Criteria.where("lastUpdated").gt(afterDate));
    return mongoOperation.find(query, Address.class);
}