List of usage examples for com.mongodb BasicDBObject BasicDBObject
public BasicDBObject()
From source file:act.server.MongoDB.java
License:Open Source License
private Cofactor getCofactorFromDB(String field, Object val) { BasicDBObject query = new BasicDBObject(); query.put(field, val); BasicDBObject keys = new BasicDBObject(); DBObject o = this.dbCofactors.findOne(query, keys); if (o == null) return null; return convertDBObjectToCofactor(o); }
From source file:act.server.MongoDB.java
License:Open Source License
public Reaction getReactionFromUUID(Long reactionUUID) { if (reactionUUID < 0) { throw new RuntimeException(String.format( "getReactionFromUUID called with a negaive number (%d). It used to reverse the reaction.", reactionUUID));//from w w w . j a v a2 s.c om } BasicDBObject query = new BasicDBObject(); query.put("_id", reactionUUID); BasicDBObject keys = new BasicDBObject(); DBObject o = this.dbReactions.findOne(query, keys); if (o == null) return null; return convertDBObjectToReaction(o); }
From source file:act.server.MongoDB.java
License:Open Source License
public Iterator<Seq> getSeqIterator(BasicDBObject query) { final DBIterator iter = getDbIteratorOverSeq(query, new BasicDBObject()); return new Iterator<Seq>() { @Override//from ww w .ja va2 s . c o m public boolean hasNext() { boolean hasNext = iter.hasNext(); if (!hasNext) iter.close(); return hasNext; } @Override public Seq next() { DBObject o = iter.next(); return convertDBObjectToSeq(o); } }; }
From source file:act.server.MongoDB.java
License:Open Source License
public BasicDBObject getRangeUUIDRestriction(Long lowUUID, Long highUUID) { BasicDBObject restrictTo = new BasicDBObject(); // need to encode { "_id" : { $gte : lowUUID, $lte : highUUID } } BasicDBObject range = new BasicDBObject(); if (lowUUID != null) range.put("$gte", lowUUID); if (highUUID != null) range.put("$lte", highUUID); restrictTo.put("_id", range); return restrictTo; }
From source file:act.server.MongoDB.java
License:Open Source License
public List<Long> getAllCollectionUUIDs(DBCollection collection) { List<Long> ids = new ArrayList<Long>(); BasicDBObject query = new BasicDBObject(); BasicDBObject keys = new BasicDBObject(); keys.put("_id", 1); // 0 means exclude, rest are included DBCursor cur = collection.find(query, keys); while (cur.hasNext()) { DBObject o = cur.next();//from w ww. j a v a 2 s. c o m long uuid = (Integer) o.get("_id"); // checked: db type IS int ids.add(uuid); } cur.close(); return ids; }
From source file:act.server.MongoDB.java
License:Open Source License
public Seq getSeqFromID(Long seqID) { BasicDBObject query = new BasicDBObject(); query.put("_id", seqID); BasicDBObject keys = new BasicDBObject(); DBObject o = this.dbSeq.findOne(query, keys); if (o == null) return null; return convertDBObjectToSeq(o); }
From source file:act.server.MongoDB.java
License:Open Source License
public List<Seq> getSeqFromSeqEcOrg(String seq, String ec, String organism) { List<Seq> seqs = new ArrayList<>(); BasicDBObject query = new BasicDBObject(); query.put("seq", seq); query.put("ecnum", ec); query.put("org", organism); DBCursor cur = this.dbSeq.find(query, new BasicDBObject()); try {//from w w w .j av a 2 s. com while (cur.hasNext()) { DBObject o = cur.next(); seqs.add(convertDBObjectToSeq(o)); } } finally { if (cur != null) { cur.close(); } } return seqs; }
From source file:act.server.MongoDB.java
License:Open Source License
public List<Seq> getSeqFromGenbankProtAccession(String accession) { List<Seq> seqs = new ArrayList<>(); BasicDBObject query = new BasicDBObject(); query.put("metadata.accession.genbank_protein", new BasicDBObject("$elemMatch", new BasicDBObject("$eq", accession))); DBCursor cur = this.dbSeq.find(query, new BasicDBObject()); try {//from ww w . j a va2 s . c o m while (cur.hasNext()) { DBObject o = cur.next(); seqs.add(convertDBObjectToSeq(o)); } } finally { if (cur != null) { cur.close(); } } return seqs; }
From source file:act.server.MongoDB.java
License:Open Source License
public List<Seq> getSeqFromGenbankNucAccessionSeq(String accession, String seq) { List<Seq> seqs = new ArrayList<>(); BasicDBObject query = new BasicDBObject(); query.put("seq", seq); query.put("metadata.accession.genbank_nucleotide", new BasicDBObject("$elemMatch", new BasicDBObject("$eq", accession))); DBCursor cur = this.dbSeq.find(query, new BasicDBObject()); try {/*from www .j a v a 2 s .co m*/ while (cur.hasNext()) { DBObject o = cur.next(); seqs.add(convertDBObjectToSeq(o)); } } finally { if (cur != null) { cur.close(); } } return seqs; }
From source file:act.server.MongoDB.java
License:Open Source License
public List<Seq> getSeqWithSARConstraints() { List<Seq> seqs = new ArrayList<Seq>(); BasicDBObject query = new BasicDBObject(); query.put("sar_constraints", new BasicDBObject("$exists", true)); BasicDBObject keys = new BasicDBObject(); DBCursor cur = this.dbSeq.find(query, keys); while (cur.hasNext()) { DBObject o = cur.next();//from w w w.j a v a2s.com seqs.add(convertDBObjectToSeq(o)); } cur.close(); return seqs; }