Search in sources :

Example 1 with ProcessModelType

use of org.geotoolkit.sml.xml.v100.ProcessModelType 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 2 with ProcessModelType

use of org.geotoolkit.sml.xml.v100.ProcessModelType 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 3 with ProcessModelType

use of org.geotoolkit.sml.xml.v100.ProcessModelType in project geotoolkit by Geomatys.

the class SmlXMLFactory method convertTo101.

public static org.geotoolkit.sml.xml.v101.SensorML convertTo101(final org.geotoolkit.sml.xml.v100.SensorML sensor) {
    List<org.geotoolkit.sml.xml.v101.SensorML.Member> newMembers = new ArrayList<org.geotoolkit.sml.xml.v101.SensorML.Member>();
    for (Member oldMember : sensor.getMember()) {
        final org.geotoolkit.sml.xml.v101.AbstractProcessType newProcess;
        if (oldMember.getRealProcess() instanceof System) {
            newProcess = new org.geotoolkit.sml.xml.v101.SystemType();
        } else if (oldMember.getRealProcess() instanceof Component) {
            newProcess = new org.geotoolkit.sml.xml.v101.ComponentType();
        } else if (oldMember.getRealProcess() instanceof AbstractDataSource) {
            newProcess = new org.geotoolkit.sml.xml.v101.DataSourceType();
        } else if (oldMember.getRealProcess() instanceof AbstractProcessModel) {
            newProcess = new org.geotoolkit.sml.xml.v101.ProcessModelType();
        } else if (oldMember.getRealProcess() instanceof ComponentArray) {
            newProcess = new org.geotoolkit.sml.xml.v101.ComponentArrayType();
        } else {
            throw new IllegalArgumentException("Other sensor type than system, component, processModel, processChain, componentArray or datasource are not yet convertible");
        }
        AbstractProcessType oldProcess = (AbstractProcessType) oldMember.getRealProcess();
        // id
        newProcess.setId(oldProcess.getId());
        // name
        newProcess.setName(oldProcess.getName());
        // srsName
        newProcess.setSrsName(oldProcess.getSrsName());
        // description
        newProcess.setDescription(oldProcess.getDescription());
        // boundedBy
        newProcess.setBoundedBy(oldProcess.getBoundedBy());
        // capabilities
        List<org.geotoolkit.sml.xml.v101.Capabilities> newCapabilities = new ArrayList<org.geotoolkit.sml.xml.v101.Capabilities>();
        for (Capabilities oldCapa : oldProcess.getCapabilities()) {
            newCapabilities.add(new org.geotoolkit.sml.xml.v101.Capabilities(oldCapa));
        }
        newProcess.setCapabilities(newCapabilities);
        // characteristics
        List<org.geotoolkit.sml.xml.v101.Characteristics> newCharacteristics = new ArrayList<org.geotoolkit.sml.xml.v101.Characteristics>();
        for (Characteristics oldChar : oldProcess.getCharacteristics()) {
            newCharacteristics.add(new org.geotoolkit.sml.xml.v101.Characteristics(oldChar));
        }
        newProcess.setCharacteristics(newCharacteristics);
        // Classification
        List<org.geotoolkit.sml.xml.v101.Classification> newClassification = new ArrayList<org.geotoolkit.sml.xml.v101.Classification>();
        for (Classification oldClass : oldProcess.getClassification()) {
            newClassification.add(new org.geotoolkit.sml.xml.v101.Classification(oldClass));
        }
        newProcess.setClassification(newClassification);
        // Contact
        List<org.geotoolkit.sml.xml.v101.Contact> newContact = new ArrayList<org.geotoolkit.sml.xml.v101.Contact>();
        for (Contact oldContact : oldProcess.getContact()) {
            newContact.add(new org.geotoolkit.sml.xml.v101.Contact(oldContact));
        }
        newProcess.setContact(newContact);
        // Contact
        List<org.geotoolkit.sml.xml.v101.Documentation> newDocumentation = new ArrayList<org.geotoolkit.sml.xml.v101.Documentation>();
        for (Documentation oldDoc : oldProcess.getDocumentation()) {
            newDocumentation.add(new org.geotoolkit.sml.xml.v101.Documentation(oldDoc));
        }
        newProcess.setDocumentation(newDocumentation);
        // History
        List<org.geotoolkit.sml.xml.v101.History> newHistory = new ArrayList<org.geotoolkit.sml.xml.v101.History>();
        for (History oldhist : oldProcess.getHistory()) {
            newHistory.add(new org.geotoolkit.sml.xml.v101.History(oldhist));
        }
        newProcess.setHistory(newHistory);
        // Identification
        List<org.geotoolkit.sml.xml.v101.Identification> newIdentification = new ArrayList<org.geotoolkit.sml.xml.v101.Identification>();
        for (Identification oldIdent : oldProcess.getIdentification()) {
            newIdentification.add(new org.geotoolkit.sml.xml.v101.Identification(oldIdent));
        }
        newProcess.setIdentification(newIdentification);
        // keywords
        List<org.geotoolkit.sml.xml.v101.Keywords> newKeywords = new ArrayList<org.geotoolkit.sml.xml.v101.Keywords>();
        for (Keywords oldKeyw : oldProcess.getKeywords()) {
            newKeywords.add(new org.geotoolkit.sml.xml.v101.Keywords(oldKeyw));
        }
        newProcess.setKeywords(newKeywords);
        // legal constraint
        List<org.geotoolkit.sml.xml.v101.LegalConstraint> newLegalConstraints = new ArrayList<org.geotoolkit.sml.xml.v101.LegalConstraint>();
        for (LegalConstraint oldcons : oldProcess.getLegalConstraint()) {
            newLegalConstraints.add(new org.geotoolkit.sml.xml.v101.LegalConstraint(oldcons));
        }
        newProcess.setLegalConstraint(newLegalConstraints);
        // security constraint
        if (oldProcess.getSecurityConstraint() != null) {
            newProcess.setSecurityConstraint(new org.geotoolkit.sml.xml.v101.SecurityConstraint(oldProcess.getSecurityConstraint()));
        }
        // validTime
        if (oldProcess.getValidTime() != null) {
            newProcess.setValidTime(oldProcess.getValidTime());
        }
        if (oldProcess instanceof AbstractComponent) {
            AbstractComponent newAbsComponent = (AbstractComponent) newProcess;
            AbstractComponent oldAbsComponent = (AbstractComponent) oldProcess;
            // Inputs
            if (oldAbsComponent.getInputs() != null) {
                newAbsComponent.setInputs(oldAbsComponent.getInputs());
            }
            // outputs
            if (oldAbsComponent.getOutputs() != null) {
                newAbsComponent.setOutputs(oldAbsComponent.getOutputs());
            }
            // parameters
            if (oldAbsComponent.getParameters() != null) {
                newAbsComponent.setParameters(oldAbsComponent.getParameters());
            }
        }
        if (oldProcess instanceof AbstractDerivableComponent) {
            org.geotoolkit.sml.xml.v101.AbstractDerivableComponentType newDerComponent = (org.geotoolkit.sml.xml.v101.AbstractDerivableComponentType) newProcess;
            AbstractDerivableComponent oldDerComponent = (AbstractDerivableComponent) oldProcess;
            // Position
            if (oldDerComponent.getPosition() != null) {
                newDerComponent.setPosition(oldDerComponent.getPosition());
            }
            if (oldDerComponent.getSMLLocation() != null) {
                newDerComponent.setSMLLocation(oldDerComponent.getSMLLocation());
            }
            if (oldDerComponent.getInterfaces() != null) {
                newDerComponent.setInterfaces(new org.geotoolkit.sml.xml.v101.Interfaces(oldDerComponent.getInterfaces()));
            }
            if (oldDerComponent.getSpatialReferenceFrame() != null) {
                newDerComponent.setSpatialReferenceFrame(new org.geotoolkit.sml.xml.v101.SpatialReferenceFrame(oldDerComponent.getSpatialReferenceFrame()));
            }
            if (oldDerComponent.getTemporalReferenceFrame() != null) {
                newDerComponent.setTemporalReferenceFrame(new org.geotoolkit.sml.xml.v101.TemporalReferenceFrame(oldDerComponent.getTemporalReferenceFrame()));
            }
            if (oldDerComponent.getTimePosition() != null) {
                newDerComponent.setTimePosition(new org.geotoolkit.sml.xml.v101.TimePosition(oldDerComponent.getTimePosition()));
            }
        }
        if (oldProcess instanceof AbstractPureProcess) {
            org.geotoolkit.sml.xml.v101.AbstractPureProcessType newAbsPuProc = (org.geotoolkit.sml.xml.v101.AbstractPureProcessType) newProcess;
            AbstractPureProcess oldAbsPuProc = (AbstractPureProcess) oldProcess;
            // Inputs
            if (oldAbsPuProc.getInputs() != null) {
                newAbsPuProc.setInputs(new org.geotoolkit.sml.xml.v101.Inputs(oldAbsPuProc.getInputs()));
            }
            // outputs
            if (oldAbsPuProc.getOutputs() != null) {
                newAbsPuProc.setOutputs(new org.geotoolkit.sml.xml.v101.Outputs(oldAbsPuProc.getOutputs()));
            }
            // parameters
            if (oldAbsPuProc.getParameters() != null) {
                newAbsPuProc.setParameters(new org.geotoolkit.sml.xml.v101.Parameters(oldAbsPuProc.getParameters()));
            }
        }
        if (oldMember.getRealProcess() instanceof System) {
            SystemType oldSystem = (SystemType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.SystemType newSystem = (org.geotoolkit.sml.xml.v101.SystemType) newProcess;
            // components
            if (oldSystem.getComponents() != null) {
                newSystem.setComponents(new org.geotoolkit.sml.xml.v101.Components(oldSystem.getComponents()));
            }
            // positions
            if (oldSystem.getPositions() != null) {
                newSystem.setPositions(new org.geotoolkit.sml.xml.v101.Positions(oldSystem.getPositions()));
            }
            // connections
            if (oldSystem.getConnections() != null) {
                newSystem.setConnections(new org.geotoolkit.sml.xml.v101.Connections(oldSystem.getConnections()));
            }
        } else if (oldMember.getRealProcess() instanceof Component) {
            ComponentType oldComponent = (ComponentType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.ComponentType newCompo = (org.geotoolkit.sml.xml.v101.ComponentType) newProcess;
            // method
            if (oldComponent.getMethod() != null) {
                newCompo.setMethod(new org.geotoolkit.sml.xml.v101.MethodPropertyType(oldComponent.getMethod()));
            }
        } else if (oldMember.getRealProcess() instanceof AbstractDataSource) {
            DataSourceType oldDataSource = (DataSourceType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.DataSourceType newDataSource = (org.geotoolkit.sml.xml.v101.DataSourceType) newProcess;
            if (oldDataSource.getDataDefinition() != null) {
                newDataSource.setDataDefinition(new org.geotoolkit.sml.xml.v101.DataDefinition(oldDataSource.getDataDefinition()));
            }
            if (oldDataSource.getValues() != null) {
                newDataSource.setValues(new org.geotoolkit.sml.xml.v101.Values(oldDataSource.getValues()));
            }
            if (oldDataSource.getObservationReference() != null) {
                newDataSource.setObservationReference(new org.geotoolkit.sml.xml.v101.ObservationReference(oldDataSource.getObservationReference()));
            }
        } else if (oldMember.getRealProcess() instanceof AbstractProcessModel) {
            ProcessModelType oldProcessModel = (ProcessModelType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.ProcessModelType newProcessModel = (org.geotoolkit.sml.xml.v101.ProcessModelType) newProcess;
            if (oldProcessModel.getMethod() != null) {
                newProcessModel.setMethod(new org.geotoolkit.sml.xml.v101.MethodPropertyType(oldProcessModel.getMethod()));
            }
        } else if (oldMember.getRealProcess() instanceof AbstractProcessChain) {
            ProcessChainType oldProcessChain = (ProcessChainType) oldMember.getRealProcess();
            org.geotoolkit.sml.xml.v101.ProcessChainType newProcessChain = (org.geotoolkit.sml.xml.v101.ProcessChainType) newProcess;
            // components
            if (oldProcessChain.getComponents() != null) {
                newProcessChain.setComponents(new org.geotoolkit.sml.xml.v101.Components(oldProcessChain.getComponents()));
            }
            // connections
            if (oldProcessChain.getConnections() != null) {
                newProcessChain.setConnections(new org.geotoolkit.sml.xml.v101.Connections(oldProcessChain.getConnections()));
            }
        } else if (oldMember.getRealProcess() instanceof ComponentArray) {
        // nothing to do
        } else {
            throw new IllegalArgumentException("Other sensor type than system ,component, processModel, processChain, componentArray or datasource are not yet convertible");
        }
        newMembers.add(new org.geotoolkit.sml.xml.v101.SensorML.Member(newProcess));
    }
    org.geotoolkit.sml.xml.v101.SensorML result = new org.geotoolkit.sml.xml.v101.SensorML("1.0.1", newMembers);
    return result;
}
Also used : ArrayList(java.util.ArrayList) SystemType(org.geotoolkit.sml.xml.v100.SystemType) History(org.geotoolkit.sml.xml.v100.History) Classification(org.geotoolkit.sml.xml.v100.Classification) DataSourceType(org.geotoolkit.sml.xml.v100.DataSourceType) Member(org.geotoolkit.sml.xml.v100.Member) Documentation(org.geotoolkit.sml.xml.v100.Documentation) AbstractProcessType(org.geotoolkit.sml.xml.v100.AbstractProcessType) Keywords(org.geotoolkit.sml.xml.v100.Keywords) LegalConstraint(org.geotoolkit.sml.xml.v100.LegalConstraint) Identification(org.geotoolkit.sml.xml.v100.Identification) ComponentType(org.geotoolkit.sml.xml.v100.ComponentType) Contact(org.geotoolkit.sml.xml.v100.Contact) Characteristics(org.geotoolkit.sml.xml.v100.Characteristics) Capabilities(org.geotoolkit.sml.xml.v100.Capabilities) ProcessModelType(org.geotoolkit.sml.xml.v100.ProcessModelType) ProcessChainType(org.geotoolkit.sml.xml.v100.ProcessChainType)

Aggregations

ComponentType (net.opengis.sensorML.x101.ComponentType)2 Component (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component)2 ProcessModelType (net.opengis.sensorML.x101.ProcessModelType)2 SystemType (net.opengis.sensorML.x101.SystemType)2 AbstractDataComponentType (net.opengis.swe.x101.AbstractDataComponentType)2 ProcessModel (org.n52.shetland.ogc.sensorML.ProcessModel)2 System (org.n52.shetland.ogc.sensorML.System)2 SmlComponent (org.n52.shetland.ogc.sensorML.elements.SmlComponent)2 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)2 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 ComponentDocument (net.opengis.sensorML.x101.ComponentDocument)1 ProcessModelDocument (net.opengis.sensorML.x101.ProcessModelDocument)1 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)1 SystemDocument (net.opengis.sensorML.x101.SystemDocument)1 AbstractProcessType (org.geotoolkit.sml.xml.v100.AbstractProcessType)1 Capabilities (org.geotoolkit.sml.xml.v100.Capabilities)1 Characteristics (org.geotoolkit.sml.xml.v100.Characteristics)1 Classification (org.geotoolkit.sml.xml.v100.Classification)1 ComponentType (org.geotoolkit.sml.xml.v100.ComponentType)1