List of usage examples for com.mongodb.util JSON parse
public static Object parse(final String jsonString)
Parses a JSON string and returns a corresponding Java object.
From source file:com.ebay.cloud.cms.metadata.mongo.converter.ObjectConverter.java
License:Apache License
public DBObject toBson(T object) { String json = toJson(object); return (DBObject) JSON.parse(json); }
From source file:com.ebay.oss.bark.repo.BaseRepo.java
License:Apache License
@Override final public void save(T t) { Gson gson = new Gson(); DBObject t1 = (DBObject) JSON.parse(gson.toJson(t)); dbCollection.save(t1); }
From source file:com.ebay.oss.bark.repo.DataAssetRepoImpl.java
License:Apache License
@Override public void update(DataAsset entity, DBObject old) { Gson gson = new Gson(); // DBObject t1 = gson.fromJson(gson.toJson(entity), // BasicDBObject.class); DBObject t1 = (DBObject) JSON.parse(gson.toJson(entity)); dbCollection.remove(old);//from w ww . ja v a 2 s.com dbCollection.save(t1); }
From source file:com.ebay.oss.bark.repo.DqJobRepoImpl.java
License:Apache License
@Override public int newJob(DqJob job) { try {//from www . j a v a 2 s .c o m DBObject temp = dboOf(job); if (temp != null) return 0; Gson gson = new Gson(); DBObject t1 = (DBObject) JSON.parse(gson.toJson(job)); dbCollection.save(t1); return 1; } catch (Exception e) { logger.warn("===========insert new job error===============" + e.getMessage()); return 0; } }
From source file:com.ebay.oss.bark.repo.DqMetricsRepoImpl.java
License:Apache License
@Override public void update(DqMetricsValue entity, DBObject old) { Gson gson = new Gson(); // DBObject t1 = gson.fromJson(gson.toJson(entity), // BasicDBObject.class); DBObject t1 = (DBObject) JSON.parse(gson.toJson(entity)); dbCollection.update(old, t1);/*ww w .j av a 2 s . co m*/ }
From source file:com.ebay.oss.bark.repo.DqModelRepoImpl.java
License:Apache License
@Override public DqModel update(DqModel entity) { DBObject temp = dbCollection.findOne(new BasicDBObject("modelId", entity.getModelName())); if (temp != null) { dbCollection.remove(temp);/* www . ja va2 s .c om*/ } Gson gson = new Gson(); DBObject t1 = (DBObject) JSON.parse(gson.toJson(entity)); dbCollection.save(t1); return toEntity(t1); }
From source file:com.ebay.oss.bark.repo.DqScheudleRepoImpl.java
License:Apache License
@Override public void updateByModelType(DqSchedule schedule, int type) { DBObject dbo = null;//from w w w.j a v a 2 s .c om if (type == ModelType.ACCURACY) { dbo = dbCollection.findOne(new BasicDBObject("modelList", schedule.getModelList())); } else if (type == ModelType.VALIDITY) { dbo = getValiditySchedule(schedule.getAssetId()); } if (dbo != null) { dbCollection.remove(dbo); } Gson gson = new Gson(); DBObject t1 = (DBObject) JSON.parse(gson.toJson(schedule)); dbCollection.save(t1); }
From source file:com.ebay.oss.bark.repo.UserSubscriptionRepoImpl.java
License:Apache License
@Override public void upsertUserSubscribe(UserSubscription item) { if (item.getNtaccount() == null) return;/*w ww .j av a2 s. c om*/ item.setId(item.getNtaccount());// user_subscribe DBObject find = dbCollection.findOne(new BasicDBObject("_id", item.getId())); if (find != null) dbCollection.remove(find); Gson gson = new Gson(); DBObject t1 = (DBObject) JSON.parse(gson.toJson(item)); dbCollection.save(t1); }
From source file:com.edgytech.umongo.AggregateDialog.java
License:Apache License
@Override protected void updateComponentCustom(JDialog old) { BasicDBObject cmd = (BasicDBObject) JSON.parse(pipeline); if (cmd != null && cmd.containsField("pipeline")) { BasicDBList list = (BasicDBList) cmd.get("pipeline"); operationList.clear();/*from w ww .j a va 2 s. com*/ for (Object op : list) { operationList.add((BasicDBObject) op); } refreshAggList(); } }
From source file:com.edgytech.umongo.CollectionPanel.java
License:Apache License
public void editTagRange(ButtonBase button) { final DB config = getCollectionNode().getCollection().getDB().getSisterDB("config"); final DBCollection col = config.getCollection("tags"); final String ns = getCollectionNode().getCollection().getFullName(); TagRangeDialog dia = (TagRangeDialog) getBoundUnit(Item.tagRangeDialog); String value = getComponentStringFieldValue(Item.tagRangeList); BasicDBObject range = (BasicDBObject) JSON.parse(value); dia.resetForEdit(config, range);/* w w w . j a v a 2 s.c om*/ if (!dia.show()) { return; } final BasicDBObject doc = dia.getRange(ns); new DbJob() { @Override public Object doRun() { return col.save(doc); } @Override public String getNS() { return ns; } @Override public String getShortName() { return "Edit Tag Range"; } @Override public DBObject getRoot(Object result) { BasicDBObject root = new BasicDBObject("doc", doc); return root; } @Override public void wrapUp(Object res) { super.wrapUp(res); refreshTagRangeList(); } }.addJob(); }