use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.
the class TestCswCqlFilter method testPropertyIsLessThanOrEqualToStringLiteral.
/**
* Property is less than or equal to tests
*/
@Test
public void testPropertyIsLessThanOrEqualToStringLiteral() throws UnsupportedQueryException {
FilterType filterType = cswFilterDelegate.propertyIsLessThanOrEqualTo(propertyName, stringLiteral);
String cqlText = CswCqlTextFilter.getInstance().getCqlText(filterType);
assertThat(propertyIsLessThanOrEqualTo, is(cqlText));
}
use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.
the class TestCswCqlFilter method testPropertyLikeAnyText.
@Test
public void testPropertyLikeAnyText() throws UnsupportedQueryException {
FilterType filterType = cswFilterDelegate.propertyIsLike(propertyNameAnyText, likeLiteral, isCaseSensitive);
String cqlText = CswCqlTextFilter.getInstance().getCqlText(filterType);
assertThat(propertyIsLikeAnyText, is(cqlText));
}
use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.
the class TestCswCqlFilter method testPropertyBetweenIntLiterals.
@Test
public void testPropertyBetweenIntLiterals() throws UnsupportedQueryException {
FilterType filterType = cswFilterDelegate.propertyIsBetween(propertyName, intLowerBoundary, intUpperBoundary);
String cqlText = CswCqlTextFilter.getInstance().getCqlText(filterType);
assertThat(propertyIsBetween, is(cqlText));
}
use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.
the class WfsFilterDelegate method not.
@Override
public FilterType not(FilterType filterToBeNoted) {
areLogicalOperationsSupported();
FilterType returnFilter = new FilterType();
if (filterToBeNoted == null) {
return null;
}
UnaryLogicOpType notType = new UnaryLogicOpType();
if (filterToBeNoted.isSetComparisonOps()) {
notType.setComparisonOps(filterToBeNoted.getComparisonOps());
} else if (filterToBeNoted.isSetLogicOps()) {
notType.setLogicOps(filterToBeNoted.getLogicOps());
} else if (filterToBeNoted.isSetSpatialOps()) {
notType.setSpatialOps(filterToBeNoted.getSpatialOps());
} else {
return returnFilter;
}
returnFilter.setLogicOps(filterObjectFactory.createNot(notType));
return returnFilter;
}
use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.
the class WfsSource method buildGetFeatureRequest.
protected GetFeatureType buildGetFeatureRequest(Query query) throws UnsupportedQueryException {
List<ContentType> contentTypes = getContentTypesFromQuery(query);
List<QueryType> queries = new ArrayList<QueryType>();
for (Entry<QName, WfsFilterDelegate> filterDelegateEntry : featureTypeFilters.entrySet()) {
if (contentTypes.isEmpty() || isFeatureTypeInQuery(contentTypes, filterDelegateEntry.getKey().getLocalPart())) {
QueryType wfsQuery = new QueryType();
String typeName = null;
if (StringUtils.isEmpty(filterDelegateEntry.getKey().getPrefix())) {
typeName = filterDelegateEntry.getKey().getLocalPart();
} else {
typeName = filterDelegateEntry.getKey().getPrefix() + ":" + filterDelegateEntry.getKey().getLocalPart();
}
if (StringUtils.isNotBlank(srsName)) {
wfsQuery.setSrsName(srsName);
}
wfsQuery.setTypeNames(Arrays.asList(typeName));
wfsQuery.setHandle(filterDelegateEntry.getKey().getLocalPart());
FilterType filter = filterAdapter.adapt(query, filterDelegateEntry.getValue());
if (filter != null) {
if (areAnyFiltersSet(filter)) {
wfsQuery.setAbstractSelectionClause(new net.opengis.filter.v_2_0_0.ObjectFactory().createFilter(filter));
}
if (!this.disableSorting) {
if (query.getSortBy() != null) {
SortOrder sortOrder = query.getSortBy().getSortOrder();
if (filterDelegateEntry.getValue().isSortingSupported() && filterDelegateEntry.getValue().getAllowedSortOrders().contains(sortOrder)) {
JAXBElement<SortByType> sortBy = buildSortBy(filterDelegateEntry.getKey(), query.getSortBy());
if (sortBy != null) {
LOGGER.debug("Sorting using sort order of [{}].", sortOrder.identifier());
wfsQuery.setAbstractSortingClause(sortBy);
}
} else if (filterDelegateEntry.getValue().isSortingSupported() && CollectionUtils.isEmpty(filterDelegateEntry.getValue().getAllowedSortOrders())) {
JAXBElement<SortByType> sortBy = buildSortBy(filterDelegateEntry.getKey(), query.getSortBy());
if (sortBy != null) {
LOGGER.debug("No sort orders defined in getCapabilities. Attempting to sort using sort order of [{}].", sortOrder.identifier());
wfsQuery.setAbstractSortingClause(sortBy);
}
} else if (filterDelegateEntry.getValue().isSortingSupported() && !filterDelegateEntry.getValue().getAllowedSortOrders().contains(sortOrder)) {
LOGGER.debug("Unsupported sort order of [{}]. Supported sort orders are {}.", sortOrder, filterDelegateEntry.getValue().getAllowedSortOrders());
} else if (!filterDelegateEntry.getValue().isSortingSupported()) {
LOGGER.debug("Sorting is not supported.");
}
}
} else {
LOGGER.debug("Sorting is disabled.");
}
queries.add(wfsQuery);
} else {
LOGGER.debug("WFS Source {}: {} has an invalid filter.", getId(), filterDelegateEntry.getKey());
}
}
}
if (queries != null && !queries.isEmpty()) {
GetFeatureType getFeatureType = new GetFeatureType();
int pageSize = query.getPageSize();
if (pageSize < 0) {
LOGGER.debug("Page size has a negative value");
throw new UnsupportedQueryException("Unable to build query. Page size has a negative value.");
}
int startIndex = query.getStartIndex();
if (startIndex < 0) {
LOGGER.debug("Start index has a negative value");
throw new UnsupportedQueryException("Unable to build query. Start index has a negative value.");
} else if (startIndex != 0) {
//Convert DDF index of 1 back to index of 0 for WFS 2.0
startIndex = query.getStartIndex() - 1;
} else {
LOGGER.debug("Query already has a start index of 0");
}
getFeatureType.setCount(BigInteger.valueOf(query.getPageSize()));
getFeatureType.setStartIndex(BigInteger.valueOf(startIndex));
List<JAXBElement<?>> incomingQueries = getFeatureType.getAbstractQueryExpression();
for (QueryType queryType : queries) {
incomingQueries.add(new net.opengis.wfs.v_2_0_0.ObjectFactory().createQuery(queryType));
}
logMessage(getFeatureType);
return getFeatureType;
} else {
throw new UnsupportedQueryException("Unable to build query. No filters could be created from query criteria.");
}
}
Aggregations