Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
Map<Long, Set<MetricEntity> > com.griddynamics.jagger.engine.e1.services.DefaultDataService.getMetricsByTestIds ( Collection< Long >  testIds)

Returns map, where key is test id and value is a list of all test metrics.

Parameters
testIds- test ids
Returns
map of <test id, list of metric entity> pairs
Author
Gribov Kirill

Implements com.griddynamics.jagger.engine.e1.services.DataService.

Definition at line 250 of file DefaultDataService.java.

References com.griddynamics.jagger.engine.e1.services.data.service.MetricEntity.setMetricNameDto(), com.griddynamics.jagger.engine.e1.services.data.service.MetricEntity.setPlotAvailable(), and com.griddynamics.jagger.engine.e1.services.data.service.MetricEntity.setSummaryAvailable().

Referenced by com.griddynamics.jagger.engine.e1.services.DefaultDataService.getMetrics(), and com.griddynamics.jagger.engine.e1.services.DefaultDataService.getMetricsByTests().

250  {
251  if (testIds.isEmpty()) {
252  return Collections.emptyMap();
253  }
254 
255  // Get
256  List<String> sessionIds = databaseService.getSessionIdsByTaskIds(new HashSet<Long>(testIds));
257 
258  // Get all test results without matching
259  SessionMatchingSetup sessionMatchingSetup = new SessionMatchingSetup(false, Collections.<SessionMatchingSetup.MatchBy>emptySet());
260  RootNode rootNode = databaseService.getControlTreeForSessions(new HashSet<String>(sessionIds), sessionMatchingSetup);
261 
262  // Filter
263  List<TestNode> summaryNodeTests = new ArrayList<TestNode>();
264  List<TestDetailsNode> detailsNodeTests = new ArrayList<TestDetailsNode>();
265 
266  for (TestNode testNode : rootNode.getSummaryNode().getTests()) {
267  Long testId = testNode.getTaskDataDto().getId();
268  if (testIds.contains(testId)) {
269  summaryNodeTests.add(testNode);
270  }
271  }
272  for (TestDetailsNode testDetailsNode : rootNode.getDetailsNode().getTests()) {
273  Long testId = testDetailsNode.getTaskDataDto().getId();
274  if (testIds.contains(testId)) {
275  detailsNodeTests.add(testDetailsNode);
276  }
277  }
278 
279  // Join
280  Map<Long, Set<MetricNameDto>> metrics = new HashMap<Long, Set<MetricNameDto>>();
281  Set<String> metricsWithSummary = new HashSet<String>();
282  Set<String> metricsWithPlots = new HashSet<String>();
283 
284  for (TestNode testNode : summaryNodeTests) {
285  Long testId = testNode.getTaskDataDto().getId();
286 
287  if (!metrics.containsKey(testId)) {
288  metrics.put(testId, new HashSet<MetricNameDto>());
289  }
290 
291  for (MetricNode metricNode : testNode.getMetrics()) {
292  for (MetricNameDto metricNameDto : metricNode.getMetricNameDtoList()) {
293  metrics.get(testId).add(metricNameDto);
294  metricsWithSummary.add(metricNameDto.getMetricName());
295  }
296  }
297  }
298 
299  for (TestDetailsNode testDetailsNode : detailsNodeTests) {
300  Long testId = testDetailsNode.getTaskDataDto().getId();
301 
302  if (!metrics.containsKey(testId)) {
303  metrics.put(testId, new HashSet<MetricNameDto>());
304  }
305 
306  for (MetricNode metricNode : testDetailsNode.getMetrics()) {
307  for (MetricNameDto metricNameDto : metricNode.getMetricNameDtoList()) {
308  metrics.get(testId).add(metricNameDto);
309  metricsWithPlots.add(metricNameDto.getMetricName());
310  }
311  }
312  }
313 
314  // Convert
315  Map<Long, Set<MetricEntity>> result = new HashMap<Long, Set<MetricEntity>>();
316  for (Long key : metrics.keySet()) {
317  result.put(key, new HashSet<MetricEntity>());
318 
319  for (MetricNameDto metricNameDto : metrics.get(key)) {
320  MetricEntity metricEntity = new MetricEntity();
321  metricEntity.setMetricNameDto(metricNameDto);
322  if (metricsWithSummary.contains(metricNameDto.getMetricName())) {
323  metricEntity.setSummaryAvailable(true);
324  }
325  if (metricsWithPlots.contains(metricNameDto.getMetricName())) {
326  metricEntity.setPlotAvailable(true);
327  }
328  result.get(key).add(metricEntity);
329  }
330  }
331 
332  return result;
333  }

Here is the call graph for this function:

Here is the caller graph for this function: