Search in sources :

Example 26 with FilterCapabilities

use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.

the class TestWfsFilterDelegate method testNoTemporalOps.

@Test
public void testNoTemporalOps() {
    FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
    capabilities.setTemporalCapabilities(null);
    WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, null, GeospatialUtil.LAT_LON_ORDER);
    assertThat(delegate.isLogicalOps(), is(true));
    assertThat(delegate.isEpsg4326(), is(true));
    assertThat(delegate.isSortingSupported(), is(true));
    assertThat(delegate.getSrsName(), is(GeospatialUtil.EPSG_4326_URN));
    assertThat(delegate.getComparisonOps().size(), is(COMPARISON_OPERATORS.values().length));
    assertThat(delegate.getGeometryOperands().size(), greaterThan(0));
    assertThat(delegate.getSpatialOps().size(), is(SPATIAL_OPERATORS.values().length));
    assertThat(delegate.getTemporalOps().size(), is(0));
    assertThat(delegate.getTemporalOperands().size(), is(0));
}
Also used : FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) Test(org.junit.Test)

Example 27 with FilterCapabilities

use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.

the class TestWfsFilterDelegate method testRelativeTemporalOnlyQueryAfterUnsupported.

/**
     * If the WFS server does not support an 'After' temporal query and supports a
     * 'During' temporal query, the query should be translated into a 'During <date> to <now>'
     */
@Test
public void testRelativeTemporalOnlyQueryAfterUnsupported() {
    setupMockMetacardType();
    FilterType afterFilter = setupAfterFilterType();
    FilterCapabilities duringFilterCapabilities = setupFilterCapabilities();
    WfsFilterDelegate duringDelegate = new WfsFilterDelegate(mockFeatureMetacardType, duringFilterCapabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
    List<FilterType> testFilters = new ArrayList<>();
    testFilters.add(afterFilter);
    List<FilterType> convertedFilters = duringDelegate.applyTemporalFallbacks(testFilters);
    FilterType duringFilter = convertedFilters.get(0);
    assertThat(duringFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}During"));
    BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) duringFilter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    TimePeriodType timePeriod = (TimePeriodType) binaryTemporalOpType.getExpression().getValue();
    TimePositionType beginPositionType = timePeriod.getBeginPosition();
    Date beginDate = timePositionTypeToDate(beginPositionType);
    TimePositionType endPositionType = timePeriod.getEndPosition();
    Date endDate = timePositionTypeToDate(endPositionType);
    // Verify Date range is created correctly
    assertThat(endDate.after(beginDate), is(true));
}
Also used : FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) FilterType(net.opengis.filter.v_2_0_0.FilterType) TimePeriodType(net.opengis.gml.v_3_2_1.TimePeriodType) ArrayList(java.util.ArrayList) BinaryTemporalOpType(net.opengis.filter.v_2_0_0.BinaryTemporalOpType) TimePositionType(net.opengis.gml.v_3_2_1.TimePositionType) Date(java.util.Date) Test(org.junit.Test)

Example 28 with FilterCapabilities

use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.

the class TestWfsSource method setUp.

public void setUp(final String schema, final List<Object> supportedGeos, final String srsName, final Integer numFeatures, final Integer numResults) throws WfsException, SecurityServiceException {
    mockFactory = mock(SecureCxfClientFactory.class);
    when(mockFactory.getClient()).thenReturn(mockWfs);
    // GetCapabilities Response
    when(mockWfs.getCapabilities(any(GetCapabilitiesRequest.class))).thenReturn(mockCapabilites);
    mockCapabilites.setFilterCapabilities(new FilterCapabilities());
    mockCapabilites.getFilterCapabilities().setSpatialCapabilities(new SpatialCapabilitiesType());
    mockCapabilites.getFilterCapabilities().getSpatialCapabilities().setSpatialOperators(new SpatialOperatorsType());
    if (null != supportedGeos && !supportedGeos.isEmpty()) {
        mockCapabilites.getFilterCapabilities().getSpatialCapabilities().getSpatialOperators().getBBOXOrEqualsOrDisjoint().addAll(supportedGeos);
    }
    // DescribeFeatureType Response
    XmlSchema xmlSchema = null;
    if (null != schema) {
        XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
        wfsUriResolver.setGmlNamespace(Wfs10Constants.GML_NAMESPACE);
        wfsUriResolver.setWfsNamespace(Wfs10Constants.WFS_NAMESPACE);
        schemaCollection.setSchemaResolver(wfsUriResolver);
        xmlSchema = schemaCollection.read(new StreamSource(new ByteArrayInputStream(schema.getBytes())));
    }
    when(mockWfs.describeFeatureType(any(DescribeFeatureTypeRequest.class))).thenReturn(xmlSchema);
    sampleFeatures = new ArrayList<>();
    mockCapabilites.setFeatureTypeList(new FeatureTypeListType());
    if (numFeatures != null) {
        for (int ii = 0; ii < numFeatures; ii++) {
            FeatureTypeType feature = new FeatureTypeType();
            QName qName;
            if (ii == 0) {
                qName = new QName("SampleFeature" + ii);
            } else {
                qName = new QName("http://example.com", "SampleFeature" + ii, "Prefix" + ii);
            }
            sampleFeatures.add(qName);
            feature.setName(qName);
            // feature.setName(SAMPLE_FEATURE[ii]);
            if (null != srsName) {
                feature.setSRS(srsName);
            }
            mockCapabilites.getFeatureTypeList().getFeatureType().add(feature);
        }
    }
    // GetFeature Response
    when(mockWfs.getFeature(any(GetFeatureType.class))).thenReturn(mockFeatureCollection);
    when(mockFeatureCollection.getFeatureMembers()).thenAnswer(new Answer<List<Metacard>>() {

        @Override
        public List<Metacard> answer(InvocationOnMock invocation) {
            // Create as many metacards as there are features
            Integer resultsToReturn = numResults;
            if (resultsToReturn == null && numFeatures != null) {
                resultsToReturn = numFeatures;
            }
            List<Metacard> metacards = new ArrayList<Metacard>(resultsToReturn);
            for (int i = 0; i < resultsToReturn; i++) {
                MetacardImpl mc = new MetacardImpl();
                mc.setId("ID_" + String.valueOf(i + 1));
                metacards.add(mc);
            }
            return metacards;
        }
    });
    when(mockAvailabilityTask.isAvailable()).thenReturn(true);
    source = new WfsSource(new GeotoolsFilterAdapterImpl(), mockContext, mockAvailabilityTask, mockFactory, encryptionService);
}
Also used : SecureCxfClientFactory(org.codice.ddf.cxf.SecureCxfClientFactory) SpatialCapabilitiesType(ogc.schema.opengis.filter_capabilities.v_1_0_0.SpatialCapabilitiesType) FilterCapabilities(ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities) SpatialOperatorsType(ogc.schema.opengis.filter_capabilities.v_1_0_0.SpatialOperatorsType) List(java.util.List) ArrayList(java.util.ArrayList) GetFeatureType(ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType) GetCapabilitiesRequest(org.codice.ddf.spatial.ogc.wfs.v1_0_0.catalog.common.GetCapabilitiesRequest) FeatureTypeType(ogc.schema.opengis.wfs_capabilities.v_1_0_0.FeatureTypeType) FeatureTypeListType(ogc.schema.opengis.wfs_capabilities.v_1_0_0.FeatureTypeListType) QName(javax.xml.namespace.QName) StreamSource(javax.xml.transform.stream.StreamSource) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) BigInteger(java.math.BigInteger) Metacard(ddf.catalog.data.Metacard) XmlSchema(org.apache.ws.commons.schema.XmlSchema) ByteArrayInputStream(java.io.ByteArrayInputStream) InvocationOnMock(org.mockito.invocation.InvocationOnMock) DescribeFeatureTypeRequest(org.codice.ddf.spatial.ogc.wfs.v1_0_0.catalog.common.DescribeFeatureTypeRequest) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)

Example 29 with FilterCapabilities

use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.

the class TestCswCqlFilter method getMockFilterCapabilities.

private static FilterCapabilities getMockFilterCapabilities() {
    FilterCapabilities mockFilterCapabilities = mock(FilterCapabilities.class);
    ComparisonOperatorsType mockComparisonOps = mock(ComparisonOperatorsType.class);
    when(mockComparisonOps.getComparisonOperator()).thenReturn(getFullComparisonOpsList());
    SpatialOperatorsType mockSpatialOperatorsType = mock(SpatialOperatorsType.class);
    when(mockSpatialOperatorsType.getSpatialOperator()).thenReturn(getSpatialOperatorsList());
    SpatialCapabilitiesType mockSpatialCapabilities = getAllSpatialCapabilities();
    when(mockSpatialCapabilities.getSpatialOperators()).thenReturn(mockSpatialOperatorsType);
    ScalarCapabilitiesType mockScalarCapabilities = mock(ScalarCapabilitiesType.class);
    when(mockScalarCapabilities.getComparisonOperators()).thenReturn(mockComparisonOps);
    when(mockFilterCapabilities.getScalarCapabilities()).thenReturn(mockScalarCapabilities);
    when(mockFilterCapabilities.getSpatialCapabilities()).thenReturn(mockSpatialCapabilities);
    when(mockScalarCapabilities.getLogicalOperators()).thenReturn(mock(LogicalOperators.class));
    return mockFilterCapabilities;
}
Also used : FilterCapabilities(net.opengis.filter.v_1_1_0.FilterCapabilities) ComparisonOperatorsType(net.opengis.filter.v_1_1_0.ComparisonOperatorsType) ScalarCapabilitiesType(net.opengis.filter.v_1_1_0.ScalarCapabilitiesType) SpatialOperatorsType(net.opengis.filter.v_1_1_0.SpatialOperatorsType) LogicalOperators(net.opengis.filter.v_1_1_0.LogicalOperators) SpatialCapabilitiesType(net.opengis.filter.v_1_1_0.SpatialCapabilitiesType)

Example 30 with FilterCapabilities

use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.

the class MockWfsServer method getFilterCapabilities.

public static FilterCapabilities getFilterCapabilities() {
    FilterCapabilities capabilities = new FilterCapabilities();
    ConformanceType conformance = new ConformanceType();
    for (CONFORMANCE_CONSTRAINTS constraint : CONFORMANCE_CONSTRAINTS.values()) {
        DomainType domain = new DomainType();
        NoValues noValues = new NoValues();
        domain.setNoValues(noValues);
        ValueType value = new ValueType();
        value.setValue("TRUE");
        domain.setDefaultValue(value);
        domain.setName(constraint.toString());
        conformance.getConstraint().add(domain);
    }
    capabilities.setConformance(conformance);
    ScalarCapabilitiesType scalar = new ScalarCapabilitiesType();
    scalar.setLogicalOperators(new LogicalOperators());
    scalar.setComparisonOperators(new ComparisonOperatorsType());
    for (COMPARISON_OPERATORS compOp : COMPARISON_OPERATORS.values()) {
        ComparisonOperatorType operator = new ComparisonOperatorType();
        operator.setName(compOp.toString());
        scalar.getComparisonOperators().getComparisonOperator().add(operator);
    }
    capabilities.setScalarCapabilities(scalar);
    SpatialCapabilitiesType spatial = new SpatialCapabilitiesType();
    spatial.setSpatialOperators(new SpatialOperatorsType());
    for (SPATIAL_OPERATORS spatialOp : SPATIAL_OPERATORS.values()) {
        SpatialOperatorType operator = new SpatialOperatorType();
        operator.setName(spatialOp.toString());
        spatial.getSpatialOperators().getSpatialOperator().add(operator);
    }
    GeometryOperandsType geometryOperands = new GeometryOperandsType();
    List<QName> qnames = Arrays.asList(Wfs20Constants.POINT, Wfs20Constants.ENVELOPE, Wfs20Constants.POLYGON, Wfs20Constants.LINESTRING);
    for (QName qName : qnames) {
        GeometryOperand operand = new GeometryOperand();
        operand.setName(qName);
        geometryOperands.getGeometryOperand().add(operand);
    }
    spatial.setGeometryOperands(geometryOperands);
    capabilities.setSpatialCapabilities(spatial);
    TemporalCapabilitiesType temporal = new TemporalCapabilitiesType();
    temporal.setTemporalOperators(new TemporalOperatorsType());
    for (TEMPORAL_OPERATORS temporalOp : TEMPORAL_OPERATORS.values()) {
        TemporalOperatorType operator = new TemporalOperatorType();
        operator.setName(temporalOp.toString());
        temporal.getTemporalOperators().getTemporalOperator().add(operator);
    }
    TemporalOperandsType temporalOperands = new TemporalOperandsType();
    List<QName> timeQNames = Arrays.asList(new QName(Wfs20Constants.GML_3_2_NAMESPACE, "TimePeriod"), new QName(Wfs20Constants.GML_3_2_NAMESPACE, "TimeInstant"));
    for (QName qName : timeQNames) {
        TemporalOperand operand = new TemporalOperand();
        operand.setName(qName);
        temporalOperands.getTemporalOperand().add(operand);
    }
    temporal.setTemporalOperands(temporalOperands);
    capabilities.setTemporalCapabilities(temporal);
    return capabilities;
}
Also used : SpatialCapabilitiesType(net.opengis.filter.v_2_0_0.SpatialCapabilitiesType) FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) DomainType(net.opengis.ows.v_1_1_0.DomainType) SpatialOperatorsType(net.opengis.filter.v_2_0_0.SpatialOperatorsType) GeometryOperandsType(net.opengis.filter.v_2_0_0.GeometryOperandsType) TemporalOperatorsType(net.opengis.filter.v_2_0_0.TemporalOperatorsType) NoValues(net.opengis.ows.v_1_1_0.NoValues) ComparisonOperatorType(net.opengis.filter.v_2_0_0.ComparisonOperatorType) TemporalOperand(net.opengis.filter.v_2_0_0.TemporalOperandsType.TemporalOperand) ConformanceType(net.opengis.filter.v_2_0_0.ConformanceType) COMPARISON_OPERATORS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.COMPARISON_OPERATORS) TemporalCapabilitiesType(net.opengis.filter.v_2_0_0.TemporalCapabilitiesType) SPATIAL_OPERATORS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.SPATIAL_OPERATORS) ValueType(net.opengis.ows.v_1_1_0.ValueType) QName(javax.xml.namespace.QName) SpatialOperatorType(net.opengis.filter.v_2_0_0.SpatialOperatorType) TEMPORAL_OPERATORS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.TEMPORAL_OPERATORS) LogicalOperators(net.opengis.filter.v_2_0_0.LogicalOperators) GeometryOperand(net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand) CONFORMANCE_CONSTRAINTS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.CONFORMANCE_CONSTRAINTS) ComparisonOperatorsType(net.opengis.filter.v_2_0_0.ComparisonOperatorsType) ScalarCapabilitiesType(net.opengis.filter.v_2_0_0.ScalarCapabilitiesType) TemporalOperatorType(net.opengis.filter.v_2_0_0.TemporalOperatorType) TemporalOperandsType(net.opengis.filter.v_2_0_0.TemporalOperandsType)

Aggregations

FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)33 ArrayList (java.util.ArrayList)28 Test (org.junit.Test)24 FilterType (net.opengis.filter.v_2_0_0.FilterType)14 FilterCapabilities (net.opengis.filter.v_1_1_0.FilterCapabilities)11 SpatialOperatorType (net.opengis.filter.v_2_0_0.SpatialOperatorType)11 ComparisonOperatorsType (net.opengis.filter.v_1_1_0.ComparisonOperatorsType)8 LogicalOperators (net.opengis.filter.v_1_1_0.LogicalOperators)8 ScalarCapabilitiesType (net.opengis.filter.v_1_1_0.ScalarCapabilitiesType)8 SpatialCapabilitiesType (net.opengis.filter.v_1_1_0.SpatialCapabilitiesType)8 SpatialOperatorsType (net.opengis.filter.v_1_1_0.SpatialOperatorsType)8 Date (java.util.Date)6 QName (javax.xml.namespace.QName)6 SpatialOperatorType (net.opengis.filter.v_1_1_0.SpatialOperatorType)6 BinarySpatialOpType (net.opengis.filter.v_2_0_0.BinarySpatialOpType)6 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)6 TimePeriodType (net.opengis.gml.v_3_2_1.TimePeriodType)6 TimePositionType (net.opengis.gml.v_3_2_1.TimePositionType)6 ConformanceType (net.opengis.filter.v_2_0_0.ConformanceType)5 GeometryOperand (net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand)5