Search in sources :

Example 1 with AllowedValues

use of net.opengis.ows.v_1_1_0.AllowedValues in project ddf by codice.

the class TestWfsFilterDelegate 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, null, 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 2 with AllowedValues

use of net.opengis.ows.v_1_1_0.AllowedValues 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 3 with AllowedValues

use of net.opengis.ows.v_1_1_0.AllowedValues 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)

Aggregations

AllowedValues (net.opengis.ows.v_1_1_0.AllowedValues)3 ValueType (net.opengis.ows.v_1_1_0.ValueType)3 ArrayList (java.util.ArrayList)2 ConformanceType (net.opengis.filter.v_2_0_0.ConformanceType)2 FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)2 DomainType (net.opengis.ows.v_1_1_0.DomainType)2 Test (org.junit.Test)2 LineString (org.locationtech.jts.geom.LineString)1