Search in sources :

Example 1 with ComponentList

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

the class SensorMLDecoderV101Test method addChildProcedure.

private void addChildProcedure(ComponentList xbComponentList, String identifier) {
    Component xbComponent = xbComponentList.addNewComponent();
    xbComponent.setName(SensorMLConstants.ELEMENT_NAME_CHILD_PROCEDURES);
    SystemType xbSystem = (SystemType) xbComponent.addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
    IdentifierList xbIdentifierList = xbSystem.addNewIdentification().addNewIdentifierList();
    addIdentifier(xbIdentifierList, "anyname", OGCConstants.URN_UNIQUE_IDENTIFIER, identifier);
}
Also used : SystemType(net.opengis.sensorML.x101.SystemType) Component(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component) IdentifierList(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList)

Example 2 with ComponentList

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

the class SensorMLDecoderV101 method parseSystem.

private System parseSystem(final SystemType xbSystemType, final System system) throws DecodingException {
    parseAbstractProcess(xbSystemType, system);
    parseAbstractComponent(xbSystemType, system);
    parseAbstractDerivableComponent(xbSystemType, system);
    if (xbSystemType.isSetComponents() && xbSystemType.getComponents().isSetComponentList()) {
        system.addComponents(parseComponents(xbSystemType.getComponents()));
        ComponentList componentList = xbSystemType.getComponents().getComponentList();
        checkComponentsForRemoval(componentList).forEach(componentList::removeComponent);
        checkAndRemoveEmptyComponents(xbSystemType);
    }
    final String xmlDescription = addSensorMLWrapperForXmlDescription(xbSystemType);
    system.setXml(xmlDescription);
    return system;
}
Also used : ComponentList(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList)

Example 3 with ComponentList

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

the class SensorMLDecoderV101Test method should_decode_child_procedure_from_sml.

@Test
public void should_decode_child_procedure_from_sml() throws DecodingException {
    SensorMLDocument xbSmlDoc = getSensorMLDoc();
    SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
    IdentifierList xbIdentifierList = xbSystem.addNewIdentification().addNewIdentifierList();
    addIdentifier(xbIdentifierList, "anyname", OGCConstants.URN_UNIQUE_IDENTIFIER, TEST_ID_1);
    ComponentList xbComponentList = xbSystem.addNewComponents().addNewComponentList();
    addChildProcedure(xbComponentList, TEST_ID_2);
    AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
    assertThat(absProcess.getIdentifier(), is(TEST_ID_1));
// assertThat(absProcess.getChildProcedures().size(), is(1));
// SosProcedureDescription childProcedure = absProcess.getChildProcedures().iterator().next();
// assertThat(childProcedure, instanceOf(System.class));
// assertThat(childProcedure.getIdentifier(), is(TEST_ID_2));
}
Also used : SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SystemType(net.opengis.sensorML.x101.SystemType) ComponentList(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList) IdentifierList(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList) Test(org.junit.Test)

Example 4 with ComponentList

use of net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList 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

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