use of com.reprezen.kaizen.oasparser.model3.Schema in project geo-platform by geosdi.
the class WFSGetFeaturesRequestTest method e_generateXMLFilesTest.
@Ignore(value = "Test to Prepare XML Files")
@Test
public void e_generateXMLFilesTest() throws Exception {
String wfsURL = "http://150.145.141.92/geoserver/wfs";
QName layerQName = new QName("sf:restricted");
GPWFSConnectorStore serverConnector = WFSConnectorBuilder.newConnector().withServerUrl(new URL(wfsURL)).build();
WFSDescribeFeatureTypeRequest<Schema> request = serverConnector.createDescribeFeatureTypeRequest();
request.setTypeName(asList(layerQName));
Schema response = request.getResponse();
String localPart = layerQName.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);
GPJAXBContextBuilder.newInstance().marshal(layerSchema, new File("./target/LayerSchemaSFRestricted.xml"));
WFSGetFeatureRequest getFeatureRequest = serverConnector.createGetFeatureRequest();
getFeatureRequest.setTypeName(new QName(layerSchema.getTypeName()));
getFeatureRequest.setSRS("EPSG:4326");
getFeatureRequest.setResultType(RESULTS.value());
String responseAsString = getFeatureRequest.formatResponseAsString(2);
try (BufferedWriter writer = Files.newBufferedWriter(Paths.get("./target/GetFeatureSFRestricted.xml"))) {
writer.write(responseAsString);
}
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project geo-platform by geosdi.
the class WFSGetFeaturesRequestTest method h_toppTasmaniaRoadsTest.
@Test
public void h_toppTasmaniaRoadsTest() throws Exception {
String wfsURL = "http://150.145.141.92/geoserver/wfs";
QName TASMANIA_ROADS = new QName("http://www.openplans.org/topp", "tasmania_roads", "topp");
GPWFSConnectorStore serverConnector = WFSConnectorBuilder.newConnector().withServerUrl(new URL(wfsURL)).build();
WFSDescribeFeatureTypeRequest<Schema> request = serverConnector.createDescribeFeatureTypeRequest();
request.setTypeName(asList(TASMANIA_ROADS));
Schema response = request.getResponse();
LayerSchemaDTO layerSchema = featureReaderXSD.getFeature(response, TASMANIA_ROADS.getLocalPart());
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());
// 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.debug("\n\t@@@@@@@@@@@@@@@@@@@@@@@@@@@FEATURE_COLLECTION_DTO : {}", featureCollection);
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project geo-platform by geosdi.
the class GPDescribeFeatureService method describeFeatureType.
/**
* @param serverURL
* @param typeName
* @param headerParams
* @return {@link LayerSchemaDTO}
* @throws Exception
*/
@Override
public LayerSchemaDTO describeFeatureType(String serverURL, String typeName, Map<String, String> headerParams) throws Exception {
checkArgument((serverURL != null) && !(serverURL.trim().isEmpty()), "The Parameter serverURL must not be null or an empty string.");
checkArgument((typeName != null) && !(typeName.trim().isEmpty()), "The Parameter typeName must not be null or an empty string.");
logger.debug("\n*** WFS DescribeFeatureType for layer {} ***", typeName);
serverURL = serverURL.replace("ows", "wfs").replace("wms", "wfs");
if (!typeName.contains(":")) {
throw new IllegalArgumentException("typeName must contain the char \":\"");
}
// if (!this.wfsConfigurator.matchDefaultDataSource(serverURL)) {
// throw new IllegalStateException("Edit Mode cannot be applied to "
// + "the server with url : " + serverURL);
// }
LayerSchemaDTO layerSchema;
try {
GPWFSConnectorStore serverConnector = ((headerParams != null) && (headerParams.size() > 0)) ? super.createWFSConnector(serverURL, headerParams) : super.createWFSConnector(serverURL);
WFSDescribeFeatureTypeRequest<Schema> request = serverConnector.createDescribeFeatureTypeRequest();
QName qName = new QName(typeName);
request.setTypeName(Arrays.asList(qName));
Schema response = request.getResponse();
String name = typeName.substring(typeName.indexOf(":") + 1);
layerSchema = GP_FEATURE_SCHEMA_READER.getFeature(response, name);
if (layerSchema == null) {
logger.error("\n### The layer \"{}\" isn't a feature ###", typeName);
} else {
layerSchema.setScope(serverURL);
}
} catch (IOException ex) {
ex.printStackTrace();
throw new IllegalStateException("Error to execute the WFS DescribeFeatureType for the layer " + typeName);
}
return layerSchema;
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project java-pubsub by googleapis.
the class SchemaServiceClientTest method createSchemaExceptionTest.
@Test
public void createSchemaExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockSchemaService.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
Schema schema = Schema.newBuilder().build();
String schemaId = "schemaId-697673060";
client.createSchema(parent, schema, schemaId);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project java-pubsub by googleapis.
the class SchemaServiceClientTest method getSchemaTest2.
@Test
public void getSchemaTest2() throws Exception {
Schema expectedResponse = Schema.newBuilder().setName(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()).setDefinition("definition-1014418093").build();
mockSchemaService.addResponse(expectedResponse);
String name = "name3373707";
Schema actualResponse = client.getSchema(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetSchemaRequest actualRequest = ((GetSchemaRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations