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:achmad.rifai.erp1.entity.Terima.java

public static Terima of(Db d, String kode) throws Exception {
    Terima t = null;//from  ww  w. j av  a 2  s  .c o m
    achmad.rifai.erp1.util.RSA r = achmad.rifai.erp1.util.Work.loadRSA();
    com.mongodb.DBObject p = new com.mongodb.BasicDBObject();
    p.put("berkas", kode);
    com.mongodb.DBCursor c = d.getD().getCollectionFromString("terima").find(p);
    if (c.hasNext()) {
        com.mongodb.BasicDBList l = (com.mongodb.BasicDBList) c.next().get("bin");
        String json = "";
        for (int x = 0; x < l.size(); x++)
            json += r.decrypt("" + l.get(x));
        t = new Terima(json);
    }
    return t;
}

From source file:achmad.rifai.erp1.entity.Tracks.java

public static Tracks of(Db d, String kode) throws Exception {
    Tracks v = null;//from w w  w. jav a2  s .co m
    achmad.rifai.erp1.util.RSA r = achmad.rifai.erp1.util.Work.loadRSA();
    com.mongodb.DBObject p = new com.mongodb.BasicDBObject();
    p.put("berkas", kode);
    com.mongodb.DBCursor c = d.getD().getCollectionFromString("tracks").find(p);
    while (c.hasNext()) {
        com.mongodb.DBObject o = c.next();
        com.mongodb.BasicDBList l = (com.mongodb.BasicDBList) o.get("bin");
        String json = "";
        for (int x = 0; x < l.size(); x++)
            json += r.decrypt("" + l.get(x));
        v = new Tracks(json);
        break;
    }
    return v;
}

From source file:achmad.rifai.erp1.entity.Tugas.java

public static Tugas of(Db d, String kode) throws Exception {
    Tugas t = null;//from  w  w  w . j av  a 2 s.com
    achmad.rifai.erp1.util.RSA r = achmad.rifai.erp1.util.Work.loadRSA();
    com.mongodb.DBObject p = new com.mongodb.BasicDBObject();
    p.put("berkas", kode);
    com.mongodb.DBCursor c = d.getD().getCollection("tugas").find(p);
    while (c.hasNext()) {
        com.mongodb.DBObject o = c.next();
        com.mongodb.BasicDBList l = (com.mongodb.BasicDBList) o.get("bin");
        String json = "";
        for (int x = 0; x < l.size(); x++)
            json += r.decrypt("" + l.get(x));
        t = new Tugas(json);
        break;
    }
    return t;
}

From source file:act.installer.metacyc.OrganismCompositionMongoWriter.java

License:Open Source License

private BasicDBList metaReferencesToDBList(String id, List<SmallMolMetaData> metas) {
    BasicDBList dbList = new BasicDBList();
    for (SmallMolMetaData meta : metas) {
        DBObject metaObj = meta.getDBObject();
        metaObj.put("id", id);
        dbList.add(metaObj);//from  w  ww.  j  a v  a  2s  .c om
    }
    return dbList;
}

From source file:act.installer.metacyc.OrganismCompositionMongoWriter.java

License:Open Source License

private JSONArray addAllToExistingMetaList(String id, Object existing, List<SmallMolMetaData> metas) {
    JSONArray metaData = null;//from w ww.j  a  va  2  s  .  c  o  m
    if (existing == null) {
        metaData = new JSONArray();
    } else if (existing instanceof JSONArray) {
        metaData = (JSONArray) existing;
    } else {
        System.out.println("SmallMolMetaDataList[0] = " + metas.get(0).toString());
        System.out.println("Existing Chemical.refs[Chemical.REFS.METACYC] not a list! = " + existing);
        System.out.println("It is of type " + existing.getClass().getSimpleName());
        System.out.println("Want to add SmallMolMetaData to list, but its not a list!");
        System.exit(-1);
        return null;
    }

    for (SmallMolMetaData meta : metas) {
        DBObject metaDBObject = meta.getDBObject();
        metaDBObject.put("id", id);
        metaData.put(metaDBObject);
    }
    return metaData;
}

From source file:act.server.MongoDB.java

License:Open Source License

public void submitToActWaterfallDB(Long ID, DBObject waterfall) {
    // insert a new doc to the collection
    waterfall.put("_id", ID);
    this.dbWaterfalls.insert(waterfall);
}

From source file:act.server.MongoDB.java

License:Open Source License

public void submitToActCascadeDB(Long ID, DBObject cascade) {
    // insert a new doc to the collection
    cascade.put("_id", ID);
    this.dbCascades.insert(cascade);
}

From source file:act.server.MongoDB.java

License:Open Source License

public void updateActChemical(Chemical c, Long id) {
    // See comment in updateActReaction about
    // db.collection.update, and $set

    BasicDBObject doc = createChemicalDoc(c, id);
    DBObject query = new BasicDBObject();
    query.put("_id", id);
    this.dbChemicals.update(query, doc);
}

From source file:act.server.MongoDB.java

License:Open Source License

public void updateStoichiometry(Reaction r) {
    BasicDBObject query = new BasicDBObject().append("_id", r.getUUID());
    DBObject obj = this.dbReactions.findOne(query);
    DBObject enz_summary = (DBObject) obj.get("enz_summary");
    BasicDBList substrates = (BasicDBList) enz_summary.get("substrates");
    BasicDBList newSubstrates = new BasicDBList();
    Set<Long> originalSubstrateIDs = new HashSet<Long>();
    for (int i = 0; i < substrates.size(); i++) {
        DBObject substrate = (DBObject) substrates.get(i);
        Long substrateID = (Long) substrate.get("pubchem");
        Boolean isForBalance = (Boolean) substrate.get("balance");
        if (isForBalance != null && isForBalance)
            continue;
        originalSubstrateIDs.add(substrateID);
        substrate.put("coefficient", r.getSubstrateCoefficient(substrateID));
        newSubstrates.add(substrate);/*from  ww w. jav  a  2s . co m*/
    }
    Set<Long> substratesNew = r.getSubstrateIdsOfSubstrateCoefficients();
    for (Long s : substratesNew) {
        if (originalSubstrateIDs.contains(s))
            continue;
        if (r.getSubstrateCoefficient(s) == null)
            continue;
        DBObject substrate = new BasicDBObject();
        substrate.put("pubchem", s);
        substrate.put("coefficient", r.getSubstrateCoefficient(s));
        substrate.put("balance", true);
        newSubstrates.add(substrate);
    }

    BasicDBList products = (BasicDBList) enz_summary.get("products");
    BasicDBList newProducts = new BasicDBList();
    Set<Long> originalProductIDs = new HashSet<Long>();
    for (int i = 0; i < products.size(); i++) {
        DBObject product = (DBObject) products.get(i);
        Long productID = (Long) product.get("pubchem");
        Boolean isForBalance = (Boolean) product.get("balance");
        if (isForBalance != null && isForBalance)
            continue;
        originalProductIDs.add(productID);
        product.put("coefficient", r.getProductCoefficient(productID));
        newProducts.add(product);
    }
    Set<Long> productsNew = r.getProductIdsOfProductCoefficients();
    for (Long p : productsNew) {
        if (originalProductIDs.contains(p))
            continue;
        if (r.getProductCoefficient(p) == null)
            continue;
        DBObject product = new BasicDBObject();
        product.put("pubchem", p);
        product.put("coefficient", r.getProductCoefficient(p));
        product.put("balance", true);
        newProducts.add(product);
    }
    enz_summary.put("substrates", newSubstrates);
    enz_summary.put("products", newProducts);
    this.dbReactions.update(query, obj);
}

From source file:act.server.MongoDB.java

License:Open Source License

public void updateEstimatedEnergy(Chemical chemical) {
    BasicDBObject query = new BasicDBObject().append("_id", chemical.getUuid());
    DBObject obj = this.dbChemicals.findOne(query);
    obj.put("estimateEnergy", chemical.getEstimatedEnergy());
    this.dbChemicals.update(query, obj);
}