Search in sources :

Example 11 with AbstractProcess

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

the class SensorMLDecoderV101Test method should_decode_features_of_interest_from_sml.

@Test
public void should_decode_features_of_interest_from_sml() throws DecodingException {
    SensorMLDocument xbSmlDoc = getSensorMLDoc();
    SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
    Capabilities xbCapabilities = xbSystem.addNewCapabilities();
    xbCapabilities.setName(SensorMLConstants.ELEMENT_NAME_FEATURES_OF_INTEREST);
    SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) xbCapabilities.addNewAbstractDataRecord().substitute(SweConstants.QN_SIMPLEDATARECORD_SWE_101, SimpleDataRecordType.type);
    addCapabilitiesInsertionMetadata(xbSimpleDataRecord, TEST_ID_1, TEST_NAME_1);
    addCapabilitiesInsertionMetadata(xbSimpleDataRecord, TEST_ID_2, TEST_NAME_2);
    AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
    // assertThat(absProcess.getFeaturesOfInterest().size(), is(2));
    assertThat(absProcess.getCapabilities().size(), is(1));
// List<String> featuresOfInterest = new ArrayList<String>(absProcess.getFeaturesOfInterest());
// Collections.sort(featuresOfInterest);
// assertThat(featuresOfInterest.get(0), is(TEST_ID_1));
// assertThat(featuresOfInterest.get(1), is(TEST_ID_2));
}
Also used : SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) Capabilities(net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities) SystemType(net.opengis.sensorML.x101.SystemType) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.Test)

Example 12 with AbstractProcess

use of org.n52.shetland.ogc.sensorML.AbstractProcess 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 13 with AbstractProcess

use of org.n52.shetland.ogc.sensorML.AbstractProcess 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 14 with AbstractProcess

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

the class SensorMLDecoderV20 method parseFeatureOfInterest.

private void parseFeatureOfInterest(FeaturesOfInterest featuresOfInterest, AbstractProcessV20 abstractProcess) throws DecodingException {
    if (CollectionHelper.isNotNullOrEmpty(featuresOfInterest.getFeatureList().getFeatureArray())) {
        SmlFeatureOfInterest smlFeatureOfInterest = new SmlFeatureOfInterest();
        for (FeaturePropertyType fpt : featuresOfInterest.getFeatureList().getFeatureArray()) {
            Object o = decodeXmlElement(fpt);
            if (o instanceof AbstractFeature) {
                smlFeatureOfInterest.addFeatureOfInterest((AbstractFeature) o);
            }
        }
        abstractProcess.setSmlFeatureOfInterest(smlFeatureOfInterest);
    }
}
Also used : SmlFeatureOfInterest(org.n52.shetland.ogc.sensorML.v20.SmlFeatureOfInterest) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) DescribedObject(org.n52.shetland.ogc.sensorML.v20.DescribedObject) XmlObject(org.apache.xmlbeans.XmlObject) FeaturePropertyType(net.opengis.gml.x32.FeaturePropertyType)

Example 15 with AbstractProcess

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

the class SensorMLDecoderV20 method parseCapabilities.

/**
 * Parses the capabilities, processing and removing special insertion
 * metadata
 *
 * @param abstractProcess
 *            The AbstractProcess to which capabilities and insertion
 *            metadata are added
 * @param capabilitiesArray
 *            XML capabilities
 *
 * @throws DecodingException
 *             * if an error occurs
 */
private void parseCapabilities(final AbstractProcess abstractProcess, final Capabilities[] capabilitiesArray) throws DecodingException {
    for (final Capabilities cs : capabilitiesArray) {
        final SmlCapabilities capabilities = new SmlCapabilities(cs.getName());
        if (cs.isSetCapabilityList()) {
            CapabilityListType cl = cs.getCapabilityList();
            if (CollectionHelper.isNotNullOrEmpty(cl.getCapabilityArray())) {
                for (Capability c : cl.getCapabilityArray()) {
                    final SmlCapability capability = new SmlCapability(c.getName());
                    if (c.isSetAbstractDataComponent()) {
                        final Object o = decodeXmlElement(c.getAbstractDataComponent());
                        if (o instanceof SweAbstractDataComponent) {
                            capability.setAbstractDataComponent((SweAbstractDataComponent) o);
                            capabilities.addCapability(capability);
                        } else {
                            throw new DecodingException(XmlHelper.getLocalName(cs), "Error while parsing the capabilities of " + "the SensorML (the capabilities data record " + "is not of type DataRecordPropertyType)!");
                        }
                    } else if (c.isSetHref()) {
                        capability.setHref(c.getHref());
                        if (c.isSetTitle()) {
                            capability.setTitle(c.getTitle());
                        }
                    }
                }
            }
        }
        abstractProcess.addCapabilities(capabilities);
    }
}
Also used : SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) CapabilityListType(net.opengis.sensorml.x20.CapabilityListType) SmlCapability(org.n52.shetland.ogc.sensorML.elements.SmlCapability) Capability(net.opengis.sensorml.x20.CapabilityListType.Capability) Capabilities(net.opengis.sensorml.x20.DescribedObjectType.Capabilities) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) DescribedObject(org.n52.shetland.ogc.sensorML.v20.DescribedObject) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) SmlCapability(org.n52.shetland.ogc.sensorML.elements.SmlCapability)

Aggregations

AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)15 SystemType (net.opengis.sensorML.x101.SystemType)14 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)12 Test (org.junit.Test)10 XmlObject (org.apache.xmlbeans.XmlObject)6 SmlComponent (org.n52.shetland.ogc.sensorML.elements.SmlComponent)6 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)6 Capabilities (net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities)5 Component (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component)4 IdentifierList (net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList)4 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)4 ComponentType (net.opengis.sensorML.x101.ComponentType)3 AbstractSensorML (org.n52.shetland.ogc.sensorML.AbstractSensorML)3 SensorML (org.n52.shetland.ogc.sensorML.SensorML)3 System (org.n52.shetland.ogc.sensorML.System)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3 AbstractProcessType (net.opengis.sensorML.x101.AbstractProcessType)2 ComponentList (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList)2 ContactList (net.opengis.sensorML.x101.ContactListDocument.ContactList)2 ProcessModelType (net.opengis.sensorML.x101.ProcessModelType)2