use of net.opengis.swes.x20.InsertSensorDocument in project arctic-sea by 52North.
the class SwesDecoderv20 method decode.
@Override
public OwsServiceRequest decode(XmlObject xmlObject) throws DecodingException {
LOGGER.debug("REQUESTTYPE:" + xmlObject.getClass());
XmlHelper.validateDocument(xmlObject);
if (xmlObject instanceof DescribeSensorDocument) {
return parseDescribeSensor((DescribeSensorDocument) xmlObject);
} else if (xmlObject instanceof InsertSensorDocument) {
return parseInsertSensor((InsertSensorDocument) xmlObject);
} else if (xmlObject instanceof UpdateSensorDescriptionDocument) {
return parseUpdateSensorDescription((UpdateSensorDescriptionDocument) xmlObject);
} else if (xmlObject instanceof DeleteSensorDocument) {
return parseDeleteSensor((DeleteSensorDocument) xmlObject);
} else {
throw new UnsupportedDecoderXmlInputException(this, xmlObject);
}
}
use of net.opengis.swes.x20.InsertSensorDocument in project arctic-sea by 52North.
the class SwesDecoderv20 method parseInsertSensor.
private OwsServiceRequest parseInsertSensor(final InsertSensorDocument xbInsSensDoc) throws DecodingException {
final InsertSensorRequest request = new InsertSensorRequest();
final InsertSensorType xbInsertSensor = xbInsSensDoc.getInsertSensor();
request.setService(xbInsertSensor.getService());
request.setVersion(xbInsertSensor.getVersion());
// format
request.setProcedureDescriptionFormat(xbInsertSensor.getProcedureDescriptionFormat());
// observable properties
if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getObservablePropertyArray())) {
request.setObservableProperty(Arrays.asList(xbInsertSensor.getObservablePropertyArray()));
}
// related features
if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getRelatedFeatureArray())) {
request.setRelatedFeature(parseRelatedFeature(xbInsertSensor.getRelatedFeatureArray()));
}
// metadata
if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getMetadataArray())) {
request.setMetadata(parseMetadata(xbInsertSensor.getMetadataArray()));
}
// extensions
request.setExtensions(parseExtensibleRequest(xbInsertSensor));
try {
final XmlObject xbProcedureDescription = XmlObject.Factory.parse(getNodeFromNodeList(xbInsertSensor.getProcedureDescription().getDomNode().getChildNodes()));
checkFormatWithNamespace(xbInsertSensor.getProcedureDescriptionFormat(), XmlHelper.getNamespace(xbProcedureDescription));
final Decoder<?, XmlObject> decoder = getDecoder(new XmlNamespaceDecoderKey(xbInsertSensor.getProcedureDescriptionFormat(), xbProcedureDescription.getClass()));
if (decoder != null) {
final Object decodedProcedureDescription = decoder.decode(xbProcedureDescription);
if (decodedProcedureDescription instanceof SosProcedureDescription) {
request.setProcedureDescription((SosProcedureDescription) decodedProcedureDescription);
} else if (decodedProcedureDescription instanceof AbstractFeature) {
request.setProcedureDescription(new SosProcedureDescription<>((AbstractFeature) decodedProcedureDescription));
}
}
} catch (final XmlException xmle) {
throw new DecodingException("Error while parsing procedure description of InsertSensor request!", xmle);
}
return request;
}
use of net.opengis.swes.x20.InsertSensorDocument in project arctic-sea by 52North.
the class InsertSensorRequestEncoderTest method shouldEncodeObservableProperty.
@Test
public void shouldEncodeObservableProperty() throws EncodingException {
XmlObject xmlObject = encoder.create(request);
Assert.assertThat(xmlObject, CoreMatchers.instanceOf(InsertSensorDocument.class));
List<String> observableProperties = Arrays.asList(((InsertSensorDocument) xmlObject).getInsertSensor().getObservablePropertyArray());
Assert.assertThat(observableProperties, Matchers.hasSize(2));
Assert.assertThat(observableProperties, Matchers.containsInAnyOrder("test-property-1", "test-property-2"));
}
use of net.opengis.swes.x20.InsertSensorDocument in project arctic-sea by 52North.
the class InsertSensorRequestEncoder method create.
@Override
protected XmlObject create(InsertSensorRequest request) throws EncodingException {
validateInput(request);
InsertSensorDocument doc = InsertSensorDocument.Factory.newInstance(getXmlOptions());
InsertSensorType insertSensor = doc.addNewInsertSensor();
addVersion(insertSensor);
addService(insertSensor);
addProcedureDescriptionFormat(request, insertSensor);
addProcedureDescription(request, insertSensor);
addObservableProperties(request, insertSensor);
addMetadata(request, insertSensor);
return doc;
}
use of net.opengis.swes.x20.InsertSensorDocument in project arctic-sea by 52North.
the class InsertSensorRequestEncoderTest method shouldEncodeProcedureDescription.
@Test
public void shouldEncodeProcedureDescription() throws EncodingException {
InsertSensorDocument isd = (InsertSensorDocument) encoder.create(request);
ProcedureDescription description = isd.getInsertSensor().getProcedureDescription();
Assert.assertThat(description, CoreMatchers.notNullValue());
Assert.assertThat(description, CoreMatchers.instanceOf(ProcedureDescription.class));
}
Aggregations