Search in sources :

Example 11 with Extensions

use of org.n52.shetland.ogc.ows.extension.Extensions in project arctic-sea by 52North.

the class SwesDecoderv20 method parseUpdateSensorDescription.

/**
 * parses the Xmlbeans UpdateSensorDescription document to a SOS request.
 *
 * @param xbUpSenDoc
 *            UpdateSensorDescription document
 * @return SOS UpdateSensor request
 *
 * @throws DecodingException
 *             * if an error occurs.
 */
private OwsServiceRequest parseUpdateSensorDescription(final UpdateSensorDescriptionDocument xbUpSenDoc) throws DecodingException {
    final UpdateSensorRequest request = new UpdateSensorRequest();
    final UpdateSensorDescriptionType xbUpdateSensor = xbUpSenDoc.getUpdateSensorDescription();
    request.setService(xbUpdateSensor.getService());
    request.setVersion(xbUpdateSensor.getVersion());
    request.setProcedureIdentifier(xbUpdateSensor.getProcedure());
    request.setProcedureDescriptionFormat(xbUpdateSensor.getProcedureDescriptionFormat());
    // extensions
    request.setExtensions(parseExtensibleRequest(xbUpdateSensor));
    for (final Description description : xbUpdateSensor.getDescriptionArray()) {
        SensorDescriptionType sensorDescription = description.getSensorDescription();
        try {
            // TODO exception if valid time is set
            final XmlObject xmlObject = XmlObject.Factory.parse(getNodeFromNodeList(sensorDescription.getData().getDomNode().getChildNodes()));
            Decoder<?, XmlObject> decoder = getDecoder(getDecoderKey(xmlObject));
            if (decoder == null) {
                throw new DecodingException(UpdateSensorDescriptionParams.procedureDescriptionFormat, "The requested procedureDescritpionFormat is not supported!");
            }
            final Object decodedObject = decoder.decode(xmlObject);
            SosProcedureDescription<?> sosProcedureDescription = null;
            if (decodedObject instanceof SosProcedureDescription) {
                sosProcedureDescription = (SosProcedureDescription) decodedObject;
            } else if (decodedObject instanceof AbstractFeature) {
                sosProcedureDescription = new SosProcedureDescription<>((AbstractFeature) decodedObject);
            }
            if (sosProcedureDescription != null) {
                if (sensorDescription.isSetValidTime()) {
                    sosProcedureDescription.setValidTime(getValidTime(sensorDescription.getValidTime()));
                }
            }
            request.addProcedureDescriptionString(sosProcedureDescription);
        } catch (final XmlException xmle) {
            throw new DecodingException("Error while parsing procedure description of UpdateSensor request!", xmle);
        }
    }
    return request;
}
Also used : UpdateSensorDescriptionType(net.opengis.swes.x20.UpdateSensorDescriptionType) UpdateSensorRequest(org.n52.shetland.ogc.sos.request.UpdateSensorRequest) SosProcedureDescription(org.n52.shetland.ogc.sos.SosProcedureDescription) Description(net.opengis.swes.x20.UpdateSensorDescriptionType.Description) XmlException(org.apache.xmlbeans.XmlException) SosProcedureDescription(org.n52.shetland.ogc.sos.SosProcedureDescription) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) XmlObject(org.apache.xmlbeans.XmlObject) SensorDescriptionType(net.opengis.swes.x20.SensorDescriptionType) UpdateSensorDescriptionType(net.opengis.swes.x20.UpdateSensorDescriptionType)

Example 12 with Extensions

use of org.n52.shetland.ogc.ows.extension.Extensions in project arctic-sea by 52North.

the class CapabilitiesTypeDecoder method parseOfferingExtension.

private Extensions parseOfferingExtension(ObservationOfferingType obsOff) throws DecodingException {
    Extensions extensions = new Extensions();
    for (XmlObject xmlObject : obsOff.getExtensionArray()) {
        try {
            Extension<?> extension = (Extension) decodeXmlElement(xmlObject);
            extensions.addExtension(extension);
        } catch (DecodingException ex) {
            LOGGER.warn(ex.getLocalizedMessage());
        }
    }
    return extensions;
}
Also used : Extension(org.n52.shetland.ogc.ows.extension.Extension) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) Extensions(org.n52.shetland.ogc.ows.extension.Extensions)

Example 13 with Extensions

use of org.n52.shetland.ogc.ows.extension.Extensions in project arctic-sea by 52North.

the class SwesExtensionsTest method getExtension_for_string_created_with_enum_schould_return_true.

@Test
public void getExtension_for_string_created_with_enum_schould_return_true() {
    final Extensions extensions = new Extensions();
    extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_1).setValue(VALUE_1));
    extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_2).setValue(VALUE_2));
    extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_3).setValue(VALUE_3));
    assertThat(extensions.getExtension(DEFINITION_1).orElse(null).getValue(), instanceOf(VALUE_1.getClass()));
    assertThat(extensions.getExtension(DEFINITION_2).orElse(null).getValue(), instanceOf(VALUE_2.getClass()));
    assertThat(extensions.getExtension(DEFINITION_3).orElse(null).getValue(), instanceOf(VALUE_3.getClass()));
}
Also used : Extensions(org.n52.shetland.ogc.ows.extension.Extensions) Test(org.junit.Test)

Example 14 with Extensions

use of org.n52.shetland.ogc.ows.extension.Extensions in project arctic-sea by 52North.

the class SwesExtensionsTest method isBooleanExtensionSet_should_return_true_if_set_to_true.

@Test
public void isBooleanExtensionSet_should_return_true_if_set_to_true() {
    final Extensions extensions = new Extensions();
    extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_1).setValue(new SweBoolean().setValue(TRUE)));
    assertThat(extensions.getBooleanExtension(DEFINITION_1), is(TRUE));
}
Also used : Extensions(org.n52.shetland.ogc.ows.extension.Extensions) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) Test(org.junit.Test)

Example 15 with Extensions

use of org.n52.shetland.ogc.ows.extension.Extensions in project arctic-sea by 52North.

the class SwesExtensionsTest method isEmpty_should_return_false_if_at_least_one_extension_is_set.

@Test
public void isEmpty_should_return_false_if_at_least_one_extension_is_set() {
    final Extensions extensions = new Extensions();
    extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_1));
    assertThat(extensions.isEmpty(), is(FALSE));
}
Also used : Extensions(org.n52.shetland.ogc.ows.extension.Extensions) Test(org.junit.Test)

Aggregations

Extensions (org.n52.shetland.ogc.ows.extension.Extensions)11 Test (org.junit.Test)10 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)4 XmlObject (org.apache.xmlbeans.XmlObject)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3 XmlException (org.apache.xmlbeans.XmlException)2 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)2 OwsCapabilities (org.n52.shetland.ogc.ows.OwsCapabilities)2 OwsCapabilitiesExtension (org.n52.shetland.ogc.ows.OwsCapabilitiesExtension)2 OwsOperationsMetadata (org.n52.shetland.ogc.ows.OwsOperationsMetadata)2 OwsServiceIdentification (org.n52.shetland.ogc.ows.OwsServiceIdentification)2 OwsServiceProvider (org.n52.shetland.ogc.ows.OwsServiceProvider)2 OwsServiceCommunicationObject (org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject)2 SosProcedureDescription (org.n52.shetland.ogc.sos.SosProcedureDescription)2 Locale (java.util.Locale)1 GetFeatureOfInterestType (net.opengis.sos.x20.GetFeatureOfInterestType)1 DeleteSensorType (net.opengis.swes.x20.DeleteSensorType)1 DescribeSensorType (net.opengis.swes.x20.DescribeSensorType)1 InsertSensorType (net.opengis.swes.x20.InsertSensorType)1 SensorDescriptionType (net.opengis.swes.x20.SensorDescriptionType)1