Search in sources :

Example 21 with GetObservationRequest

use of org.n52.shetland.ogc.sos.request.GetObservationRequest in project arctic-sea by 52North.

the class GetObservationRequestDecoderTest method hasObservedProperties.

@Test
public void hasObservedProperties() throws IOException, DecodingException {
    final GetObservationRequest req = loadMultiple();
    assertThat(req.getObservedProperties(), is(notNullValue()));
    assertThat(req.getObservedProperties(), hasSize(2));
    assertThat(req.getObservedProperties().get(0), is(notNullValue()));
    assertThat(req.getObservedProperties().get(0), is(equalTo("observedProperty1")));
    assertThat(req.getObservedProperties().get(1), is(notNullValue()));
    assertThat(req.getObservedProperties().get(1), is(equalTo("observedProperty2")));
}
Also used : GetObservationRequest(org.n52.shetland.ogc.sos.request.GetObservationRequest) Test(org.junit.Test)

Example 22 with GetObservationRequest

use of org.n52.shetland.ogc.sos.request.GetObservationRequest in project arctic-sea by 52North.

the class SosDecoderv20 method parseGetObservation.

/**
 * parses the XmlBean representing the getObservation request and creates a
 * SoSGetObservation request
 *
 * @param getObsDoc
 *            XmlBean created from the incoming request stream
 * @return Returns SosGetObservationRequest representing the request
 *
 * @throws DecodingException
 *             * If parsing the XmlBean failed
 */
private OwsServiceRequest parseGetObservation(final GetObservationDocument getObsDoc) throws DecodingException {
    final GetObservationRequest getObsRequest = new GetObservationRequest();
    final GetObservationType getObsType = getObsDoc.getGetObservation();
    // TODO: check
    getObsRequest.setService(getObsType.getService());
    getObsRequest.setVersion(getObsType.getVersion());
    getObsRequest.setOfferings(Arrays.asList(getObsType.getOfferingArray()));
    getObsRequest.setObservedProperties(Arrays.asList(getObsType.getObservedPropertyArray()));
    getObsRequest.setProcedures(Arrays.asList(getObsType.getProcedureArray()));
    getObsRequest.setTemporalFilters(parseTemporalFilters4GetObservation(getObsType.getTemporalFilterArray()));
    if (getObsType.isSetSpatialFilter()) {
        getObsRequest.setSpatialFilter(parseSpatialFilter4GetObservation(getObsType.getSpatialFilter()));
    }
    getObsRequest.setFeatureIdentifiers(Arrays.asList(getObsType.getFeatureOfInterestArray()));
    if (getObsType.isSetResponseFormat()) {
        try {
            final String responseFormat = URLDecoder.decode(getObsType.getResponseFormat(), "UTF-8");
            getObsRequest.setResponseFormat(responseFormat);
        } catch (final UnsupportedEncodingException e) {
            throw new DecodingException(e, "Error while encoding response format!");
        }
    }
    getObsRequest.setExtensions(parseExtensibleRequest(getObsType));
    return getObsRequest;
}
Also used : GetObservationRequest(org.n52.shetland.ogc.sos.request.GetObservationRequest) GetObservationType(net.opengis.sos.x20.GetObservationType) UnsupportedEncodingException(java.io.UnsupportedEncodingException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlString(org.apache.xmlbeans.XmlString)

Example 23 with GetObservationRequest

use of org.n52.shetland.ogc.sos.request.GetObservationRequest in project arctic-sea by 52North.

the class SosDecoderv20Test method should_decode_text_swesExtensions.

@Test
public void should_decode_text_swesExtensions() throws XmlException, OwsExceptionReport, DecodingException {
    final GetObservationDocument doc = GetObservationDocument.Factory.parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<sos:GetObservation service=\"SOS\" version=\"2.0.0\"\n" + "    xmlns:sos=\"http://www.opengis.net/sos/2.0\"\n" + "    xmlns:swe=\"http://www.opengis.net/swe/2.0\"\n" + "    xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" + "    xmlns:swes=\"http://www.opengis.net/swes/2.0\"\n" + "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.opengis.net/sos/2.0 http://schemas.opengis.net/sos/2.0/sos.xsd\">\n" + "    <swes:extension>\n" + "        <swe:Text definition=\"my-text-extension\">\n" + "            <swe:value>true</swe:value>\n" + "        </swe:Text>\n" + "    </swes:extension>\n" + "</sos:GetObservation>");
    final OwsServiceCommunicationObject decodedObject = decoder.decode(doc);
    assertThat(decodedObject, instanceOf(GetObservationRequest.class));
    final GetObservationRequest request = (GetObservationRequest) decodedObject;
    assertThat(request.getExtension("my-text-extension").map(e -> e.getValue()).map(v -> (SweText) v).map(v -> v.getValue()).orElse(null), is("true"));
}
Also used : OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) Arrays(java.util.Arrays) DecodingException(org.n52.svalbard.decode.exception.DecodingException) IsInstanceOf.instanceOf(org.hamcrest.core.IsInstanceOf.instanceOf) InsertResultTemplateDocument(net.opengis.sos.x20.InsertResultTemplateDocument) Test(org.junit.Test) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) GetObservationRequest(org.n52.shetland.ogc.sos.request.GetObservationRequest) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) GetObservationDocument(net.opengis.sos.x20.GetObservationDocument) Assert.assertThat(org.junit.Assert.assertThat) XmlException(org.apache.xmlbeans.XmlException) XmlOptions(org.apache.xmlbeans.XmlOptions) After(org.junit.After) Matchers.is(org.hamcrest.Matchers.is) TRUE(java.lang.Boolean.TRUE) Producer(org.n52.janmayen.Producer) Before(org.junit.Before) GetObservationRequest(org.n52.shetland.ogc.sos.request.GetObservationRequest) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) GetObservationDocument(net.opengis.sos.x20.GetObservationDocument) Test(org.junit.Test)

Aggregations

GetObservationRequest (org.n52.shetland.ogc.sos.request.GetObservationRequest)22 Test (org.junit.Test)15 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 OwsServiceCommunicationObject (org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject)3 GetObservationDocument (net.opengis.sos.x20.GetObservationDocument)2 DateTime (org.joda.time.DateTime)2 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)2 DecodingException (org.n52.svalbard.decode.exception.DecodingException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 TRUE (java.lang.Boolean.TRUE)1 Arrays (java.util.Arrays)1 Set (java.util.Set)1 GetFeatureOfInterest (net.opengis.sos.x10.GetFeatureOfInterestDocument.GetFeatureOfInterest)1 GetObservation (net.opengis.sos.x10.GetObservationDocument.GetObservation)1 FeatureOfInterest (net.opengis.sos.x10.GetObservationDocument.GetObservation.FeatureOfInterest)1 GetObservationType (net.opengis.sos.x20.GetObservationType)1 InsertResultTemplateDocument (net.opengis.sos.x20.InsertResultTemplateDocument)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1 XmlOptions (org.apache.xmlbeans.XmlOptions)1