List of usage examples for com.mongodb BasicDBObject BasicDBObject
public BasicDBObject()
From source file:act.server.MongoDB.java
License:Open Source License
public void updateEstimatedEnergy(Chemical chemical) { BasicDBObject query = new BasicDBObject().append("_id", chemical.getUuid()); DBObject obj = this.dbChemicals.findOne(query); obj.put("estimateEnergy", chemical.getEstimatedEnergy()); this.dbChemicals.update(query, obj); }
From source file:act.server.MongoDB.java
License:Open Source License
public void updateEstimatedEnergy(Reaction reaction) { BasicDBObject query = new BasicDBObject().append("_id", reaction.getUUID()); DBObject obj = this.dbReactions.findOne(query); obj.put("estimateEnergy", reaction.getEstimatedEnergy()); this.dbReactions.update(query, obj); }
From source file:act.server.MongoDB.java
License:Open Source License
public void updateReactionRefsOf(Seq seq) { BasicDBObject query = new BasicDBObject().append("_id", seq.getUUID()); DBObject obj = this.dbSeq.findOne(query); BasicDBList refs = new BasicDBList(); for (Long r : seq.getReactionsCatalyzed()) refs.add(r);/* w w w . java2s.co m*/ obj.put("rxn_refs", refs); this.dbSeq.update(query, obj); }
From source file:act.server.MongoDB.java
License:Open Source License
public void updateKeywordsCascade(Long id, Set<String> kwrds, Set<String> ciKwrds) { BasicDBObject query = new BasicDBObject().append("_id", id); DBObject obj = this.dbCascades.findOne(query); obj.put("keywords", kwrds); obj.put("keywords_case_insensitive", ciKwrds); this.dbCascades.update(query, obj); }
From source file:act.server.MongoDB.java
License:Open Source License
public void updateKeywordsWaterfall(Long id, Set<String> kwrds, Set<String> ciKwrds) { BasicDBObject query = new BasicDBObject().append("_id", id); DBObject obj = this.dbWaterfalls.findOne(query); obj.put("keywords", kwrds); obj.put("keywords_case_insensitive", ciKwrds); this.dbWaterfalls.update(query, obj); }
From source file:act.server.MongoDB.java
License:Open Source License
public void updateKeywords(Reaction reaction) { BasicDBObject query = new BasicDBObject().append("_id", reaction.getUUID()); DBObject obj = this.dbReactions.findOne(query); obj.put("keywords", reaction.getKeywords()); obj.put("keywords_case_insensitive", reaction.getCaseInsensitiveKeywords()); this.dbReactions.update(query, obj); }
From source file:act.server.MongoDB.java
License:Open Source License
public void updateActReaction(Reaction r, int id) { // db.collection.update(query, update, options) // updates document(s) that match query with the update doc // Ref: http://docs.mongodb.org/manual/reference/method/db.collection.update/ ///*from w w w . j a va 2s . c om*/ // Update doc: Can be { $set : { <field> : <val> } } // in case you need to keep the old document, but just update // some fields inside of it. // Ref: http://docs.mongodb.org/manual/reference/operator/update/set/ // // But here (and in updateActChemical) we want to overwrite // the entire document with a new one, and so // a simple update call with the new document is what we need. BasicDBObject doc = createReactionDoc(r, id); DBObject query = new BasicDBObject(); query.put("_id", id); this.dbReactions.update(query, doc); }
From source file:act.server.MongoDB.java
License:Open Source License
public static BasicDBObject createReactionDoc(Reaction r, int id) { BasicDBObject doc = new BasicDBObject(); doc.put("_id", id); doc.put("ecnum", r.getECNum()); doc.put("easy_desc", r.getReactionName()); BasicDBList substr = new BasicDBList(); Long[] ss = r.getSubstrates(); for (int i = 0; i < ss.length; i++) { DBObject o = getObject("pubchem", ss[i]); o.put("coefficient", r.getSubstrateCoefficient(ss[i])); substr.put(i, o);/* w ww . j av a 2s. c om*/ } BasicDBList prods = new BasicDBList(); Long[] pp = r.getProducts(); for (int i = 0; i < pp.length; i++) { DBObject o = getObject("pubchem", pp[i]); o.put("coefficient", r.getProductCoefficient(pp[i])); prods.put(i, o); } BasicDBList prodCofactors = new BasicDBList(); Long[] ppc = r.getProductCofactors(); for (int i = 0; i < ppc.length; i++) { DBObject o = getObject("pubchem", ppc[i]); prodCofactors.put(i, o); } BasicDBList substrCofactors = new BasicDBList(); Long[] ssc = r.getSubstrateCofactors(); for (int i = 0; i < ssc.length; i++) { DBObject o = getObject("pubchem", ssc[i]); substrCofactors.put(i, o); } BasicDBList coenzymes = new BasicDBList(); Long[] coenz = r.getCoenzymes(); for (int i = 0; i < coenz.length; i++) { DBObject o = getObject("pubchem", coenz[i]); coenzymes.put(i, o); } BasicDBObject enz = new BasicDBObject(); enz.put("products", prods); enz.put("substrates", substr); enz.put("product_cofactors", prodCofactors); enz.put("substrate_cofactors", substrCofactors); enz.put("coenzymes", coenzymes); doc.put("enz_summary", enz); doc.put("is_abstract", r.getRxnDetailType().name()); if (r.getDataSource() != null) doc.put("datasource", r.getDataSource().name()); if (r.getMechanisticValidatorResult() != null) { doc.put("mechanistic_validator_result", MongoDBToJSON.conv(r.getMechanisticValidatorResult())); } BasicDBList refs = new BasicDBList(); for (P<Reaction.RefDataSource, String> ref : r.getReferences()) { BasicDBObject refEntry = new BasicDBObject(); refEntry.put("src", ref.fst().toString()); refEntry.put("val", ref.snd()); refs.add(refEntry); } doc.put("references", refs); BasicDBList proteins = new BasicDBList(); for (JSONObject proteinData : r.getProteinData()) { proteins.add(MongoDBToJSON.conv(proteinData)); } doc.put("proteins", proteins); ConversionDirectionType cd = r.getConversionDirection(); doc.put("conversion_direction", cd == null ? null : cd.toString()); StepDirection psd = r.getPathwayStepDirection(); doc.put("pathway_step_direction", psd == null ? null : psd.toString()); return doc; }
From source file:act.server.MongoDB.java
License:Open Source License
public void submitToActOrganismDB(Organism o) { BasicDBObject doc = new BasicDBObject(); doc.put("_id", o.getUUID()); doc.put("parent_id", o.getParent()); doc.put("rank", o.getRank()); if (this.dbOrganisms == null) { System.out.print("Organism: " + o); } else {/*from w w w . j av a 2s.c o m*/ this.dbOrganisms.insert(doc); } }
From source file:act.server.MongoDB.java
License:Open Source License
public void submitToActOrganismNameDB(Organism o) { BasicDBObject doc = new BasicDBObject(); doc.put("org_id", o.getUUID()); doc.put("name", o.getName()); // TODO: support NCBI ids too. if (this.dbOrganismNames == null) { System.out.print("Organism: " + o); } else {/*from www .java 2s . c o m*/ this.dbOrganismNames.insert(doc); } }