use of net.opengis.swes.x20.SensorDescriptionType in project arctic-sea by 52North.
the class SwesDecoderv20 method parseUpdateSensorDescription.
/**
* parses the Xmlbeans UpdateSensorDescription document to a SOS request.
*
* @param xbUpSenDoc
* UpdateSensorDescription document
* @return SOS UpdateSensor request
*
* @throws DecodingException
* * if an error occurs.
*/
private OwsServiceRequest parseUpdateSensorDescription(final UpdateSensorDescriptionDocument xbUpSenDoc) throws DecodingException {
final UpdateSensorRequest request = new UpdateSensorRequest();
final UpdateSensorDescriptionType xbUpdateSensor = xbUpSenDoc.getUpdateSensorDescription();
request.setService(xbUpdateSensor.getService());
request.setVersion(xbUpdateSensor.getVersion());
request.setProcedureIdentifier(xbUpdateSensor.getProcedure());
request.setProcedureDescriptionFormat(xbUpdateSensor.getProcedureDescriptionFormat());
// extensions
request.setExtensions(parseExtensibleRequest(xbUpdateSensor));
for (final Description description : xbUpdateSensor.getDescriptionArray()) {
SensorDescriptionType sensorDescription = description.getSensorDescription();
try {
// TODO exception if valid time is set
final XmlObject xmlObject = XmlObject.Factory.parse(getNodeFromNodeList(sensorDescription.getData().getDomNode().getChildNodes()));
Decoder<?, XmlObject> decoder = getDecoder(getDecoderKey(xmlObject));
if (decoder == null) {
throw new DecodingException(UpdateSensorDescriptionParams.procedureDescriptionFormat, "The requested procedureDescritpionFormat is not supported!");
}
final Object decodedObject = decoder.decode(xmlObject);
SosProcedureDescription<?> sosProcedureDescription = null;
if (decodedObject instanceof SosProcedureDescription) {
sosProcedureDescription = (SosProcedureDescription) decodedObject;
} else if (decodedObject instanceof AbstractFeature) {
sosProcedureDescription = new SosProcedureDescription<>((AbstractFeature) decodedObject);
}
if (sosProcedureDescription != null) {
if (sensorDescription.isSetValidTime()) {
sosProcedureDescription.setValidTime(getValidTime(sensorDescription.getValidTime()));
}
}
request.addProcedureDescriptionString(sosProcedureDescription);
} catch (final XmlException xmle) {
throw new DecodingException("Error while parsing procedure description of UpdateSensor request!", xmle);
}
}
return request;
}
use of net.opengis.swes.x20.SensorDescriptionType in project arctic-sea by 52North.
the class DescribeSensorResponseEncoder method create.
@Override
protected XmlObject create(DescribeSensorResponse response) throws EncodingException {
DescribeSensorResponseDocument doc = DescribeSensorResponseDocument.Factory.newInstance(getXmlOptions());
DescribeSensorResponseType dsr = doc.addNewDescribeSensorResponse();
dsr.setProcedureDescriptionFormat(response.getOutputFormat());
for (SosProcedureDescription<?> sosProcedureDescription : response.getProcedureDescriptions()) {
SensorDescriptionType sensorDescription = dsr.addNewDescription().addNewSensorDescription();
sensorDescription.addNewData().set(getSensorDescription(response, sosProcedureDescription));
if (sosProcedureDescription.isSetValidTime()) {
XmlObject xoValidTime = encodeObjectToXml(GmlConstants.NS_GML_32, sosProcedureDescription.getValidTime());
XmlObject substitution = sensorDescription.addNewValidTime().addNewAbstractTimeGeometricPrimitive().substitute(GmlHelper.getGml321QnameForITime(sosProcedureDescription.getValidTime()), xoValidTime.schemaType());
substitution.set(xoValidTime);
}
}
// in a single observation the gml:ids must be unique
if (response.getProcedureDescriptions().size() > 1) {
XmlHelper.makeGmlIdsUnique(doc.getDomNode());
}
return doc;
}
Aggregations