use of org.n52.shetland.ogc.sensorML.elements.SmlCharacteristic in project arctic-sea by 52North.
the class SensorMLEncoderv20 method createCharacteristics.
/**
* Creates the characteristics section of the SensorML description.
*
* @param smlCharacteristics
* SOS characteristics list
*
* @return XML Characteristics array
*
* @throws EncodingException
* If an error occurs
*/
private Characteristics[] createCharacteristics(final List<SmlCharacteristics> smlCharacteristics) throws EncodingException {
final List<Characteristics> characteristicsList = new ArrayList<>(smlCharacteristics.size());
for (final SmlCharacteristics sosSMLCharacteristics : smlCharacteristics) {
Characteristics xbCharacteristics = Characteristics.Factory.newInstance(getXmlOptions());
if (sosSMLCharacteristics.isSetName()) {
xbCharacteristics.setName(sosSMLCharacteristics.getName());
} else {
xbCharacteristics.setName("characteristics_" + smlCharacteristics.lastIndexOf(sosSMLCharacteristics));
}
CharacteristicListType characteristicList = xbCharacteristics.addNewCharacteristicList();
if (sosSMLCharacteristics.isSetCharacteristics()) {
for (SmlCharacteristic characteristic : sosSMLCharacteristics.getCharacteristic()) {
Characteristic c = characteristicList.addNewCharacteristic();
c.setName(NcName.makeValid(characteristic.getName()));
if (characteristic.isSetAbstractDataComponent()) {
XmlObject encodeObjectToXml = encodeObjectToXml(SweConstants.NS_SWE_20, characteristic.getAbstractDataComponent());
XmlObject substituteElement = XmlHelper.substituteElement(c.addNewAbstractDataComponent(), encodeObjectToXml);
substituteElement.set(encodeObjectToXml);
} else if (characteristic.isSetHref()) {
c.setHref(characteristic.getHref());
if (characteristic.isSetTitle()) {
c.setTitle(characteristic.getTitle());
}
}
}
}
if (sosSMLCharacteristics.isSetAbstractDataComponents()) {
if (sosSMLCharacteristics.isSetAbstractDataComponents()) {
for (SweAbstractDataComponent component : sosSMLCharacteristics.getAbstractDataComponents()) {
XmlObject encodeObjectToXml = encodeObjectToXml(SweConstants.NS_SWE_20, component);
Characteristic c = characteristicList.addNewCharacteristic();
c.setName(NcName.makeValid(component.getName().getValue()));
XmlObject substituteElement = XmlHelper.substituteElement(c.addNewAbstractDataComponent(), encodeObjectToXml);
substituteElement.set(encodeObjectToXml);
}
}
}
characteristicsList.add(xbCharacteristics);
}
return characteristicsList.toArray(new Characteristics[characteristicsList.size()]);
}
use of org.n52.shetland.ogc.sensorML.elements.SmlCharacteristic in project arctic-sea by 52North.
the class SmlCharacteristics method getCharacteristic.
/**
* @return the characteristics
*/
public List<SmlCharacteristic> getCharacteristic() {
if (!hasCharacteristics() && isSetAbstractDataComponents()) {
List<SmlCharacteristic> c = Lists.newArrayList();
for (SweAbstractDataComponent component : getAbstractDataComponents()) {
SmlCharacteristic smlCharacteristic = new SmlCharacteristic(component.getName().getValue());
smlCharacteristic.setAbstractDataComponent(component);
c.add(smlCharacteristic);
}
return c;
}
return this.characteristics;
}
use of org.n52.shetland.ogc.sensorML.elements.SmlCharacteristic in project arctic-sea by 52North.
the class SensorMLDecoderV20 method parseCharacteristics.
/**
* Parses the characteristics
*
* @param clpts
* XML characteristics
* @return SOS characteristics
*
* @throws DecodingException
* * if an error occurs
*/
private List<SmlCharacteristics> parseCharacteristics(final CharacteristicListPropertyType[] clpts) throws DecodingException {
final List<SmlCharacteristics> sosCharacteristicsList = new ArrayList<>(clpts.length);
for (final CharacteristicListPropertyType clpt : clpts) {
final SmlCharacteristics sosCharacteristics = new SmlCharacteristics();
if (clpt.isSetCharacteristicList()) {
CharacteristicListType clt = clpt.getCharacteristicList();
if (CollectionHelper.isNotNullOrEmpty(clt.getCharacteristicArray())) {
for (Characteristic c : clt.getCharacteristicArray()) {
final SmlCharacteristic characteristic = new SmlCharacteristic(c.getName());
if (c.isSetAbstractDataComponent()) {
final Object o = decodeXmlElement(c.getAbstractDataComponent());
if (o instanceof SweAbstractDataComponent) {
characteristic.setAbstractDataComponent((SweAbstractDataComponent) o);
} else {
throw new DecodingException(XmlHelper.getLocalName(clpt), "Error while parsing the characteristics of the SensorML " + "(the characteristics' data record is not of " + "type DataRecordPropertyType)!");
}
} else if (c.isSetHref()) {
characteristic.setHref(c.getHref());
if (c.isSetTitle()) {
characteristic.setTitle(c.getTitle());
}
}
sosCharacteristics.addCharacteristic(characteristic);
}
}
}
sosCharacteristicsList.add(sosCharacteristics);
}
return sosCharacteristicsList;
}
Aggregations