use of net.opengis.sos.x20.SosInsertionMetadataType in project arctic-sea by 52North.
the class SosInsertionMetadataTypeEncoderTest method shouldEncodeObservationTypes.
@Test
public void shouldEncodeObservationTypes() throws EncodingException {
SosInsertionMetadataType encoded = encoder.encode(insertionMetadata);
Assert.assertThat(encoded.getObservationTypeArray().length, Is.is(2));
List<String> observationTypes = Arrays.asList(encoded.getObservationTypeArray());
Collections.sort(observationTypes);
Assert.assertThat(observationTypes, Matchers.contains("type-1", "type-2"));
}
use of net.opengis.sos.x20.SosInsertionMetadataType in project arctic-sea by 52North.
the class SosInsertionMetadataTypeEncoderTest method shouldEncodeFeatureOfInterestTypes.
@Test
public void shouldEncodeFeatureOfInterestTypes() throws EncodingException {
SosInsertionMetadataTypeEncoder encoder = new SosInsertionMetadataTypeEncoder();
encoder.setXmlOptions(() -> new XmlOptions());
SosInsertionMetadataType encoded = encoder.encode(insertionMetadata);
Assert.assertThat(encoded.getFeatureOfInterestTypeArray().length, Is.is(2));
List<String> featureTypes = Arrays.asList(encoded.getFeatureOfInterestTypeArray());
Assert.assertThat(featureTypes, Matchers.containsInAnyOrder("f-type-1", "f-type-2"));
}
use of net.opengis.sos.x20.SosInsertionMetadataType in project arctic-sea by 52North.
the class SosInsertionMetadataTypeEncoder method encode.
@Override
public SosInsertionMetadataType encode(SosInsertionMetadata objectToEncode, EncodingContext additionalValues) throws EncodingException {
SosInsertionMetadataType simt = SosInsertionMetadataType.Factory.newInstance(getXmlOptions());
objectToEncode.getObservationTypes().parallelStream().forEach(ot -> {
simt.addNewObservationType().setStringValue(ot);
});
objectToEncode.getFeatureOfInterestTypes().parallelStream().forEach(ft -> {
simt.addNewFeatureOfInterestType().setStringValue(ft);
});
return simt;
}
use of net.opengis.sos.x20.SosInsertionMetadataType in project arctic-sea by 52North.
the class SwesDecoderv20 method parseMetadata.
private SosInsertionMetadata parseMetadata(final Metadata[] metadataArray) throws DecodingException {
final SosInsertionMetadata sosMetadata = new SosInsertionMetadata();
try {
for (final Metadata metadata : metadataArray) {
SosInsertionMetadataType xbSosInsertionMetadata = null;
if (metadata.getInsertionMetadata() != null && metadata.getInsertionMetadata().schemaType() == SosInsertionMetadataType.type) {
xbSosInsertionMetadata = (SosInsertionMetadataType) metadata.getInsertionMetadata();
} else {
if (metadata.getDomNode().hasChildNodes()) {
final Node node = getNodeFromNodeList(metadata.getDomNode().getChildNodes());
final SosInsertionMetadataPropertyType xbMetadata = SosInsertionMetadataPropertyType.Factory.parse(node);
xbSosInsertionMetadata = xbMetadata.getSosInsertionMetadata();
}
}
if (xbSosInsertionMetadata != null) {
// featureOfInterest types
if (xbSosInsertionMetadata.getFeatureOfInterestTypeArray() != null) {
sosMetadata.setFeatureOfInterestTypes(Arrays.asList(xbSosInsertionMetadata.getFeatureOfInterestTypeArray()));
}
// observation types
if (xbSosInsertionMetadata.getObservationTypeArray() != null) {
sosMetadata.setObservationTypes(Arrays.asList(xbSosInsertionMetadata.getObservationTypeArray()));
}
}
}
} catch (final XmlException xmle) {
throw new DecodingException("An error occurred while parsing the metadata in the http post request", xmle);
}
return sosMetadata;
}
use of net.opengis.sos.x20.SosInsertionMetadataType in project arctic-sea by 52North.
the class InsertSensorRequestEncoderTest method shouldEncodeSosInsertionMetadata.
@Test
public void shouldEncodeSosInsertionMetadata() throws EncodingException {
InsertSensorDocument isd = (InsertSensorDocument) encoder.create(request);
Assert.assertThat(isd.getInsertSensor().getMetadataArray().length, Is.is(1));
Assert.assertThat(isd.getInsertSensor().getMetadataArray(0).getInsertionMetadata(), CoreMatchers.instanceOf(SosInsertionMetadataType.class));
SosInsertionMetadataType insertionMetadata = (SosInsertionMetadataType) isd.getInsertSensor().getMetadataArray(0).getInsertionMetadata();
Assert.assertThat(insertionMetadata.getFeatureOfInterestTypeArray(), CoreMatchers.notNullValue());
List<String> foiTypes = Arrays.asList(insertionMetadata.getFeatureOfInterestTypeArray());
Assert.assertThat(foiTypes, Matchers.hasSize(2));
Assert.assertThat(foiTypes, Matchers.containsInAnyOrder("test-foi-type-1", "test-foi-type-2"));
Assert.assertThat(insertionMetadata.getObservationTypeArray(), CoreMatchers.notNullValue());
List<String> oTypes = Arrays.asList(insertionMetadata.getObservationTypeArray());
Assert.assertThat(oTypes, Matchers.hasSize(2));
Assert.assertThat(oTypes, Matchers.containsInAnyOrder("test-observation-type-1", "test-observation-type-2"));
}
Aggregations