List of usage examples for org.springframework.data.mongodb.core.query Query Query
public Query(CriteriaDefinition criteriaDefinition)
From source file:eu.trentorise.smartcampus.communicatorservice.manager.UserAccountManager.java
/** * retrieves all the {@link UserAccount} of a given user * /*from ww w. j av a 2 s . c o m*/ * @param uid * id of the owner of user storage accounts * @return a list of UserAccount of the given user id */ public List<UserAccount> findBy(long userid) { Criteria criteria = new Criteria(); criteria = criteria.and("userId").is(userid); return db.find(Query.query(criteria), UserAccount.class); }
From source file:quanlyhocvu.api.mongodb.DAO.LopHocDAO.java
public List<LopHocDTO> getLopHocTheoNamHoc(String namHocId) { Query query = Query.query(Criteria.where("namHoc.$id").is(new ObjectId(namHocId))); return mongoOperation.find(query, LopHocDTO.class); }
From source file:se.inera.axel.shs.broker.messagestore.internal.MongoMessageLogAdminService.java
@Override public int countMessages(Filter filter) { Criteria criteria = buildCriteria(filter); Query query = Query.query(criteria); return (int) mongoTemplate.count(query, ShsMessageEntry.class); }
From source file:org.shredzone.flufftron.repository.PersonDao.java
/** * Finds all {@link Person} who have not or not recently received a fluff. Returns all * unfluffed persons, followed by all least recently fluffed persons. * <p>// w w w. jav a2 s.com * If there are more than {@code max} unfluffed persons, the unfluffed persons are * returned in no certain order. * * @param max * Maximum number of returned persons. * @return List of {@link Person} */ public List<Person> findUnfluffed(int max) { Query q; List<Person> result = new ArrayList<Person>(max); // First find all unfluffed persons q = new Query(where("timeline.lastFluff").exists(false)).limit(max); result.addAll(mongoOperations.find(q, Person.class)); // Now fill up with last recently fluffed persons if (result.size() < max) { q = new Query(where("timeline.lastFluff").exists(true)).limit(max - result.size()); q.sort().on("timeline.lastFluff", Order.ASCENDING); result.addAll(mongoOperations.find(q, Person.class)); } return result; }
From source file:quanlyhocvu.api.mongodb.DAO.HocSinhDAO.java
public List<HocSinhDTO> getHocSinhChuaXepLopTheoKhoiLop(String khoiLopId) { Query query = Query .query(Criteria.where("maLopHoc").is(null).and("khoiLopHienTai.$id").is(new ObjectId(khoiLopId))); return mongoOperations.find(query, HocSinhDTO.class); }
From source file:uk.gov.nationalarchives.discovery.taxonomy.common.repository.mongo.impl.IAViewUpdateRepositoryImpl.java
@Override public void findAndRemoveByDocReference(String docReference) { Query query = new Query(Criteria.where(IAViewUpdate.FIELD_DOCREFERENCE).is(docReference)); mongoTemplate.remove(query, IAViewUpdate.class); }
From source file:eu.cloudwave.wp5.feedbackhandler.repositories.MetricRepositoryImpl.java
/** * {@inheritDoc}/* ww w . jav a2s . com*/ */ @Override public List<? extends ProcedureExecutionMetric> find(final DbApplication application, final String className, final String procedureName, final String[] procedureArguments) { final Criteria criteria = new Criteria(APPLICATION).is(application).and(PROC__CLASS_NAME).is(className) .and(PROC__NAME).is(procedureName).and(PROC__ARGUMENTS).is(procedureArguments); final Sort sort = new Sort(Sort.Direction.ASC, TIMESTAMP); final Query query = new Query(criteria).with(sort); return mongoTemplate.find(query, DbProcedureExecutionMetricImpl.class, DbTableNames.METRICS); }
From source file:com.comcast.video.dawg.service.pound.DawgPoundMongoService.java
@SuppressWarnings("unchecked") @Override/*from w w w .java2 s . c o m*/ public Map<String, Object>[] getByReserver(String token) { List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); Criteria c = new Criteria("reserver").is(token); Query q = new Query(c); Collection<? extends DawgDevice> col = mongoTemplate.find(q, PersistableDevice.class, COLLECTION_NAME); for (DawgDevice device : col) { list.add(device.getData()); } return list.toArray(new Map[list.size()]); }
From source file:org.cbioportal.session_service.domain.internal.SessionRepositoryImpl.java
public int deleteBySourceAndTypeAndId(String source, String type, String id) { return this.mongoTemplate .remove(new Query(Criteria.where("source").is(source).and("type").is(type).and("id").is(id)), Session.class, type) .getN();/* w ww . ja v a 2 s . c om*/ }
From source file:com.enitalk.opentok.OpenTokListener.java
@Override @RabbitListener(queues = "tokbox") public void onMessage(Message msg) { try {/*w w w . ja v a 2s.c o m*/ ObjectNode tree = (ObjectNode) jackson.readTree(msg.getBody()); logger.info("Tokbox status came {}", tree); Query q = Query.query(Criteria.where("sessionId").is(tree.path("sessionId").asText())); HashMap event = mongo.findOne(q, HashMap.class, "events"); if (event != null) { String status = tree.path("status").asText(); ObjectNode evJson = jackson.convertValue(event, ObjectNode.class); HashMap item = jackson.convertValue(tree, HashMap.class); item.put("came", new Date()); Update update = new Update().push("opentok", item); switch (status) { case "uploaded": logger.info("Video uploaded for event {} ", evJson.path("ii").asText()); break; case "paused": logger.info("Paused event {}", evJson.path("ii").asText()); break; default: } mongo.updateFirst(q, update, "events"); } } catch (Exception e) { logger.info(ExceptionUtils.getFullStackTrace(e)); } finally { } }