use of net.opengis.sos.x20.GetResultTemplateResponseType.ResultEncoding in project arctic-sea by 52North.
the class SosDecoderv20 method parseGetResultTemplateResponse.
private OwsServiceResponse parseGetResultTemplateResponse(final GetResultTemplateResponseDocument getResultTemplateResponseDoc) throws DecodingException {
final GetResultTemplateResponse sosGetResultTemplateResponse = new GetResultTemplateResponse();
final GetResultTemplateResponseType getResultTemplateResponse = getResultTemplateResponseDoc.getGetResultTemplateResponse();
final SosResultEncoding resultEncoding = parseResultEncoding(getResultTemplateResponse.getResultEncoding().getAbstractEncoding());
final SosResultStructure resultStructure = parseResultStructure(getResultTemplateResponse.getResultStructure().getAbstractDataComponent());
sosGetResultTemplateResponse.setResultEncoding(resultEncoding);
sosGetResultTemplateResponse.setResultStructure(resultStructure);
return sosGetResultTemplateResponse;
}
use of net.opengis.sos.x20.GetResultTemplateResponseType.ResultEncoding 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));
}
use of net.opengis.sos.x20.GetResultTemplateResponseType.ResultEncoding in project arctic-sea by 52North.
the class GetResultTemplateResponseEncoder method createResultEncoding.
private ResultEncoding createResultEncoding(SosResultEncoding resultEncoding) throws EncodingException {
// TODO move encoding to SWECommonEncoder
final TextEncodingDocument xbEncoding;
if (resultEncoding.isEncoded()) {
try {
xbEncoding = TextEncodingDocument.Factory.parse(resultEncoding.getXml().get());
} catch (XmlException ex) {
throw unsupportedResultEncoding(ex);
}
} else {
XmlObject xml = encodeSwe(EncodingContext.of(XmlBeansEncodingFlags.DOCUMENT), resultEncoding.get().get());
if (xml instanceof TextEncodingDocument) {
xbEncoding = (TextEncodingDocument) xml;
} else {
throw unsupportedResultEncoding();
}
}
ResultEncoding xbResultEncoding = ResultEncoding.Factory.newInstance(getXmlOptions());
xbResultEncoding.addNewAbstractEncoding().set(xbEncoding.getTextEncoding());
XmlHelper.substituteElement(xbResultEncoding.getAbstractEncoding(), xbEncoding.getTextEncoding());
return xbResultEncoding;
}
Aggregations