use of org.n52.shetland.ogc.swe.SweAbstractDataComponent in project arctic-sea by 52North.
the class SweCommonDecoderV20 method parseAbstractDataComponentDocument.
private Object parseAbstractDataComponentDocument(final AbstractDataComponentDocument abstractDataComponentDoc) throws DecodingException {
SweAbstractDataComponent sosAbstractDataComponent = parseAbstractDataComponent(abstractDataComponentDoc.getAbstractDataComponent());
sosAbstractDataComponent.setXml(abstractDataComponentDoc.xmlText(getXmlOptions()));
return sosAbstractDataComponent;
}
use of org.n52.shetland.ogc.swe.SweAbstractDataComponent 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.swe.SweAbstractDataComponent 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.swe.SweAbstractDataComponent in project arctic-sea by 52North.
the class SensorMLEncoderv20 method createCapability.
private Capabilities createCapability(final SmlCapabilities capabilities) throws EncodingException {
Capabilities xbCapabilities = null;
if (capabilities.isSetAbstractDataComponents()) {
xbCapabilities = Capabilities.Factory.newInstance(getXmlOptions());
if (capabilities.isSetName()) {
xbCapabilities.setName(capabilities.getName());
}
CapabilityListType capabilityList = xbCapabilities.addNewCapabilityList();
if (capabilities.isSetCapabilities()) {
for (SmlCapability capability : capabilities.getCapabilities()) {
XmlObject encodeObjectToXml = encodeObjectToXmlSwe20(capability.getAbstractDataComponent());
Capability c = capabilityList.addNewCapability();
if (capability.isSetName()) {
c.setName(NcName.makeValid(capability.getName()));
} else if (capability.getAbstractDataComponent().isSetName()) {
capability.setName(NcName.makeValid(capability.getAbstractDataComponent().getName().getValue()));
} else {
capability.setName(NcName.makeValid(capability.getAbstractDataComponent().getDefinition()));
}
XmlObject substituteElement = XmlHelper.substituteElement(c.addNewAbstractDataComponent(), encodeObjectToXml);
substituteElement.set(encodeObjectToXml);
}
} else if (capabilities.isSetAbstractDataComponents()) {
for (SweAbstractDataComponent component : capabilities.getAbstractDataComponents()) {
XmlObject encodeObjectToXml = encodeObjectToXmlSwe20(component);
Capability capability = capabilityList.addNewCapability();
if (component.isSetName()) {
capability.setName(NcName.makeValid(component.getName().getValue()));
} else {
capability.setName(NcName.makeValid(component.getDefinition()));
}
XmlObject substituteElement = XmlHelper.substituteElement(capability.addNewAbstractDataComponent(), encodeObjectToXml);
substituteElement.set(encodeObjectToXml);
}
}
}
return xbCapabilities;
}
use of org.n52.shetland.ogc.swe.SweAbstractDataComponent in project arctic-sea by 52North.
the class SweCommonEncoderv101 method createFieldForSimpleDataRecord.
private AnyScalarPropertyType createFieldForSimpleDataRecord(SweField sweField) throws EncodingException {
SweAbstractDataComponent sosElement = sweField.getElement();
AnyScalarPropertyType xbField = AnyScalarPropertyType.Factory.newInstance(getXmlOptions());
if (sweField.isSetName()) {
xbField.setName(sweField.getName().getValue());
}
AbstractDataComponentType xbDCD;
if (sosElement instanceof SweBoolean) {
xbDCD = xbField.addNewBoolean();
xbDCD.set(createSimpleType((SweBoolean) sosElement));
} else if (sosElement instanceof SweCategory) {
xbDCD = xbField.addNewCategory();
xbDCD.set(createSimpleType((SweCategory) sosElement));
} else if (sosElement instanceof SweCount) {
xbDCD = xbField.addNewCount();
xbDCD.set(createSimpleType((SweCount) sosElement));
} else if (sosElement instanceof SweQuantity) {
xbDCD = xbField.addNewQuantity();
xbDCD.set(createSimpleType((SweQuantity) sosElement));
} else if (sosElement instanceof SweText) {
xbDCD = xbField.addNewText();
xbDCD.set(createSimpleType((SweText) sosElement));
} else if (sosElement instanceof SweTime) {
xbDCD = xbField.addNewTime();
xbDCD.set(createSimpleType((SweTime) sosElement));
} else {
throw new EncodingException("The element type '%s' of the received %s is not supported by this encoder '%s'.", new Object[] { sosElement != null ? sosElement.getClass().getName() : null, sweField.getClass().getName(), getClass().getName() });
}
return xbField;
}
Aggregations