Search in sources :

Example 1 with SmlIo

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

the class SmlIoTest method should_return_true_if_ioValue_is_set.

@Test
public void should_return_true_if_ioValue_is_set() {
    final SweBoolean ioValue = new SweBoolean();
    final SmlIo smlIo = new SmlIo(ioValue);
    assertThat(smlIo.isSetValue(), is(TRUE));
}
Also used : SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) Test(org.junit.Test)

Example 2 with SmlIo

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

the class SensorMLDecoderV20 method parseOutput.

@SuppressWarnings({ "rawtypes" })
private SmlIo parseOutput(Output xbOutput) throws DecodingException {
    final SmlIo sosIo = new SmlIo();
    sosIo.setIoName(xbOutput.getName());
    if (xbOutput.isSetHref()) {
        parseReference(xbOutput, sosIo);
    } else {
        sosIo.setIoValue(parseDataComponentOrObservablePropertyType(xbOutput));
    }
    return sosIo;
}
Also used : SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo)

Example 3 with SmlIo

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

the class SensorMLDecoderV101 method parseIoComponentPropertyType.

/**
 * Parses the components
 *
 * @param xbIoCompPropType XML components
 *
 * @return SOS components
 *
 * @throws DecodingException if an error occurs
 */
@SuppressWarnings({ "rawtypes" })
private SmlIo parseIoComponentPropertyType(final IoComponentPropertyType xbIoCompPropType) throws DecodingException {
    final SmlIo sosIo = new SmlIo();
    sosIo.setIoName(xbIoCompPropType.getName());
    XmlObject toDecode = null;
    if (xbIoCompPropType.isSetHref()) {
        sosIo.setHref(xbIoCompPropType.getHref());
        if (xbIoCompPropType.isSetTitle()) {
            sosIo.setTitle(xbIoCompPropType.getTitle());
        }
        return sosIo;
    }
    if (xbIoCompPropType.isSetBoolean()) {
        toDecode = xbIoCompPropType.getBoolean();
    } else if (xbIoCompPropType.isSetCategory()) {
        toDecode = xbIoCompPropType.getCategory();
    } else if (xbIoCompPropType.isSetCount()) {
        toDecode = xbIoCompPropType.getCount();
    } else if (xbIoCompPropType.isSetCountRange()) {
        toDecode = xbIoCompPropType.getCountRange();
    } else if (xbIoCompPropType.isSetObservableProperty()) {
        toDecode = xbIoCompPropType.getObservableProperty();
    } else if (xbIoCompPropType.isSetQuantity()) {
        toDecode = xbIoCompPropType.getQuantity();
    } else if (xbIoCompPropType.isSetQuantityRange()) {
        toDecode = xbIoCompPropType.getQuantityRange();
    } else if (xbIoCompPropType.isSetText()) {
        toDecode = xbIoCompPropType.getText();
    } else if (xbIoCompPropType.isSetTime()) {
        toDecode = xbIoCompPropType.getTime();
    } else if (xbIoCompPropType.isSetTimeRange()) {
        toDecode = xbIoCompPropType.getTimeRange();
    } else if (xbIoCompPropType.isSetAbstractDataArray1()) {
        toDecode = xbIoCompPropType.getAbstractDataArray1();
    } else if (xbIoCompPropType.isSetAbstractDataRecord()) {
        toDecode = xbIoCompPropType.getAbstractDataRecord();
    } else {
        throw new DecodingException(XmlHelper.getLocalName(xbIoCompPropType), "An 'IoComponentProperty' is not supported");
    }
    final Object decodedObject = decodeXmlElement(toDecode);
    if (decodedObject instanceof SweAbstractDataComponent) {
        sosIo.setIoValue((SweAbstractDataComponent) decodedObject);
    } else {
        throw new DecodingException(XmlHelper.getLocalName(xbIoCompPropType), "The 'IoComponentProperty' with type '%s' as value for '%s' is not supported.", XmlHelper.getLocalName(toDecode), XmlHelper.getLocalName(xbIoCompPropType));
    }
    return sosIo;
}
Also used : SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlObject(org.apache.xmlbeans.XmlObject) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo)

Example 4 with SmlIo

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

the class SensorMLEncoderv101 method createOutputs.

/**
 * Creates the outputs section of the SensorML description.
 *
 * @param sosOutputs
 *            SOS SWE representation.
 *
 * @return XML Outputs element
 *
 * @throws EncodingException
 *             if the encoding fails
 */
private Outputs createOutputs(final List<SmlIo> sosOutputs) throws EncodingException {
    Outputs outputs = Outputs.Factory.newInstance(getXmlOptions());
    OutputList outputList = outputs.addNewOutputList();
    Set<String> definitions = Sets.newHashSet();
    int counter = 1;
    Set<String> outputNames = Sets.newHashSet();
    for (SmlIo sosSMLIo : sosOutputs) {
        if (sosSMLIo.isSetValue() && !definitions.contains(sosSMLIo.getIoValue().getDefinition())) {
            if (!sosSMLIo.isSetName() || outputNames.contains(sosSMLIo.getIoName())) {
                sosSMLIo.setIoName(getValidOutputName(counter++, outputNames));
            }
            outputNames.add(sosSMLIo.getIoName());
            addIoComponentPropertyType(outputList.addNewOutput(), sosSMLIo);
            definitions.add(sosSMLIo.getIoValue().getDefinition());
        }
    }
    return outputs;
}
Also used : Outputs(net.opengis.sensorML.x101.OutputsDocument.Outputs) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo) OutputList(net.opengis.sensorML.x101.OutputsDocument.Outputs.OutputList)

Example 5 with SmlIo

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

the class SensorMLEncoderv20 method createOutputs.

/**
 * Creates the outputs section of the SensorML description.
 *
 * @param sosOutputs
 *            SOS SWE representation.
 *
 * @return XML Outputs element
 *
 * @throws org.n52.svalbard.encode.exception.EncodingException
 *             if the encoding fails
 */
private Outputs createOutputs(final List<SmlIo> sosOutputs) throws EncodingException {
    final Outputs outputs = Outputs.Factory.newInstance(getXmlOptions());
    final OutputListType outputList = outputs.addNewOutputList();
    final Set<String> definitions = Sets.newHashSet();
    int counter = 1;
    final Set<String> outputNames = Sets.newHashSet();
    for (final SmlIo sosSMLIo : sosOutputs) {
        if (sosSMLIo.isSetValue() && !definitions.contains(sosSMLIo.getIoValue().getDefinition())) {
            if (!sosSMLIo.isSetName() || outputNames.contains(sosSMLIo.getIoName())) {
                sosSMLIo.setIoName(getValidOutputName(counter++, outputNames));
            } else {
                sosSMLIo.setIoName(NcName.makeValid(sosSMLIo.getIoName()));
            }
            outputNames.add(sosSMLIo.getIoName());
            addOutput(outputList.addNewOutput(), sosSMLIo);
            definitions.add(sosSMLIo.getIoValue().getDefinition());
        }
    }
    return outputs;
}
Also used : Outputs(net.opengis.sensorml.x20.AbstractProcessType.Outputs) OutputListType(net.opengis.sensorml.x20.OutputListType) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo)

Aggregations

SmlIo (org.n52.shetland.ogc.sensorML.elements.SmlIo)8 Inputs (net.opengis.sensorML.x101.InputsDocument.Inputs)2 InputList (net.opengis.sensorML.x101.InputsDocument.Inputs.InputList)2 SystemType (net.opengis.sensorML.x101.SystemType)2 SensorML (org.n52.shetland.ogc.sensorML.SensorML)2 SmlPerson (org.n52.shetland.ogc.sensorML.SmlPerson)2 System (org.n52.shetland.ogc.sensorML.System)2 Joiner (com.google.common.base.Joiner)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 QName (javax.xml.namespace.QName)1 PointType (net.opengis.gml.PointType)1 AbstractProcessType (net.opengis.sensorML.x101.AbstractProcessType)1