use of org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest in project arctic-sea by 52North.
the class InsertResultTemplateRequestDecoderTest method resultEncoding.
@Test
public void resultEncoding() throws IOException, DecodingException {
InsertResultTemplateRequest req = load();
assertThat(req.getResultEncoding(), is(notNullValue()));
assertThat(req.getResultEncoding().isDecoded(), is(true));
assertThat(req.getResultEncoding().isEncoded(), is(false));
assertThat(req.getResultEncoding().get().get(), is(instanceOf(SweTextEncoding.class)));
SweTextEncoding encoding = (SweTextEncoding) req.getResultEncoding().get().get();
errors.checkThat(encoding.getTokenSeparator(), is(","));
errors.checkThat(encoding.getBlockSeparator(), is("#"));
}
use of org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest in project arctic-sea by 52North.
the class InsertResultTemplateRequestDecoderTest method resultStructure.
@Test
public void resultStructure() throws IOException, DecodingException {
InsertResultTemplateRequest req = load();
assertThat(req.getResultStructure(), is(notNullValue()));
assertThat(req.getResultStructure().isDecoded(), is(true));
assertThat(req.getResultStructure().isEncoded(), is(false));
assertThat(req.getResultStructure().get().get(), is(instanceOf(SweDataRecord.class)));
SweDataRecord structure = (SweDataRecord) req.getResultStructure().get().get();
assertThat(structure.getFields(), is(notNullValue()));
assertThat(structure.getFields(), hasSize(3));
SweField field1 = structure.getFields().get(0);
assertThat(field1, is(notNullValue()));
errors.checkThat(field1.getName().getValue(), is("phenomenonTime"));
assertThat(field1.getElement(), is(instanceOf(SweTimeRange.class)));
SweTimeRange phenomenonTime = (SweTimeRange) field1.getElement();
errors.checkThat(phenomenonTime.getDefinition(), is("http://www.opengis.net/def/property/OGC/0/PhenomenonTime"));
errors.checkThat(phenomenonTime.getUom(), is("http://www.opengis.net/def/uom/ISO-8601/0/Gregorian"));
SweField field2 = structure.getFields().get(1);
assertThat(field2, is(notNullValue()));
errors.checkThat(field2.getName().getValue(), is("resultTime"));
assertThat(field2.getElement(), is(instanceOf(SweTime.class)));
SweTime resultTime = (SweTime) field2.getElement();
errors.checkThat(resultTime.getDefinition(), is("http://www.opengis.net/def/property/OGC/0/ResultTime"));
errors.checkThat(resultTime.getUom(), is("testunit1"));
SweField field3 = structure.getFields().get(2);
assertThat(field3, is(notNullValue()));
errors.checkThat(field3.getName().getValue(), is("observable_property_6"));
assertThat(field3.getElement(), is(instanceOf(SweQuantity.class)));
SweQuantity quantity = (SweQuantity) field3.getElement();
errors.checkThat(quantity.getDefinition(), is("http://www.52north.org/test/observableProperty/6"));
errors.checkThat(quantity.getUom(), is("test_unit_6"));
}
use of org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest in project arctic-sea by 52North.
the class SosDecoderv20 method parseInsertResultTemplate.
private OwsServiceRequest parseInsertResultTemplate(final InsertResultTemplateDocument insertResultTemplateDoc) throws DecodingException {
InsertResultTemplateRequest sosInsertResultTemplate = new InsertResultTemplateRequest();
InsertResultTemplateType insertResultTemplate = insertResultTemplateDoc.getInsertResultTemplate();
sosInsertResultTemplate.setService(insertResultTemplate.getService());
sosInsertResultTemplate.setVersion(insertResultTemplate.getVersion());
ResultTemplateType resultTemplate = insertResultTemplate.getProposedTemplate().getResultTemplate();
sosInsertResultTemplate.setIdentifier(resultTemplate.getIdentifier());
OmObservationConstellation sosObservationConstellation = parseObservationTemplate(resultTemplate.getObservationTemplate());
sosObservationConstellation.addOffering(resultTemplate.getOffering());
sosInsertResultTemplate.setObservationTemplate(sosObservationConstellation);
try {
sosInsertResultTemplate.setResultStructure(parseResultStructure(XmlObject.Factory.parse(resultTemplate.getResultStructure().xmlText())));
sosInsertResultTemplate.setResultEncoding(parseResultEncoding(XmlObject.Factory.parse(resultTemplate.getResultEncoding().xmlText())));
} catch (XmlException e) {
throw new DecodingException(e, "Error while parsing InsertResultTemplate request!");
}
sosInsertResultTemplate.setExtensions(parseExtensibleRequest(insertResultTemplate));
return sosInsertResultTemplate;
}
use of org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest in project arctic-sea by 52North.
the class InsertResultTemplateRequestEncoderTest method shouldThrowExceptionWhenObservationTemplateIsMissing.
@Test
public void shouldThrowExceptionWhenObservationTemplateIsMissing() throws EncodingException {
thrown.expect(UnsupportedEncoderInputException.class);
thrown.expectMessage(Is.is("Encoder " + InsertResultTemplateRequestEncoder.class.getSimpleName() + " can not encode 'missing ObservationTemplate'"));
encoder.create(new InsertResultTemplateRequest("service", "version"));
}
use of org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest in project arctic-sea by 52North.
the class InsertResultTemplateRequestEncoderTest method setup.
@Before
public void setup() throws InvalidSridException, ParseException {
SensorML procedure = new SensorML();
procedure.setIdentifier(procedureIdentifier);
SamplingFeature featureOfInterest = new SamplingFeature(new CodeWithAuthority(featureIdentifier));
featureOfInterest.setIdentifier(featureIdentifier);
featureOfInterest.setName(new CodeType(featureName));
featureOfInterest.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_POINT);
featureOfInterest.setGeometry(JTSHelper.createGeometryFromWKT("POINT(30 10)", 4326));
observationTemplate = new OmObservationConstellation();
observationTemplate.addOffering(offering);
observationTemplate.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
observationTemplate.setProcedure(procedure);
observationTemplate.setObservableProperty(new OmObservableProperty(observedProperty));
observationTemplate.setFeatureOfInterest(featureOfInterest);
SweTextEncoding textEncoding = new SweTextEncoding();
textEncoding.setBlockSeparator(blockSeparator);
textEncoding.setTokenSeparator(tokenSeparator);
SweDataRecord resultStructure = new SweDataRecord();
SweTime sweTime = new SweTime();
sweTime.setDefinition(field1Definition);
sweTime.setUom(field1Uom);
resultStructure.addField(new SweField(field1Name, sweTime));
request = new InsertResultTemplateRequest(SosConstants.SOS, Sos2Constants.SERVICEVERSION, Sos2Constants.Operations.InsertResultTemplate.name());
request.setResultEncoding(new SosResultEncoding(textEncoding));
request.setResultStructure(new SosResultStructure(resultStructure));
request.setIdentifier(templateIdentifier);
request.setObservationTemplate(observationTemplate);
Supplier<XmlOptions> xmlOptions = () -> new XmlOptions();
encoder = new InsertResultTemplateRequestEncoder();
encoder.setXmlOptions(xmlOptions);
OmEncoderv20 omEncoder = new OmEncoderv20();
omEncoder.setXmlOptions(xmlOptions);
SamplingEncoderv20 samsEncoder = new SamplingEncoderv20();
samsEncoder.setXmlOptions(xmlOptions);
GmlEncoderv321 gml32Encoder = new GmlEncoderv321();
gml32Encoder.setXmlOptions(xmlOptions);
SweCommonEncoderv20 sweEncoderv20 = new SweCommonEncoderv20();
sweEncoderv20.setXmlOptions(xmlOptions);
EncoderRepository encoderRepository = new EncoderRepository();
encoderRepository.setEncoders(Arrays.asList(encoder, omEncoder, samsEncoder, gml32Encoder, sweEncoderv20));
encoderRepository.init();
encoderRepository.getEncoders().stream().forEach(e -> ((AbstractDelegatingEncoder<?, ?>) e).setEncoderRepository(encoderRepository));
}
Aggregations