Search in sources :

Example 1 with SosInsertionMetadataType

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"));
}
Also used : SosInsertionMetadataType(net.opengis.sos.x20.SosInsertionMetadataType) Test(org.junit.Test)

Example 2 with SosInsertionMetadataType

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"));
}
Also used : XmlOptions(org.apache.xmlbeans.XmlOptions) SosInsertionMetadataType(net.opengis.sos.x20.SosInsertionMetadataType) Test(org.junit.Test)

Example 3 with SosInsertionMetadataType

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;
}
Also used : SosInsertionMetadataType(net.opengis.sos.x20.SosInsertionMetadataType)

Example 4 with SosInsertionMetadataType

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;
}
Also used : XmlException(org.apache.xmlbeans.XmlException) Node(org.w3c.dom.Node) SosInsertionMetadata(org.n52.shetland.ogc.sos.SosInsertionMetadata) Metadata(net.opengis.swes.x20.InsertSensorType.Metadata) SosInsertionMetadataPropertyType(net.opengis.sos.x20.SosInsertionMetadataPropertyType) SosInsertionMetadata(org.n52.shetland.ogc.sos.SosInsertionMetadata) DecodingException(org.n52.svalbard.decode.exception.DecodingException) SosInsertionMetadataType(net.opengis.sos.x20.SosInsertionMetadataType)

Example 5 with SosInsertionMetadataType

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"));
}
Also used : InsertSensorDocument(net.opengis.swes.x20.InsertSensorDocument) SosInsertionMetadataType(net.opengis.sos.x20.SosInsertionMetadataType) Test(org.junit.Test)

Aggregations

SosInsertionMetadataType (net.opengis.sos.x20.SosInsertionMetadataType)5 Test (org.junit.Test)3 SosInsertionMetadataPropertyType (net.opengis.sos.x20.SosInsertionMetadataPropertyType)1 InsertSensorDocument (net.opengis.swes.x20.InsertSensorDocument)1 Metadata (net.opengis.swes.x20.InsertSensorType.Metadata)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlOptions (org.apache.xmlbeans.XmlOptions)1 SosInsertionMetadata (org.n52.shetland.ogc.sos.SosInsertionMetadata)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1 Node (org.w3c.dom.Node)1