Search in sources :

Example 1 with ResultEncoding

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;
}
Also used : GetResultTemplateResponseType(net.opengis.sos.x20.GetResultTemplateResponseType) GetResultTemplateResponse(org.n52.shetland.ogc.sos.response.GetResultTemplateResponse) SosResultEncoding(org.n52.shetland.ogc.sos.SosResultEncoding) SosResultStructure(org.n52.shetland.ogc.sos.SosResultStructure)

Example 2 with ResultEncoding

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));
}
Also used : TextEncodingType(net.opengis.swe.x20.TextEncodingType) AbstractEncodingType(net.opengis.swe.x20.AbstractEncodingType) ResultTemplateType(net.opengis.sos.x20.ResultTemplateType) InsertResultTemplateType(net.opengis.sos.x20.InsertResultTemplateType) InsertResultTemplateDocument(net.opengis.sos.x20.InsertResultTemplateDocument) Test(org.junit.Test)

Example 3 with ResultEncoding

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;
}
Also used : TextEncodingDocument(net.opengis.swe.x20.TextEncodingDocument) XmlException(org.apache.xmlbeans.XmlException) SosResultEncoding(org.n52.shetland.ogc.sos.SosResultEncoding) ResultEncoding(net.opengis.sos.x20.GetResultTemplateResponseType.ResultEncoding) XmlObject(org.apache.xmlbeans.XmlObject)

Aggregations

SosResultEncoding (org.n52.shetland.ogc.sos.SosResultEncoding)2 GetResultTemplateResponseType (net.opengis.sos.x20.GetResultTemplateResponseType)1 ResultEncoding (net.opengis.sos.x20.GetResultTemplateResponseType.ResultEncoding)1 InsertResultTemplateDocument (net.opengis.sos.x20.InsertResultTemplateDocument)1 InsertResultTemplateType (net.opengis.sos.x20.InsertResultTemplateType)1 ResultTemplateType (net.opengis.sos.x20.ResultTemplateType)1 AbstractEncodingType (net.opengis.swe.x20.AbstractEncodingType)1 TextEncodingDocument (net.opengis.swe.x20.TextEncodingDocument)1 TextEncodingType (net.opengis.swe.x20.TextEncodingType)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1 Test (org.junit.Test)1 SosResultStructure (org.n52.shetland.ogc.sos.SosResultStructure)1 GetResultTemplateResponse (org.n52.shetland.ogc.sos.response.GetResultTemplateResponse)1