use of org.gluu.search.filter.Filter 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;
}
use of org.gluu.search.filter.Filter in project oxCore by GluuFederation.
the class MetricService method findAllPeriodBranches.
public List<SimpleBranch> findAllPeriodBranches(DefaultBatchOperation<SimpleBranch> batchOperation, ApplicationType applicationType, String applianceInum, int sizeLimit, int chunkSize) {
String baseDn = buildDn(null, null, applicationType, applianceInum);
Filter skipRootDnFilter = Filter.createNOTFilter(Filter.createEqualityFilter("ou", applicationType.getValue()));
return ldapEntryManager.findEntries(baseDn, SimpleBranch.class, skipRootDnFilter, SearchScope.SUB, new String[] { "ou" }, batchOperation, 0, sizeLimit, chunkSize);
}
Aggregations