List of usage examples for com.mongodb BasicDBObject BasicDBObject
public BasicDBObject()
From source file:act.server.MongoDB.java
License:Open Source License
/** * establishes new numbering system for organisms not already in our database * @param name the name of the organism to be added to the database * @return the id of the new organism added to the database *///from w ww .j av a 2 s .co m public Long submitToActOrganismNameDB(String name) { BasicDBObject doc = new BasicDBObject(); Long id = this.dbOrganismNames.count() + ORG_ID_BASE; doc.put("org_id", id); doc.put("name", name); // TODO: support NCBI ids too. if (this.dbOrganismNames == null) { System.out.print("Organism: " + name); return null; } else { this.dbOrganismNames.insert(doc); return id; } }
From source file:act.server.MongoDB.java
License:Open Source License
private static BasicDBObject getObject(String field, Long val) { BasicDBObject singularObj = new BasicDBObject(); singularObj.put(field, val); return singularObj; }
From source file:act.server.MongoDB.java
License:Open Source License
private BasicDBObject getObject(String f1, Long v1, String f2, Float v2) { BasicDBObject o = new BasicDBObject(); o.put(f1, v1);/*from w w w.j a v a 2s .co m*/ o.put(f2, v2); return o; }
From source file:act.server.MongoDB.java
License:Open Source License
private long alreadyEntered(Chemical c) { BasicDBObject query;/* ww w. j a va 2 s . co m*/ String inchi = c.getInChI(); long retId = -1; if (inchi != null) { query = new BasicDBObject(); query.put("InChI", inchi); DBObject o = this.dbChemicals.findOne(query); if (o != null) retId = (Long) o.get("_id"); // checked: db type IS long } return retId; }
From source file:act.server.MongoDB.java
License:Open Source License
private long alreadyEntered(Cofactor cof) { BasicDBObject query;//from w ww. j a v a2 s. co m String inchi = cof.getInChI(); long retId = -1; if (inchi != null) { query = new BasicDBObject(); query.put("InChI", inchi); DBObject o = this.dbCofactors.findOne(query); if (o != null) retId = (Long) o.get("_id"); // checked: db type IS long } return retId; }
From source file:act.server.MongoDB.java
License:Open Source License
private boolean alreadyEntered(Reaction r) { BasicDBObject query = new BasicDBObject(); query.put("_id", r.getUUID()); DBObject o = this.dbReactions.findOne(query); return o != null; // meaning there is at least one document that matches }
From source file:act.server.MongoDB.java
License:Open Source License
private boolean alreadyEntered(PubmedEntry entry, int pmid) { BasicDBObject query = new BasicDBObject(); query.put("_id", pmid); DBObject o = this.dbPubmed.findOne(query); return o != null; }
From source file:act.server.MongoDB.java
License:Open Source License
public List<Long> getRxnsWith(Long reactant, Long product) { BasicDBObject query = new BasicDBObject(); query.put("enz_summary.products.pubchem", product); query.put("enz_summary.substrates.pubchem", reactant); DBCursor cur = this.dbReactions.find(query); List<Long> reactions = new ArrayList<Long>(); while (cur.hasNext()) { DBObject o = cur.next();/* w ww .j av a 2s. co m*/ long id = (Integer) o.get("_id"); // checked: db type IS int reactions.add(id); } cur.close(); return reactions; }
From source file:act.server.MongoDB.java
License:Open Source License
public List<Reaction> getRxnsWithAll(List<Long> reactants, List<Long> products) { if (reactants.size() == 0 && products.size() == 0) { throw new IllegalArgumentException("Reactants and products both empty! Query would return entire DB."); }/* ww w. j a v a 2s .c o m*/ BasicDBObject query = new BasicDBObject(); if (!reactants.isEmpty()) { BasicDBList substrateIds = new BasicDBList(); substrateIds.addAll(reactants); query.put("enz_summary.substrates.pubchem", new BasicDBObject("$all", substrateIds)); } if (!products.isEmpty()) { BasicDBList productIds = new BasicDBList(); productIds.addAll(products); query.put("enz_summary.products.pubchem", new BasicDBObject("$all", productIds)); } DBCursor cur = this.dbReactions.find(query); List<Reaction> reactions = new ArrayList<Reaction>(); try { while (cur.hasNext()) { DBObject o = cur.next(); reactions.add(convertDBObjectToReaction(o)); } } finally { cur.close(); } return reactions; }
From source file:act.server.MongoDB.java
License:Open Source License
public List<Long> getRxnsWithEnzyme(String enzyme, Long org, List<Long> substrates) { BasicDBObject query = new BasicDBObject(); query.put("ecnum", enzyme); query.put("organisms.id", org); for (Long substrate : substrates) { BasicDBObject mainQuery = new BasicDBObject(); mainQuery.put("$ne", substrate); BasicDBList queryList = new BasicDBList(); BasicDBObject productQuery = new BasicDBObject(); productQuery.put("enz_summary.products.pubchem", mainQuery); BasicDBObject substrateQuery = new BasicDBObject(); substrateQuery.put("enz_summary.substrates.pubchem", mainQuery); queryList.add(substrateQuery);/*from w w w. j a v a 2 s . c o m*/ queryList.add(productQuery); query.put("$or", queryList); } DBCursor cur = this.dbReactions.find(query); List<Long> reactions = new ArrayList<Long>(); while (cur.hasNext()) { DBObject o = cur.next(); long id = (Integer) o.get("_id"); // checked: db type IS int reactions.add(id); } cur.close(); return reactions; }