List of usage examples for com.mongodb BasicDBList get
public Object get(final String key)
From source file:tango.plugin.measurement.MeasurementSequence.java
License:Open Source License
public MeasurementSequence(Experiment xp, BasicDBList list, boolean override) { this.override = override; if (list == null) { return;/*from ww w . jav a 2 s .com*/ } mS = new ArrayList<MeasurementStructure>(list.size()); mO = new ArrayList<MeasurementObject>(list.size()); for (int i = 0; i < list.size(); i++) { addMeasurement(list.get(i)); } //ij.IJ.log("list:"+list.size()+ " mC2C:"+mS.size()+ " mO:"+mO.size()); }
From source file:tango.plugin.measurement.MeasurementSequence.java
License:Open Source License
public MeasurementSequence(Experiment xp, BasicDBList list, int idx) { override = true;/*from ww w .j a v a2s .co m*/ if (list == null || idx >= list.size()) { return; } mS = new ArrayList<MeasurementStructure>(list.size()); mO = new ArrayList<MeasurementObject>(list.size()); addMeasurement(list.get(idx)); }
From source file:tango.plugin.sampler.SampleRunner.java
License:Open Source License
private static Object3D[][][] runCell(Cell cell, int nbSamples) { BasicDBList sampleChannels = cell.getExperiment().getSampleChannels(); int nbSampleChannels = sampleChannels.size(); Object3D[][][] objects = new Object3D[nbSampleChannels][nbSamples][]; for (int i = 0; i < nbSampleChannels; i++) { BasicDBObject sampleSettings = (BasicDBObject) sampleChannels.get(i); Sampler s = PluginFactory.getSampler(sampleSettings.getString("method")); for (Parameter p : s.getParameters()) p.dbGet(sampleSettings);/*www . j av a2 s .c om*/ s.initSampler(cell.getRawImages(), cell.getSegmentedImages()); for (int j = 0; j < nbSamples; j++) objects[i][j] = s.getSample(); } return objects; }
From source file:twitterprojectwithoutmaven.DBTweet.java
public ArrayList<String> getURLS() { BasicDBList list = ((BasicDBList) obj.get("URLs")); ArrayList<String> toReturn = new ArrayList<>(); for (int i = 0; i < list.size(); i++) { BasicDBObject o = (BasicDBObject) list.get(i); String url = o.get("" + (i + 1)).toString(); url = getExpandedUrl(url);/*from w w w.ja va 2 s . co m*/ toReturn.add(url); } return toReturn; }
From source file:xbdd.util.StatusHelper.java
License:Apache License
public static Statuses getFinalScenarioStatus(final DBObject scenario, final boolean includeManualResults) { final List<String> allStatuses = new ArrayList<String>(); final BasicDBList steps = (BasicDBList) scenario.get("steps"); if (includeManualResults) { // if we have got a bunch of manual step executions boolean hasManuallyExecutedSteps = false; final List<String> manualSteps = new ArrayList<String>(); // go through each step creating an array as though they were manual if (steps != null) { for (int i = 0; i < steps.size(); i++) { final DBObject step = (DBObject) steps.get(i); final DBObject result = (DBObject) step.get("result"); if (result != null) { if (result.get("manualStatus") != null) { manualSteps.add((String) result.get("manualStatus")); // if there is manual status include it hasManuallyExecutedSteps = true; // mark that there is a manual step executed } else { manualSteps.add("undefined"); // otherwise it is effectively unexecuted/undefined }/*from w w w.j a va 2s.c o m*/ } } } // do the same for the background steps if (scenario.get("background") != null) {// only if there are background steps. final BasicDBList backgroundSteps = (BasicDBList) ((DBObject) scenario.get("background")) .get("steps"); if (backgroundSteps != null) { for (int i = 0; i < backgroundSteps.size(); i++) { final DBObject backGroundStep = (DBObject) backgroundSteps.get(i); final DBObject result = (DBObject) backGroundStep.get("result"); if (result != null) { final String manualStatus = (String) result.get("manualStatus"); if (manualStatus != null) { manualSteps.add(manualStatus); // if there is manual status include it hasManuallyExecutedSteps = true; // mark that there is a manual step executed } else { manualSteps.add("undefined"); // otherwise it is effectively unexecuted/undefined } } } } } if (hasManuallyExecutedSteps) { // if any steps have been executed allStatuses.addAll(manualSteps);// then treat this scenario as though it has been manually executed. } else { if (steps != null) { for (int i = 0; i < steps.size(); i++) { final DBObject step = (DBObject) steps.get(i); final DBObject result = (DBObject) step.get("result"); if (result == null) { throw new RuntimeException( "You are missing a 'result' element in your steps, perhaps you need to use a later version of cucumber to generate your report (>1.1.3)?'"); } allStatuses.add((String) result.get("status"));// otherwise just include whatever automated step statuses exist. } } if (scenario.get("background") != null) { final BasicDBList backgroundSteps = (BasicDBList) ((DBObject) scenario.get("background")) .get("steps"); if (backgroundSteps != null) { for (int i = 0; i < backgroundSteps.size(); i++) { final DBObject step = (DBObject) backgroundSteps.get(i); final DBObject result = (DBObject) step.get("result"); allStatuses.add((String) result.get("status"));// make sure to include the background steps too. } } } } } else { // if we are not including manual steps then just include the automated statuses. if (steps != null) { for (int i = 0; i < steps.size(); i++) { final DBObject step = (DBObject) steps.get(i); final DBObject result = (DBObject) step.get("result"); allStatuses.add((String) result.get("status")); } } if (scenario.get("background") != null) { final BasicDBList backgroundSteps = (BasicDBList) ((DBObject) scenario.get("background")) .get("steps"); if (backgroundSteps != null) { for (int i = 0; i < backgroundSteps.size(); i++) { final DBObject step = (DBObject) backgroundSteps.get(i); allStatuses.add((String) ((DBObject) step.get("result")).get("status"));// make sure to include the background steps // too. } } } } return reduceStatuses(allStatuses); }
From source file:xbdd.util.StatusHelper.java
License:Apache License
public static String getFeatureStatus(final DBObject feature) { final List<String> allStatuses = new ArrayList<String>(); final BasicDBList featureElements = (BasicDBList) feature.get("elements"); if (featureElements != null) { for (int i = 0; i < featureElements.size(); i++) { final DBObject scenario = (DBObject) featureElements.get(i); if (isScenarioKeyword((String) scenario.get("keyword"))) { allStatuses.add(getScenarioStatus(scenario)); }/*from www.java2 s . c o m*/ } } final String result = reduceStatuses(allStatuses).getTextName(); return result; }
From source file:xbdd.webapp.resource.feature.AutomationStatistics.java
License:Apache License
/** * Go through the prior versions of this product; for each version, find the latest build and contribute the stats for that to the * returned list./*from w w w .jav a 2 s. com*/ * * @param coordinates * @param limit * @return A list of report stats in reverse version order. * @throws UnknownHostException */ @GET @Path("/recent-versions/{product}") public DBObject getRecentVersionStatsForProduct(@BeanParam final Coordinates coordinates, @QueryParam("limit") final Integer limit) { final BasicDBList returns = new BasicDBList(); final DB db = this.client.getDB("bdd"); final DBCollection summaryCollection = db.getCollection("summary"); final DBCollection reportStatsCollection = db.getCollection("reportStats"); final DBCursor versions = summaryCollection.find(coordinates.getQueryObject(Field.PRODUCT)) .sort(Coordinates.getFeatureSortingObject()); if (limit != null) { versions.limit(limit); } try { while (versions.hasNext()) { // go through each summary document final DBObject version = versions.next(); // each represents the coordinates for a given version final Coordinates c = new Coordinates((DBObject) version.get("coordinates")); final BasicDBList builds = (BasicDBList) version.get("builds"); c.setBuild((String) builds.get(builds.size() - 1)); // we need to specify which build (the latest is last in the list) final DBObject query = c.getQueryObject(); returns.add(reportStatsCollection.findOne(query)); } } finally { versions.close(); } return returns; }
From source file:xbdd.webapp.resource.feature.Feature.java
License:Apache License
private BasicDBList constructEditStepChanges(final DBObject currentVersion, final DBObject previousVersion) { final BasicDBList stepChanges = new BasicDBList(); final BasicDBList elements = (BasicDBList) currentVersion.get("elements"); final BasicDBList prevElements = (BasicDBList) previousVersion.get("elements"); if (elements != null) { for (int i = 0; i < elements.size(); i++) { final BasicDBList allSteps = new BasicDBList(); final BasicDBList changes = new BasicDBList(); final BasicDBObject element = (BasicDBObject) elements.get(i); final BasicDBObject prevElement = (BasicDBObject) prevElements.get(i); final String scenarioName = (String) element.get("name"); boolean currManual = false; boolean prevManual = false; // get all scenario steps if ((BasicDBObject) element.get("background") != null) { for (int j = 0; j < ((BasicDBList) ((BasicDBObject) element.get("background")).get("steps")) .size(); j++) {/*from www. j ava 2 s. c o m*/ final BasicDBObject step = (BasicDBObject) ((BasicDBList) ((BasicDBObject) element .get("background")).get("steps")).get(j); final BasicDBObject prevStep = (BasicDBObject) ((BasicDBList) ((BasicDBObject) prevElement .get("background")).get("steps")).get(j); final String id = (String) step.get("keyword") + (String) step.get("name"); if (((BasicDBObject) step.get("result")).get("manualStatus") != null) { currManual = true; } if (((BasicDBObject) prevStep.get("result")).get("manualStatus") != null) { prevManual = true; } final BasicDBObject compareStep = new BasicDBObject().append("id", id).append("curr", step) .append("prev", prevStep); allSteps.add(compareStep); } } if ((BasicDBList) element.get("steps") != null) { for (int j = 0; j < ((BasicDBList) element.get("steps")).size(); j++) { final BasicDBObject step = (BasicDBObject) ((BasicDBList) element.get("steps")).get(j); final BasicDBObject prevStep = (BasicDBObject) ((BasicDBList) prevElement.get("steps")) .get(j); final String id = (String) step.get("keyword") + (String) step.get("name"); if (((BasicDBObject) step.get("result")).get("manualStatus") != null) { currManual = true; } if (((BasicDBObject) prevStep.get("result")).get("manualStatus") != null) { prevManual = true; } final BasicDBObject compareStep = new BasicDBObject().append("id", id).append("curr", step) .append("prev", prevStep); allSteps.add(compareStep); } } for (int j = 0; j < allSteps.size(); j++) { formatStep(changes, (BasicDBObject) allSteps.get(j), currManual, prevManual); } // only add if changes have been made if (changes.size() > 0) { final BasicDBObject singleScenario = new BasicDBObject().append("scenario", scenarioName) .append("changes", changes); stepChanges.add(singleScenario); } } } return stepChanges; }
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. *//*from ww w.ja v a 2 s . c om*/ 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()); } } } } } } }
From source file:xbdd.webapp.resource.feature.Report.java
License:Apache License
/** * go through find all the backgrounds elements and nest them in their scenarios (simplifies application logic downstream) *//* w w w.j a va2 s .c om*/ protected void packBackgroundsInToScenarios(final DBObject feature) { final List<DBObject> packedScenarios = new ArrayList<DBObject>(); // go through all the backgrounds /scenarios final BasicDBList elements = (BasicDBList) feature.get("elements"); if (elements != null) { for (int i = 0; i < elements.size(); i++) { final DBObject element = (DBObject) elements.get(i); if (element.get("type").equals("background")) { // if its a background ((DBObject) elements.get(i + 1)).put("background", element); // push it in to the next element. } else { // assume this is a scenario/other top level element and push it to the packed array. packedScenarios.add(element); } } elements.clear(); elements.addAll(packedScenarios); } }