use of net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList in project arctic-sea by 52North.
the class SensorMLDecoderV101Test method addChildProcedure.
private void addChildProcedure(ComponentList xbComponentList, String identifier) {
Component xbComponent = xbComponentList.addNewComponent();
xbComponent.setName(SensorMLConstants.ELEMENT_NAME_CHILD_PROCEDURES);
SystemType xbSystem = (SystemType) xbComponent.addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
IdentifierList xbIdentifierList = xbSystem.addNewIdentification().addNewIdentifierList();
addIdentifier(xbIdentifierList, "anyname", OGCConstants.URN_UNIQUE_IDENTIFIER, identifier);
}
use of net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList in project arctic-sea by 52North.
the class SensorMLDecoderV101 method parseSystem.
private System parseSystem(final SystemType xbSystemType, final System system) throws DecodingException {
parseAbstractProcess(xbSystemType, system);
parseAbstractComponent(xbSystemType, system);
parseAbstractDerivableComponent(xbSystemType, system);
if (xbSystemType.isSetComponents() && xbSystemType.getComponents().isSetComponentList()) {
system.addComponents(parseComponents(xbSystemType.getComponents()));
ComponentList componentList = xbSystemType.getComponents().getComponentList();
checkComponentsForRemoval(componentList).forEach(componentList::removeComponent);
checkAndRemoveEmptyComponents(xbSystemType);
}
final String xmlDescription = addSensorMLWrapperForXmlDescription(xbSystemType);
system.setXml(xmlDescription);
return system;
}
use of net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList in project arctic-sea by 52North.
the class SensorMLDecoderV101Test method should_decode_child_procedure_from_sml.
@Test
public void should_decode_child_procedure_from_sml() throws DecodingException {
SensorMLDocument xbSmlDoc = getSensorMLDoc();
SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
IdentifierList xbIdentifierList = xbSystem.addNewIdentification().addNewIdentifierList();
addIdentifier(xbIdentifierList, "anyname", OGCConstants.URN_UNIQUE_IDENTIFIER, TEST_ID_1);
ComponentList xbComponentList = xbSystem.addNewComponents().addNewComponentList();
addChildProcedure(xbComponentList, TEST_ID_2);
AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
assertThat(absProcess.getIdentifier(), is(TEST_ID_1));
// assertThat(absProcess.getChildProcedures().size(), is(1));
// SosProcedureDescription childProcedure = absProcess.getChildProcedures().iterator().next();
// assertThat(childProcedure, instanceOf(System.class));
// assertThat(childProcedure.getIdentifier(), is(TEST_ID_2));
}
use of net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList 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