Search in sources :

Example 1 with ResultTemplateType

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;
}
Also used : InsertResultTemplateType(net.opengis.sos.x20.InsertResultTemplateType) XmlException(org.apache.xmlbeans.XmlException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) ResultTemplateType(net.opengis.sos.x20.ResultTemplateType) GetResultTemplateType(net.opengis.sos.x20.GetResultTemplateType) InsertResultTemplateType(net.opengis.sos.x20.InsertResultTemplateType) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest)

Example 2 with ResultTemplateType

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;
}
Also used : InsertResultTemplateType(net.opengis.sos.x20.InsertResultTemplateType) ResultTemplateType(net.opengis.sos.x20.ResultTemplateType) InsertResultTemplateType(net.opengis.sos.x20.InsertResultTemplateType) InsertResultTemplateDocument(net.opengis.sos.x20.InsertResultTemplateDocument)

Example 3 with ResultTemplateType

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));
}
Also used : DataRecordType(net.opengis.swe.x20.DataRecordType) SweField(org.n52.shetland.ogc.swe.SweField) Field(net.opengis.swe.x20.DataRecordType.Field) AbstractDataComponentType(net.opengis.swe.x20.AbstractDataComponentType) ResultTemplateType(net.opengis.sos.x20.ResultTemplateType) InsertResultTemplateType(net.opengis.sos.x20.InsertResultTemplateType) InsertResultTemplateDocument(net.opengis.sos.x20.InsertResultTemplateDocument) TimeType(net.opengis.swe.x20.TimeType) Test(org.junit.Test)

Example 4 with ResultTemplateType

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));
}
Also used : SFSamplingFeatureType(net.opengis.sampling.x20.SFSamplingFeatureType) ObservationTemplate(net.opengis.sos.x20.ResultTemplateType.ObservationTemplate) OMObservationType(net.opengis.om.x20.OMObservationType) SFSamplingFeatureDocument(net.opengis.sampling.x20.SFSamplingFeatureDocument) XmlObject(org.apache.xmlbeans.XmlObject) ResultTemplateType(net.opengis.sos.x20.ResultTemplateType) InsertResultTemplateType(net.opengis.sos.x20.InsertResultTemplateType) InsertResultTemplateDocument(net.opengis.sos.x20.InsertResultTemplateDocument) Test(org.junit.Test)

Example 5 with ResultTemplateType

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));
}
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)

Aggregations

InsertResultTemplateType (net.opengis.sos.x20.InsertResultTemplateType)8 ResultTemplateType (net.opengis.sos.x20.ResultTemplateType)8 InsertResultTemplateDocument (net.opengis.sos.x20.InsertResultTemplateDocument)7 Test (org.junit.Test)6 OMObservationType (net.opengis.om.x20.OMObservationType)1 SFSamplingFeatureDocument (net.opengis.sampling.x20.SFSamplingFeatureDocument)1 SFSamplingFeatureType (net.opengis.sampling.x20.SFSamplingFeatureType)1 GetResultTemplateType (net.opengis.sos.x20.GetResultTemplateType)1 ObservationTemplate (net.opengis.sos.x20.ResultTemplateType.ObservationTemplate)1 AbstractDataComponentType (net.opengis.swe.x20.AbstractDataComponentType)1 AbstractEncodingType (net.opengis.swe.x20.AbstractEncodingType)1 DataRecordType (net.opengis.swe.x20.DataRecordType)1 Field (net.opengis.swe.x20.DataRecordType.Field)1 TextEncodingType (net.opengis.swe.x20.TextEncodingType)1 TimeType (net.opengis.swe.x20.TimeType)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)1 InsertResultTemplateRequest (org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest)1 SweField (org.n52.shetland.ogc.swe.SweField)1