Search in sources :

Example 6 with SmlComponent

use of org.n52.shetland.ogc.sensorML.elements.SmlComponent 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 7 with SmlComponent

use of org.n52.shetland.ogc.sensorML.elements.SmlComponent 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

SmlComponent (org.n52.shetland.ogc.sensorML.elements.SmlComponent)7 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)5 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)4 Component (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component)3 ComponentListPropertyType (net.opengis.sensorml.x20.ComponentListPropertyType)3 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)2 SystemType (net.opengis.sensorML.x101.SystemType)2 Component (net.opengis.sensorml.x20.ComponentListType.Component)2 XmlObject (org.apache.xmlbeans.XmlObject)2 AbstractSensorML (org.n52.shetland.ogc.sensorML.AbstractSensorML)2 System (org.n52.shetland.ogc.sensorML.System)2 PhysicalComponent (org.n52.shetland.ogc.sensorML.v20.PhysicalComponent)2 QName (javax.xml.namespace.QName)1 AbstractProcessType (net.opengis.sensorML.x101.AbstractProcessType)1 ComponentType (net.opengis.sensorML.x101.ComponentType)1 Components (net.opengis.sensorML.x101.ComponentsDocument.Components)1 ComponentList (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList)1 ProcessModelType (net.opengis.sensorML.x101.ProcessModelType)1 Member (net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member)1 ComponentListType (net.opengis.sensorml.x20.ComponentListType)1