Search in sources :

Example 1 with FeatureQueryException

use of org.codice.ddf.spatial.geocoding.FeatureQueryException in project ddf by codice.

the class CatalogFeatureQueryable method query.

@Override
public List<SimpleFeature> query(String queryString, String featureCode, int maxResults) throws FeatureQueryException {
    Validate.notNull(queryString, "queryString can't be null");
    if (maxResults < 0) {
        throw new IllegalArgumentException("maxResults can't be negative");
    }
    Query query = catalogHelper.getQueryForName(queryString);
    QueryRequest queryRequest = new QueryRequestImpl(query);
    SourceResponse response;
    try {
        response = catalogFramework.query(queryRequest);
    } catch (UnsupportedQueryException | SourceUnavailableException | FederationException e) {
        throw new FeatureQueryException("Failed to query catalog", e);
    }
    return response.getResults().stream().map(Result::getMetacard).map(this::getFeatureForMetacard).filter(Objects::nonNull).limit(maxResults).collect(Collectors.toList());
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) Query(ddf.catalog.operation.Query) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponse(ddf.catalog.operation.SourceResponse) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) Objects(java.util.Objects) FederationException(ddf.catalog.federation.FederationException) FeatureQueryException(org.codice.ddf.spatial.geocoding.FeatureQueryException) Result(ddf.catalog.data.Result)

Aggregations

Result (ddf.catalog.data.Result)1 FederationException (ddf.catalog.federation.FederationException)1 Query (ddf.catalog.operation.Query)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 SourceResponse (ddf.catalog.operation.SourceResponse)1 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)1 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)1 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)1 Objects (java.util.Objects)1 FeatureQueryException (org.codice.ddf.spatial.geocoding.FeatureQueryException)1