Search in sources :

Example 6 with ValueType

use of net.opengis.ows11.ValueType in project ddf by codice.

the class WfsFilterDelegate method configureSorting.

private void configureSorting(DomainType constraint) {
    if (constraint.getNoValues() != null && constraint.getDefaultValue() != null) {
        if (StringUtils.equalsIgnoreCase(constraint.getDefaultValue().getValue(), Boolean.TRUE.toString())) {
            this.isSortingSupported = true;
        } else if (StringUtils.equalsIgnoreCase(constraint.getDefaultValue().getValue(), Boolean.FALSE.toString())) {
            this.isSortingSupported = false;
        }
    }
    if (constraint.getAllowedValues() != null) {
        this.isSortingSupported = true;
        AllowedValues allowedValues = constraint.getAllowedValues();
        List<Object> values = allowedValues.getValueOrRange();
        for (Object value : values) {
            if (value instanceof ValueType) {
                String sortOrder = ((ValueType) value).getValue();
                // Could be ASC, ASCENDING, etc.
                if (StringUtils.startsWithIgnoreCase(sortOrder, "A")) {
                    allowedSortOrders.add(SortOrder.ASCENDING);
                } else if (StringUtils.startsWithIgnoreCase(sortOrder, "D")) {
                    allowedSortOrders.add(SortOrder.DESCENDING);
                }
            }
        }
    }
}
Also used : AllowedValues(net.opengis.ows.v_1_1_0.AllowedValues) ValueType(net.opengis.ows.v_1_1_0.ValueType) LineString(org.locationtech.jts.geom.LineString)

Example 7 with ValueType

use of net.opengis.ows11.ValueType in project ddf by codice.

the class WfsFilterDelegateTest method testConformanceAllowedValues.

@Test
public void testConformanceAllowedValues() {
    // Setup
    FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
    ConformanceType conformance = capabilities.getConformance();
    List<DomainType> domainTypes = conformance.getConstraint();
    for (DomainType domainType : domainTypes) {
        if (StringUtils.equals(domainType.getName(), "ImplementsSorting")) {
            domainType.setNoValues(null);
            ValueType asc = new ValueType();
            asc.setValue("ASC");
            ValueType desc = new ValueType();
            desc.setValue("DESC");
            AllowedValues allowedValues = new AllowedValues();
            List<Object> values = new ArrayList<>();
            values.add(asc);
            values.add(desc);
            allowedValues.setValueOrRange(values);
            domainType.setAllowedValues(allowedValues);
            ValueType defaultValue = new ValueType();
            defaultValue.setValue("ASC");
            domainType.setDefaultValue(defaultValue);
            break;
        }
    }
    // Perform Test
    WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
    // Verify
    assertThat(delegate.isSortingSupported(), is(true));
    assertThat(delegate.getAllowedSortOrders().size(), is(2));
    assertThat(delegate.getAllowedSortOrders().contains(SortOrder.ASCENDING), is(true));
    assertThat(delegate.getAllowedSortOrders().contains(SortOrder.DESCENDING), is(true));
}
Also used : FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) DomainType(net.opengis.ows.v_1_1_0.DomainType) AllowedValues(net.opengis.ows.v_1_1_0.AllowedValues) ValueType(net.opengis.ows.v_1_1_0.ValueType) ArrayList(java.util.ArrayList) ConformanceType(net.opengis.filter.v_2_0_0.ConformanceType) Test(org.junit.Test)

Example 8 with ValueType

use of net.opengis.ows11.ValueType in project ddf by codice.

the class WfsSourceTest method testSortingAscendingSortingNotSupported.

/**
 * Verify that the SortBy is NOT set. In this case, sorting is not supported in the capabilities.
 */
@Test
public void testSortingAscendingSortingNotSupported() throws Exception {
    // Setup
    final String searchPhrase = "*";
    final String mockTemporalFeatureProperty = "myTemporalFeatureProperty";
    final String mockFeatureType = "{http://example.com}" + SAMPLE_FEATURE_NAME + 0;
    final int pageSize = 1;
    // Set ImplementsSorting to FALSE (sorting not supported)
    FilterCapabilities mockCapabilitiesSortingNotSupported = MockWfsServer.getFilterCapabilities();
    ConformanceType conformance = mockCapabilitiesSortingNotSupported.getConformance();
    List<DomainType> domainTypes = conformance.getConstraint();
    for (DomainType domainType : domainTypes) {
        if (StringUtils.equals(domainType.getName(), "ImplementsSorting")) {
            ValueType valueType = new ValueType();
            valueType.setValue("FALSE");
            domainType.setDefaultValue(valueType);
            break;
        }
    }
    WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, mockCapabilitiesSortingNotSupported, 1, false, false, 0);
    MetacardMapper mockMetacardMapper = mock(MetacardMapper.class);
    when(mockMetacardMapper.getFeatureType()).thenReturn(mockFeatureType);
    when(mockMetacardMapper.getSortByTemporalFeatureProperty()).thenReturn(mockTemporalFeatureProperty);
    List<MetacardMapper> mappers = new ArrayList<>(1);
    mappers.add(mockMetacardMapper);
    source.setMetacardToFeatureMapper(mappers);
    QueryImpl query = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text(searchPhrase));
    query.setPageSize(pageSize);
    SortBy sortBy = new SortByImpl(Result.TEMPORAL, SortOrder.ASCENDING);
    query.setSortBy(sortBy);
    // Perform Test
    GetFeatureType featureType = source.buildGetFeatureRequest(query);
    // Verify
    QueryType queryType = (QueryType) featureType.getAbstractQueryExpression().get(0).getValue();
    assertFalse(queryType.isSetAbstractSortingClause());
}
Also used : ValueType(net.opengis.ows.v_1_1_0.ValueType) SortBy(org.opengis.filter.sort.SortBy) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) QueryImpl(ddf.catalog.operation.impl.QueryImpl) DomainType(net.opengis.ows.v_1_1_0.DomainType) SortByImpl(ddf.catalog.filter.impl.SortByImpl) ConformanceType(net.opengis.filter.v_2_0_0.ConformanceType) QueryType(net.opengis.wfs.v_2_0_0.QueryType) MetacardMapper(org.codice.ddf.spatial.ogc.wfs.catalog.mapper.MetacardMapper) GetFeatureType(net.opengis.wfs.v_2_0_0.GetFeatureType) Test(org.junit.Test)

Aggregations

ValueType (net.opengis.ows.v_1_1_0.ValueType)6 ArrayList (java.util.ArrayList)5 ConformanceType (net.opengis.filter.v_2_0_0.ConformanceType)5 FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)5 DomainType (net.opengis.ows.v_1_1_0.DomainType)5 Test (org.junit.Test)5 AllowedValues (net.opengis.ows.v_1_1_0.AllowedValues)3 SortByImpl (ddf.catalog.filter.impl.SortByImpl)2 QueryImpl (ddf.catalog.operation.impl.QueryImpl)2 GetFeatureType (net.opengis.wfs.v_2_0_0.GetFeatureType)2 QueryType (net.opengis.wfs.v_2_0_0.QueryType)2 CustomProcessFunction (com.sldeditor.rendertransformation.CustomProcessFunction)1 ProcessFunctionParameterValue (com.sldeditor.rendertransformation.ProcessFunctionParameterValue)1 MalformedURLException (java.net.MalformedURLException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 JAXBElement (javax.xml.bind.JAXBElement)1 Duration (javax.xml.datatype.Duration)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 QName (javax.xml.namespace.QName)1