Search in sources :

Example 46 with SourceResponse

use of ddf.catalog.operation.SourceResponse in project ddf by codice.

the class SolrCache method query.

@Override
public List<Metacard> query(Filter filter) throws UnsupportedQueryException {
    QueryRequest queryRequest = new QueryRequestImpl(new QueryImpl(filter), true);
    SourceResponse response = solrClientAdaptor.getSolrMetacardClient().query(queryRequest);
    return getMetacardsFromResponse(response);
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponse(ddf.catalog.operation.SourceResponse) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl)

Example 47 with SourceResponse

use of ddf.catalog.operation.SourceResponse in project ddf by codice.

the class TestGeoJsonQueryResponseTransformer method testNullMetacard.

@Test(expected = CatalogTransformerException.class)
public void testNullMetacard() throws CatalogTransformerException {
    List<Result> results = new LinkedList<Result>();
    Result result = new ResultImpl(null);
    results.add(result);
    SourceResponse sourceResponse = new SourceResponseImpl(null, results, 1L);
    new GeoJsonQueryResponseTransformer().transform(sourceResponse, null);
}
Also used : SourceResponse(ddf.catalog.operation.SourceResponse) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) LinkedList(java.util.LinkedList) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 48 with SourceResponse

use of ddf.catalog.operation.SourceResponse in project ddf by codice.

the class TestGeoJsonQueryResponseTransformer method testGoodResponse.

@Test
public void testGoodResponse() throws CatalogTransformerException, IOException, ParseException {
    final int resultCount = 3;
    final int hitCount = 12;
    SourceResponse sourceResponse = setupResponse(resultCount, hitCount);
    JSONObject obj = transform(sourceResponse, resultCount, hitCount);
    verifyResponse(obj, resultCount, hitCount);
}
Also used : SourceResponse(ddf.catalog.operation.SourceResponse) JSONObject(net.minidev.json.JSONObject) Test(org.junit.Test)

Example 49 with SourceResponse

use of ddf.catalog.operation.SourceResponse in project ddf by codice.

the class TestGeoJsonQueryResponseTransformer method testNullResult.

@Test(expected = CatalogTransformerException.class)
public void testNullResult() throws CatalogTransformerException {
    List<Result> results = new LinkedList<Result>();
    results.add(null);
    results.add(null);
    SourceResponse sourceResponse = new SourceResponseImpl(null, results, 2L);
    new GeoJsonQueryResponseTransformer().transform(sourceResponse, null);
}
Also used : SourceResponse(ddf.catalog.operation.SourceResponse) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) LinkedList(java.util.LinkedList) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 50 with SourceResponse

use of ddf.catalog.operation.SourceResponse in project ddf by codice.

the class DuplicationValidator method query.

private SourceResponse query(Set<Attribute> attributes, String originalId) {
    final Filter filter = filterBuilder.allOf(filterBuilder.anyOf(buildFilters(attributes)), filterBuilder.not(filterBuilder.attribute(Metacard.ID).is().equalTo().text(originalId)));
    LOGGER.debug("filter {}", filter);
    QueryImpl query = new QueryImpl(filter);
    query.setRequestsTotalResultsCount(false);
    QueryRequest request = new QueryRequestImpl(query);
    SourceResponse response = null;
    try {
        response = catalogFramework.query(request);
    } catch (FederationException | SourceUnavailableException | UnsupportedQueryException e) {
        LOGGER.debug("Query failed ", e);
    }
    return response;
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponse(ddf.catalog.operation.SourceResponse) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FederationException(ddf.catalog.federation.FederationException)

Aggregations

SourceResponse (ddf.catalog.operation.SourceResponse)199 Test (org.junit.Test)146 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)99 QueryImpl (ddf.catalog.operation.impl.QueryImpl)95 Result (ddf.catalog.data.Result)79 Metacard (ddf.catalog.data.Metacard)73 Filter (org.opengis.filter.Filter)58 QueryRequest (ddf.catalog.operation.QueryRequest)52 BinaryContent (ddf.catalog.data.BinaryContent)40 ResultImpl (ddf.catalog.data.impl.ResultImpl)29 SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)25 ArrayList (java.util.ArrayList)25 HashMap (java.util.HashMap)24 Matchers.containsString (org.hamcrest.Matchers.containsString)24 Matchers.anyString (org.mockito.Matchers.anyString)21 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)20 Serializable (java.io.Serializable)20 MetacardTransformer (ddf.catalog.transform.MetacardTransformer)19 SortByImpl (ddf.catalog.filter.impl.SortByImpl)18 Map (java.util.Map)16