use of net.opengis.sensorml.x20.ComponentListType.Component in project arctic-sea by 52North.
the class SensorMLDecoderV20 method parseComponents.
private List<SmlComponent> parseComponents(ComponentListPropertyType 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.isSetAbstractProcess() || component.isSetHref() || component.isSetTitle()) {
final SmlComponent sosSmlcomponent = new SmlComponent(component.getName());
AbstractSensorML abstractProcess;
if (component.isSetAbstractProcess()) {
abstractProcess = parse(component.getAbstractProcess());
} else {
if (component.isSetTitle()) {
sosSmlcomponent.setTitle(component.getTitle());
}
if (component.isSetHref()) {
sosSmlcomponent.setHref(component.getHref());
}
abstractProcess = new AbstractProcess();
if (sosSmlcomponent.isSetTitle()) {
abstractProcess.setIdentifier(sosSmlcomponent.getTitle());
} else if (!sosSmlcomponent.isSetTitle() && sosSmlcomponent.isSetHref()) {
abstractProcess.setIdentifier(sosSmlcomponent.getHref());
}
}
sosSmlcomponent.setProcess(abstractProcess);
sosSmlComponents.add(sosSmlcomponent);
}
}
}
return sosSmlComponents;
}
use of net.opengis.sensorml.x20.ComponentListType.Component in project arctic-sea by 52North.
the class SensorMLEncoderv20 method createComponents.
/**
* Creates the components section of the SensorML description.
*
* @param sosComponents
* SOS SWE representation.
*
* @return encoded sml:components
*
* @throws EncodingException
* if the process encoding fails
*/
private ComponentListPropertyType createComponents(final List<SmlComponent> sosComponents) throws EncodingException {
ComponentListPropertyType clpt = ComponentListPropertyType.Factory.newInstance(getXmlOptions());
final ComponentListType clt = clpt.addNewComponentList();
for (final SmlComponent sosSMLComponent : sosComponents) {
final Component component = clt.addNewComponent();
if (sosSMLComponent.isSetName()) {
component.setName(sosSMLComponent.getName());
}
if (sosSMLComponent.isSetHref()) {
component.setHref(sosSMLComponent.getHref());
if (sosSMLComponent.isSetTitle()) {
component.setTitle(sosSMLComponent.getTitle());
}
} else if (sosSMLComponent.isSetProcess()) {
XmlObject xmlObject = encode(sosSMLComponent.getProcess(), EncodingContext.of(XmlBeansEncodingFlags.TYPE));
// }
if (xmlObject != null) {
// AbstractProcessType xbProcess = null;
// if (xmlObject instanceof AbstractProcessType) {
// xbProcess = (AbstractProcessType) xmlObject;
// } else {
// throw new NoApplicableCodeException()
// .withMessage("The sensor type is not supported by this
// SOS");
// }
// TODO add feature/parentProcs/childProcs to component - is
// this already done?
// XmlObject substituteElement =
// XmlHelper.substituteElement(component.addNewAbstractProcess(),
// xmlObject);
// substituteElement.set(xmlObject);
substitute(component.addNewAbstractProcess(), xmlObject);
}
}
}
return clpt;
}
use of net.opengis.sensorml.x20.ComponentListType.Component 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 net.opengis.sensorml.x20.ComponentListType.Component 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;
}
Aggregations