List of usage examples for com.mongodb BasicDBList put
@Override public Object put(final String key, final Object v)
From source file:xbdd.webapp.resource.feature.Report.java
License:Apache License
/** * go through all the embedded content, store it to GridFS, replace the doc embeddings with a hyperlink to the saved content. */// w ww . j a v a2s. co m protected void embedSteps(final DBObject feature, final GridFS gridFS, final Coordinates coordinates) { final BasicDBList elements = (BasicDBList) feature.get("elements"); final String featureId = (String) feature.get("_id"); if (elements != null) { for (int j = 0; j < elements.size(); j++) { final DBObject scenario = (DBObject) elements.get(j); final String scenarioId = (String) scenario.get("_id"); final BasicDBList steps = (BasicDBList) scenario.get("steps"); if (steps != null) { for (int k = 0; k < steps.size(); k++) { final DBObject step = (DBObject) steps.get(k); final BasicDBList embeddings = (BasicDBList) step.get("embeddings"); if (embeddings != null) { for (int l = 0; l < embeddings.size(); l++) { final DBObject embedding = (DBObject) embeddings.get(l); final GridFSInputFile image = gridFS.createFile( Base64.decodeBase64(((String) embedding.get("data")).getBytes())); image.setFilename(guid()); final BasicDBObject metadata = new BasicDBObject() .append("product", coordinates.getProduct()) .append("major", coordinates.getMajor()) .append("minor", coordinates.getMinor()) .append("servicePack", coordinates.getServicePack()) .append("build", coordinates.getBuild()).append("feature", featureId) .append("scenario", scenarioId); image.setMetaData(metadata); image.setContentType((String) embedding.get("mime_type")); image.save(); embeddings.put(l, image.getFilename()); } } } } } } }