Search in sources :

Example 1 with ValidationQueryDelegate

use of ddf.catalog.filter.delegate.ValidationQueryDelegate in project ddf by codice.

the class ValidationQueryFactory method getQueryRequestWithValidationFilter.

QueryRequest getQueryRequestWithValidationFilter(QueryRequest input, Boolean showErrors, Boolean showWarnings) {
    Query inputQuery = input.getQuery();
    try {
        if ((showErrors && showWarnings) || adapter.adapt(input.getQuery(), new ValidationQueryDelegate())) {
            return input;
        }
    } catch (UnsupportedQueryException e) {
        LOGGER.info("This attribute filter is not supported by ValidationQueryDelegate.", e);
    }
    List<Filter> filters = new ArrayList<>();
    if (!showErrors) {
        filters.add(builder.attribute(Validation.VALIDATION_ERRORS).is().empty());
    }
    if (!showWarnings) {
        filters.add(builder.attribute(Validation.VALIDATION_WARNINGS).is().empty());
    }
    QueryImpl query = new QueryImpl(builder.allOf(builder.allOf(filters), inputQuery), inputQuery.getStartIndex(), inputQuery.getPageSize(), inputQuery.getSortBy(), inputQuery.requestsTotalResultsCount(), inputQuery.getTimeoutMillis());
    return new QueryRequestImpl(query, input.isEnterprise(), input.getSourceIds(), input.getProperties());
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) Query(ddf.catalog.operation.Query) Filter(org.opengis.filter.Filter) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) ValidationQueryDelegate(ddf.catalog.filter.delegate.ValidationQueryDelegate) ArrayList(java.util.ArrayList)

Example 2 with ValidationQueryDelegate

use of ddf.catalog.filter.delegate.ValidationQueryDelegate in project ddf by codice.

the class ValidationQueryFactoryTest method setUp.

@Before
public void setUp() {
    filterAdapter = new GeotoolsFilterAdapterImpl();
    filterBuilder = new GeotoolsFilterBuilder();
    validationQueryFactory = new ValidationQueryFactory(filterAdapter, filterBuilder);
    testValidationQueryDelegate = new ValidationQueryDelegate();
}
Also used : GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) ValidationQueryDelegate(ddf.catalog.filter.delegate.ValidationQueryDelegate) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl) Before(org.junit.Before)

Example 3 with ValidationQueryDelegate

use of ddf.catalog.filter.delegate.ValidationQueryDelegate in project ddf by codice.

the class ValidationQueryFactoryTest method testSearchValid.

@Test
public void testSearchValid() throws StopProcessingException, PluginExecutionException, UnsupportedQueryException {
    QueryImpl query = new QueryImpl(filterBuilder.attribute(Validation.VALIDATION_WARNINGS).is().empty());
    ValidationQueryDelegate delegate = new ValidationQueryDelegate();
    assertThat(filterAdapter.adapt(query, delegate), is(true));
    QueryRequest returnQuery = validationQueryFactory.getQueryRequestWithValidationFilter(new QueryRequestImpl(query));
    assertThat(filterAdapter.adapt(returnQuery.getQuery(), delegate), is(true));
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequest(ddf.catalog.operation.QueryRequest) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) ValidationQueryDelegate(ddf.catalog.filter.delegate.ValidationQueryDelegate) Test(org.junit.Test)

Example 4 with ValidationQueryDelegate

use of ddf.catalog.filter.delegate.ValidationQueryDelegate in project ddf by codice.

the class ValidationQueryFactoryTest method testSearchInvalid.

@Test
public void testSearchInvalid() throws StopProcessingException, PluginExecutionException, UnsupportedQueryException {
    QueryImpl query = new QueryImpl(filterBuilder.attribute(Validation.VALIDATION_WARNINGS).is().equalTo().text("sample"));
    ValidationQueryDelegate delegate = new ValidationQueryDelegate();
    assertThat(filterAdapter.adapt(query, testValidationQueryDelegate), is(true));
    QueryRequest returnQuery = validationQueryFactory.getQueryRequestWithValidationFilter(new QueryRequestImpl(query));
    assertThat(filterAdapter.adapt(returnQuery.getQuery(), testValidationQueryDelegate), is(true));
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequest(ddf.catalog.operation.QueryRequest) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) ValidationQueryDelegate(ddf.catalog.filter.delegate.ValidationQueryDelegate) Test(org.junit.Test)

Aggregations

ValidationQueryDelegate (ddf.catalog.filter.delegate.ValidationQueryDelegate)4 QueryImpl (ddf.catalog.operation.impl.QueryImpl)3 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)3 QueryRequest (ddf.catalog.operation.QueryRequest)2 Test (org.junit.Test)2 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)1 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)1 Query (ddf.catalog.operation.Query)1 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 Filter (org.opengis.filter.Filter)1