Search in sources :

Example 26 with FilterType

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));
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) Test(org.junit.Test)

Example 27 with FilterType

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));
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) Test(org.junit.Test)

Example 28 with FilterType

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));
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) Test(org.junit.Test)

Example 29 with FilterType

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;
}
Also used : UnaryLogicOpType(net.opengis.filter.v_2_0_0.UnaryLogicOpType) FilterType(net.opengis.filter.v_2_0_0.FilterType)

Example 30 with FilterType

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.");
    }
}
Also used : ContentType(ddf.catalog.data.ContentType) QName(javax.xml.namespace.QName) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) ArrayList(java.util.ArrayList) SortOrder(org.opengis.filter.sort.SortOrder) SortByType(net.opengis.filter.v_2_0_0.SortByType) JAXBElement(javax.xml.bind.JAXBElement) FilterType(net.opengis.filter.v_2_0_0.FilterType) QueryType(net.opengis.wfs.v_2_0_0.QueryType) GetFeatureType(net.opengis.wfs.v_2_0_0.GetFeatureType)

Aggregations

Test (org.junit.Test)212 FilterType (net.opengis.filter.v_1_1_0.FilterType)209 FilterType (net.opengis.filter.v_2_0_0.FilterType)58 ArrayList (java.util.ArrayList)50 JAXBElement (javax.xml.bind.JAXBElement)12 CswSourceConfiguration (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration)12 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)11 FeatureAttributeDescriptor (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor)11 QName (javax.xml.namespace.QName)10 BinarySpatialOpType (net.opengis.filter.v_2_0_0.BinarySpatialOpType)10 LineString (com.vividsolutions.jts.geom.LineString)9 Date (java.util.Date)9 DistanceBufferType (net.opengis.filter.v_2_0_0.DistanceBufferType)9 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)9 DateTime (org.joda.time.DateTime)8 Method (java.lang.reflect.Method)7 QueryConstraintType (net.opengis.cat.csw.v_2_0_2.QueryConstraintType)7 FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)7 TimePeriodType (net.opengis.gml.v_3_2_1.TimePeriodType)7 TimePositionType (net.opengis.gml.v_3_2_1.TimePositionType)7