@Override public Map<ReportNodeStatus, Integer> getLeafReportNodesStatusDistribution(String executionID, String reportNodeClass) { HashMap<ReportNodeStatus, Integer> result = new HashMap<ReportNodeStatus, Integer>(); for(ReportNodeStatusReportEntry entry:collection.aggregate("{$match:{executionID:'"+executionID+"',_class:'"+reportNodeClass+"'}}"). and("{$group:{_id:'$status',sum:{$sum:1}}}").as(ReportNodeStatusReportEntry.class)) { result.put(entry._id, entry.sum); } return result; }
@Override public DataTable getTimeBasedReport(String executionID, int resolution) { String reportNodeClass = "step.artefacts.collection.CallFunctionReportNode"; DataTable t = new DataTable(); final double normalizationFactor = (1.0*resolution)/1000; collection.aggregate("{$match:{executionID:'"+executionID+"',_class:'"+reportNodeClass+"'}}"). and("{$group:{_id:{time:{$subtract:[\"$executionTime\",{$mod:[\"$executionTime\","+resolution+"]}]}},value:{$sum:1}}}"). and("{$sort:{\"_id\":1}}").map(new ResultHandler<TableRow>() { @Override public TableRow map(DBObject result) { Date date = new Date((long) ((DBObject)result.get("_id")).get("time")); double value = new Double((Integer) result.get("value"))/normalizationFactor; TableRow r = new TableRow(date, value); return r; } }).forEach(row->t.addRow(row)); return t; }