use of org.xdi.model.metric.ldap.MetricEntry in project oxCore by GluuFederation.
the class MetricService method findMetricEntry.
public Map<MetricType, List<? extends MetricEntry>> findMetricEntry(ApplicationType applicationType, String applianceInum, List<MetricType> metricTypes, Date startDate, Date endDate, String... returnAttributes) {
prepareBranch(null, applicationType);
Map<MetricType, List<? extends MetricEntry>> result = new HashMap<MetricType, List<? extends MetricEntry>>();
if ((metricTypes == null) || (metricTypes.size() == 0)) {
return result;
}
// Prepare list of DNs
Set<String> metricDns = getBaseDnForPeriod(applicationType, applianceInum, startDate, endDate);
if (metricDns.size() == 0) {
return result;
}
for (MetricType metricType : metricTypes) {
List<MetricEntry> metricTypeResult = new LinkedList<MetricEntry>();
for (String metricDn : metricDns) {
List<Filter> metricTypeFilters = new ArrayList<Filter>();
Filter applicationTypeFilter = Filter.createEqualityFilter("oxApplicationType", applicationType.getValue());
Filter eventTypeTypeFilter = Filter.createEqualityFilter("oxMetricType", metricType.getValue());
Filter startDateFilter = Filter.createGreaterOrEqualFilter("oxStartDate", ldapEntryManager.encodeGeneralizedTime((startDate)));
Filter endDateFilter = Filter.createLessOrEqualFilter("oxEndDate", ldapEntryManager.encodeGeneralizedTime(endDate));
metricTypeFilters.add(applicationTypeFilter);
metricTypeFilters.add(eventTypeTypeFilter);
metricTypeFilters.add(startDateFilter);
metricTypeFilters.add(endDateFilter);
Filter filter = Filter.createANDFilter(metricTypeFilters);
List<? extends MetricEntry> metricTypeMonthResult = (List<? extends MetricEntry>) ldapEntryManager.findEntries(metricDn, metricType.getMetricEntryType(), filter, returnAttributes);
metricTypeResult.addAll(metricTypeMonthResult);
}
// Sort entries to avoid calculation errors
ldapEntryManager.sortListByProperties(MetricEntry.class, metricTypeResult, false, "creationDate");
result.put(metricType, metricTypeResult);
}
return result;
}
Aggregations