Search in sources :

Example 11 with FeatureTypeType

use of ogc.schema.opengis.wfs_capabilities.v_1_0_0.FeatureTypeType in project ddf by codice.

the class XStreamWfs11FeatureTransformerTest method mockFeatureType.

private FeatureTypeType mockFeatureType() {
    FeatureTypeType featureTypeType = new FeatureTypeType();
    featureTypeType.setName(PETER_PAN_NAME);
    featureTypeType.setDefaultSRS("urn:x-ogc:def:crs:EPSG:4326");
    return featureTypeType;
}
Also used : FeatureTypeType(net.opengis.wfs.v_1_1_0.FeatureTypeType)

Example 12 with FeatureTypeType

use of ogc.schema.opengis.wfs_capabilities.v_1_0_0.FeatureTypeType in project ddf by codice.

the class WfsSourceTest method getWfsSource.

private WfsSource getWfsSource(final String schema, final FilterCapabilities filterCapabilities, final int numFeatures, final boolean throwExceptionOnDescribeFeatureType, boolean prefix, int numReturned) throws WfsException {
    mockFactory = mock(SecureCxfClientFactory.class);
    when(mockFactory.getClient()).thenReturn(mockWfs);
    ClientBuilder<Wfs> clientBuilder = new ClientBuilderImpl<Wfs>(mock(OAuthSecurity.class), mock(SamlSecurity.class), mock(SecurityLogger.class), mock(SecurityManager.class)) {

        @Override
        public SecureCxfClientFactory<Wfs> build() {
            return mockFactory;
        }
    };
    when(mockClientBuilderFactory.<Wfs>getClientBuilder()).thenReturn(clientBuilder);
    // GetCapabilities Response
    when(mockWfs.getCapabilities(any(GetCapabilitiesRequest.class))).thenReturn(mockCapabilities);
    when(mockFeatureCollection.getMembers()).thenAnswer(new Answer<List<Metacard>>() {

        @Override
        public List<Metacard> answer(InvocationOnMock invocation) {
            // Create as many metacards as there are features
            List<Metacard> metacards = new ArrayList<>(numFeatures);
            for (int i = 0; i < numFeatures; i++) {
                MetacardImpl mc = new MetacardImpl();
                mc.setId("ID_" + (i + 1));
                metacards.add(mc);
            }
            return metacards;
        }
    });
    if (numReturned != NULL_NUM_RETURNED) {
        when(mockFeatureCollection.getNumberReturned()).thenReturn(BigInteger.valueOf(numReturned));
    } else {
        when(mockFeatureCollection.getNumberReturned()).thenReturn(null);
    }
    when(mockWfs.getFeature(any(GetFeatureType.class))).thenReturn(mockFeatureCollection);
    mockCapabilities.setFilterCapabilities(filterCapabilities);
    when(mockAvailabilityTask.isAvailable()).thenReturn(true);
    mockCapabilities.setFeatureTypeList(new FeatureTypeListType());
    for (int ii = 0; ii < numFeatures; ii++) {
        FeatureTypeType feature = new FeatureTypeType();
        QName qName;
        if (prefix) {
            qName = new QName("http://example.com", SAMPLE_FEATURE_NAME + ii, "Prefix" + ii);
        } else {
            qName = new QName("http://example.com", SAMPLE_FEATURE_NAME + ii);
        }
        feature.setName(qName);
        feature.setDefaultCRS(GeospatialUtil.EPSG_4326_URN);
        mockCapabilities.getFeatureTypeList().getFeatureType().add(feature);
    }
    XmlSchema xmlSchema = null;
    if (StringUtils.isNotBlank(schema)) {
        XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
        WfsUriResolver wfsUriResolver = new WfsUriResolver();
        wfsUriResolver.setGmlNamespace(Wfs20Constants.GML_3_2_NAMESPACE);
        wfsUriResolver.setWfsNamespace(Wfs20Constants.WFS_2_0_NAMESPACE);
        schemaCollection.setSchemaResolver(wfsUriResolver);
        xmlSchema = schemaCollection.read(new StreamSource(new ByteArrayInputStream(schema.getBytes())));
    }
    if (throwExceptionOnDescribeFeatureType) {
        when(mockWfs.describeFeatureType(any(DescribeFeatureTypeRequest.class))).thenThrow(new WfsException(""));
    } else {
        when(mockWfs.describeFeatureType(any(DescribeFeatureTypeRequest.class))).thenReturn(xmlSchema);
    }
    final ScheduledFuture<?> mockAvailabilityPollFuture = mock(ScheduledFuture.class);
    doReturn(mockAvailabilityPollFuture).when(mockScheduler).scheduleWithFixedDelay(any(), anyInt(), anyInt(), any());
    WfsSource wfsSource = new WfsSource(mockClientBuilderFactory, encryptionService, mockScheduler);
    wfsSource.setContext(mockContext);
    wfsSource.setFilterAdapter(new GeotoolsFilterAdapterImpl());
    wfsSource.setFeatureCollectionReader(mockReader);
    wfsSource.setMetacardToFeatureMapper(metacardMappers);
    wfsSource.setPollInterval(10);
    wfsSource.setWfsUrl(SAMPLE_WFS_URL);
    wfsSource.init();
    return wfsSource;
}
Also used : SecurityManager(ddf.security.service.SecurityManager) SecureCxfClientFactory(org.codice.ddf.cxf.client.SecureCxfClientFactory) WfsUriResolver(org.codice.ddf.spatial.ogc.wfs.catalog.source.WfsUriResolver) List(java.util.List) ArrayList(java.util.ArrayList) GetFeatureType(net.opengis.wfs.v_2_0_0.GetFeatureType) GetCapabilitiesRequest(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.GetCapabilitiesRequest) ClientBuilderImpl(org.codice.ddf.cxf.client.impl.ClientBuilderImpl) FeatureTypeType(net.opengis.wfs.v_2_0_0.FeatureTypeType) FeatureTypeListType(net.opengis.wfs.v_2_0_0.FeatureTypeListType) Wfs(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs) QName(javax.xml.namespace.QName) OAuthSecurity(org.codice.ddf.cxf.oauth.OAuthSecurity) StreamSource(javax.xml.transform.stream.StreamSource) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) XmlSchema(org.apache.ws.commons.schema.XmlSchema) ByteArrayInputStream(java.io.ByteArrayInputStream) WfsException(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException) InvocationOnMock(org.mockito.invocation.InvocationOnMock) SamlSecurity(org.codice.ddf.security.jaxrs.SamlSecurity) DescribeFeatureTypeRequest(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.DescribeFeatureTypeRequest) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl) SecurityLogger(ddf.security.audit.SecurityLogger)

Example 13 with FeatureTypeType

use of ogc.schema.opengis.wfs_capabilities.v_1_0_0.FeatureTypeType in project ddf by codice.

the class WfsSource method configureWfsFeatures.

private void configureWfsFeatures() {
    WFSCapabilitiesType capabilities = getCapabilities();
    if (capabilities != null) {
        wfsVersion = capabilities.getVersion();
        List<FeatureTypeType> featureTypes = getFeatureTypes(capabilities);
        List<String> supportedSpatialOperators = getSupportedSpatialOperators(capabilities);
        List<QName> supportedGeometryOperands = getSupportedGeometryOperators(capabilities);
        buildFeatureFilters(featureTypes, supportedSpatialOperators, supportedGeometryOperands);
    } else {
        LOGGER.info("WfsSource {}: WFS Server did not return any capabilities.", getId());
    }
}
Also used : WFSCapabilitiesType(net.opengis.wfs.v_1_1_0.WFSCapabilitiesType) FeatureTypeType(net.opengis.wfs.v_1_1_0.FeatureTypeType) QName(javax.xml.namespace.QName)

Aggregations

QName (javax.xml.namespace.QName)8 XmlSchema (org.apache.ws.commons.schema.XmlSchema)7 ArrayList (java.util.ArrayList)6 FeatureTypeType (net.opengis.wfs.v_1_1_0.FeatureTypeType)6 WfsException (org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException)6 Metacard (ddf.catalog.data.Metacard)5 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)4 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)4 HashMap (java.util.HashMap)4 List (java.util.List)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)4 FeatureTypeType (net.opengis.wfs.v_2_0_0.FeatureTypeType)3 FeatureTypeType (ogc.schema.opengis.wfs_capabilities.v_1_0_0.FeatureTypeType)3 SecurityLogger (ddf.security.audit.SecurityLogger)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 StreamSource (javax.xml.transform.stream.StreamSource)2 SpatialOperatorType (net.opengis.filter.v_1_1_0.SpatialOperatorType)2 XmlSchemaCollection (org.apache.ws.commons.schema.XmlSchemaCollection)2 ClientBuilderFactory (org.codice.ddf.cxf.client.ClientBuilderFactory)2