public List<MetricDisplaySummary> getMetricSummaries() {
if (null != metricSummaries) {
return metricSummaries;
}
WebUser user = EnterpriseFacesContextUtility.getWebUser();
MeasurementPreferences preferences = user.getMeasurementPreferences();
MetricRangePreferences range = preferences.getMetricRangePreferences();
if (context.type == EntityContext.Type.Resource) {
//null -> don't filter, we want everything, false -> not only enabled
List<MeasurementSchedule> measurementSchedules = scheduleManager.findSchedulesForResourceAndType(
user.getSubject(), context.resourceId, DataType.MEASUREMENT, null, true);
int[] scheduleIds = new int[measurementSchedules.size()];
int i = 0;
for (MeasurementSchedule sched : measurementSchedules) {
scheduleIds[i++] = sched.getId();
}
metricSummaries = chartManager.getMetricDisplaySummariesForResource(user.getSubject(), context.resourceId,
scheduleIds, range.begin, range.end);
} else if (context.type == EntityContext.Type.ResourceGroup) {
List<MeasurementDefinition> measurementDefinitions = definitionManager
.findMeasurementDefinitionsByResourceType(user.getSubject(), getResourceGroup(user).getResourceType()
.getId(), DataType.MEASUREMENT, null);
int[] defIds = new int[measurementDefinitions.size()];
int i = 0;
for (MeasurementDefinition def : measurementDefinitions) {
defIds[i++] = def.getId();
}
metricSummaries = chartManager.getMetricDisplaySummariesForCompatibleGroup(user.getSubject(), context,
defIds, range.begin, range.end, true);
} else if (context.type == EntityContext.Type.AutoGroup) {
List<MeasurementDefinition> measurementDefinitions = definitionManager
.findMeasurementDefinitionsByResourceType(user.getSubject(), context.getResourceTypeId(),
DataType.MEASUREMENT, null);
int[] defIds = new int[measurementDefinitions.size()];
int i = 0;
for (MeasurementDefinition def : measurementDefinitions) {
defIds[i++] = def.getId();
}
metricSummaries = chartManager.getMetricDisplaySummariesForAutoGroup(user.getSubject(),
context.getParentResourceId(), context.getResourceTypeId(), defIds, range.begin, range.end, true);
} else {
log.error(context.getUnknownContextMessage());
// return an empty list in this unlikely scenario