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));
}
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);
}
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);
}
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);
}
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);
}
Aggregations