use of org.gluu.search.filter.Filter in project oxAuth by GluuFederation.
the class CleanerTimer method cleanup.
public int cleanup(final Map.Entry<String, Class<?>> baseDn, final Date now, final int batchSize) {
try {
Filter filter = Filter.createANDFilter(Filter.createEqualityFilter("del", true), Filter.createLessOrEqualFilter("exp", entryManager.encodeTime(baseDn.getKey(), now)));
int removedCount = entryManager.remove(baseDn.getKey(), baseDn.getValue(), filter, batchSize);
log.trace("Removed " + removedCount + " entries from " + baseDn.getKey());
return removedCount;
} catch (Exception e) {
log.error("Failed to perform clean up.", e);
}
return 0;
}
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, 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, 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", getEntryManager().encodeTime(metricDn, (startDate)));
Filter endDateFilter = Filter.createLessOrEqualFilter("oxEndDate", getEntryManager().encodeTime(metricDn, 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>) getEntryManager().findEntries(metricDn, metricType.getMetricEntryType(), filter, returnAttributes);
metricTypeResult.addAll(metricTypeMonthResult);
}
// Sort entries to avoid calculation errors
getEntryManager().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 AbstractCustomScriptService method findCustomScripts.
public List<CustomScript> findCustomScripts(List<CustomScriptType> customScriptTypes, String... returnAttributes) {
String baseDn = baseDn();
if ((customScriptTypes == null) || (customScriptTypes.size() == 0)) {
return findAllCustomScripts(returnAttributes);
}
List<Filter> customScriptTypeFilters = new ArrayList<Filter>();
for (CustomScriptType customScriptType : customScriptTypes) {
Filter customScriptTypeFilter = Filter.createEqualityFilter("oxScriptType", customScriptType.getValue());
customScriptTypeFilters.add(customScriptTypeFilter);
}
Filter filter = Filter.createORFilter(customScriptTypeFilters);
List<CustomScript> result = persistenceEntryManager.findEntries(baseDn, CustomScript.class, filter, returnAttributes);
return result;
}
use of org.gluu.search.filter.Filter in project oxCore by GluuFederation.
the class AbstractCustomScriptService method getScriptByDisplayName.
public CustomScript getScriptByDisplayName(String name) {
Filter searchFilter = Filter.createEqualityFilter("displayName", name);
List<CustomScript> result = persistenceEntryManager.findEntries(baseDn(), CustomScript.class, searchFilter, 1);
if (result != null && !result.isEmpty()) {
return result.get(0);
}
return null;
}
use of org.gluu.search.filter.Filter in project oxCore by GluuFederation.
the class AbstractCustomScriptService method findOtherCustomScripts.
public List<CustomScript> findOtherCustomScripts(String pattern, int sizeLimit) {
String[] targetArray = new String[] { pattern };
Filter descriptionFilter = Filter.createSubstringFilter(OxConstants.DESCRIPTION, null, targetArray, null);
Filter scriptTypeFilter = Filter.createNOTFilter(Filter.createEqualityFilter(OxConstants.SCRIPT_TYPE, CustomScriptType.PERSON_AUTHENTICATION));
Filter displayNameFilter = Filter.createSubstringFilter(OxConstants.DISPLAY_NAME, null, targetArray, null);
Filter searchFilter = Filter.createORFilter(descriptionFilter, displayNameFilter);
return persistenceEntryManager.findEntries(baseDn(), CustomScript.class, Filter.createANDFilter(searchFilter, scriptTypeFilter), sizeLimit);
}
Aggregations