use of net.opengis.sensorml.x20.ComponentListPropertyType 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.ComponentListPropertyType 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.ComponentListPropertyType in project arctic-sea by 52North.
the class SensorMLEncoderv20 method addPhysicalSystemValues.
private void addPhysicalSystemValues(PhysicalSystemType pst, PhysicalSystem abstractPhysicalProcess) throws EncodingException {
addAbstractProcessValues(pst, abstractPhysicalProcess);
addDescribedObjectValues(pst, abstractPhysicalProcess);
addAbstractPhysicalProcessValues(pst, abstractPhysicalProcess);
// set components
if (abstractPhysicalProcess.isSetComponents()) {
List<SmlComponent> smlComponents = checkForComponents(abstractPhysicalProcess);
if (!smlComponents.isEmpty()) {
ComponentListPropertyType clpt = createComponents(smlComponents);
if (clpt != null && clpt.getComponentList() != null && clpt.getComponentList().sizeOfComponentArray() > 0) {
pst.setComponents(clpt);
}
}
}
// set connections
if (abstractPhysicalProcess.isSetConnections() && !pst.isSetConnections()) {
pst.setConnections(createConnections(abstractPhysicalProcess.getConnections()));
}
}
use of net.opengis.sensorml.x20.ComponentListPropertyType in project arctic-sea by 52North.
the class SensorMLEncoderv20 method addAggregateProcessValues.
private void addAggregateProcessValues(AggregateProcessType apt, AggregateProcess abstractProcess) throws EncodingException {
addAbstractProcessValues(apt, abstractProcess);
addDescribedObjectValues(apt, abstractProcess);
// set components
if (abstractProcess.isSetComponents()) {
List<SmlComponent> smlComponents = checkForComponents(abstractProcess);
if (!smlComponents.isEmpty()) {
ComponentListPropertyType clpt = createComponents(smlComponents);
if (clpt != null && clpt.getComponentList() != null && clpt.getComponentList().sizeOfComponentArray() > 0) {
apt.setComponents(clpt);
}
}
}
// set connections
}
Aggregations