}
continue;
}
MetricDisplaySummary summary = new MetricDisplaySummary();
// See MetricsDisplay.jsp for wrt the next two lines.
summary.setNumberCollecting(collecting);
summary.setShowNumberCollecting(true);
summary.setDefinitionId(definitionId);
summary.setBeginTimeFrame(begin);
summary.setAlertCount(getAlertCountForContext(definitionId, context, begin, end));
summary.setEndTimeFrame(end);
MeasurementDefinition definition = entityManager.find(MeasurementDefinition.class, definitionId);
summary.setDefinitionId(definition.getId());
summary.setUnits(definition.getUnits().getName());
summary.setDescription(definition.getDescription());
summary.setMetricName(definition.getName());
summary.setLabel(definition.getDisplayName());
summary.setDescription(definition.getDescription());
summary.setMetricSource(definition.getResourceType().getName());
/*
* Get the aggregate data from the backend and check if it is empty or not. If it is empty (for all members
* of the group), skip over this metric.
*/
MeasurementAggregate aggregate;
if (totalScheduleCount == 0) {
aggregate = new MeasurementAggregate(null, null, null);
log.warn("No metric schedules found for def=[" + definition + "] and " + context
+ ", using empty aggregate");
} else {
if (context.type == EntityContext.Type.ResourceGroup
&& definition.getDataType() == DataType.MEASUREMENT) {
aggregate = dataManager.getAggregate(subject, context.getGroupId(), definitionId, begin, end);
} else {
aggregate = dataUtil.getAggregateByDefinitionAndContext(begin, end, definitionId, context);
}
}
if (aggregate.isEmpty()) {
if (log.isTraceEnabled()) {
log.warn("No metric data found for def=[" + definition + "] and " + context + " in the timeframe ["
+ new Date(begin) + ", " + new Date(end) + "]");
}
summary.setValuesPresent(false);
}
Map<String, MetricDisplayValue> metricValues = new HashMap<String, MetricDisplayValue>();
metricValues.put(MetricDisplayConstants.MIN_KEY, new MetricDisplayValue(aggregate.getMin()));
metricValues.put(MetricDisplayConstants.AVERAGE_KEY, new MetricDisplayValue(aggregate.getAvg()));
metricValues.put(MetricDisplayConstants.MAX_KEY, new MetricDisplayValue(aggregate.getMax()));
// TODO put the sum back on - JBNADM-2626
//metricValues.put(MetricDisplayConstants.SUMMARY_KEY, new MetricDisplayValue(aggregate.getSum()));
summary.setMetrics(metricValues);
// TODO what else do we need ?
data.add(summary);
}