List of usage examples for org.springframework.data.mongodb.core.query Criteria where
public static Criteria where(String key)
From source file:com.pubkit.platform.persistence.impl.ApplicationDaoImpl.java
public Application findByApplicationName(String applicationName) { Criteria criteria = Criteria.where("applicationName").is(applicationName); return mongoTemplate.findOne(Query.query(criteria), Application.class); }
From source file:eu.trentorise.smartcampus.profileservice.storage.ProfileStorage.java
public List<ExtendedProfile> findExtendedProfiles(String profileId, Map<String, Object> profileAttrs) { Criteria criteria = new Criteria(); criteria = Criteria.where("content.profileId").is(profileId); for (String key : profileAttrs.keySet()) { criteria.and("content.content." + key).is(profileAttrs.get(key)); }//w w w.j a v a 2s.c o m criteria.and("type").is(ExtendedProfile.class.getCanonicalName()); criteria.and("deleted").is(false); List<ExtendedProfile> profiles = find(Query.query(criteria), ExtendedProfile.class); return profiles; }
From source file:net.cit.tetrad.utility.QueryUtils.java
public static Query setGroupCode(CommonDto dto) { Query query = new Query(); if (dto.getGroupCode() != 0) query.addCriteria(Criteria.where("groupCode").is(dto.getGroupCode())); if (!Utility.isNull(dto.getType()).equals("")) query.addCriteria(Criteria.where("type").is(dto.getType())); if (!Utility.isNull(dto.getSort()).equals("")) { if (Utility.isNull(dto.getSort()).equals("asc")) { query.sort().on(dto.getSortItem(), Order.ASCENDING); } else if (Utility.isNull(dto.getSort()).equals("desc")) { query.sort().on(dto.getSortItem(), Order.DESCENDING); }//from ww w . jav a 2s . c o m } return query; }
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; }// www . ja v a 2s . co m return new Scope(scope.name, scope.description, Boolean.FALSE); }
From source file:app.data.local.CollectionBindingRepositoryImpl.java
@Override public void removeFavor(long colId, String uid) { Query query = new Query(); query.addCriteria(/* w w w. j a v a2 s. c o m*/ Criteria.where("collectionId").is(colId).and("favors").elemMatch(Criteria.where("uid").is(uid))); Update update = new Update(); //update.unset("dataList.$"); //mMongoTemplate.upsert(query, update, Favor.class); // http://stackoverflow.com/questions/35600557/mongodb-how-using-spring-cryteria-remove-element-from-nested-object-array // http://ufasoli.blogspot.fr/2012/09/mongodb-spring-data-remove-elements.html?view=sidebar update.pull("favors", new BasicDBObject("uid", uid)); mMongoTemplate.updateMulti(query, update, CollectionBinding.class); }
From source file:com.enitalk.controllers.OpentokSessionController.java
@RequestMapping(method = RequestMethod.GET, value = "/session/teacher/{id}", produces = "text/html") @ResponseBody/*from ww w . j a va 2 s. c om*/ 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; }
From source file:com.epam.ta.reportportal.database.search.ModifiableQueryBuilder.java
/** * Find entities modified lately//from w ww .ja v a 2s .c o m * * @param period * @return */ public static Query findModifiedLately(final Time period) { return Query.query(Criteria.where(Modifiable.LAST_MODIFIED).gt( DateUtils.addSeconds(Calendar.getInstance().getTime(), (int) (-1 * period.in(TimeUnit.SECONDS))))); }
From source file:data.repository.pragma.mongo.PermanentRepository.java
public GridFSDBFile findDOByKey(String key, String value) { return repoTemplate.findOne(Query.query(Criteria.where(key).is(value))); }
From source file:com.traffitruck.service.MongoDAO.java
public List<Alert> getUserAlerts(String username) { Query q = new Query().addCriteria(Criteria.where("username").is(username)); return mongoTemplate.find(q, Alert.class); }
From source file:no.nlf.dal.LicenseController.java
public License delete(int id) { Query searchQuery = new Query(Criteria.where("id").is(id)); MongoLicense mongoLicense = appContext.mongoOperation().findOne(searchQuery, MongoLicense.class); if (mongoLicense == null) { return new License(); }// ww w.ja va 2 s .c o m appContext.mongoOperation().remove(mongoLicense); return mongoLicense.toLicense(); }