Search in sources :

Example 1 with SosProcedureDescription

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

the class InsertSensorRequestDecoder method parseProcedureDescription.

private SosProcedureDescription<?> parseProcedureDescription(JsonNode path, String pdf) throws DecodingException {
    try {
        final XmlObject xb = XmlObject.Factory.parse(path.textValue());
        Decoder<?, XmlObject> decoder = getProcedureDescriptionDecoder(pdf, xb);
        if (decoder == null) {
            throw new DecodingException(JSONConstants.PROCEDURE_DESCRIPTION_FORMAT, "The requested %s is not supported!", JSONConstants.PROCEDURE_DESCRIPTION_FORMAT);
        }
        Object decode = decoder.decode(xb);
        if (decode instanceof SosProcedureDescription<?>) {
            return (SosProcedureDescription<?>) decode;
        } else if (decode instanceof AbstractFeature) {
            return new SosProcedureDescription<AbstractFeature>((AbstractFeature) decode);
        } else {
            throw new DecodingException("The decoded element {} is not of type {}!", decode.getClass().getName(), AbstractFeature.class.getName());
        }
    } catch (final XmlException xmle) {
        throw new DecodingException("Error while parsing procedure description of InsertSensor request!", xmle);
    }
}
Also used : 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) XmlObject(org.apache.xmlbeans.XmlObject)

Example 2 with SosProcedureDescription

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

the class SwesDecoderv20 method parseInsertSensor.

private OwsServiceRequest parseInsertSensor(final InsertSensorDocument xbInsSensDoc) throws DecodingException {
    final InsertSensorRequest request = new InsertSensorRequest();
    final InsertSensorType xbInsertSensor = xbInsSensDoc.getInsertSensor();
    request.setService(xbInsertSensor.getService());
    request.setVersion(xbInsertSensor.getVersion());
    // format
    request.setProcedureDescriptionFormat(xbInsertSensor.getProcedureDescriptionFormat());
    // observable properties
    if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getObservablePropertyArray())) {
        request.setObservableProperty(Arrays.asList(xbInsertSensor.getObservablePropertyArray()));
    }
    // related features
    if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getRelatedFeatureArray())) {
        request.setRelatedFeature(parseRelatedFeature(xbInsertSensor.getRelatedFeatureArray()));
    }
    // metadata
    if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getMetadataArray())) {
        request.setMetadata(parseMetadata(xbInsertSensor.getMetadataArray()));
    }
    // extensions
    request.setExtensions(parseExtensibleRequest(xbInsertSensor));
    try {
        final XmlObject xbProcedureDescription = XmlObject.Factory.parse(getNodeFromNodeList(xbInsertSensor.getProcedureDescription().getDomNode().getChildNodes()));
        checkFormatWithNamespace(xbInsertSensor.getProcedureDescriptionFormat(), XmlHelper.getNamespace(xbProcedureDescription));
        final Decoder<?, XmlObject> decoder = getDecoder(new XmlNamespaceDecoderKey(xbInsertSensor.getProcedureDescriptionFormat(), xbProcedureDescription.getClass()));
        if (decoder != null) {
            final Object decodedProcedureDescription = decoder.decode(xbProcedureDescription);
            if (decodedProcedureDescription instanceof SosProcedureDescription) {
                request.setProcedureDescription((SosProcedureDescription) decodedProcedureDescription);
            } else if (decodedProcedureDescription instanceof AbstractFeature) {
                request.setProcedureDescription(new SosProcedureDescription<>((AbstractFeature) decodedProcedureDescription));
            }
        }
    } catch (final XmlException xmle) {
        throw new DecodingException("Error while parsing procedure description of InsertSensor request!", xmle);
    }
    return request;
}
Also used : XmlException(org.apache.xmlbeans.XmlException) InsertSensorType(net.opengis.swes.x20.InsertSensorType) SosProcedureDescription(org.n52.shetland.ogc.sos.SosProcedureDescription) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) XmlObject(org.apache.xmlbeans.XmlObject) OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) InsertSensorRequest(org.n52.shetland.ogc.sos.request.InsertSensorRequest)

Example 3 with SosProcedureDescription

use of org.n52.shetland.ogc.sos.SosProcedureDescription 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 4 with SosProcedureDescription

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

the class AbstractOmEncoderv20 method encode.

@Override
public XmlObject encode(Object element, EncodingContext additionalValues) throws EncodingException {
    XmlObject encodedObject = null;
    if (element instanceof OmObservation) {
        encodedObject = encodeOmObservation((OmObservation) element, additionalValues);
    } else if (element instanceof NamedValue) {
        NamedValueType nvt = createNamedValue((NamedValue<?>) element);
        if (additionalValues.has(XmlBeansEncodingFlags.DOCUMENT)) {
            NamedValueDocument nvd = NamedValueDocument.Factory.newInstance();
            nvd.setNamedValue(nvt);
            encodedObject = nvd;
        } else if (additionalValues.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
            NamedValuePropertyType nvpt = NamedValuePropertyType.Factory.newInstance();
            nvpt.setNamedValue(nvt);
            encodedObject = nvpt;
        } else {
            encodedObject = nvt;
        }
    } else if (element instanceof AbstractFeature) {
        encodedObject = encodeFeatureOfInterest((AbstractFeature) element);
    } else if (element instanceof SosProcedureDescription) {
        encodedObject = encodeProcedureDescription((SosProcedureDescription<?>) element);
    } else {
        throw new UnsupportedEncoderInputException(this, element);
    }
    // XmlHelper.validateDocument(encodedObject));
    return encodedObject;
}
Also used : NamedValueDocument(net.opengis.om.x20.NamedValueDocument) NamedValueType(net.opengis.om.x20.NamedValueType) OmObservation(org.n52.shetland.ogc.om.OmObservation) SosProcedureDescription(org.n52.shetland.ogc.sos.SosProcedureDescription) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) XmlObject(org.apache.xmlbeans.XmlObject) NamedValue(org.n52.shetland.ogc.om.NamedValue) NamedValuePropertyType(net.opengis.om.x20.NamedValuePropertyType) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Example 5 with SosProcedureDescription

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

the class UpdateSensorRequestDecoder method parseProcedureDesciption.

private SosProcedureDescription<?> parseProcedureDesciption(String xml, String pdf) throws DecodingException {
    try {
        final XmlObject xb = XmlObject.Factory.parse(xml);
        Decoder<?, XmlObject> decoder = getDecoder(new XmlNamespaceDecoderKey(pdf, xb.getClass()));
        if (decoder == null) {
            throw new DecodingException(JSONConstants.PROCEDURE_DESCRIPTION_FORMAT, "The requested %s is not supported!", JSONConstants.PROCEDURE_DESCRIPTION_FORMAT);
        }
        Object decode = decoder.decode(xb);
        if (decode instanceof SosProcedureDescription<?>) {
            return (SosProcedureDescription<?>) decode;
        } else if (decode instanceof AbstractFeature) {
            return new SosProcedureDescription<AbstractFeature>((AbstractFeature) decode);
        } else {
            throw new DecodingException("The decoded element {} is not of type {}!", decode.getClass().getName(), AbstractFeature.class.getName());
        }
    } catch (XmlException xmle) {
        throw new DecodingException("Error while parsing procedure description of InsertSensor request!", xmle);
    }
}
Also used : XmlNamespaceDecoderKey(org.n52.svalbard.decode.XmlNamespaceDecoderKey) 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) XmlObject(org.apache.xmlbeans.XmlObject)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)6 SosProcedureDescription (org.n52.shetland.ogc.sos.SosProcedureDescription)6 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)5 XmlException (org.apache.xmlbeans.XmlException)4 DecodingException (org.n52.svalbard.decode.exception.DecodingException)4 OwsServiceCommunicationObject (org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject)2 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)2 NamedValueDocument (net.opengis.om.x20.NamedValueDocument)1 NamedValuePropertyType (net.opengis.om.x20.NamedValuePropertyType)1 NamedValueType (net.opengis.om.x20.NamedValueType)1 ComponentList (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList)1 IdentifierList (net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList)1 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)1 SystemType (net.opengis.sensorML.x101.SystemType)1 InsertSensorType (net.opengis.swes.x20.InsertSensorType)1 SensorDescriptionType (net.opengis.swes.x20.SensorDescriptionType)1 UpdateSensorDescriptionType (net.opengis.swes.x20.UpdateSensorDescriptionType)1 Description (net.opengis.swes.x20.UpdateSensorDescriptionType.Description)1 Test (org.junit.Test)1 NamedValue (org.n52.shetland.ogc.om.NamedValue)1