public Map<String, LineChart> buildDashboardByGroup(Date start, Date end, String metricGroup) { Map<String, LineChart> result = new LinkedHashMap<String, LineChart>(); List<MetricKeyConfig> metricConfigs = m_metricGroupConfigManager.queryMetricGroupConfig(metricGroup); Collection<ProductLine> productLines = m_productLineConfigManager.queryAllProductLines().values(); Map<String, LineChart> allCharts = new LinkedHashMap<String, LineChart>(); for (ProductLine productLine : productLines) { if (isProductLineInGroup(productLine.getId(), metricConfigs)) { allCharts.putAll(buildChartsByProductLine(productLine.getId(), start, end)); } } for (MetricKeyConfig metric : metricConfigs) { String domain = metric.getMetricDomain(); String type = metric.getMetricType().equalsIgnoreCase("metric") ? "Metric" : metric.getMetricType(); String key = metric.getMetricKey(); String id = m_metricConfigManager.buildMetricKey(domain, type, key) + ":" + metric.getDisplayType().toUpperCase(); put(allCharts, result, id); } return result; }
private boolean isProductLineInGroup(String productLine, List<MetricKeyConfig> configs) { List<String> domains = m_productLineConfigManager.queryDomainsByProductLine(productLine); List<MetricItemConfig> metricConfig = m_metricConfigManager.queryMetricItemConfigs(domains); for (MetricKeyConfig metric : configs) { String domain = metric.getMetricDomain(); String type = metric.getMetricType(); String key = metric.getMetricKey(); for (MetricItemConfig item : metricConfig) { if (item.getDomain().equalsIgnoreCase(domain) && item.getType().equalsIgnoreCase(type) && item.getMetricKey().equalsIgnoreCase(key)) { return true; } } } return false; }