Search in sources :

Example 1 with NamedValueType

use of net.opengis.om.x20.NamedValueType in project arctic-sea by 52North.

the class AbstractGmlDecoderv321 method parseNamedValueType.

protected NamedValue<?> parseNamedValueType(NamedValuePropertyType namedValueProperty) throws DecodingException {
    if (namedValueProperty.isSetNamedValue()) {
        NamedValueType namedValue = namedValueProperty.getNamedValue();
        NamedValue<?> sosNamedValue = parseNamedValueValue(namedValue.getValue());
        org.n52.shetland.ogc.gml.ReferenceType referenceType = (org.n52.shetland.ogc.gml.ReferenceType) decodeXmlObject(namedValue.getName());
        sosNamedValue.setName(referenceType);
        return sosNamedValue;
    } else if (namedValueProperty.isSetHref()) {
        NamedValue<org.n52.shetland.ogc.gml.ReferenceType> sosNamedValue = new NamedValue<>();
        org.n52.shetland.ogc.gml.ReferenceType referenceType = new org.n52.shetland.ogc.gml.ReferenceType(namedValueProperty.getHref());
        if (namedValueProperty.isSetTitle()) {
            referenceType.setTitle(namedValueProperty.getTitle());
        }
        sosNamedValue.setName(referenceType);
        return sosNamedValue;
    } else {
        throw new UnsupportedDecoderInputException(this, namedValueProperty);
    }
}
Also used : NamedValueType(net.opengis.om.x20.NamedValueType) NamedValue(org.n52.shetland.ogc.om.NamedValue) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException) ReferenceType(net.opengis.gml.x32.ReferenceType)

Example 2 with NamedValueType

use of net.opengis.om.x20.NamedValueType 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 3 with NamedValueType

use of net.opengis.om.x20.NamedValueType in project arctic-sea by 52North.

the class AbstractOmEncoderv20 method createNamedValue.

/**
 * Method to encode a SOS NamedValue to an XmlBeans representation
 *
 * @param sosNamedValue
 *            SOS NamedValue
 * @return XmlBeans object
 * @throws EncodingException
 *             If an error occurs.
 */
protected NamedValueType createNamedValue(NamedValue<?> sosNamedValue) throws EncodingException {
    // encode value (any)
    XmlObject namedValuePropertyValue = getNamedValueValue(sosNamedValue.getValue());
    if (namedValuePropertyValue != null) {
        NamedValueType xbNamedValue = NamedValueType.Factory.newInstance(getXmlOptions());
        // encode gml:ReferenceType
        XmlObject encodeObjectToXml = encodeGML(sosNamedValue.getName());
        xbNamedValue.addNewName().set(encodeObjectToXml);
        // set value (any)
        xbNamedValue.setValue(namedValuePropertyValue);
        return xbNamedValue;
    }
    return null;
}
Also used : NamedValueType(net.opengis.om.x20.NamedValueType) XmlObject(org.apache.xmlbeans.XmlObject)

Aggregations

NamedValueType (net.opengis.om.x20.NamedValueType)3 XmlObject (org.apache.xmlbeans.XmlObject)2 NamedValue (org.n52.shetland.ogc.om.NamedValue)2 ReferenceType (net.opengis.gml.x32.ReferenceType)1 NamedValueDocument (net.opengis.om.x20.NamedValueDocument)1 NamedValuePropertyType (net.opengis.om.x20.NamedValuePropertyType)1 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)1 OmObservation (org.n52.shetland.ogc.om.OmObservation)1 SosProcedureDescription (org.n52.shetland.ogc.sos.SosProcedureDescription)1 UnsupportedDecoderInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderInputException)1 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)1