List of usage examples for com.mongodb DBCursor hasNext
@Override public boolean hasNext()
From source file:act.server.MongoDB.java
License:Open Source License
private List<Reaction> keywordInReaction(String in_field, String keyword) { List<Reaction> rxns = new ArrayList<Reaction>(); BasicDBObject query = new BasicDBObject(); query.put(in_field, keyword);// w w w. ja va2s .co m BasicDBObject keys = new BasicDBObject(); DBCursor cur = this.dbReactions.find(query, keys); while (cur.hasNext()) { DBObject o = cur.next(); rxns.add(convertDBObjectToReaction(o)); } cur.close(); return rxns; }
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 w w.j a v a2 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 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 a2 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> 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 {/* ww w.ja v a2 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 w ww .j a v a 2 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> 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();// ww w. j av a 2 s . co m seqs.add(convertDBObjectToSeq(o)); } cur.close(); return seqs; }
From source file:act.server.MongoDB.java
License:Open Source License
public List<Seq> getSeqWithRxnRef(Long rxnId) { List<Seq> seqs = new ArrayList<>(); BasicDBObject query = new BasicDBObject(); query.put("rxn_refs", rxnId); DBCursor cur = this.dbSeq.find(query, new BasicDBObject()); try {/*from ww w. j a v a 2 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:AdminServer.ServiceS.java
private ArrayList getData(DBCollection collection, methodS type, String name) { ArrayList data = new ArrayList<>(); DBCursor cursor; if (type == methodS.ATM) { cursor = collection.find();/*from w ww. j a v a 2 s. c om*/ while (cursor.hasNext()) { DBObject obj = cursor.next(); String no = obj.get("SerialNum").toString(); String ip = obj.get("ipAddr").toString(); String money = obj.get("money").toString(); String usr = obj.get("currentUser").toString(); data.add(new tellerD(no, ip, money, usr)); } } else if (type == methodS.USER) { cursor = collection.find(new BasicDBObject("name", name)); while (cursor.hasNext()) { DBObject obj = cursor.next(); String usr = obj.get("name").toString(); boolean ip = (boolean) obj.get("locked"); data.add(new userD(usr, ip)); } } else if (type == methodS.TRADE) { cursor = collection.find(new BasicDBObject("ipAddr", name)); while (cursor.hasNext()) { DBObject obj = cursor.next(); String no = obj.get("serial").toString(); String ip = obj.get("ipAddr").toString(); String method = obj.get("type").toString(); String usr = obj.get("name").toString(); String delta = obj.get("delta").toString(); String remains = obj.get("remains").toString(); String date = obj.get("time").toString(); data.add(new tradeD(no, ip, usr, method, delta, remains, date)); } } return data; }
From source file:aic2013.extractor.MongoDataAccess.java
public void forAll(Processor<Status> processor) { DB db = mongoClient.getDB("twitterdb"); DBCollection statusCollection = db.getCollection("statuses"); DBCursor cursor = statusCollection.find(); while (cursor.hasNext()) { try {/*from www . j a v a 2 s . c om*/ processor.process(DataObjectFactory.createStatus(cursor.next().toString())); } catch (TwitterException ex) { Logger.getLogger(MongoDataAccess.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:aic2013.extractor.MongoDataAccess.java
public void forAllByUserId(long id, Processor<Status> processor) { DB db = mongoClient.getDB("twitterdb"); DBCollection statusCollection = db.getCollection("statuses"); DBCursor cursor = statusCollection.find(new BasicDBObject("user.id", id)); while (cursor.hasNext()) { try {//w ww . j a v a2 s . c o m processor.process(DataObjectFactory.createStatus(cursor.next().toString())); } catch (TwitterException ex) { Logger.getLogger(MongoDataAccess.class.getName()).log(Level.SEVERE, null, ex); } } }