Search in sources :

Example 1 with Component

use of net.opengis.sensorml.x20.ComponentListType.Component in project arctic-sea by 52North.

the class SensorMLDecoderV20 method parseComponents.

private List<SmlComponent> parseComponents(ComponentListPropertyType components) throws DecodingException {
    final List<SmlComponent> sosSmlComponents = Lists.newLinkedList();
    if (components.isSetComponentList() && components.getComponentList().getComponentArray() != null) {
        for (final Component component : components.getComponentList().getComponentArray()) {
            if (component.isSetAbstractProcess() || component.isSetHref() || component.isSetTitle()) {
                final SmlComponent sosSmlcomponent = new SmlComponent(component.getName());
                AbstractSensorML abstractProcess;
                if (component.isSetAbstractProcess()) {
                    abstractProcess = parse(component.getAbstractProcess());
                } else {
                    if (component.isSetTitle()) {
                        sosSmlcomponent.setTitle(component.getTitle());
                    }
                    if (component.isSetHref()) {
                        sosSmlcomponent.setHref(component.getHref());
                    }
                    abstractProcess = new AbstractProcess();
                    if (sosSmlcomponent.isSetTitle()) {
                        abstractProcess.setIdentifier(sosSmlcomponent.getTitle());
                    } else if (!sosSmlcomponent.isSetTitle() && sosSmlcomponent.isSetHref()) {
                        abstractProcess.setIdentifier(sosSmlcomponent.getHref());
                    }
                }
                sosSmlcomponent.setProcess(abstractProcess);
                sosSmlComponents.add(sosSmlcomponent);
            }
        }
    }
    return sosSmlComponents;
}
Also used : AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) PhysicalComponent(org.n52.shetland.ogc.sensorML.v20.PhysicalComponent) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent) Component(net.opengis.sensorml.x20.ComponentListType.Component) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent)

Example 2 with Component

use of net.opengis.sensorml.x20.ComponentListType.Component in project arctic-sea by 52North.

the class SensorMLEncoderv20 method createComponents.

/**
 * Creates the components section of the SensorML description.
 *
 * @param sosComponents
 *            SOS SWE representation.
 *
 * @return encoded sml:components
 *
 * @throws EncodingException
 *             if the process encoding fails
 */
private ComponentListPropertyType createComponents(final List<SmlComponent> sosComponents) throws EncodingException {
    ComponentListPropertyType clpt = ComponentListPropertyType.Factory.newInstance(getXmlOptions());
    final ComponentListType clt = clpt.addNewComponentList();
    for (final SmlComponent sosSMLComponent : sosComponents) {
        final Component component = clt.addNewComponent();
        if (sosSMLComponent.isSetName()) {
            component.setName(sosSMLComponent.getName());
        }
        if (sosSMLComponent.isSetHref()) {
            component.setHref(sosSMLComponent.getHref());
            if (sosSMLComponent.isSetTitle()) {
                component.setTitle(sosSMLComponent.getTitle());
            }
        } else if (sosSMLComponent.isSetProcess()) {
            XmlObject xmlObject = encode(sosSMLComponent.getProcess(), EncodingContext.of(XmlBeansEncodingFlags.TYPE));
            // }
            if (xmlObject != null) {
                // AbstractProcessType xbProcess = null;
                // if (xmlObject instanceof AbstractProcessType) {
                // xbProcess = (AbstractProcessType) xmlObject;
                // } else {
                // throw new NoApplicableCodeException()
                // .withMessage("The sensor type is not supported by this
                // SOS");
                // }
                // TODO add feature/parentProcs/childProcs to component - is
                // this already done?
                // XmlObject substituteElement =
                // XmlHelper.substituteElement(component.addNewAbstractProcess(),
                // xmlObject);
                // substituteElement.set(xmlObject);
                substitute(component.addNewAbstractProcess(), xmlObject);
            }
        }
    }
    return clpt;
}
Also used : ComponentListPropertyType(net.opengis.sensorml.x20.ComponentListPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) PhysicalComponent(org.n52.shetland.ogc.sensorML.v20.PhysicalComponent) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent) Component(net.opengis.sensorml.x20.ComponentListType.Component) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) ComponentListType(net.opengis.sensorml.x20.ComponentListType) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent)

Example 3 with Component

use of net.opengis.sensorml.x20.ComponentListType.Component 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 4 with Component

use of net.opengis.sensorml.x20.ComponentListType.Component 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)

Aggregations

SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)4 XmlObject (org.apache.xmlbeans.XmlObject)3 Component (net.opengis.sensorml.x20.ComponentListType.Component)2 SmlComponent (org.n52.shetland.ogc.sensorML.elements.SmlComponent)2 PhysicalComponent (org.n52.shetland.ogc.sensorML.v20.PhysicalComponent)2 ArrayList (java.util.ArrayList)1 CapabilityListType (net.opengis.sensorml.x20.CapabilityListType)1 Capability (net.opengis.sensorml.x20.CapabilityListType.Capability)1 CharacteristicListType (net.opengis.sensorml.x20.CharacteristicListType)1 Characteristic (net.opengis.sensorml.x20.CharacteristicListType.Characteristic)1 ComponentListPropertyType (net.opengis.sensorml.x20.ComponentListPropertyType)1 ComponentListType (net.opengis.sensorml.x20.ComponentListType)1 Capabilities (net.opengis.sensorml.x20.DescribedObjectType.Capabilities)1 Characteristics (net.opengis.sensorml.x20.DescribedObjectType.Characteristics)1 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)1 AbstractSensorML (org.n52.shetland.ogc.sensorML.AbstractSensorML)1 SmlCapabilities (org.n52.shetland.ogc.sensorML.elements.SmlCapabilities)1 SmlCapability (org.n52.shetland.ogc.sensorML.elements.SmlCapability)1 SmlCharacteristic (org.n52.shetland.ogc.sensorML.elements.SmlCharacteristic)1 SmlCharacteristics (org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics)1