Search in sources :

Example 1 with InsertResultTemplateRequest

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("#"));
}
Also used : SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) Test(org.junit.Test)

Example 2 with InsertResultTemplateRequest

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"));
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) Test(org.junit.Test)

Example 3 with InsertResultTemplateRequest

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;
}
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 4 with InsertResultTemplateRequest

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"));
}
Also used : InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) Test(org.junit.Test)

Example 5 with InsertResultTemplateRequest

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));
}
Also used : SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) XmlOptions(org.apache.xmlbeans.XmlOptions) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) SensorML(org.n52.shetland.ogc.sensorML.SensorML) SosResultEncoding(org.n52.shetland.ogc.sos.SosResultEncoding) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) CodeType(org.n52.shetland.ogc.gml.CodeType) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) SosResultStructure(org.n52.shetland.ogc.sos.SosResultStructure) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) Before(org.junit.Before)

Aggregations

InsertResultTemplateRequest (org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest)14 Test (org.junit.Test)10 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)6 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)3 SosResultStructure (org.n52.shetland.ogc.sos.SosResultStructure)2 SweField (org.n52.shetland.ogc.swe.SweField)2 SweTextEncoding (org.n52.shetland.ogc.swe.encoding.SweTextEncoding)2 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 GetResultTemplateType (net.opengis.sos.x20.GetResultTemplateType)1 InsertResultTemplateType (net.opengis.sos.x20.InsertResultTemplateType)1 ResultTemplateType (net.opengis.sos.x20.ResultTemplateType)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlOptions (org.apache.xmlbeans.XmlOptions)1 Before (org.junit.Before)1 CodeType (org.n52.shetland.ogc.gml.CodeType)1 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)1 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)1 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)1 SensorML (org.n52.shetland.ogc.sensorML.SensorML)1