Example usage for com.mongodb DBCursor close

List of usage examples for com.mongodb DBCursor close

Introduction

In this page you can find the example usage for com.mongodb DBCursor close.

Prototype

@Override
    public void close() 

Source Link

Usage

From source file:act.server.MongoDB.java

License:Open Source License

private List<Seq> keywordInSequence(String in_field, String keyword) {
    List<Seq> seqs = new ArrayList<Seq>();
    BasicDBObject query = new BasicDBObject();
    query.put(in_field, keyword);/*  w  w  w  .  j av  a 2  s  . c o  m*/

    BasicDBObject keys = new BasicDBObject();

    DBCursor cur = this.dbSeq.find(query, keys);
    while (cur.hasNext()) {
        DBObject o = cur.next();
        seqs.add(convertDBObjectToSeq(o));
    }
    cur.close();

    return seqs;
}

From source file:act.server.MongoDB.java

License:Open Source License

private List<DBObject> keywordInCascade(String in_field, String keyword) {
    List<DBObject> cascades = new ArrayList<DBObject>();
    BasicDBObject query = new BasicDBObject();
    query.put(in_field, keyword);/*from w ww  . jav  a2s  .  c om*/

    BasicDBObject keys = new BasicDBObject();

    DBCursor cur = this.dbCascades.find(query, keys);
    while (cur.hasNext()) {
        DBObject o = cur.next();
        cascades.add(convertDBObjectToCascade(o));
    }
    cur.close();

    return cascades;
}

From source file:act.server.MongoDB.java

License:Open Source License

private List<DBObject> keywordInWaterfall(String in_field, String keyword) {
    List<DBObject> waterfalls = new ArrayList<DBObject>();
    BasicDBObject query = new BasicDBObject();
    query.put(in_field, keyword);//  w  w w.  j a va  2s . co m

    BasicDBObject keys = new BasicDBObject();

    DBCursor cur = this.dbWaterfalls.find(query, keys);
    while (cur.hasNext()) {
        DBObject o = cur.next();
        waterfalls.add(convertDBObjectToWaterfall(o));
    }
    cur.close();

    return waterfalls;
}

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);//from   w w w .  jav  a 2s  .c om

    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 .  ja v a 2  s. co  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  www. j a v a 2s.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> 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   w w w . j a v a  2 s  . c  om
        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 {//  w  w  w  .  jav  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> 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 . ja  v  a2 s .  c o 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 {/*  ww  w.  j  a v  a 2s .  com*/
        while (cur.hasNext()) {
            DBObject o = cur.next();
            seqs.add(convertDBObjectToSeq(o));
        }
    } finally {
        if (cur != null) {
            cur.close();
        }
    }

    return seqs;
}