public QueryResult<VariantAnalysisInfo> getAnalysisInfo(String studyId) { long start = System.currentTimeMillis(); QueryResult<VariantAnalysisInfo> qres = new QueryResult<>(); VariantAnalysisInfo vi = new VariantAnalysisInfo(); DBCollection coll = db.getCollection("sources"); DBCollection collV = db.getCollection("variants"); long dbStart = System.currentTimeMillis(); DBObject study = coll.findOne(new BasicDBObject("alias", studyId)); if (study != null) { Iterator<Object> it = ((BasicDBList) study.get("samples")).iterator(); while (it.hasNext()) { vi.addSample((String) it.next()); } BasicDBObject gs = (BasicDBObject) study.get("globalStats"); for (String elem : gs.keySet()) { if (!elem.equalsIgnoreCase("consequenceTypes")) { double val = gs.getDouble(elem); vi.addGlobalStats(elem, val); } else { BasicDBObject cts = (BasicDBObject) gs.get("consequenceTypes"); for (String ct : cts.keySet()) { vi.addConsequenceType(ct, cts.getInt(ct)); } } } } qres.setDbTime(System.currentTimeMillis() - dbStart); qres.setResult(Arrays.asList(vi)); qres.setTime(System.currentTimeMillis() - start); return qres; }
@Test(groups = "dev") public void collectionTest() { DB db = mongo.getDB(DBNAME); DBCollection myCollection = db.getCollection("myCollection"); myCollection.save( new BasicDBObject( MapUtils.putAll(new HashMap(), new Object[] {"name", "leon", "age", 33}))); myCollection.findOne(); Set<String> names = db.getCollectionNames(); assertNotNull(names); boolean hit = false; for (String name : names) { if ("myCollection".equals(name)) { hit = true; break; } } assertTrue(hit); }