Search in sources :

Example 1 with PropertyNameImpl

use of ddf.catalog.filter.impl.PropertyNameImpl in project ddf by codice.

the class FederationAdminServiceImpl method getRegistryMetacardsByFilter.

private List<Metacard> getRegistryMetacardsByFilter(Filter filter, Set<String> sourceIds) throws FederationAdminException {
    if (filter == null) {
        throw new FederationAdminException("Error getting registry metacards. Null filter provided.");
    }
    PropertyName propertyName = new PropertyNameImpl(Metacard.MODIFIED);
    SortBy sortBy = new SortByImpl(propertyName, SortOrder.ASCENDING);
    QueryImpl query = new QueryImpl(filter);
    query.setSortBy(sortBy);
    query.setPageSize(PAGE_SIZE);
    QueryRequest queryRequest = new QueryRequestImpl(query, sourceIds);
    try {
        QueryResponse queryResponse = security.runWithSubjectOrElevate(() -> catalogFramework.query(queryRequest));
        return queryResponse.getResults().stream().map(Result::getMetacard).filter(Objects::nonNull).collect(Collectors.toList());
    } catch (SecurityServiceException | InvocationTargetException e) {
        String message = "Error querying for registry metacards.";
        LOGGER.debug("{} For Filter: {}", message, filter);
        throw new FederationAdminException(message, e);
    }
}
Also used : FederationAdminException(org.codice.ddf.registry.federationadmin.service.internal.FederationAdminException) PropertyName(org.opengis.filter.expression.PropertyName) SecurityServiceException(ddf.security.service.SecurityServiceException) QueryRequest(ddf.catalog.operation.QueryRequest) SortBy(org.opengis.filter.sort.SortBy) InvocationTargetException(java.lang.reflect.InvocationTargetException) Result(ddf.catalog.data.Result) QueryImpl(ddf.catalog.operation.impl.QueryImpl) SortByImpl(org.geotools.filter.SortByImpl) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) QueryResponse(ddf.catalog.operation.QueryResponse) PropertyNameImpl(ddf.catalog.filter.impl.PropertyNameImpl)

Example 2 with PropertyNameImpl

use of ddf.catalog.filter.impl.PropertyNameImpl in project ddf by codice.

the class RefreshRegistryEntries method getBasicRegistryQuery.

private Query getBasicRegistryQuery() {
    List<Filter> filters = new ArrayList<>();
    filters.add(filterBuilder.attribute(Metacard.TAGS).is().equalTo().text(RegistryConstants.REGISTRY_TAG));
    PropertyName propertyName = new PropertyNameImpl(Metacard.MODIFIED);
    SortBy sortBy = new SortByImpl(propertyName, SortOrder.ASCENDING);
    QueryImpl query = new QueryImpl(filterBuilder.allOf(filters));
    query.setSortBy(sortBy);
    query.setPageSize(PAGE_SIZE);
    return query;
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) QueryImpl(ddf.catalog.operation.impl.QueryImpl) Filter(org.opengis.filter.Filter) SortByImpl(org.geotools.filter.SortByImpl) SortBy(org.opengis.filter.sort.SortBy) ArrayList(java.util.ArrayList) PropertyNameImpl(ddf.catalog.filter.impl.PropertyNameImpl)

Aggregations

PropertyNameImpl (ddf.catalog.filter.impl.PropertyNameImpl)2 QueryImpl (ddf.catalog.operation.impl.QueryImpl)2 SortByImpl (org.geotools.filter.SortByImpl)2 PropertyName (org.opengis.filter.expression.PropertyName)2 SortBy (org.opengis.filter.sort.SortBy)2 Result (ddf.catalog.data.Result)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 QueryResponse (ddf.catalog.operation.QueryResponse)1 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)1 SecurityServiceException (ddf.security.service.SecurityServiceException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 FederationAdminException (org.codice.ddf.registry.federationadmin.service.internal.FederationAdminException)1 Filter (org.opengis.filter.Filter)1