Search in sources :

Example 16 with SystemType

use of org.geotoolkit.sml.xml.v101.SystemType in project geotoolkit by Geomatys.

the class SmlXMLBindingTest method DataSourceMarshalingTest.

@Test
public void DataSourceMarshalingTest() throws Exception {
    final SystemType system = new SystemType();
    final List<DataComponentPropertyType> fields = new ArrayList<>();
    fields.add(DataComponentPropertyType.LATITUDE_FIELD);
    fields.add(DataComponentPropertyType.LONGITUDE_FIELD);
    fields.add(DataComponentPropertyType.TIME_FIELD);
    final DataRecordType posRecord = new DataRecordType(null, fields);
    final DataBlockDefinitionType definition = new DataBlockDefinitionType(null, Arrays.asList(posRecord), TextBlockType.DEFAULT_ENCODING);
    final DataDefinition dataDefinition = new DataDefinition(definition);
    final org.geotoolkit.sml.xml.v101.Values trajValues = new org.geotoolkit.sml.xml.v101.Values();
    trajValues.setAny("test");
    final DataSourceType datasource = new DataSourceType(dataDefinition, trajValues, null);
    final Position pos = new Position(null, datasource);
    system.setPosition(pos);
    DataSourceType expds = (DataSourceType) pos.getAbstractProcess();
    DataSourceType resds = (DataSourceType) system.getPosition().getAbstractProcess();
    assertEquals(expds.getDataDefinition(), resds.getDataDefinition());
    assertEquals(expds, resds);
    assertEquals(pos.getAbstractProcess(), system.getPosition().getAbstractProcess());
    assertEquals(pos.getPosition(), system.getPosition().getPosition());
    assertEquals(pos, system.getPosition());
    final SensorML sml = new SensorML("1.0.1", Arrays.asList(new SensorML.Member(system)));
    Marshaller m = SensorMLMarshallerPool.getInstance().acquireMarshaller();
    ObjectFactory factory = new ObjectFactory();
    // m.marshal(factory.createPosition(pos), System.out);
    // m.marshal(factory.createSystem(system), System.out);
    // m.marshal(sml, System.out);
    SensorMLMarshallerPool.getInstance().recycle(m);
}
Also used : DataRecordType(org.geotoolkit.swe.xml.v101.DataRecordType) Marshaller(javax.xml.bind.Marshaller) Position(org.geotoolkit.sml.xml.v101.Position) ArrayList(java.util.ArrayList) SystemType(org.geotoolkit.sml.xml.v101.SystemType) DataDefinition(org.geotoolkit.sml.xml.v101.DataDefinition) SensorML(org.geotoolkit.sml.xml.v101.SensorML) DataBlockDefinitionType(org.geotoolkit.swe.xml.v101.DataBlockDefinitionType) ObjectFactory(org.geotoolkit.sml.xml.v101.ObjectFactory) DataSourceType(org.geotoolkit.sml.xml.v101.DataSourceType) DataComponentPropertyType(org.geotoolkit.swe.xml.v101.DataComponentPropertyType)

Example 17 with SystemType

use of org.geotoolkit.sml.xml.v101.SystemType in project arctic-sea by 52North.

the class SensorMLDecoderV101 method parseSensorML.

@SuppressFBWarnings("BC_VACUOUS_INSTANCEOF")
private SensorML parseSensorML(final SensorMLDocument xbSensorML) throws DecodingException {
    final SensorML sensorML = new SensorML();
    // get member process
    for (final Member xbMember : xbSensorML.getSensorML().getMemberArray()) {
        if (xbMember.getProcess() != null) {
            if (xbMember.getProcess() instanceof AbstractProcessType) {
                final AbstractProcessType xbAbstractProcess = xbMember.getProcess();
                AbstractProcess abstractProcess = null;
                if (xbAbstractProcess.schemaType() == SystemType.type) {
                    abstractProcess = parseSystem((SystemType) xbAbstractProcess);
                } else if (xbAbstractProcess.schemaType() == ProcessModelType.type) {
                    abstractProcess = parseProcessModel((ProcessModelType) xbAbstractProcess);
                } else if (xbAbstractProcess.schemaType() == ComponentType.type) {
                    abstractProcess = parseComponent((ComponentType) xbAbstractProcess);
                } else {
                    throw unsupportedMemberProcess(xbMember);
                }
                sensorML.addMember(abstractProcess);
            } else {
                throw unsupportedMemberProcess(xbMember);
            }
        } else {
            throw new DecodingException(XmlHelper.getLocalName(xbMember), "The process of a member of the SensorML Document is null (%s)!", xbMember.getProcess());
        }
    }
    sensorML.setXml(xbSensorML.xmlText(getXmlOptions()));
    return sensorML;
}
Also used : AbstractProcessType(net.opengis.sensorML.x101.AbstractProcessType) AbstractComponentType(net.opengis.sensorML.x101.AbstractComponentType) AbstractDerivableComponentType(net.opengis.sensorML.x101.AbstractDerivableComponentType) ComponentType(net.opengis.sensorML.x101.ComponentType) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SystemType(net.opengis.sensorML.x101.SystemType) DecodingException(org.n52.svalbard.decode.exception.DecodingException) SensorML(org.n52.shetland.ogc.sensorML.SensorML) AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) Member(net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 18 with SystemType

use of org.geotoolkit.sml.xml.v101.SystemType 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 19 with SystemType

use of org.geotoolkit.sml.xml.v101.SystemType in project arctic-sea by 52North.

the class SensorMLEncoderv101 method createProcessDescription.

private XmlObject createProcessDescription(final AbstractProcess sensorDesc) throws EncodingException {
    // TODO Review: System -> return doc; ProcessModel -> return type
    if (sensorDesc instanceof System) {
        System system = (System) sensorDesc;
        SystemDocument xbSystemDoc = SystemDocument.Factory.newInstance(getXmlOptions());
        SystemType xbSystem = xbSystemDoc.addNewSystem();
        addAbstractProcessValues(xbSystem, system);
        addSystemValues(xbSystem, system);
        return xbSystem;
    } else if (sensorDesc instanceof ProcessModel) {
        // TODO: set values
        ProcessModel processModel = (ProcessModel) sensorDesc;
        ProcessModelDocument xbProcessModelDoc = ProcessModelDocument.Factory.newInstance(getXmlOptions());
        ProcessModelType xbProcessModel = xbProcessModelDoc.addNewProcessModel();
        addAbstractProcessValues(xbProcessModel, processModel);
        addProcessModelValues(xbProcessModel, processModel);
        return xbProcessModel;
    } else if (sensorDesc instanceof org.n52.shetland.ogc.sensorML.Component) {
        org.n52.shetland.ogc.sensorML.Component component = (org.n52.shetland.ogc.sensorML.Component) sensorDesc;
        ComponentDocument cd = ComponentDocument.Factory.newInstance(getXmlOptions());
        ComponentType ct = cd.addNewComponent();
        addAbstractProcessValues(ct, component);
        return ct;
    } else {
        throw unsupportedDescriptionType();
    }
}
Also used : ProcessModel(org.n52.shetland.ogc.sensorML.ProcessModel) ComponentType(net.opengis.sensorML.x101.ComponentType) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) ComponentDocument(net.opengis.sensorML.x101.ComponentDocument) SystemType(net.opengis.sensorML.x101.SystemType) ProcessModelDocument(net.opengis.sensorML.x101.ProcessModelDocument) System(org.n52.shetland.ogc.sensorML.System) SystemDocument(net.opengis.sensorML.x101.SystemDocument) 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 20 with SystemType

use of org.geotoolkit.sml.xml.v101.SystemType 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.jupiter.api.Test)

Aggregations

SystemType (net.opengis.sensorML.x101.SystemType)24 Test (org.junit.jupiter.api.Test)18 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)15 SystemType (org.osate.aadl2.SystemType)14 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)13 ArrayList (java.util.ArrayList)12 System (org.n52.shetland.ogc.sensorML.System)11 EObject (org.eclipse.emf.ecore.EObject)9 SensorML (org.n52.shetland.ogc.sensorML.SensorML)9 AnnexSubclause (org.osate.aadl2.AnnexSubclause)8 IdentifierList (net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList)6 PublicPackageSection (org.osate.aadl2.PublicPackageSection)6 CyberReq (com.ge.research.osate.verdict.dsl.verdict.CyberReq)5 HashSet (java.util.HashSet)5 SystemImplementation (org.osate.aadl2.SystemImplementation)5 SafetyReq (com.ge.research.osate.verdict.dsl.verdict.SafetyReq)4 Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)4 Verdict (com.ge.research.osate.verdict.dsl.verdict.Verdict)4 Component (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component)4 SmlPerson (org.n52.shetland.ogc.sensorML.SmlPerson)4