SOSWrapper
Introduction
The SOSWrapper is a new interface, designed to access the OX-Framework's SOS functionality in an easy and intuitive manner. This document shows the structure of the interface, compares the structure with the underlying SOSAdapter and explains how to use this interface.
Structure
To get an overview the following figure will show the integration of the interface to the existing components:
The architecture of this interface can be separated into two big parts. The first part is a set of parameter assemling classes, which are used to collect certain request properties. For every SOS request there is one parameter builder. At the moment this affects following operations:
Pre-Collecting Builder
SOS-Operation |
According Prameter Builder |
Pre-Collecting Builder |
describeSensor |
"DescribeSensorParameterBuilder_v100" |
- |
getfeatureOfInterest |
"GetFeatureOfInterestParameterBuilder_v100" |
- |
getObservation |
"GetObservationParameterBuilder_v100" |
- |
getObservationById |
"GetObservationByIdParameterBuilder_v100" |
- |
registerSensor |
"RegisterSensorParameterBuilder_v100" |
"SensorDescriptionBuilder", "ObservationTemplateBuilder" |
insertObservation |
"InsertObservationParameterBuilder_v100" |
"BooleanObservationBilder", "CountObservationBuilder", "MeasurementBuilder", "TextObservationBuilder" |
Most of them collect properties of simple types or String values. But there are also some, that expect more complex types, e.g.
RegisterSensorParameterBuilder _v100
or
InsertObservationParameterBuilder_v100
. Those more complex types in this case are types that on their part "pre-collect" information. Performing a register sensor operation thus does not only mean to create the according parameter builder but also means to create those pre-collecting instances as well, here this is a sensor description and an observation template.
To keep this explanation here short and not going to far into detail a complete example for this case will be mentioned in a following section.
In comparison to the SOSAdapter with the builder structure it's possible to collect the request properties more easily. There is no need anymore to collect all of them manually by putting them into a
ParameterContainer
(essentially a Map data structure).
The other main component of this structure, next to the parameter assembling classes, is the
SOSWrapper
. After you gathered together all the request property information by using the parameter builder, you just pass this builder to the appropriate method of the
SOSWrapper
. E.g. if you want to perform a describe sensor request you first gather together information with the
DescribeSensorParameterBuilder
and then pass this instance to the
doDescribeSensor(DescribeSensorParameterBuilder_v100 builder)
. As result you will get an
OperationResult
, that can be processed in further steps.
Example
The first thing you have to do is getting an instance of the
SOSMapper
. This can be done by calling the
createFromCapabilities(String url, String acceptVersion)
method. As you can see there are two parameters, which are necessary to send requests to a SOS. Creating a new instance always means to request the capabilities of the SOS.Thus you can be sure that if no SOSWrapper can be created, the get capabilities request failed.
1 SosWrapper sw;
2 try {
3 sw = MySosWrapperSeam.createFromCapabilities([URL], [VERSION]);
4 } catch (ExceptionReport e) {
5 LOGGER.error(e);
6 } catch (OXFException e) {
7 LOGGER.error(e);
8 }
When an instance is created you only have to assemble the request properties that you need by a parameter builder and pass this to the according method of the
SOSWrapper
.
1 DescribeSensorParamterBuilder_v100 dspb = new DescribeSensorParamterBuilder_v100
2 ("sensorId", DescribeSensorParamterBuilder_v100.OUTPUT_FORMAT_SENSORML);
3 try {
4 sw.doDescribeSensor(dspb);
5 } catch(OXFException e) {
6 LOGGER.error(e);
7 } catch(ExceptionReport e) {
8 LOGGER.error(e);
9 }
Other Resources
If this is the first time you get in touch with the SWE (SensorWebEnablement), probably this article will guide you for a better understanding:
SensorWebForDummies.
More information about the builder design pattern you can get from
the according wikipedia article.