Search in sources :

Example 16 with Result

use of ddf.catalog.data.Result in project ddf by codice.

the class RegistryStoreImpl method query.

@Override
public SourceResponse query(QueryRequest request) throws UnsupportedQueryException {
    //This is a registry store so only allow registry requests through
    if (!filterAdapter.adapt(request.getQuery(), new TagsFilterDelegate(ImmutableSet.of(RegistryConstants.REGISTRY_TAG, RegistryConstants.REGISTRY_TAG_INTERNAL), true))) {
        return new SourceResponseImpl(request, Collections.emptyList());
    }
    SourceResponse registryQueryResponse = super.query(request);
    for (Result singleResult : registryQueryResponse.getResults()) {
        if (registryId.equals(RegistryUtility.getRegistryId(singleResult.getMetacard()))) {
            String metacardTitle = singleResult.getMetacard().getTitle();
            if (metacardTitle != null && getId() != null && !getId().equals(getFullRegistryName(metacardTitle))) {
                setId(metacardTitle);
                updateConfiguration(metacardTitle);
            }
            break;
        }
    }
    return registryQueryResponse;
}
Also used : TagsFilterDelegate(ddf.catalog.filter.delegate.TagsFilterDelegate) SourceResponse(ddf.catalog.operation.SourceResponse) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) Result(ddf.catalog.data.Result)

Example 17 with Result

use of ddf.catalog.data.Result in project ddf by codice.

the class TestRegistryStore method testRegistryQuery.

@Test
public void testRegistryQuery() throws Exception {
    Filter filter = filterBuilder.attribute(Metacard.TAGS).is().like().text(RegistryConstants.REGISTRY_TAG);
    queryResults.add(new ResultImpl(getDefaultMetacard()));
    QueryRequest testRequest = new QueryRequestImpl(new QueryImpl(filter));
    SourceResponse answer = registryStore.query(testRequest);
    List<Result> testResults = answer.getResults();
    assertThat(testResults.size(), is(1));
}
Also used : 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) ResultImpl(ddf.catalog.data.impl.ResultImpl) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 18 with Result

use of ddf.catalog.data.Result in project ddf by codice.

the class TestWfsSource method testPagingStartIndexOne.

/**
     * Given 10 features (and metacards) exist that match search criteria, since page size=4 and
     * startIndex=1, should get 4 results back - metacards 1 thru 4.
     *
     * @throws WfsException
     * @throws SecurityServiceException
     * @throws TransformerConfigurationException
     * @throws UnsupportedQueryException
     */
@Test
public void testPagingStartIndexOne() throws WfsException, SecurityServiceException, TransformerConfigurationException, UnsupportedQueryException {
    int pageSize = 4;
    int startIndex = 1;
    setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, MAX_FEATURES, null);
    SourceResponse response = executeQuery(startIndex, pageSize);
    List<Result> results = response.getResults();
    assertThat(results.size(), is(pageSize));
    assertThat(response.getHits(), equalTo(new Long(MAX_FEATURES)));
    // Verify that metacards 1 thru 4 were returned since pageSize=4
    assertCorrectMetacardsReturned(results, startIndex, pageSize);
}
Also used : SourceResponse(ddf.catalog.operation.SourceResponse) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 19 with Result

use of ddf.catalog.data.Result in project ddf by codice.

the class TestWfsSource method testPagingPageSizeExceedsFeatureCountStartIndexOne.

/**
     * Given 10 features (and metacards) exist that match search criteria, since page size=20 (which
     * is larger than number of features) and startIndex=1, should get 10 results back - metacards 1
     * thru 10.
     *
     * @throws WfsException,                     SecurityServiceException
     * @throws TransformerConfigurationException
     * @throws UnsupportedQueryException
     */
@Test
public void testPagingPageSizeExceedsFeatureCountStartIndexOne() throws WfsException, SecurityServiceException, TransformerConfigurationException, UnsupportedQueryException {
    int pageSize = 20;
    int startIndex = 1;
    setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, MAX_FEATURES, null);
    SourceResponse response = executeQuery(startIndex, pageSize);
    List<Result> results = response.getResults();
    assertThat(results.size(), is(MAX_FEATURES));
    assertThat(response.getHits(), equalTo(new Long(MAX_FEATURES)));
    // Verify that metacards 1 thru 10 were returned
    assertCorrectMetacardsReturned(results, startIndex, MAX_FEATURES);
}
Also used : SourceResponse(ddf.catalog.operation.SourceResponse) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 20 with Result

use of ddf.catalog.data.Result in project ddf by codice.

the class TestWfsSource method testPagingPageSizeNegative.

/**
     * Verify that if page size is negative, WfsSource defaults it to the max features that can be
     * returned.
     *
     * @throws WfsException,                     SecurityServiceException
     * @throws TransformerConfigurationException
     * @throws UnsupportedQueryException
     */
@Test
public void testPagingPageSizeNegative() throws WfsException, SecurityServiceException, TransformerConfigurationException, UnsupportedQueryException {
    int pageSize = -1;
    int startIndex = 1;
    int numResults = WfsSource.WFS_MAX_FEATURES_RETURNED + 10;
    setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, 1, numResults);
    SourceResponse response = executeQuery(startIndex, pageSize);
    List<Result> results = response.getResults();
    assertThat(results.size(), is(WfsSource.WFS_MAX_FEATURES_RETURNED));
    assertThat(response.getHits(), equalTo(new Long(numResults)));
}
Also used : SourceResponse(ddf.catalog.operation.SourceResponse) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Aggregations

Result (ddf.catalog.data.Result)361 Test (org.junit.Test)205 Metacard (ddf.catalog.data.Metacard)159 SourceResponse (ddf.catalog.operation.SourceResponse)153 ArrayList (java.util.ArrayList)137 ResultImpl (ddf.catalog.data.impl.ResultImpl)120 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)119 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)102 QueryImpl (ddf.catalog.operation.impl.QueryImpl)91 Filter (org.opengis.filter.Filter)91 QueryResponse (ddf.catalog.operation.QueryResponse)87 QueryRequest (ddf.catalog.operation.QueryRequest)84 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)50 Serializable (java.io.Serializable)50 BinaryContent (ddf.catalog.data.BinaryContent)48 HashMap (java.util.HashMap)45 SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)43 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)39 Map (java.util.Map)36 DateTime (org.joda.time.DateTime)33