use of net.opengis.sos.x20.ResultTemplateType 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 net.opengis.sos.x20.ResultTemplateType in project arctic-sea by 52North.
the class InsertResultTemplateRequestEncoder method create.
@Override
protected XmlObject create(InsertResultTemplateRequest request) throws EncodingException {
validateInput(request);
InsertResultTemplateDocument doc = InsertResultTemplateDocument.Factory.newInstance(getXmlOptions());
InsertResultTemplateType insertResultTemplate = doc.addNewInsertResultTemplate();
insertResultTemplate.setService(request.getService());
insertResultTemplate.setVersion(request.getVersion());
// reduced element hierarchy and switched to sos:ResultTemplate level
ResultTemplateType resultTemplate = insertResultTemplate.addNewProposedTemplate().addNewResultTemplate();
addIdentifier(resultTemplate, request);
addOffering(resultTemplate, request);
addObservationTemplate(resultTemplate, request);
addResultStructure(resultTemplate, request.getResultStructure().get().get());
addResultEncoding(resultTemplate, request.getResultEncoding().get().get());
return doc;
}
use of net.opengis.sos.x20.ResultTemplateType in project arctic-sea by 52North.
the class InsertResultTemplateRequestEncoderTest method shouldEncodeResultStructure.
@Test
public void shouldEncodeResultStructure() throws EncodingException {
ResultTemplateType template = ((InsertResultTemplateDocument) encoder.create(request)).getInsertResultTemplate().getProposedTemplate().getResultTemplate();
Assert.assertThat(template.getResultStructure(), Matchers.notNullValue());
AbstractDataComponentType abstractDataComponent = template.getResultStructure().getAbstractDataComponent();
Assert.assertThat(abstractDataComponent, Matchers.notNullValue());
Assert.assertThat(abstractDataComponent, Matchers.instanceOf(DataRecordType.class));
DataRecordType xbResultStructure = (DataRecordType) abstractDataComponent;
Assert.assertThat(xbResultStructure.getFieldArray().length, Is.is(1));
Assert.assertThat(xbResultStructure.getFieldArray(0), Matchers.instanceOf(Field.class));
Assert.assertThat(xbResultStructure.getFieldArray(0).getName(), Is.is(field1Name));
Assert.assertThat(xbResultStructure.getFieldArray(0).getAbstractDataComponent(), Matchers.instanceOf(TimeType.class));
TimeType xbTime = (TimeType) xbResultStructure.getFieldArray(0).getAbstractDataComponent();
Assert.assertThat(xbTime.getDefinition(), Is.is(field1Definition));
Assert.assertThat(xbTime.getUom().getCode(), Is.is(field1Uom));
}
use of net.opengis.sos.x20.ResultTemplateType in project arctic-sea by 52North.
the class InsertResultTemplateRequestEncoderTest method shouldEncodeObservationTemplate.
@Test
public void shouldEncodeObservationTemplate() throws EncodingException, XmlException, IOException {
ResultTemplateType template = ((InsertResultTemplateDocument) encoder.create(request)).getInsertResultTemplate().getProposedTemplate().getResultTemplate();
ObservationTemplate observationTemplate = template.getObservationTemplate();
Assert.assertThat(observationTemplate, Matchers.notNullValue());
Assert.assertThat(observationTemplate, Matchers.instanceOf(ObservationTemplate.class));
OMObservationType omObservation = observationTemplate.getOMObservation();
Assert.assertThat(omObservation, Matchers.instanceOf(OMObservationType.class));
Assert.assertThat(omObservation.getType().getHref(), Is.is(OmConstants.OBS_TYPE_MEASUREMENT));
Assert.assertThat(omObservation.getPhenomenonTime().isNil(), Is.is(false));
Assert.assertThat(omObservation.getPhenomenonTime().isSetNilReason(), Is.is(true));
Assert.assertThat(omObservation.getPhenomenonTime().getNilReason(), Is.is("template"));
Assert.assertThat(omObservation.getResultTime().isNil(), Is.is(false));
Assert.assertThat(omObservation.getResultTime().isSetNilReason(), Is.is(true));
Assert.assertThat(omObservation.getResultTime().getNilReason(), Is.is("template"));
Assert.assertThat(omObservation.getProcedure().isNil(), Is.is(false));
Assert.assertThat(omObservation.getProcedure().getHref(), Is.is(procedureIdentifier));
Assert.assertThat(omObservation.getObservedProperty().isNil(), Is.is(false));
Assert.assertThat(omObservation.getObservedProperty().getHref(), Is.is(observedProperty));
Assert.assertThat(omObservation.getFeatureOfInterest(), Matchers.notNullValue());
XmlObject xmlObject = XmlObject.Factory.parse(omObservation.getFeatureOfInterest().newInputStream());
Assert.assertThat(xmlObject, Matchers.instanceOf(SFSamplingFeatureDocument.class));
SFSamplingFeatureType feature = ((SFSamplingFeatureDocument) xmlObject).getSFSamplingFeature();
Assert.assertThat(feature.getIdentifier().getStringValue(), Is.is(featureIdentifier));
Assert.assertThat(feature.getNameArray().length, Is.is(1));
Assert.assertThat(feature.getNameArray(0).getStringValue(), Is.is(featureName));
}
use of net.opengis.sos.x20.ResultTemplateType in project arctic-sea by 52North.
the class InsertResultTemplateRequestEncoderTest method shouldEncodeResultEncoding.
@Test
public void shouldEncodeResultEncoding() throws EncodingException, DecodingException {
ResultTemplateType template = ((InsertResultTemplateDocument) encoder.create(request)).getInsertResultTemplate().getProposedTemplate().getResultTemplate();
XmlHelper.validateDocument(template);
Assert.assertThat(template.getResultEncoding(), Matchers.notNullValue());
Assert.assertThat(template.getResultEncoding().getAbstractEncoding(), Matchers.notNullValue());
AbstractEncodingType resultEncoding = template.getResultEncoding().getAbstractEncoding();
Assert.assertThat(resultEncoding, Matchers.instanceOf(TextEncodingType.class));
TextEncodingType xbTextEncoding = (TextEncodingType) resultEncoding;
Assert.assertThat(xbTextEncoding.getBlockSeparator(), Is.is(blockSeparator));
Assert.assertThat(xbTextEncoding.getTokenSeparator(), Is.is(tokenSeparator));
}
Aggregations