Search in sources :

Example 1 with UpdateSensorDescriptionDocument

use of net.opengis.swes.x20.UpdateSensorDescriptionDocument in project arctic-sea by 52North.

the class SwesDecoderv20 method decode.

@Override
public OwsServiceRequest decode(XmlObject xmlObject) throws DecodingException {
    LOGGER.debug("REQUESTTYPE:" + xmlObject.getClass());
    XmlHelper.validateDocument(xmlObject);
    if (xmlObject instanceof DescribeSensorDocument) {
        return parseDescribeSensor((DescribeSensorDocument) xmlObject);
    } else if (xmlObject instanceof InsertSensorDocument) {
        return parseInsertSensor((InsertSensorDocument) xmlObject);
    } else if (xmlObject instanceof UpdateSensorDescriptionDocument) {
        return parseUpdateSensorDescription((UpdateSensorDescriptionDocument) xmlObject);
    } else if (xmlObject instanceof DeleteSensorDocument) {
        return parseDeleteSensor((DeleteSensorDocument) xmlObject);
    } else {
        throw new UnsupportedDecoderXmlInputException(this, xmlObject);
    }
}
Also used : InsertSensorDocument(net.opengis.swes.x20.InsertSensorDocument) DeleteSensorDocument(net.opengis.swes.x20.DeleteSensorDocument) DescribeSensorDocument(net.opengis.swes.x20.DescribeSensorDocument) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) UpdateSensorDescriptionDocument(net.opengis.swes.x20.UpdateSensorDescriptionDocument)

Example 2 with UpdateSensorDescriptionDocument

use of net.opengis.swes.x20.UpdateSensorDescriptionDocument 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)

Aggregations

DeleteSensorDocument (net.opengis.swes.x20.DeleteSensorDocument)1 DescribeSensorDocument (net.opengis.swes.x20.DescribeSensorDocument)1 InsertSensorDocument (net.opengis.swes.x20.InsertSensorDocument)1 SensorDescriptionType (net.opengis.swes.x20.SensorDescriptionType)1 UpdateSensorDescriptionDocument (net.opengis.swes.x20.UpdateSensorDescriptionDocument)1 UpdateSensorDescriptionType (net.opengis.swes.x20.UpdateSensorDescriptionType)1 Description (net.opengis.swes.x20.UpdateSensorDescriptionType.Description)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)1 OwsServiceCommunicationObject (org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject)1 SosProcedureDescription (org.n52.shetland.ogc.sos.SosProcedureDescription)1 UpdateSensorRequest (org.n52.shetland.ogc.sos.request.UpdateSensorRequest)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1 UnsupportedDecoderXmlInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException)1