use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.
the class SensorMLDecoderV101 method parseLocation.
/**
* Parses the location
*
* @param location XML location
*
* @return SOS location
*
* @throws DecodingException if an error occurs
*/
private org.n52.shetland.ogc.sensorML.elements.SmlLocation parseLocation(final SmlLocation2 location) throws DecodingException {
if (!location.isSetPoint()) {
throw new DecodingException(XmlHelper.getLocalName(location), "Error while parsing the sml:location of the SensorML " + "(point is not set, only point is supported)!");
}
org.n52.shetland.ogc.sensorML.elements.SmlLocation sosSmlLocation = null;
final Object point = decodeXmlElement(location.getPoint());
if (point instanceof Point) {
sosSmlLocation = new org.n52.shetland.ogc.sensorML.elements.SmlLocation((Point) point);
}
return sosSmlLocation;
}
use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.
the class SensorMLDecoderV101 method parseCapabilities.
/**
* Parses the capabilities, processing and removing special insertion metadata
*
* @param abstractProcess The AbstractProcess to which capabilities and insertion metadata are added
* @param capabilitiesArray XML capabilities
*
* @throws DecodingException if an error occurs
*/
private void parseCapabilities(final AbstractProcess abstractProcess, final Capabilities[] capabilitiesArray) throws DecodingException {
for (final Capabilities xbcaps : capabilitiesArray) {
final SmlCapabilities caps = new SmlCapabilities();
if (xbcaps.isSetName()) {
caps.setName(xbcaps.getName());
}
if (xbcaps.isSetAbstractDataRecord()) {
final Object o = decodeXmlElement(xbcaps.getAbstractDataRecord());
if (o instanceof DataRecord) {
final DataRecord record = (DataRecord) o;
caps.setDataRecord(record).setName(xbcaps.getName());
} else {
throw new DecodingException(XmlHelper.getLocalName(xbcaps), "Error while parsing the capabilities of the SensorML (the " + "capabilities data record is not of type DataRecordPropertyType)!");
}
} else if (xbcaps.isSetHref()) {
caps.setHref(xbcaps.getHref());
if (xbcaps.isSetTitle()) {
caps.setTitle(xbcaps.getTitle());
}
}
if (caps.isSetName()) {
abstractProcess.addCapabilities(caps);
}
}
}
use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createIdentification.
/**
* Creates the valueentification section of the SensorML description.
*
* @param identifications
* SOS valueentifications
*
* @return XML Identification array
*/
protected Identification[] createIdentification(List<SmlIdentifier> identifications) {
Identification xbIdentification = Identification.Factory.newInstance(getXmlOptions());
IdentifierList xbIdentifierList = xbIdentification.addNewIdentifierList();
identifications.forEach(sosSMLIdentifier -> {
Identifier xbIdentifier = xbIdentifierList.addNewIdentifier();
if (sosSMLIdentifier.getName() != null) {
xbIdentifier.setName(sosSMLIdentifier.getName());
}
Term xbTerm = xbIdentifier.addNewTerm();
xbTerm.setDefinition(sosSMLIdentifier.getDefinition());
xbTerm.setValue(sosSMLIdentifier.getValue());
});
return new Identification[] { xbIdentification };
}
use of org.n52.shetland.ogc.sensorML.SensorML 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.SensorML in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createOutputs.
/**
* Creates the outputs section of the SensorML description.
*
* @param sosOutputs
* SOS SWE representation.
*
* @return XML Outputs element
*
* @throws EncodingException
* if the encoding fails
*/
private Outputs createOutputs(final List<SmlIo> sosOutputs) throws EncodingException {
Outputs outputs = Outputs.Factory.newInstance(getXmlOptions());
OutputList outputList = outputs.addNewOutputList();
Set<String> definitions = Sets.newHashSet();
int counter = 1;
Set<String> outputNames = Sets.newHashSet();
for (SmlIo sosSMLIo : sosOutputs) {
if (sosSMLIo.isSetValue() && !definitions.contains(sosSMLIo.getIoValue().getDefinition())) {
if (!sosSMLIo.isSetName() || outputNames.contains(sosSMLIo.getIoName())) {
sosSMLIo.setIoName(getValidOutputName(counter++, outputNames));
}
outputNames.add(sosSMLIo.getIoName());
addIoComponentPropertyType(outputList.addNewOutput(), sosSMLIo);
definitions.add(sosSMLIo.getIoValue().getDefinition());
}
}
return outputs;
}
Aggregations