Search in sources :

Example 11 with SweAbstractDataComponent

use of org.n52.shetland.ogc.swe.SweAbstractDataComponent in project arctic-sea by 52North.

the class SweCommonDecoderV20 method parseAbstractDataComponentDocument.

private Object parseAbstractDataComponentDocument(final AbstractDataComponentDocument abstractDataComponentDoc) throws DecodingException {
    SweAbstractDataComponent sosAbstractDataComponent = parseAbstractDataComponent(abstractDataComponentDoc.getAbstractDataComponent());
    sosAbstractDataComponent.setXml(abstractDataComponentDoc.xmlText(getXmlOptions()));
    return sosAbstractDataComponent;
}
Also used : SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent)

Example 12 with SweAbstractDataComponent

use of org.n52.shetland.ogc.swe.SweAbstractDataComponent in project arctic-sea by 52North.

the class SensorMLDecoderV101 method parseIoComponentPropertyType.

/**
 * Parses the components
 *
 * @param xbIoCompPropType XML components
 *
 * @return SOS components
 *
 * @throws DecodingException if an error occurs
 */
@SuppressWarnings({ "rawtypes" })
private SmlIo parseIoComponentPropertyType(final IoComponentPropertyType xbIoCompPropType) throws DecodingException {
    final SmlIo sosIo = new SmlIo();
    sosIo.setIoName(xbIoCompPropType.getName());
    XmlObject toDecode = null;
    if (xbIoCompPropType.isSetHref()) {
        sosIo.setHref(xbIoCompPropType.getHref());
        if (xbIoCompPropType.isSetTitle()) {
            sosIo.setTitle(xbIoCompPropType.getTitle());
        }
        return sosIo;
    }
    if (xbIoCompPropType.isSetBoolean()) {
        toDecode = xbIoCompPropType.getBoolean();
    } else if (xbIoCompPropType.isSetCategory()) {
        toDecode = xbIoCompPropType.getCategory();
    } else if (xbIoCompPropType.isSetCount()) {
        toDecode = xbIoCompPropType.getCount();
    } else if (xbIoCompPropType.isSetCountRange()) {
        toDecode = xbIoCompPropType.getCountRange();
    } else if (xbIoCompPropType.isSetObservableProperty()) {
        toDecode = xbIoCompPropType.getObservableProperty();
    } else if (xbIoCompPropType.isSetQuantity()) {
        toDecode = xbIoCompPropType.getQuantity();
    } else if (xbIoCompPropType.isSetQuantityRange()) {
        toDecode = xbIoCompPropType.getQuantityRange();
    } else if (xbIoCompPropType.isSetText()) {
        toDecode = xbIoCompPropType.getText();
    } else if (xbIoCompPropType.isSetTime()) {
        toDecode = xbIoCompPropType.getTime();
    } else if (xbIoCompPropType.isSetTimeRange()) {
        toDecode = xbIoCompPropType.getTimeRange();
    } else if (xbIoCompPropType.isSetAbstractDataArray1()) {
        toDecode = xbIoCompPropType.getAbstractDataArray1();
    } else if (xbIoCompPropType.isSetAbstractDataRecord()) {
        toDecode = xbIoCompPropType.getAbstractDataRecord();
    } else {
        throw new DecodingException(XmlHelper.getLocalName(xbIoCompPropType), "An 'IoComponentProperty' is not supported");
    }
    final Object decodedObject = decodeXmlElement(toDecode);
    if (decodedObject instanceof SweAbstractDataComponent) {
        sosIo.setIoValue((SweAbstractDataComponent) decodedObject);
    } else {
        throw new DecodingException(XmlHelper.getLocalName(xbIoCompPropType), "The 'IoComponentProperty' with type '%s' as value for '%s' is not supported.", XmlHelper.getLocalName(toDecode), XmlHelper.getLocalName(xbIoCompPropType));
    }
    return sosIo;
}
Also used : SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlObject(org.apache.xmlbeans.XmlObject) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo)

Example 13 with SweAbstractDataComponent

use of org.n52.shetland.ogc.swe.SweAbstractDataComponent in project arctic-sea by 52North.

the class SensorMLEncoderv20 method createCharacteristics.

/**
 * Creates the characteristics section of the SensorML description.
 *
 * @param smlCharacteristics
 *            SOS characteristics list
 *
 * @return XML Characteristics array
 *
 * @throws EncodingException
 *             If an error occurs
 */
private Characteristics[] createCharacteristics(final List<SmlCharacteristics> smlCharacteristics) throws EncodingException {
    final List<Characteristics> characteristicsList = new ArrayList<>(smlCharacteristics.size());
    for (final SmlCharacteristics sosSMLCharacteristics : smlCharacteristics) {
        Characteristics xbCharacteristics = Characteristics.Factory.newInstance(getXmlOptions());
        if (sosSMLCharacteristics.isSetName()) {
            xbCharacteristics.setName(sosSMLCharacteristics.getName());
        } else {
            xbCharacteristics.setName("characteristics_" + smlCharacteristics.lastIndexOf(sosSMLCharacteristics));
        }
        CharacteristicListType characteristicList = xbCharacteristics.addNewCharacteristicList();
        if (sosSMLCharacteristics.isSetCharacteristics()) {
            for (SmlCharacteristic characteristic : sosSMLCharacteristics.getCharacteristic()) {
                Characteristic c = characteristicList.addNewCharacteristic();
                c.setName(NcName.makeValid(characteristic.getName()));
                if (characteristic.isSetAbstractDataComponent()) {
                    XmlObject encodeObjectToXml = encodeObjectToXml(SweConstants.NS_SWE_20, characteristic.getAbstractDataComponent());
                    XmlObject substituteElement = XmlHelper.substituteElement(c.addNewAbstractDataComponent(), encodeObjectToXml);
                    substituteElement.set(encodeObjectToXml);
                } else if (characteristic.isSetHref()) {
                    c.setHref(characteristic.getHref());
                    if (characteristic.isSetTitle()) {
                        c.setTitle(characteristic.getTitle());
                    }
                }
            }
        }
        if (sosSMLCharacteristics.isSetAbstractDataComponents()) {
            if (sosSMLCharacteristics.isSetAbstractDataComponents()) {
                for (SweAbstractDataComponent component : sosSMLCharacteristics.getAbstractDataComponents()) {
                    XmlObject encodeObjectToXml = encodeObjectToXml(SweConstants.NS_SWE_20, component);
                    Characteristic c = characteristicList.addNewCharacteristic();
                    c.setName(NcName.makeValid(component.getName().getValue()));
                    XmlObject substituteElement = XmlHelper.substituteElement(c.addNewAbstractDataComponent(), encodeObjectToXml);
                    substituteElement.set(encodeObjectToXml);
                }
            }
        }
        characteristicsList.add(xbCharacteristics);
    }
    return characteristicsList.toArray(new Characteristics[characteristicsList.size()]);
}
Also used : SmlCharacteristics(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics) Characteristics(net.opengis.sensorml.x20.DescribedObjectType.Characteristics) SmlCharacteristics(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics) SmlCharacteristic(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristic) SmlCharacteristic(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristic) Characteristic(net.opengis.sensorml.x20.CharacteristicListType.Characteristic) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) ArrayList(java.util.ArrayList) CharacteristicListType(net.opengis.sensorml.x20.CharacteristicListType) XmlObject(org.apache.xmlbeans.XmlObject)

Example 14 with SweAbstractDataComponent

use of org.n52.shetland.ogc.swe.SweAbstractDataComponent in project arctic-sea by 52North.

the class SensorMLEncoderv20 method createCapability.

private Capabilities createCapability(final SmlCapabilities capabilities) throws EncodingException {
    Capabilities xbCapabilities = null;
    if (capabilities.isSetAbstractDataComponents()) {
        xbCapabilities = Capabilities.Factory.newInstance(getXmlOptions());
        if (capabilities.isSetName()) {
            xbCapabilities.setName(capabilities.getName());
        }
        CapabilityListType capabilityList = xbCapabilities.addNewCapabilityList();
        if (capabilities.isSetCapabilities()) {
            for (SmlCapability capability : capabilities.getCapabilities()) {
                XmlObject encodeObjectToXml = encodeObjectToXmlSwe20(capability.getAbstractDataComponent());
                Capability c = capabilityList.addNewCapability();
                if (capability.isSetName()) {
                    c.setName(NcName.makeValid(capability.getName()));
                } else if (capability.getAbstractDataComponent().isSetName()) {
                    capability.setName(NcName.makeValid(capability.getAbstractDataComponent().getName().getValue()));
                } else {
                    capability.setName(NcName.makeValid(capability.getAbstractDataComponent().getDefinition()));
                }
                XmlObject substituteElement = XmlHelper.substituteElement(c.addNewAbstractDataComponent(), encodeObjectToXml);
                substituteElement.set(encodeObjectToXml);
            }
        } else if (capabilities.isSetAbstractDataComponents()) {
            for (SweAbstractDataComponent component : capabilities.getAbstractDataComponents()) {
                XmlObject encodeObjectToXml = encodeObjectToXmlSwe20(component);
                Capability capability = capabilityList.addNewCapability();
                if (component.isSetName()) {
                    capability.setName(NcName.makeValid(component.getName().getValue()));
                } else {
                    capability.setName(NcName.makeValid(component.getDefinition()));
                }
                XmlObject substituteElement = XmlHelper.substituteElement(capability.addNewAbstractDataComponent(), encodeObjectToXml);
                substituteElement.set(encodeObjectToXml);
            }
        }
    }
    return xbCapabilities;
}
Also used : CapabilityListType(net.opengis.sensorml.x20.CapabilityListType) SmlCapability(org.n52.shetland.ogc.sensorML.elements.SmlCapability) Capability(net.opengis.sensorml.x20.CapabilityListType.Capability) Capabilities(net.opengis.sensorml.x20.DescribedObjectType.Capabilities) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) XmlObject(org.apache.xmlbeans.XmlObject) SmlCapability(org.n52.shetland.ogc.sensorML.elements.SmlCapability)

Example 15 with SweAbstractDataComponent

use of org.n52.shetland.ogc.swe.SweAbstractDataComponent in project arctic-sea by 52North.

the class SweCommonEncoderv101 method createFieldForSimpleDataRecord.

private AnyScalarPropertyType createFieldForSimpleDataRecord(SweField sweField) throws EncodingException {
    SweAbstractDataComponent sosElement = sweField.getElement();
    AnyScalarPropertyType xbField = AnyScalarPropertyType.Factory.newInstance(getXmlOptions());
    if (sweField.isSetName()) {
        xbField.setName(sweField.getName().getValue());
    }
    AbstractDataComponentType xbDCD;
    if (sosElement instanceof SweBoolean) {
        xbDCD = xbField.addNewBoolean();
        xbDCD.set(createSimpleType((SweBoolean) sosElement));
    } else if (sosElement instanceof SweCategory) {
        xbDCD = xbField.addNewCategory();
        xbDCD.set(createSimpleType((SweCategory) sosElement));
    } else if (sosElement instanceof SweCount) {
        xbDCD = xbField.addNewCount();
        xbDCD.set(createSimpleType((SweCount) sosElement));
    } else if (sosElement instanceof SweQuantity) {
        xbDCD = xbField.addNewQuantity();
        xbDCD.set(createSimpleType((SweQuantity) sosElement));
    } else if (sosElement instanceof SweText) {
        xbDCD = xbField.addNewText();
        xbDCD.set(createSimpleType((SweText) sosElement));
    } else if (sosElement instanceof SweTime) {
        xbDCD = xbField.addNewTime();
        xbDCD.set(createSimpleType((SweTime) sosElement));
    } else {
        throw new EncodingException("The element type '%s' of the received %s is not supported by this encoder '%s'.", new Object[] { sosElement != null ? sosElement.getClass().getName() : null, sweField.getClass().getName(), getClass().getName() });
    }
    return xbField;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) EncodingException(org.n52.svalbard.encode.exception.EncodingException) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) XmlObject(org.apache.xmlbeans.XmlObject) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean)

Aggregations

SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)24 XmlObject (org.apache.xmlbeans.XmlObject)11 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)8 SweField (org.n52.shetland.ogc.swe.SweField)7 ArrayList (java.util.ArrayList)4 DecodingException (org.n52.svalbard.decode.exception.DecodingException)4 EncodingException (org.n52.svalbard.encode.exception.EncodingException)4 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)3 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)3 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 CapabilityListType (net.opengis.sensorml.x20.CapabilityListType)2 Capability (net.opengis.sensorml.x20.CapabilityListType.Capability)2 CharacteristicListType (net.opengis.sensorml.x20.CharacteristicListType)2 Characteristic (net.opengis.sensorml.x20.CharacteristicListType.Characteristic)2 Capabilities (net.opengis.sensorml.x20.DescribedObjectType.Capabilities)2 DataRecordType (net.opengis.swe.x20.DataRecordType)2 DescribedObject (org.n52.shetland.ogc.sensorML.v20.DescribedObject)2 SweDataArray (org.n52.shetland.ogc.swe.SweDataArray)2 SweEnvelope (org.n52.shetland.ogc.swe.SweEnvelope)2