Example usage for org.springframework.data.mongodb.core.query Query Query

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

Introduction

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

Prototype

public Query(CriteriaDefinition criteriaDefinition) 

Source Link

Document

Creates a new Query using the given CriteriaDefinition .

Usage

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

@Override
public void deleteAddressStats(Integer addressId) {
    Query query = new Query(Criteria.where("addressId").is(addressId));
    mongoOperation.remove(query, AddressStats.class);
}

From source file:data.repository.pragma.mongo.PermanentRepository.java

public boolean existDOByKey(String key, String value) {
    boolean result = repoTemplate.findOne(Query.query(Criteria.where(key).is(value))).equals(null);
    return !result;
}

From source file:com.viz.mkt.dataserviceimplementation.BaseDataServiceImpl.java

@SuppressWarnings("unchecked")
public T findById(String id) {
    T obj = (T) TemplateFactory.TEMPLATE.getMongoTemplate().findOne(
            new Query(Criteria.where(this.collectionName + "Id").is(id)), this.domainClass,
            this.collectionName);
    return obj;//from  w w  w  . java 2 s.c  om
}

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

@Override
public Address getAddress(String address) {
    Query query = new Query(Criteria.where("address").is(address));
    return mongoOperation.findOne(query, Address.class);
}

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

@Override
public List<Transaction> getTransactionsBetween(Date startDate, Date endDate) {
    Query query = new Query(
            Criteria.where("date").lt(endDate).andOperator(Criteria.where("date").gt(startDate)));
    return mongoOperation.find(query, Transaction.class);
}

From source file:com.springsource.html5expense.mongodb.services.ExpenseRepository.java

@Override
public Expense getExpense(Long expenseId) {
    List<Expense> expenseList = mongoTemplate.find(new Query(Criteria.where("expenseId").is(expenseId)),
            Expense.class);
    return expenseList != null && expenseList.size() > 0 ? expenseList.get(0) : null;
}

From source file:data.repository.pragma.mongo.StagingDBRepository.java

public boolean deleteDOByKey(String key, String value) {
    if (stagingDBTemplate.findOne(Query.query(Criteria.where(key).is(value))).equals(null))
        return false;
    else {//from ww w  . ja v a  2  s  . c om
        stagingDBTemplate.delete(Query.query(Criteria.where(key).is(value)));
        return true;
    }
}

From source file:eu.trentorise.smartcampus.unidataservice.controller.rest.CanteenController.java

/**
 * //w  w  w  .j a v a2  s .co  m
 * @param request
 * @param response
 * @param from start date in format yyyy-mm-dd
 * @param to end date in format yyyy-mm-dd
 * @return
 * @throws InvocationException
 */
@RequestMapping(method = RequestMethod.GET, value = "/data/getmenu/{from}/{to}")
public @ResponseBody List<Menu> getMenu(HttpServletRequest request, HttpServletResponse response,
        @PathVariable String from, @PathVariable String to) throws InvocationException {
    try {
        Criteria criteria = new Criteria("date").gte(from).lte(to);
        Query query = new Query(criteria);

        List<Menu> result = mongoTemplate.find(query, Menu.class, "menu");

        return result;
    } catch (Exception e) {
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
    return null;
}

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

@Override
public Scope getScope(final String name) {
    final OpenScienceFrameworkScope scope = this.mongoTemplate
            .findOne(new Query(new Criteria().andOperator(Criteria.where("name").is(name.toLowerCase()),
                    Criteria.where("isActive").is(Boolean.TRUE))), OpenScienceFrameworkScope.class);

    if (scope == null) {
        return null;
    }/*w  w w .  java 2s  .c  om*/

    return new Scope(scope.name, scope.description, Boolean.FALSE);
}

From source file:com.enitalk.controllers.OpentokSessionController.java

@RequestMapping(method = RequestMethod.GET, value = "/session/teacher/{id}", produces = "text/html")
@ResponseBody/* w w w . j a  v  a 2  s. co m*/
public byte[] sessionTeacher(@PathVariable String id, HttpServletResponse res, boolean requireUrl)
        throws IOException {
    byte[] out = null;
    try {
        Query q = Query.query(Criteria.where("ii").is(id).andOperator(Criteria.where("status").is(2)));
        logger.info("Looking for teacher event {}", id);
        HashMap ev = mongo.findOne(q, HashMap.class, "events");
        if (ev == null) {
            return "Sorry, no such event found.".getBytes();
        }

        Date date = (Date) ev.get("dd");
        DateTime scheduled = new DateTime(date.getTime()).toDateTime(DateTimeZone.UTC);
        DateTime nnow = new DateTime(DateTimeZone.UTC);
        int bt = Minutes.minutesBetween(nnow, scheduled).getMinutes();

        logger.info("Scheduled joda {} diff {}", scheduled, bt);

        ObjectNode evJson = jackson.convertValue(ev, ObjectNode.class);

        if (bt > 6) {
            String rs = "You're a bit early, please visit this page at "
                    + scheduled.minusMinutes(5).toString("yyyy/MM/dd HH:mm:ss 'GMT'");
            return rs.getBytes();
        }
        //            
        if (bt < -62) {
            String rs = "It seems that your session has already ended or expired. Please, contact us at ceo@enitalk.com if there seems to be a mistake.";
            return rs.getBytes();
        }

        String url = s3Cache.get(evJson);

        if (!requireUrl) {
            url += "?dest=" + evJson.at("/ii").asText() + "&i=" + evJson.path("ii").asText();
            String signed = signer.signUrl(url, new DateTime().plusMinutes(80));
            res.sendRedirect(signed);
        } else {
            return url.getBytes();
        }
    } catch (Exception e) {
        logger.error(ExceptionUtils.getFullStackTrace(e));
        return "Oops. Something went wrong. Contact us at ceo@enitalk.com".getBytes();
    }
    return out;
}