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());
}
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();
}
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));
}
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));
}
Aggregations