Search in sources :

Example 51 with Filter

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;
}
Also used : HashMap(java.util.HashMap) MetricType(org.xdi.model.metric.MetricType) ArrayList(java.util.ArrayList) MetricEntry(org.xdi.model.metric.ldap.MetricEntry) LinkedList(java.util.LinkedList) Filter(org.gluu.search.filter.Filter) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List)

Example 52 with Filter

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);
}
Also used : Filter(org.gluu.search.filter.Filter)

Aggregations

Filter (org.gluu.search.filter.Filter)52 ArrayList (java.util.ArrayList)22 EntryPersistenceException (org.gluu.persist.exception.mapping.EntryPersistenceException)7 MappingException (org.gluu.persist.exception.mapping.MappingException)7 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)6 SearchException (org.gluu.persist.exception.operation.SearchException)6 LdapEntryManager (org.gluu.persist.ldap.impl.LdapEntryManager)6 PropertyAnnotation (org.gluu.persist.model.PropertyAnnotation)5 SearchResult (com.unboundid.ldap.sdk.SearchResult)4 ParseException (java.text.ParseException)4 AuthenticationException (org.gluu.persist.exception.operation.AuthenticationException)4 ConnectionException (org.gluu.persist.exception.operation.ConnectionException)4 SearchScopeException (org.gluu.persist.exception.operation.SearchScopeException)4 GluuAttribute (org.xdi.model.GluuAttribute)4 SearchResultEntry (com.unboundid.ldap.sdk.SearchResultEntry)3 HashSet (java.util.HashSet)3 List (java.util.List)3 GluuGroup (org.gluu.oxtrust.model.GluuGroup)3 BaseScimResource (org.gluu.oxtrust.model.scim2.BaseScimResource)3 AttributeData (org.gluu.persist.model.AttributeData)3