List of usage examples for com.mongodb BasicDBObject parse
public static BasicDBObject parse(final String json)
From source file:com.picdrop.repository.mongo.MorphiaRepository.java
protected DBObject compileQuery(String qname, Object... params) throws IOException { String rawquery = this.namedQueries.get(qname); if (rawquery == null) { throw new IllegalArgumentException("Query not found"); }//from www .j ava 2 s. c o m if (params.length > 0) { int i = 0; for (Object p : params) { rawquery = rawquery.replaceAll(String.format("[?]%s", i), Matcher.quoteReplacement(mapper.writeValueAsString(p))); i++; } } return BasicDBObject.parse(rawquery); }
From source file:hulop.hokoukukan.utils.MongoAdapter.java
License:Open Source License
@Override public void insert(String json) { synchronized (insertList) { insertList.add(BasicDBObject.parse(json)); }/*from w ww.j a v a2 s . c o m*/ if (insertList.size() >= 1000) { flush(); } }
From source file:hulop.hokoukukan.utils.MongoAdapter.java
License:Open Source License
@Override public void update(String json) { mapCol.save(BasicDBObject.parse(json)); }
From source file:hulop.hokoukukan.utils.MongoAdapter.java
License:Open Source License
@Override public void setOBJ(JSONObject obj) { mapCol.save(BasicDBObject.parse(obj.toString())); }
From source file:hulop.hokoukukan.utils.MongoAdapter.java
License:Open Source License
@Override public void updateUser(String json) { userCol.save(BasicDBObject.parse(json)); }
From source file:hulop.hokoukukan.utils.MongoAdapter.java
License:Open Source License
@Override public void insertLog(String json) { synchronized (insertLogList) { insertLogList.add(BasicDBObject.parse(json)); }//ww w . j a v a 2 s. c o m if (insertLogList.size() >= 1000) { flush(); } }
From source file:hulop.hokoukukan.utils.MongoAdapter.java
License:Open Source License
@Override public void setEntry(JSONObject entry) { entryCol.save(BasicDBObject.parse(entry.toString())); }
From source file:org.hibernate.ogm.datastore.mongodb.impl.MongoDBSchemaDefiner.java
License:LGPL
private DBObject getIndexOptionDBObject(Table table, IndexOption indexOption) { try {//from www.j a va 2 s .co m BasicDBObject options; if (StringHelper.isNullOrEmptyString(indexOption.getOptions())) { options = new BasicDBObject(); } else { options = BasicDBObject.parse(indexOption.getOptions()); } options.put("name", indexOption.getTargetIndexName()); return options; } catch (Exception e) { throw log.invalidOptionsFormatForIndex(table.getName(), indexOption.getTargetIndexName(), e); } }
From source file:pt.ua.cbd.cbd_project.service.BookServiceMongo.java
public Book addNewBook(Book book) { JSONObject jsonObject = new JSONObject(); jsonObject.put("authors", book.getAuthorsArray()); jsonObject.put("id", book.getId()); jsonObject.put("title", book.getTitle()); jsonObject.put("addToLibraryDate", book.getAddToLibraryDate()); String jsonFormattedString = jsonObject.toString().replaceAll("\\\\", ""); BasicDBObject dbObject = (BasicDBObject.parse(jsonFormattedString)); MongoCollection<BasicDBObject> coll = db.getCollection("book", BasicDBObject.class); coll.insertOne(dbObject);/*from w w w . ja v a 2s . co m*/ return book; }