use of org.n52.shetland.ogc.sensorML.elements.SmlComponent 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 org.n52.shetland.ogc.sensorML.elements.SmlComponent in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createSensorMLDescription.
protected SensorMLDocument createSensorMLDescription(final SensorML smlSensorDesc) throws EncodingException {
final SensorMLDocument sensorMLDoc = SensorMLDocument.Factory.newInstance(getXmlOptions());
final net.opengis.sensorML.x101.SensorMLDocument.SensorML xbSensorML = sensorMLDoc.addNewSensorML();
xbSensorML.setVersion(SensorMLConstants.VERSION_V101);
if (smlSensorDesc.isSetMembers()) {
for (final AbstractProcess sml : smlSensorDesc.getMembers()) {
if (sml instanceof System) {
final SystemType xbSystem = (SystemType) xbSensorML.addNewMember().addNewProcess().substitute(new QName(SensorMLConstants.NS_SML, SensorMLConstants.EN_SYSTEM), SystemType.type);
final System smlSystem = (System) sml;
addAbstractProcessValues(xbSystem, smlSystem);
addSystemValues(xbSystem, smlSystem);
} else if (sml instanceof ProcessModel) {
final ProcessModelType xbProcessModel = (ProcessModelType) xbSensorML.addNewMember().addNewProcess().substitute(new QName(SensorMLConstants.NS_SML, SensorMLConstants.EN_PROCESS_MODEL), ProcessModelType.type);
final ProcessModel smlProcessModel = (ProcessModel) sml;
addAbstractProcessValues(xbProcessModel, smlProcessModel);
addProcessModelValues(xbProcessModel, smlProcessModel);
} else if (sml instanceof org.n52.shetland.ogc.sensorML.Component) {
final ComponentType xbCompontent = (ComponentType) xbSensorML.addNewMember().addNewProcess().substitute(new QName(SensorMLConstants.NS_SML, SensorMLConstants.EN_COMPONENT), ComponentType.type);
final org.n52.shetland.ogc.sensorML.Component smlComponent = (org.n52.shetland.ogc.sensorML.Component) sml;
addAbstractProcessValues(xbCompontent, smlComponent);
addComponentValues(xbCompontent, smlComponent);
}
}
}
return sensorMLDoc;
}
use of org.n52.shetland.ogc.sensorML.elements.SmlComponent 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 org.n52.shetland.ogc.sensorML.elements.SmlComponent 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 org.n52.shetland.ogc.sensorML.elements.SmlComponent 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