Search in sources :

Example 1 with Components

use of net.opengis.sensorML.x101.ComponentsDocument.Components in project arctic-sea by 52North.

the class SensorMLDecoderV101 method checkAndRemoveEmptyComponents.

private void checkAndRemoveEmptyComponents(final SystemType system) {
    boolean removeComponents = false;
    final Components components = system.getComponents();
    if (components != null) {
        if (components.getComponentList() == null) {
            removeComponents = true;
        } else if (components.getComponentList().getComponentArray() == null || ((components.getComponentList().getComponentArray() != null && components.getComponentList().getComponentArray().length == 0))) {
            removeComponents = true;
        }
    }
    if (removeComponents) {
        system.unsetComponents();
    }
}
Also used : Components(net.opengis.sensorML.x101.ComponentsDocument.Components)

Example 2 with Components

use of net.opengis.sensorML.x101.ComponentsDocument.Components in project arctic-sea by 52North.

the class SensorMLDecoderV101 method parseComponents.

private List<SmlComponent> parseComponents(final Components 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.isSetProcess() || component.isSetHref()) {
                final SmlComponent sosSmlcomponent = new SmlComponent(component.getName());
                AbstractProcess abstractProcess = null;
                if (component.isSetProcess()) {
                    if (component.getProcess() instanceof SystemType) {
                        abstractProcess = new System();
                        parseSystem((SystemType) component.getProcess(), (System) abstractProcess);
                    } else {
                        abstractProcess = new AbstractProcess();
                        parseAbstractProcess(component.getProcess(), abstractProcess);
                    }
                } else {
                    abstractProcess = new AbstractProcess();
                    abstractProcess.setIdentifier(component.getHref());
                }
                sosSmlcomponent.setProcess(abstractProcess);
                sosSmlComponents.add(sosSmlcomponent);
            }
        }
    }
    return sosSmlComponents;
}
Also used : AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SystemType(net.opengis.sensorML.x101.SystemType) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent) AbstractComponent(org.n52.shetland.ogc.sensorML.AbstractComponent) Component(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent) System(org.n52.shetland.ogc.sensorML.System)

Example 3 with Components

use of net.opengis.sensorML.x101.ComponentsDocument.Components in project arctic-sea by 52North.

the class SensorMLEncoderv101 method createComponents.

/**
 * Creates the components section of the SensorML description.
 *
 * @param sosComponents
 *            SOS SWE representation.
 *
 * @return encoded sml:components
 *
 * @throws EncodingException
 *             if the encoding fails
 */
private Components createComponents(List<SmlComponent> sosComponents) throws EncodingException {
    Components components = Components.Factory.newInstance(getXmlOptions());
    ComponentList componentList = components.addNewComponentList();
    for (SmlComponent sosSMLComponent : sosComponents) {
        Component component = componentList.addNewComponent();
        if (sosSMLComponent.getName() != null) {
            component.setName(sosSMLComponent.getName());
        }
        if (sosSMLComponent.getHref() != null) {
            component.setHref(sosSMLComponent.getHref());
            if (sosSMLComponent.getTitle() != null) {
                component.setTitle(sosSMLComponent.getTitle());
            }
        } else if (sosSMLComponent.getProcess() != null) {
            XmlObject xmlObject = null;
            if (sosSMLComponent.getProcess().isSetXml()) {
                try {
                    xmlObject = XmlObject.Factory.parse(sosSMLComponent.getProcess().getXml());
                } catch (XmlException xmle) {
                    throw new EncodingException("Error while encoding SensorML child procedure description " + "from stored SensorML encoded sensor description with XMLBeans", xmle);
                }
            } else {
                if (sosSMLComponent.getProcess() instanceof SensorML) {
                    xmlObject = createSensorDescriptionFromObject(((SensorML) sosSMLComponent.getProcess()).getMembers().iterator().next());
                } else if (sosSMLComponent.getProcess() instanceof AbstractProcess) {
                    xmlObject = createSensorDescriptionFromObject(sosSMLComponent.getProcess());
                }
            }
            if (xmlObject != null) {
                AbstractProcessType xbProcess = null;
                if (xmlObject instanceof SensorMLDocument) {
                    final SensorMLDocument smlDoc = (SensorMLDocument) xmlObject;
                    for (final Member member : smlDoc.getSensorML().getMemberArray()) {
                        xbProcess = member.getProcess();
                        break;
                    }
                } else if (xmlObject instanceof AbstractProcessType) {
                    xbProcess = (AbstractProcessType) xmlObject;
                }
                if (xbProcess == null) {
                    throw new EncodingException("The sensor type is not supported by this SOS");
                }
                // TODO add feature/parentProcs/childProcs to component - is
                // this already done?
                SchemaType schemaType = xbProcess.schemaType();
                component.addNewProcess().substitute(getQnameForType(schemaType), schemaType).set(xbProcess);
            }
        }
    }
    return components;
}
Also used : AbstractProcessType(net.opengis.sensorML.x101.AbstractProcessType) EncodingException(org.n52.svalbard.encode.exception.EncodingException) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) ComponentList(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList) SensorML(org.n52.shetland.ogc.sensorML.SensorML) AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) SchemaType(org.apache.xmlbeans.SchemaType) Components(net.opengis.sensorML.x101.ComponentsDocument.Components) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) XmlException(org.apache.xmlbeans.XmlException) XmlObject(org.apache.xmlbeans.XmlObject) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent) Component(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) Member(net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent)

Aggregations

Components (net.opengis.sensorML.x101.ComponentsDocument.Components)2 Component (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component)2 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)2 SmlComponent (org.n52.shetland.ogc.sensorML.elements.SmlComponent)2 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)2 AbstractProcessType (net.opengis.sensorML.x101.AbstractProcessType)1 ComponentList (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList)1 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)1 Member (net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member)1 SystemType (net.opengis.sensorML.x101.SystemType)1 SchemaType (org.apache.xmlbeans.SchemaType)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1 AbstractComponent (org.n52.shetland.ogc.sensorML.AbstractComponent)1 AbstractSensorML (org.n52.shetland.ogc.sensorML.AbstractSensorML)1 SensorML (org.n52.shetland.ogc.sensorML.SensorML)1 System (org.n52.shetland.ogc.sensorML.System)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1