Example usage for com.mongodb DBObject put

List of usage examples for com.mongodb DBObject put

Introduction

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

Prototype

Object put(String key, Object v);

Source Link

Document

Sets a name/value pair in this object.

Usage

From source file:act.server.MongoDB.java

License:Open Source License

public List<Chemical> getChemicalsThatHaveField(String field) {
    DBObject val = new BasicDBObject();
    val.put("$exists", "true");
    return constructAllChemicalsFromActData(field, val);
}

From source file:act.server.MongoDB.java

License:Open Source License

public List<Chemical> getDrugbankChemicals() {
    DBObject val = new BasicDBObject();
    val.put("$ne", null);
    String field = "xref.DRUGBANK";

    return constructAllChemicalsFromActData(field, val);
}

From source file:act.server.MongoDB.java

License:Open Source License

public List<Chemical> getSigmaChemicals() {
    DBObject val = new BasicDBObject();
    val.put("$ne", null);
    String field = "xref.SIGMA";

    return constructAllChemicalsFromActData(field, val);
}

From source file:act.server.MongoDB.java

License:Open Source License

public DBIterator getIdCursorForFakeChemicals() {
    DBObject fakeRegex = new BasicDBObject();
    DBObject abstractInchi = new BasicDBObject();
    fakeRegex.put(ChemicalKeywords.INCHI$.MODULE$.toString(),
            new BasicDBObject(MongoKeywords.REGEX$.MODULE$.toString(), "^InChI=/FAKE"));

    abstractInchi.put(ChemicalKeywords.INCHI$.MODULE$.toString(),
            new BasicDBObject(MongoKeywords.REGEX$.MODULE$.toString(), "^InChI=.*R.*"));

    BasicDBList conditionList = new BasicDBList();
    conditionList.add(fakeRegex);/*w  w  w .j  a v  a2 s.c om*/
    conditionList.add(abstractInchi);

    BasicDBObject conditions = new BasicDBObject(MongoKeywords.OR$.MODULE$.toString(), conditionList);

    return getIteratorOverChemicals(conditions,
            new BasicDBObject(ChemicalKeywords.ID$.MODULE$.toString(), true));
}

From source file:act.server.MongoDB.java

License:Open Source License

public Set<Long> getOrganismIDs(Long reactionID) {
    if (reactionID < 0) {
        reactionID = Reaction.reverseID(reactionID);
    }/*from w  w  w  . java2  s .co  m*/
    DBObject query = new BasicDBObject();
    query.put("_id", reactionID);
    Set<Long> ids = new HashSet<Long>();
    DBObject reaction = this.dbReactions.findOne(query);
    if (reaction != null) {
        BasicDBList orgs = (BasicDBList) reaction.get("organisms");
        for (Object o : orgs) {
            ids.add((Long) ((DBObject) o).get("id")); // checked: db type IS long
        }
    }
    return ids;
}

From source file:act.server.MongoDB.java

License:Open Source License

public List<P<Reaction.RefDataSource, String>> getReferences(Long reactionID) {
    if (reactionID < 0) {
        reactionID = Reaction.reverseID(reactionID);
    }/*from   w  w  w . j  ava2s  .co  m*/
    DBObject query = new BasicDBObject();
    query.put("_id", reactionID);
    List<P<Reaction.RefDataSource, String>> refs = new ArrayList<>();
    DBObject reaction = this.dbReactions.findOne(query);
    if (reaction != null) {
        BasicDBList dbrefs = (BasicDBList) reaction.get("references");
        if (dbrefs != null)
            for (Object oo : dbrefs) {
                DBObject ref = (DBObject) oo;
                Reaction.RefDataSource src = Reaction.RefDataSource.valueOf((String) ref.get("src"));
                String val = (String) ref.get("val");
                refs.add(new P<Reaction.RefDataSource, String>(src, val));
            }
    }
    return refs;
}

From source file:act.server.MongoDB.java

License:Open Source License

public Set<String> getKMValues(Long reactionID) {
    DBObject query = new BasicDBObject();
    query.put("_id", reactionID);
    Set<String> kmSet = new HashSet<String>();
    DBObject reaction = this.dbReactions.findOne(query);
    if (reaction != null) {
        BasicDBList kms = (BasicDBList) reaction.get("km_values");
        if (kms != null) {
            for (Object km : kms) {
                kmSet.add((String) km);
            }/* w w  w  .  java  2 s . co  m*/
        }
    }
    return kmSet;
}

From source file:act.server.MongoDB.java

License:Open Source License

public Set<String> getTurnoverNumbers(Long reactionID) {
    DBObject query = new BasicDBObject();
    query.put("_id", reactionID);
    Set<String> turnoverSet = new HashSet<String>();
    DBObject reaction = this.dbReactions.findOne(query);
    if (reaction != null) {
        BasicDBList turnovers = (BasicDBList) reaction.get("turnover_numbers");
        if (turnovers != null) {
            for (Object turnover : turnovers) {
                turnoverSet.add((String) turnover);
            }/*from  w  w w . j a  v a2s . c  om*/
        }
    }
    return turnoverSet;
}

From source file:act.server.MongoDB.java

License:Open Source License

public void updateMetadata(Seq seq) {
    BasicDBObject query = new BasicDBObject().append("_id", seq.getUUID());
    DBObject obj = this.dbSeq.findOne(query);
    obj.put("metadata", MongoDBToJSON.conv(seq.getMetadata()));
    this.dbSeq.update(query, obj);
}

From source file:act.server.MongoDB.java

License:Open Source License

public void updateReferences(Seq seq) {
    BasicDBObject query = new BasicDBObject().append("_id", seq.getUUID());
    DBObject obj = this.dbSeq.findOne(query);
    BasicDBList refs = new BasicDBList();

    List<DBObject> newReferences = new ArrayList<>();
    for (JSONObject ref : seq.getReferences()) {
        newReferences.add(MongoDBToJSON.conv(ref));
    }/*from   w ww  .  jav  a  2 s.c  o  m*/

    refs.addAll(newReferences);
    obj.put("references", refs);
    this.dbSeq.update(query, obj);
}