Search in sources :

Example 1 with SmlComponent

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

use of org.n52.shetland.ogc.sensorML.elements.SmlComponent in project arctic-sea by 52North.

the class SensorMLEncoderv101 method createSensorMLDescription.

protected SensorMLDocument createSensorMLDescription(final SensorML smlSensorDesc) throws EncodingException {
    final SensorMLDocument sensorMLDoc = SensorMLDocument.Factory.newInstance(getXmlOptions());
    final net.opengis.sensorML.x101.SensorMLDocument.SensorML xbSensorML = sensorMLDoc.addNewSensorML();
    xbSensorML.setVersion(SensorMLConstants.VERSION_V101);
    if (smlSensorDesc.isSetMembers()) {
        for (final AbstractProcess sml : smlSensorDesc.getMembers()) {
            if (sml instanceof System) {
                final SystemType xbSystem = (SystemType) xbSensorML.addNewMember().addNewProcess().substitute(new QName(SensorMLConstants.NS_SML, SensorMLConstants.EN_SYSTEM), SystemType.type);
                final System smlSystem = (System) sml;
                addAbstractProcessValues(xbSystem, smlSystem);
                addSystemValues(xbSystem, smlSystem);
            } else if (sml instanceof ProcessModel) {
                final ProcessModelType xbProcessModel = (ProcessModelType) xbSensorML.addNewMember().addNewProcess().substitute(new QName(SensorMLConstants.NS_SML, SensorMLConstants.EN_PROCESS_MODEL), ProcessModelType.type);
                final ProcessModel smlProcessModel = (ProcessModel) sml;
                addAbstractProcessValues(xbProcessModel, smlProcessModel);
                addProcessModelValues(xbProcessModel, smlProcessModel);
            } else if (sml instanceof org.n52.shetland.ogc.sensorML.Component) {
                final ComponentType xbCompontent = (ComponentType) xbSensorML.addNewMember().addNewProcess().substitute(new QName(SensorMLConstants.NS_SML, SensorMLConstants.EN_COMPONENT), ComponentType.type);
                final org.n52.shetland.ogc.sensorML.Component smlComponent = (org.n52.shetland.ogc.sensorML.Component) sml;
                addAbstractProcessValues(xbCompontent, smlComponent);
                addComponentValues(xbCompontent, smlComponent);
            }
        }
    }
    return sensorMLDoc;
}
Also used : ProcessModel(org.n52.shetland.ogc.sensorML.ProcessModel) ComponentType(net.opengis.sensorML.x101.ComponentType) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) QName(javax.xml.namespace.QName) SystemType(net.opengis.sensorML.x101.SystemType) System(org.n52.shetland.ogc.sensorML.System) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent) Component(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) ProcessModelType(net.opengis.sensorML.x101.ProcessModelType)

Example 3 with SmlComponent

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

use of org.n52.shetland.ogc.sensorML.elements.SmlComponent in project arctic-sea by 52North.

the class SensorMLEncoderv20 method addPhysicalSystemValues.

private void addPhysicalSystemValues(PhysicalSystemType pst, PhysicalSystem abstractPhysicalProcess) throws EncodingException {
    addAbstractProcessValues(pst, abstractPhysicalProcess);
    addDescribedObjectValues(pst, abstractPhysicalProcess);
    addAbstractPhysicalProcessValues(pst, abstractPhysicalProcess);
    // set components
    if (abstractPhysicalProcess.isSetComponents()) {
        List<SmlComponent> smlComponents = checkForComponents(abstractPhysicalProcess);
        if (!smlComponents.isEmpty()) {
            ComponentListPropertyType clpt = createComponents(smlComponents);
            if (clpt != null && clpt.getComponentList() != null && clpt.getComponentList().sizeOfComponentArray() > 0) {
                pst.setComponents(clpt);
            }
        }
    }
    // set connections
    if (abstractPhysicalProcess.isSetConnections() && !pst.isSetConnections()) {
        pst.setConnections(createConnections(abstractPhysicalProcess.getConnections()));
    }
}
Also used : ComponentListPropertyType(net.opengis.sensorml.x20.ComponentListPropertyType) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent)

Example 5 with SmlComponent

use of org.n52.shetland.ogc.sensorML.elements.SmlComponent in project arctic-sea by 52North.

the class SensorMLEncoderv20 method addAggregateProcessValues.

private void addAggregateProcessValues(AggregateProcessType apt, AggregateProcess abstractProcess) throws EncodingException {
    addAbstractProcessValues(apt, abstractProcess);
    addDescribedObjectValues(apt, abstractProcess);
    // set components
    if (abstractProcess.isSetComponents()) {
        List<SmlComponent> smlComponents = checkForComponents(abstractProcess);
        if (!smlComponents.isEmpty()) {
            ComponentListPropertyType clpt = createComponents(smlComponents);
            if (clpt != null && clpt.getComponentList() != null && clpt.getComponentList().sizeOfComponentArray() > 0) {
                apt.setComponents(clpt);
            }
        }
    }
// set connections
}
Also used : ComponentListPropertyType(net.opengis.sensorml.x20.ComponentListPropertyType) 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