Search in sources :

Example 6 with UnsupportedQueryException

use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.

the class CopyFilterDelegateTest method assertFilterEquals.

private void assertFilterEquals(Filter filterIn) {
    FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
    FilterDelegate<Filter> delegate = new CopyFilterDelegate(filterBuilder);
    FilterAdapter fa = new GeotoolsFilterAdapterImpl();
    Filter filterCopy = null;
    try {
        filterCopy = fa.adapt(filterIn, delegate);
    } catch (UnsupportedQueryException e) {
        fail(e.getMessage());
    }
    assertNotNull(filterCopy);
    // Verify object references are different, indicating a copy was made of the filter
    assertNotSame(filterIn, filterCopy);
    assertFilterContentsEqual(filterIn, filterCopy);
    // Verify filter contents (attributes, operands, etc) are identical
    assertThat(filterCopy, is(filterIn));
}
Also used : Filter(org.opengis.filter.Filter) FilterBuilder(ddf.catalog.filter.FilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)

Example 7 with UnsupportedQueryException

use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.

the class CopyFilterDelegateTest method testFilterModification.

@Test
public void testFilterModification() {
    Filter filterIn = FF.equals(TEST_PROPERTY, FOO_LITERAL);
    FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
    FilterDelegate<Filter> delegate = new FilterModifierDelegate(filterBuilder);
    FilterAdapter fa = new GeotoolsFilterAdapterImpl();
    Filter modifiedFilter = null;
    try {
        modifiedFilter = fa.adapt(filterIn, delegate);
    } catch (UnsupportedQueryException e) {
        fail(e.getMessage());
    }
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("testFeatureType");
    b.add(TEST_PROPERTY_VALUE, String.class);
    b.add("classification", String.class);
    SimpleFeatureType featureType = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
    builder.add(FOO_LITERAL_VALUE);
    builder.add("UNCLASS");
    SimpleFeature feature = builder.buildFeature("test");
    assertTrue(modifiedFilter.evaluate(feature));
}
Also used : SimpleFeatureTypeBuilder(org.geotools.feature.simple.SimpleFeatureTypeBuilder) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) Filter(org.opengis.filter.Filter) FilterBuilder(ddf.catalog.filter.FilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl) SimpleFeature(org.opengis.feature.simple.SimpleFeature) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder) Test(org.junit.Test)

Example 8 with UnsupportedQueryException

use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.

the class FilterAdapterTest method assertFilterEquals.

private void assertFilterEquals(String expected, Filter filter) {
    FilterDelegate<String> delegate = new FilterToTextDelegate();
    FilterAdapter fa = new GeotoolsFilterAdapterImpl();
    String result = null;
    try {
        result = fa.adapt(filter, delegate);
    } catch (UnsupportedQueryException e) {
        fail(e.getMessage());
    }
    assertThat(result, is(expected));
}
Also used : FilterToTextDelegate(ddf.catalog.filter.delegate.FilterToTextDelegate) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)

Example 9 with UnsupportedQueryException

use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.

the class CatalogMetrics method recordSourceQueryExceptions.

private void recordSourceQueryExceptions(QueryResponse response) {
    Set<ProcessingDetails> processingDetails = (Set<ProcessingDetails>) response.getProcessingDetails();
    if (processingDetails == null || processingDetails.iterator() == null) {
        return;
    }
    Iterator<ProcessingDetails> iterator = processingDetails.iterator();
    while (iterator.hasNext()) {
        ProcessingDetails next = iterator.next();
        if (next != null && next.getException() != null) {
            if (next.getException() instanceof UnsupportedQueryException) {
                unsupportedQueryExceptions.mark();
            } else if (next.getException() instanceof SourceUnavailableException) {
                sourceUnavailableExceptions.mark();
            } else if (next.getException() instanceof FederationException) {
                federationExceptions.mark();
            }
            exceptions.mark();
        }
    }
    return;
}
Also used : ProcessingDetails(ddf.catalog.operation.ProcessingDetails) SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) Set(java.util.Set) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FederationException(ddf.catalog.federation.FederationException)

Example 10 with UnsupportedQueryException

use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.

the class CatalogMetricsTest method catalogExceptionMetric.

@Test
public void catalogExceptionMetric() throws Exception {
    QueryResponse response = new QueryResponseImpl(new QueryRequestImpl(new QueryImpl(idFilter)));
    Set<ProcessingDetails> details = response.getProcessingDetails();
    details.addAll(new HashSet<ProcessingDetails>() {

        {
            add(new ProcessingDetailsImpl("source1", new UnsupportedQueryException()));
            add(new ProcessingDetailsImpl("source2", new SourceUnavailableException()));
            add(new ProcessingDetailsImpl("source3", new FederationException()));
            add(new ProcessingDetailsImpl("source4", new Exception()));
        }
    });
    underTest.process(response);
    assertThat(underTest.exceptions.getCount(), is(4L));
    assertThat(underTest.unsupportedQueryExceptions.getCount(), is(1L));
    assertThat(underTest.sourceUnavailableExceptions.getCount(), is(1L));
    assertThat(underTest.federationExceptions.getCount(), is(1L));
}
Also used : ProcessingDetails(ddf.catalog.operation.ProcessingDetails) SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryResponse(ddf.catalog.operation.QueryResponse) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FederationException(ddf.catalog.federation.FederationException) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FederationException(ddf.catalog.federation.FederationException) Test(org.junit.Test)

Aggregations

UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)85 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)34 FederationException (ddf.catalog.federation.FederationException)31 QueryRequest (ddf.catalog.operation.QueryRequest)31 Metacard (ddf.catalog.data.Metacard)28 QueryImpl (ddf.catalog.operation.impl.QueryImpl)27 Filter (org.opengis.filter.Filter)27 ArrayList (java.util.ArrayList)26 Result (ddf.catalog.data.Result)25 QueryResponse (ddf.catalog.operation.QueryResponse)25 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)25 Test (org.junit.Test)21 SourceResponse (ddf.catalog.operation.SourceResponse)16 IngestException (ddf.catalog.source.IngestException)15 IOException (java.io.IOException)15 Query (ddf.catalog.operation.Query)12 CreateResponse (ddf.catalog.operation.CreateResponse)10 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)9 ResourceNotFoundException (ddf.catalog.resource.ResourceNotFoundException)9 Subject (ddf.security.Subject)9