Search in sources :

Example 91 with Schema

use of com.reprezen.kaizen.oasparser.model3.Schema in project odata-client by davidmoten.

the class EntitySet method getBaseCollectionRequestClassName.

public String getBaseCollectionRequestClassName(Imports imports) {
    String t = entitySet.getEntityType();
    // an entity set is always a collection
    Schema schema = names.getSchema(t);
    return imports.add(names.getFullClassNameCollectionRequestFromTypeWithNamespace(schema, t));
}
Also used : Schema(org.oasisopen.odata.csdl.v4.Schema)

Example 92 with Schema

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

the class WFSDescribeFeatureTest method e_describeLayerDtsupStromboliTest.

@Test
@Ignore
public void e_describeLayerDtsupStromboliTest() throws Exception {
    String serverURL = "https://servizi.protezionecivile.it/webgis/sitdpc/gpServerProxy?targetURL=https://insar.irea.cnr.it/geoserver/wms%26v=dpc%26p=4WzL06EA";
    serverURL = decode(serverURL.replaceAll("wms", "wfs"), UTF_8.name());
    logger.info("########################SERVER_URL : {}\n", serverURL);
    WFSDescribeFeatureTypeRequest<Schema> request = newConnector().withServerUrl(new URL(serverURL)).build().createDescribeFeatureTypeRequest();
    QName dtsupStromboli = new QName("geonode:dtsup_stromboli");
    String localPart = dtsupStromboli.getLocalPart();
    request.setTypeName(Arrays.asList(dtsupStromboli));
    logger.info("{}\n", request.showRequestAsString());
    logger.info("#########################SCHEMA_AS_STRING : \n{}\n", request.getResponseAsString());
    Schema s = request.getResponse();
    String name = localPart.substring(localPart.indexOf(":") + 1);
    JAXBElement<LayerSchemaDTO> root = new JAXBElement<>(dtsupStromboli, LayerSchemaDTO.class, schemaReader.getFeature(s, name));
    StringWriter writer = new StringWriter();
    gpJAXBContextBuilder.marshal(root, writer);
    logger.info("######################LAYER_SCHEMA_DTSUP_STROMBOLI_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) URL(java.net.URL) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 93 with Schema

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

the class WFSGetFeaturesRequestTest method m_ospedaliTest.

@Test
public void m_ospedaliTest() throws Exception {
    String wfsURL = "https://servizi.protezionecivile.it/geoserver/wfs";
    GPWFSConnectorStore serverConnector = WFSConnectorBuilder.newConnector().withClientSecurity(new BasicPreemptiveSecurityConnector("MAIDNT78M23G942L", "mdonato")).withServerUrl(new URL(wfsURL)).build();
    QName ospedali = new QName("PNSRS:CAL_4_6_ospedali");
    String localPart = ospedali.getLocalPart();
    String name = localPart.substring(localPart.indexOf(":") + 1);
    WFSDescribeFeatureTypeRequest<Schema> request = serverConnector.createDescribeFeatureTypeRequest();
    request.setTypeName(asList(ospedali));
    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(2));
    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<>(ospedali, FeatureCollectionDTO.class, featureCollection);
    gpJAXBContextBuilder.marshal(root, new File(of(new File(".").getCanonicalPath(), "target", "Ospedali").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", "Ospedali").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) BasicPreemptiveSecurityConnector(org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector) LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) Test(org.junit.Test)

Example 94 with Schema

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

the class WFSGetFeaturesRequestTest method a_getAllFeaturesTest.

@Ignore(value = "Geoserver is Down")
@Test
public void a_getAllFeaturesTest() throws Exception {
    String wfsURL = "http://geoserver.wfppal.org/geoserver/wfs";
    GPWFSConnectorStore serverConnector = WFSConnectorBuilder.newConnector().withServerUrl(new URL(wfsURL)).build();
    WFSDescribeFeatureTypeRequest<Schema> request = serverConnector.createDescribeFeatureTypeRequest();
    request.setTypeName(asList(information));
    Schema response = request.getResponse();
    LayerSchemaDTO layerSchema = featureReaderXSD.getFeature(response, informationName);
    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("\n\t@@@@@@@@@@@@@@@@@@RESPONSE_AS_STRING : {}", getFeatureRequest.getResponseAsString());
    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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 95 with Schema

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

the class WFSGetFeaturesRequestTest method p_itGrandiDigheTest.

@Test
public void p_itGrandiDigheTest() throws Exception {
    String wfsURL = "https://servizi.protezionecivile.it/geoserver/wfs";
    GPWFSConnectorStore serverConnector = WFSConnectorBuilder.newConnector().withClientSecurity(new BasicPreemptiveSecurityConnector("MAIDNT78M23G942L", "mdonato")).withServerUrl(new URL(wfsURL)).build();
    QName grandiDighe = new QName("IDROGEOLOGICO:IT_grandi_dighe_MIT2019");
    String localPart = grandiDighe.getLocalPart();
    String name = localPart.substring(localPart.indexOf(":") + 1);
    WFSDescribeFeatureTypeRequest<Schema> request = serverConnector.createDescribeFeatureTypeRequest();
    request.setTypeName(asList(grandiDighe));
    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.setBBox(new BBox(14.131237640976908, 36.56356461583572, 15.821758881211283, 37.143760728459014));
    getFeatureRequest.setQueryDTO(newInstance().unmarshal(new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<QueryDTO>\n" + "    <matchOperator>ANY</matchOperator>\n" + "    <queryRestrictionList>\n" + "        <queryRestriction>\n" + "            <attribute>\n" + "                <type>string</type>\n" + "                <name>diga</name>\n" + "                <value></value>\n" + "                <maxOccurs>1</maxOccurs>\n" + "                <minOccurs>0</minOccurs>\n" + "                <nillable>true</nillable>\n" + "            </attribute>\n" + "            <operator>EQUAL</operator>\n" + "            <restriction>SANTA ROSALIA</restriction>\n" + "        </queryRestriction>\n" + "        <queryRestriction>\n" + "            <attribute>\n" + "                <type>string</type>\n" + "                <name>diga</name>\n" + "                <value></value>\n" + "                <maxOccurs>1</maxOccurs>\n" + "                <minOccurs>0</minOccurs>\n" + "                <nillable>true</nillable>\n" + "            </attribute>\n" + "            <operator>EQUAL</operator>\n" + "            <restriction>MONTE CAVALLARO</restriction>\n" + "        </queryRestriction>\n" + "    </queryRestrictionList>\n" + "</QueryDTO>"), QueryDTO.class));
    getFeatureRequest.setGeometryName(layerSchema.getGeometry().getName());
    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<>(grandiDighe, FeatureCollectionDTO.class, featureCollection);
    gpJAXBContextBuilder.marshal(root, new File(of(new File(".").getCanonicalPath(), "target", "GrandiDighe").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", "GrandiDighe").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) QueryDTO(org.geosdi.geoplatform.connector.wfs.response.QueryDTO) 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) BBox(org.geosdi.geoplatform.gui.shared.bean.BBox) BasicPreemptiveSecurityConnector(org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector) LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) 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