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));
}
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;
}
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;
}
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;
}
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;
}
Aggregations