Search in sources :

Example 26 with Schema

use of com.reprezen.kaizen.oasparser.model3.Schema in project geo-platform by geosdi.

the class WFSDescribeFeatureTest method a_describeToppStatesTest.

@Test
public void a_describeToppStatesTest() throws Exception {
    WFSDescribeFeatureTypeRequest<Schema> request = serverConnector.createDescribeFeatureTypeRequest();
    String localPart = statesName.getLocalPart();
    request.setTypeName(Arrays.asList(statesName));
    logger.info("\n{}\n", request.showRequestAsString());
    Schema s = request.getResponse();
    String name = localPart.substring(localPart.indexOf(":") + 1);
    QName qName = new QName("org.geosdi.geoplatform.connector.wfs.response", "LayerSchemaDTO");
    JAXBElement<LayerSchemaDTO> root = new JAXBElement<>(qName, LayerSchemaDTO.class, schemaReader.getFeature(s, name));
    StringWriter writer = new StringWriter();
    gpJAXBContextBuilder.marshal(root, writer);
    logger.info("######################LAYER_SCHEMA_TOPP_STATES_XML : \n{}\n", writer);
}
Also used : StringWriter(java.io.StringWriter) QName(javax.xml.namespace.QName) Schema(org.geosdi.geoplatform.xml.xsd.v2001.Schema) LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

Example 27 with Schema

use of com.reprezen.kaizen.oasparser.model3.Schema in project geo-platform by geosdi.

the class WFSDescribeFeatureTest method b_describeSFRoadTest.

@Test
public void b_describeSFRoadTest() throws Exception {
    WFSDescribeFeatureTypeRequest<Schema> request = serverConnector.createDescribeFeatureTypeRequest();
    String localPart = sfRoads.getLocalPart();
    request.setTypeName(Arrays.asList(sfRoads));
    Schema s = request.getResponse();
    String name = localPart.substring(localPart.indexOf(":") + 1);
    QName qName = new QName("org.geosdi.geoplatform.connector.wfs.response", "LayerSchemaDTO");
    JAXBElement<LayerSchemaDTO> root = new JAXBElement<>(qName, LayerSchemaDTO.class, schemaReader.getFeature(s, name));
    StringWriter writer = new StringWriter();
    gpJAXBContextBuilder.marshal(root, writer);
    logger.info("######################LAYER_SCHEMA_SF_ROAD_XML : \n{}\n", writer);
}
Also used : StringWriter(java.io.StringWriter) QName(javax.xml.namespace.QName) Schema(org.geosdi.geoplatform.xml.xsd.v2001.Schema) LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

Example 28 with Schema

use of com.reprezen.kaizen.oasparser.model3.Schema in project geo-platform by geosdi.

the class WFSGetFeaturesRequestTest method l_percorsiNavetteTest.

@Ignore
@Test
public void l_percorsiNavetteTest() throws Exception {
    String wfsURL = "http://mappe-dpc.protezionecivile.it/gssitdpc/wfs";
    GPWFSConnectorStore serverConnector = WFSConnectorBuilder.newConnector().withServerUrl(new URL(wfsURL)).build();
    QName percorsiNavette = new QName("PianoCampiFlegrei:CF_PercorsiNavette");
    String localPart = percorsiNavette.getLocalPart();
    String name = localPart.substring(localPart.indexOf(":") + 1);
    WFSDescribeFeatureTypeRequest<Schema> request = serverConnector.createDescribeFeatureTypeRequest();
    request.setTypeName(asList(percorsiNavette));
    Schema response = request.getResponse();
    logger.info("#################SCHEMA : {}\n", response);
    LayerSchemaDTO layerSchema = featureReaderXSD.getFeature(response, name);
    if (layerSchema == null) {
        throw new IllegalStateException("The Layer Schema is null.");
    }
    layerSchema.setScope(wfsURL);
    logger.debug("\n\t##################################LAYER_SCHEMA : {}", layerSchema);
    WFSGetFeatureRequest getFeatureRequest = serverConnector.createGetFeatureRequest();
    getFeatureRequest.setTypeName(new QName(layerSchema.getTypeName()));
    getFeatureRequest.setSRS("EPSG:4326");
    getFeatureRequest.setResultType(RESULTS.value());
    getFeatureRequest.setMaxFeatures(valueOf(50));
    logger.debug("@@@@@@@@@@@@@@@@@@REQUEST_AS_STRING : \n{}\n", getFeatureRequest.showRequestAsString());
    InputStream is = getFeatureRequest.getResponseAsStream();
    WFSGetFeatureStaxReader featureReaderStAX = new WFSGetFeatureStaxReader(layerSchema);
    FeatureCollectionDTO featureCollection = featureReaderStAX.read(is);
    if (!featureCollection.isFeaturesLoaded()) {
        featureCollection.setErrorMessage(getFeatureRequest.getResponseAsString());
    }
    JAXBElement<FeatureCollectionDTO> root = new JAXBElement<>(percorsiNavette, FeatureCollectionDTO.class, featureCollection);
    gpJAXBContextBuilder.marshal(root, new File(of(new File(".").getCanonicalPath(), "target", "PercorsiNavette").collect(joining(separator, "", ".xml"))));
    getFeatureRequest.setOutputFormat("json");
    InputStream isJson = getFeatureRequest.getResponseAsStream();
    FeatureCollection featureCollectionJson = JACKSON_SUPPORT.getDefaultMapper().readValue(isJson, FeatureCollection.class);
    JACKSON_SUPPORT.getDefaultMapper().writeValue(new File(of(new File(".").getCanonicalPath(), "target", "PercorsiNavette").collect(joining(separator, "", ".json"))), featureCollectionJson);
}
Also used : GPWFSConnectorStore(org.geosdi.geoplatform.connector.GPWFSConnectorStore) QName(javax.xml.namespace.QName) Schema(org.geosdi.geoplatform.xml.xsd.v2001.Schema) JAXBElement(javax.xml.bind.JAXBElement) WFSGetFeatureRequest(org.geosdi.geoplatform.connector.server.request.WFSGetFeatureRequest) URL(java.net.URL) FeatureCollectionDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO) WFSGetFeatureStaxReader(org.geosdi.geoplatform.support.wfs.feature.reader.WFSGetFeatureStaxReader) FeatureCollection(org.geojson.FeatureCollection) LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 29 with Schema

use of com.reprezen.kaizen.oasparser.model3.Schema in project geo-platform by geosdi.

the class WFSGetFeaturesRequestTest method c_tigerRoadsTest.

@Test
public void c_tigerRoadsTest() throws Exception {
    String wfsURL = "http://150.145.141.92/geoserver/wfs";
    GPWFSConnectorStore serverConnector = WFSConnectorBuilder.newConnector().withServerUrl(new URL(wfsURL)).build();
    WFSDescribeFeatureTypeRequest<Schema> request = serverConnector.createDescribeFeatureTypeRequest();
    request.setTypeName(asList(tigerRoads));
    Schema response = request.getResponse();
    LayerSchemaDTO layerSchema = featureReaderXSD.getFeature(response, tigerRoadsName);
    if (layerSchema == null) {
        throw new IllegalStateException("The Layer Schema is null.");
    }
    layerSchema.setScope(wfsURL);
    logger.debug("\n\t##################################LAYER_SCHEMA : {}", layerSchema);
    WFSGetFeatureRequest getFeatureRequest = serverConnector.createGetFeatureRequest();
    getFeatureRequest.setTypeName(new QName(layerSchema.getTypeName()));
    getFeatureRequest.setSRS("EPSG:4326");
    getFeatureRequest.setResultType(RESULTS.value());
    getFeatureRequest.setMaxFeatures(valueOf(50));
    logger.debug("@@@@@@@@@@@@@@@@@@RESPONSE_AS_STRING : \n{}\n", getFeatureRequest.showRequestAsString());
    InputStream is = getFeatureRequest.getResponseAsStream();
    WFSGetFeatureStaxReader featureReaderStAX = new WFSGetFeatureStaxReader(layerSchema);
    FeatureCollectionDTO featureCollection = featureReaderStAX.read(is);
    if (!featureCollection.isFeaturesLoaded()) {
        featureCollection.setErrorMessage(getFeatureRequest.getResponseAsString());
    }
    logger.debug("\n\t@@@@@@@@@@@@@@@@@@@@@@@@@@@FEATURE_COLLECTION_DTO : {}", featureCollection);
}
Also used : WFSGetFeatureStaxReader(org.geosdi.geoplatform.support.wfs.feature.reader.WFSGetFeatureStaxReader) GPWFSConnectorStore(org.geosdi.geoplatform.connector.GPWFSConnectorStore) QName(javax.xml.namespace.QName) Schema(org.geosdi.geoplatform.xml.xsd.v2001.Schema) LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) WFSGetFeatureRequest(org.geosdi.geoplatform.connector.server.request.WFSGetFeatureRequest) URL(java.net.URL) FeatureCollectionDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO) Test(org.junit.Test)

Example 30 with Schema

use of com.reprezen.kaizen.oasparser.model3.Schema in project geo-platform by geosdi.

the class WFSGetFeaturesRequestTest method d_siteTrTest.

@Ignore(value = "Geoserver is Down")
@Test
public void d_siteTrTest() throws Exception {
    String wfsURL = "http://150.145.141.241/geoserver/wfs";
    QName siteTRCom = new QName("cite:tr_com");
    GPWFSConnectorStore serverConnector = WFSConnectorBuilder.newConnector().withServerUrl(new URL(wfsURL)).build();
    WFSDescribeFeatureTypeRequest<Schema> request = serverConnector.createDescribeFeatureTypeRequest();
    request.setTypeName(asList(siteTRCom));
    Schema response = request.getResponse();
    String localPart = siteTRCom.getLocalPart();
    String name = localPart.substring(localPart.indexOf(":") + 1);
    LayerSchemaDTO layerSchema = featureReaderXSD.getFeature(response, name);
    if (layerSchema == null) {
        throw new IllegalStateException("The Layer Schema is null.");
    }
    layerSchema.setScope(wfsURL);
    WFSGetFeatureRequest getFeatureRequest = serverConnector.createGetFeatureRequest();
    getFeatureRequest.setTypeName(new QName(layerSchema.getTypeName()));
    getFeatureRequest.setSRS("EPSG:4326");
    getFeatureRequest.setResultType(RESULTS.value());
    getFeatureRequest.setMaxFeatures(valueOf(50));
    logger.debug("@@@@@@@@@@@@@@@@@@REQUEST_AS_STRING : \n{}\n", getFeatureRequest.showRequestAsString());
    logger.debug("######################RESPONSE_AS_STRING : \n{}\n", getFeatureRequest.formatResponseAsString(2));
    InputStream is = getFeatureRequest.getResponseAsStream();
    WFSGetFeatureStaxReader featureReaderStAX = new WFSGetFeatureStaxReader(layerSchema);
    FeatureCollectionDTO featureCollection = featureReaderStAX.read(is);
    if (!featureCollection.isFeaturesLoaded()) {
        featureCollection.setErrorMessage(getFeatureRequest.getResponseAsString());
    }
    logger.info("###################################FEATURE_COLLECTION : {}\n", featureCollection);
    getFeatureRequest.setGeometryName(layerSchema.getGeometry().getName());
    getFeatureRequest.setBBox(new BBox(10.329274141729897, 44.64877730606194, 10.35673996203874, 44.66831396911103));
    logger.debug("@@@@@@@@@@@@@@@@@@REQUEST_FILTERED_BY_BBOX_AS_STRING : \n{}\n", getFeatureRequest.showRequestAsString());
    logger.debug("######################RESPONSE_FILTERED_BY_BBOX_AS_STRING : \n{}\n", getFeatureRequest.formatResponseAsString(2));
    InputStream si = getFeatureRequest.getResponseAsStream();
    FeatureCollectionDTO featureCollectionByBBOX = featureReaderStAX.read(si);
    if (!featureCollectionByBBOX.isFeaturesLoaded()) {
        featureCollectionByBBOX.setErrorMessage(getFeatureRequest.getResponseAsString());
    }
    logger.info("###################################FEATURE_COLLECTION_BY_BBOX : {}\n", featureCollectionByBBOX);
}
Also used : GPWFSConnectorStore(org.geosdi.geoplatform.connector.GPWFSConnectorStore) QName(javax.xml.namespace.QName) Schema(org.geosdi.geoplatform.xml.xsd.v2001.Schema) WFSGetFeatureRequest(org.geosdi.geoplatform.connector.server.request.WFSGetFeatureRequest) URL(java.net.URL) FeatureCollectionDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO) WFSGetFeatureStaxReader(org.geosdi.geoplatform.support.wfs.feature.reader.WFSGetFeatureStaxReader) BBox(org.geosdi.geoplatform.gui.shared.bean.BBox) LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)57 Schema (com.google.pubsub.v1.Schema)38 Schema (org.molgenis.emx2.Schema)38 AbstractMessage (com.google.protobuf.AbstractMessage)16 ByteString (com.google.protobuf.ByteString)16 QName (javax.xml.namespace.QName)16 File (java.io.File)15 URL (java.net.URL)15 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)15 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)14 ProjectName (com.google.pubsub.v1.ProjectName)14 LayerSchemaDTO (org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO)14 IOException (java.io.IOException)13 StringWriter (java.io.StringWriter)13 Schema (org.oasisopen.odata.csdl.v4.Schema)13 Schema (com.reprezen.kaizen.oasparser.model3.Schema)11 JAXBElement (javax.xml.bind.JAXBElement)10 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 List (java.util.List)8