Search in sources :

Example 1 with AbstractProcessType

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

use of org.geotoolkit.sml.xml.v100.AbstractProcessType in project arctic-sea by 52North.

the class SensorMLDecoderV101 method addSensorMLWrapperForXmlDescription.

private String addSensorMLWrapperForXmlDescription(final AbstractProcessType xbProcessType) {
    final SensorMLDocument xbSensorMLDoc = SensorMLDocument.Factory.newInstance(getXmlOptions());
    final net.opengis.sensorML.x101.SensorMLDocument.SensorML xbSensorML = xbSensorMLDoc.addNewSensorML();
    xbSensorML.setVersion(SensorMLConstants.VERSION_V101);
    final Member member = xbSensorML.addNewMember();
    final AbstractProcessType xbAbstractProcessType = (AbstractProcessType) member.addNewProcess().substitute(getQnameForType(xbProcessType.schemaType()), xbProcessType.schemaType());
    xbAbstractProcessType.set(xbProcessType);
    return xbSensorMLDoc.xmlText(getXmlOptions());
}
Also used : AbstractProcessType(net.opengis.sensorML.x101.AbstractProcessType) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) Member(net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member)

Example 3 with AbstractProcessType

use of org.geotoolkit.sml.xml.v100.AbstractProcessType 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)

Example 4 with AbstractProcessType

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

AbstractProcessType (net.opengis.sensorML.x101.AbstractProcessType)3 Member (net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member)3 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)2 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)2 AbstractSensorML (org.n52.shetland.ogc.sensorML.AbstractSensorML)2 SensorML (org.n52.shetland.ogc.sensorML.SensorML)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ArrayList (java.util.ArrayList)1 AbstractComponentType (net.opengis.sensorML.x101.AbstractComponentType)1 AbstractDerivableComponentType (net.opengis.sensorML.x101.AbstractDerivableComponentType)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 Component (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component)1 SystemType (net.opengis.sensorML.x101.SystemType)1 SchemaType (org.apache.xmlbeans.SchemaType)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1 AbstractProcessType (org.geotoolkit.sml.xml.v100.AbstractProcessType)1 Capabilities (org.geotoolkit.sml.xml.v100.Capabilities)1