List of usage examples for com.mongodb BasicDBObjectBuilder BasicDBObjectBuilder
public BasicDBObjectBuilder()
From source file:org.ff4j.store.mongodb.PropertyDBObjectBuilder.java
License:Apache License
/** * Mongo internal object representing attribute 'strategy'. * * @param value// ww w. ja v a 2s . com * target value * @return * internal mong object */ public DBObject getValue(String value) { return new BasicDBObjectBuilder().add(PROPERTY_VALUE, value).get(); }
From source file:org.ff4j.store.mongodb.PropertyDBObjectBuilder.java
License:Apache License
/** * Mongo internal object representing attribute 'expression'. * /*w w w .ja v a2s. c om*/ * @param value * target value * @return internal mongo object */ public DBObject getFixedValues(String value) { return new BasicDBObjectBuilder().add(PROPERTY_FIXEDVALUES, value).get(); }
From source file:org.ff4j.store.PropertyStoreMongoDB.java
License:Apache License
/** {@inheritDoc} */ public Set<String> listPropertyNames() { Set<String> properties = new HashSet<String>(); for (DBObject dbObject : collection.find(new BasicDBObject(), new BasicDBObjectBuilder().add(PROPERTY_NAME, true).get())) { properties.add((String) dbObject.get(PROPERTY_NAME)); }/*from w w w. j a va 2 s. c om*/ return properties; }
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."); }/*from w w w. j av 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); }/*from w ww . j a v a2 s .com*/ 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.springframework.data.mongodb.test.util.MongoVersionRule.java
License:Apache License
private void initCurrentVersion() { if (currentVersion == null) { try {/*from w w w. ja v a 2 s .com*/ MongoClient client; client = new MongoClient(host, port); DB db = client.getDB("test"); CommandResult result = db.command(new BasicDBObjectBuilder().add("buildInfo", 1).get()); this.currentVersion = Version.parse(result.get("version").toString()); } catch (Exception e) { e.printStackTrace(); } } }
From source file:v7cr.ProjectEditor.java
License:Open Source License
public void buttonClick(ClickEvent event) { rightSide.removeAllComponents();/*from w ww . j ava 2 s .c om*/ final DBObject b = new BasicDBObject(); Project p = new Project(new BSONBackedObject()); final Form form = new Form(); form.setWidth("100%"); rightSide.addComponent(form); form.setFormFieldFactory(new BSONFormFieldFactory(p.getSchemaDefinition())); form.setItemDataSource(new BSONItem(b, p.getSchemaDefinition())); form.setVisibleItemProperties(new String[] { "_id", "name", "repo", "viewChanges" }); V7CR v7 = V7CR.getInstance(); Button submit = new Button(v7.getMessage("button.create")); rightSide.addComponent(submit); submit.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { form.commit(); V7CR v7 = V7CR.getInstance(); v7.insert("projects", b); // also create the member role DBObject r = new BasicDBObjectBuilder().add("_id", "project:" + b.get("_id")) .add("name", "Reviewers of project '" + b.get("_id") + "'").get(); v7.insert("roles", r); rightSide.removeAllComponents(); reload(v7); } }); }