List of usage examples for com.mongodb QueryBuilder put
public QueryBuilder put(final String key)
From source file:net.atos.entng.wiki.service.WikiServiceMongoImpl.java
License:Open Source License
@Override public void deleteRevisions(String wikiId, String pageId, Handler<Either<String, JsonObject>> handler) { QueryBuilder query = QueryBuilder.start("wikiId").is(wikiId); if (pageId != null && !pageId.trim().isEmpty()) { query.put("pageId").is(pageId); }/*from www . j ava 2 s . c o m*/ mongo.delete(REVISIONS_COLLECTION, MongoQueryBuilder.build(query), MongoDbResult.validResultHandler(handler)); }
From source file:org.entcore.common.service.impl.MongoDbCrudService.java
License:Open Source License
@Override public void retrieve(String id, UserInfos user, Handler<Either<String, JsonObject>> handler) { QueryBuilder builder = QueryBuilder.start("_id").is(id); if (user == null) { builder.put("visibility").is(VisibilityFilter.PUBLIC.name()); }//from ww w . j a v a 2 s . com mongo.findOne(collection, MongoQueryBuilder.build(builder), defaultRetrieveProjection, validResultHandler(handler)); }
From source file:org.entcore.timeline.services.impl.FlashMsgServiceMongoImpl.java
License:Open Source License
@Override public void listForUser(UserInfos user, String lang, String domain, Handler<Either<String, JsonArray>> handler) { String profile = user.getType(); String now = mongoFormat.format(new Date()); QueryBuilder query = QueryBuilder.start("contents." + lang).exists(true); query.put("contents." + lang).notEquals(""); query.put("profiles").is(profile); query.put("markedAsRead").notEquals(user.getUserId()); query.put("startDate").lessThanEquals(now); query.put("endDate").greaterThan(now); query.put("domain").is(domain); JsonObject sort = new JsonObject().put("modified", -1); JsonObject keys = new JsonObject().put("contents", 1).put("color", 1).put("customColor", 1); //Eventually add a limit. mongo.find(collection, MongoQueryBuilder.build(query), sort, keys, MongoDbResult.validResultsHandler(handler)); }
From source file:org.entcore.workspace.service.impl.DefaultFolderService.java
License:Open Source License
@Override public void list(String path, UserInfos owner, boolean hierarchical, String filter, final Handler<Either<String, JsonArray>> results) { if (owner == null) { results.handle(new Either.Left<String, JsonArray>("workspace.invalid.user")); return;/* ww w . j av a2 s . co m*/ } QueryBuilder q = QueryBuilder.start(); if ("shared".equals(filter)) { List<DBObject> groups = new ArrayList<>(); groups.add(QueryBuilder.start("userId").is(owner.getUserId()).get()); for (String gpId : owner.getGroupsIds()) { groups.add(QueryBuilder.start("groupId").is(gpId).get()); } q.put("shared").elemMatch(new QueryBuilder().or(groups.toArray(new DBObject[groups.size()])).get()); } else { q.put("owner").is(owner.getUserId()); } q.and("file").exists(false).and("application").is(WorkspaceService.WORKSPACE_NAME); if (path != null && !path.trim().isEmpty()) { if (hierarchical) { q = q.put("folder").regex(Pattern.compile("^" + Pattern.quote(path) + "_[^_]+$")); } else { q = q.put("folder").regex(Pattern.compile("^" + Pattern.quote(path) + "_")); } } else if (hierarchical) { q = q.put("folder").regex(Pattern.compile("^[^_]+$")); } mongo.find(DOCUMENTS_COLLECTION, MongoQueryBuilder.build(q), new Handler<Message<JsonObject>>() { @Override public void handle(Message<JsonObject> res) { results.handle(Utils.validResults(res)); } }); }