Example usage for com.mongodb BasicDBObject BasicDBObject

List of usage examples for com.mongodb BasicDBObject BasicDBObject

Introduction

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

Prototype

public BasicDBObject() 

Source Link

Document

Creates an empty object.

Usage

From source file:act.server.MongoDB.java

License:Open Source License

public Map<String, Long> constructAllInChIs() {
    Map<String, Long> chems = new HashMap<String, Long>();
    BasicDBObject keys = new BasicDBObject();
    keys.append("_id", true);
    keys.append("InChI", true);
    DBCursor cur = constructCursorForMatchingChemicals(null, null, keys);
    while (cur.hasNext()) {
        DBObject o = cur.next();/*from   w w  w  .j av  a 2s  .c om*/
        long uuid = (Long) o.get("_id"); // checked: db type IS long
        String inchi = (String) o.get("InChI");
        chems.put(inchi, uuid);
    }

    cur.close();
    return chems;
}

From source file:act.server.MongoDB.java

License:Open Source License

private Chemical convertDBObjectToChemicalFromActData(String field, Object val) {
    BasicDBObject query = new BasicDBObject();
    query.put(field, val);

    // project out the synonyms field, even though we don't have anything in it right now.
    BasicDBObject keys = new BasicDBObject();
    // keys.put("names", 0); // 0 means exclude, rest are included
    DBObject o = this.dbChemicals.findOne(query, keys);
    if (o == null)
        return null;
    return convertDBObjectToChemical(o);
}

From source file:act.server.MongoDB.java

License:Open Source License

public DBIterator getDbIteratorOverSeq(BasicDBObject matchCriterion, BasicDBObject keys) {
    if (keys == null) {
        keys = new BasicDBObject();
    }/*w  w w .  java  2  s .co m*/

    DBCursor cursor = this.dbSeq.find(matchCriterion, keys);
    cursor = cursor.addOption(Bytes.QUERYOPTION_NOTIMEOUT);
    return new DBIterator(cursor);
}

From source file:act.server.MongoDB.java

License:Open Source License

public DBIterator getIteratorOverChemicals(BasicDBObject matchCriterion, BasicDBObject keys) {
    if (keys == null) {
        keys = new BasicDBObject();
    }/*from  w w w.  java  2s .  com*/
    DBCursor cursor = this.dbChemicals.find(matchCriterion, keys);
    cursor = cursor.addOption(Bytes.QUERYOPTION_NOTIMEOUT);

    return new DBIterator(cursor); // DBIterator is just a wrapper class
}

From source file:act.server.MongoDB.java

License:Open Source License

public DBIterator getIteratorOverReactions(BasicDBObject matchCriterion, BasicDBObject keys) {

    if (keys == null) {
        keys = new BasicDBObject();
    }/*from  ww w  . ja  v  a 2  s .c  o m*/

    DBCursor cursor = this.dbReactions.find(matchCriterion, keys);
    cursor = cursor.addOption(Bytes.QUERYOPTION_NOTIMEOUT);
    return new DBIterator(cursor); // DBIterator is just a wrapper classs
}

From source file:act.server.MongoDB.java

License:Open Source License

public Set<Reaction> getReactionsConstrained(Map<String, Object> equalityCriteria) {
    BasicDBList andList = new BasicDBList();
    for (String k : equalityCriteria.keySet()) {
        BasicDBObject query = new BasicDBObject();
        query.put(k, equalityCriteria.get(k));
        andList.add(query);/*from w  w  w  .  ja  v  a2  s.  com*/
    }
    BasicDBObject query = new BasicDBObject();
    query.put("$and", andList);
    DBCursor cur = this.dbReactions.find(query);

    Set<Reaction> results = new HashSet<Reaction>();
    while (cur.hasNext()) {
        results.add(convertDBObjectToReaction(cur.next()));
    }
    return results;
}

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);//from   w ww . ja  v a  2  s.co 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);/*  ww w . j  a va  2  s. c o m*/

    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  av  a2  s . c om

    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  ww.  jav a 2 s  . 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;
}