List of usage examples for com.mongodb BasicDBObjectBuilder get
public DBObject get()
From source file:org.sglover.entities.dao.mongo.MongoEntitiesDAO.java
License:Open Source License
@Override public Stream<Node> matchingNodes(EntityType type, String name) { List<Node> nodes = new LinkedList<>(); QueryBuilder queryBuilder = QueryBuilder.start("t").is(type).and("nm").is(name); DBObject query = queryBuilder.get(); BasicDBObjectBuilder orderByBuilder = BasicDBObjectBuilder.start("c", 1); DBObject orderBy = orderByBuilder.get(); DBCursor cursor = entitiesData.find(query).sort(orderBy); try {//from w ww . j a va 2 s . c o m for (DBObject dbObject : cursor) { String nodeId = (String) dbObject.get("n"); long nodeInternalId = (Long) dbObject.get("ni"); Long nodeVersion = (Long) dbObject.get("v"); Node node = Node.build().nodeInternalId(nodeInternalId).nodeId(nodeId).nodeVersion(nodeVersion); nodes.add(node); } } finally { if (cursor != null) { cursor.close(); } } return nodes.stream(); }
From source file:org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver.java
License:Apache License
private DBObject resolveCompoundIndexKeyFromStringDefinition(String dotPath, String keyDefinitionString) { if (!StringUtils.hasText(dotPath) && !StringUtils.hasText(keyDefinitionString)) { throw new InvalidDataAccessApiUsageException("Cannot create index on root level for empty keys."); }/* ww w . j a v a 2 s .c o m*/ if (!StringUtils.hasText(keyDefinitionString)) { return new BasicDBObject(dotPath, 1); } DBObject dbo = (DBObject) JSON.parse(keyDefinitionString); if (!StringUtils.hasText(dotPath)) { return dbo; } BasicDBObjectBuilder dboBuilder = new BasicDBObjectBuilder(); for (String key : dbo.keySet()) { dboBuilder.add(dotPath + "." + key, dbo.get(key)); } return dboBuilder.get(); }
From source file:org.springframework.data.mongodb.core.query.TextCriteria.java
License:Apache License
@Override public DBObject getCriteriaObject() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); if (StringUtils.hasText(language)) { builder.add("$language", language); }/* w w w . j av a 2 s .c o m*/ if (!terms.isEmpty()) { builder.add("$search", join(terms)); } if (caseSensitive != null) { builder.add("$caseSensitive", caseSensitive); } if (diacriticSensitive != null) { builder.add("$diacriticSensitive", diacriticSensitive); } return new BasicDBObject("$text", builder.get()); }
From source file:org.teiid.translator.mongodb.MongoDBSelectVisitor.java
License:Open Source License
private DBObject buildGeoNearFunction(Function function) { List<Expression> args = function.getParameters(); // Column Name int paramIndex = 0; ColumnDetail column = getExpressionAlias(args.get(paramIndex++)); BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); builder.push(column.documentFieldName); builder.push(function.getName());//ww w . j a v a 2s . co m builder.push("$geometry");//$NON-NLS-1$ builder.add("type", SpatialType.Point.name());//$NON-NLS-1$ // walk the co-ordinates append(args.get(paramIndex++)); BasicDBList coordinates = new BasicDBList(); coordinates.add(this.onGoingExpression.pop()); builder.add("coordinates", coordinates); //$NON-NLS-1$ // maxdistance append(args.get(paramIndex++)); builder.pop().add("$maxDistance", this.onGoingExpression.pop()); //$NON-NLS-1$ return builder.get(); }
From source file:org.teiid.translator.mongodb.MongoDBSelectVisitor.java
License:Open Source License
private DBObject buildGeoFunction(Function function) { List<Expression> args = function.getParameters(); // Column Name int paramIndex = 0; ColumnDetail column = getExpressionAlias(args.get(paramIndex++)); // Type: Point, LineString, Polygon.. append(args.get(paramIndex++));//from w ww.j ava2 s . c o m SpatialType type = SpatialType.valueOf((String) this.onGoingExpression.pop()); BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); builder.push(column.documentFieldName); builder.push(function.getName()); builder.push("$geometry");//$NON-NLS-1$ builder.add("type", type.name());//$NON-NLS-1$ // walk the co-ordinates append(args.get(paramIndex++)); BasicDBList coordinates = new BasicDBList(); coordinates.add(this.onGoingExpression.pop()); builder.add("coordinates", coordinates); //$NON-NLS-1$ return builder.get(); }
From source file:org.wso2.security.tools.util.DatabaseUtils.java
License:Open Source License
private static DBObject getWhereClause_1(String methodName, String className) { BasicDBObjectBuilder whereBuilder = BasicDBObjectBuilder.start(); whereBuilder.append("method_name", methodName); whereBuilder.append("owner_class", className); DBObject where = whereBuilder.get(); System.out.println(where.toString()); return where; }
From source file:uk.ac.ebi.eva.pipeline.io.readers.MongoDbCursorItemReader.java
License:Apache License
private DBObject createDbObjectKeys() { if (fields == null) { return new BasicDBObject(); } else {/*from ww w.j ava 2 s .c o m*/ BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); for (String field : fields) { builder.add(field, 1); } return builder.get(); } }
From source file:usermanager.Main.java
private static DBObject createDBObject(User user) { BasicDBObjectBuilder docBuilder = BasicDBObjectBuilder.start(); docBuilder.append("_id", user.getId()); docBuilder.append("firstName", user.getFirstName()); docBuilder.append("lastName", user.getLastName()); docBuilder.append("email", user.getEmail()); return docBuilder.get(); }
From source file:usermanager.Main.java
private static DBObject updateDBObject(User user) { BasicDBObjectBuilder docBuilder = BasicDBObjectBuilder.start(); docBuilder.append("firstName", user.getFirstName()); docBuilder.append("lastName", user.getLastName()); docBuilder.append("email", user.getEmail()); return docBuilder.get(); }