use of net.opengis.sensorML.x101.ComponentsDocument.Components in project arctic-sea by 52North.
the class SensorMLDecoderV101 method checkAndRemoveEmptyComponents.
private void checkAndRemoveEmptyComponents(final SystemType system) {
boolean removeComponents = false;
final Components components = system.getComponents();
if (components != null) {
if (components.getComponentList() == null) {
removeComponents = true;
} else if (components.getComponentList().getComponentArray() == null || ((components.getComponentList().getComponentArray() != null && components.getComponentList().getComponentArray().length == 0))) {
removeComponents = true;
}
}
if (removeComponents) {
system.unsetComponents();
}
}
use of net.opengis.sensorML.x101.ComponentsDocument.Components in project arctic-sea by 52North.
the class SensorMLDecoderV101 method parseComponents.
private List<SmlComponent> parseComponents(final Components 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.isSetProcess() || component.isSetHref()) {
final SmlComponent sosSmlcomponent = new SmlComponent(component.getName());
AbstractProcess abstractProcess = null;
if (component.isSetProcess()) {
if (component.getProcess() instanceof SystemType) {
abstractProcess = new System();
parseSystem((SystemType) component.getProcess(), (System) abstractProcess);
} else {
abstractProcess = new AbstractProcess();
parseAbstractProcess(component.getProcess(), abstractProcess);
}
} else {
abstractProcess = new AbstractProcess();
abstractProcess.setIdentifier(component.getHref());
}
sosSmlcomponent.setProcess(abstractProcess);
sosSmlComponents.add(sosSmlcomponent);
}
}
}
return sosSmlComponents;
}
use of net.opengis.sensorML.x101.ComponentsDocument.Components in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createComponents.
/**
* Creates the components section of the SensorML description.
*
* @param sosComponents
* SOS SWE representation.
*
* @return encoded sml:components
*
* @throws EncodingException
* if the encoding fails
*/
private Components createComponents(List<SmlComponent> sosComponents) throws EncodingException {
Components components = Components.Factory.newInstance(getXmlOptions());
ComponentList componentList = components.addNewComponentList();
for (SmlComponent sosSMLComponent : sosComponents) {
Component component = componentList.addNewComponent();
if (sosSMLComponent.getName() != null) {
component.setName(sosSMLComponent.getName());
}
if (sosSMLComponent.getHref() != null) {
component.setHref(sosSMLComponent.getHref());
if (sosSMLComponent.getTitle() != null) {
component.setTitle(sosSMLComponent.getTitle());
}
} else if (sosSMLComponent.getProcess() != null) {
XmlObject xmlObject = null;
if (sosSMLComponent.getProcess().isSetXml()) {
try {
xmlObject = XmlObject.Factory.parse(sosSMLComponent.getProcess().getXml());
} catch (XmlException xmle) {
throw new EncodingException("Error while encoding SensorML child procedure description " + "from stored SensorML encoded sensor description with XMLBeans", xmle);
}
} else {
if (sosSMLComponent.getProcess() instanceof SensorML) {
xmlObject = createSensorDescriptionFromObject(((SensorML) sosSMLComponent.getProcess()).getMembers().iterator().next());
} else if (sosSMLComponent.getProcess() instanceof AbstractProcess) {
xmlObject = createSensorDescriptionFromObject(sosSMLComponent.getProcess());
}
}
if (xmlObject != null) {
AbstractProcessType xbProcess = null;
if (xmlObject instanceof SensorMLDocument) {
final SensorMLDocument smlDoc = (SensorMLDocument) xmlObject;
for (final Member member : smlDoc.getSensorML().getMemberArray()) {
xbProcess = member.getProcess();
break;
}
} else if (xmlObject instanceof AbstractProcessType) {
xbProcess = (AbstractProcessType) xmlObject;
}
if (xbProcess == null) {
throw new EncodingException("The sensor type is not supported by this SOS");
}
// TODO add feature/parentProcs/childProcs to component - is
// this already done?
SchemaType schemaType = xbProcess.schemaType();
component.addNewProcess().substitute(getQnameForType(schemaType), schemaType).set(xbProcess);
}
}
}
return components;
}
Aggregations