use of org.n52.shetland.ogc.swe.SweAbstractDataRecord in project arctic-sea by 52North.
the class ObservationEncoder method encodeComplexValue.
private JsonNode encodeComplexValue(Value<?> value) throws EncodingException {
ArrayNode result = nodeFactory().arrayNode();
ComplexValue complexValue = (ComplexValue) value;
SweAbstractDataRecord sweDataRecord = complexValue.getValue();
for (SweField field : sweDataRecord.getFields()) {
result.add(encodeObjectToJson(field));
}
return result;
}
use of org.n52.shetland.ogc.swe.SweAbstractDataRecord in project arctic-sea by 52North.
the class OmDecoderV20Test method testComplexObservation.
@Test
public void testComplexObservation() throws XmlException, DecodingException {
XmlObject xml = XmlObject.Factory.parse(getComplexObservationXml());
// FIXME
// Object decoded = CodingHelper.decodeXmlObject(xml);
Object decoded = omDecoderv20.decode(xml);
assertThat(decoded, is(instanceOf(OmObservation.class)));
OmObservation observation = (OmObservation) decoded;
assertThat(observation.getValue(), is(instanceOf(SingleObservationValue.class)));
assertThat(observation.getValue().getValue(), is(instanceOf(ComplexValue.class)));
ComplexValue value = (ComplexValue) observation.getValue().getValue();
assertThat(value.getValue(), is(notNullValue()));
SweAbstractDataRecord dataRecord = value.getValue();
assertThat(dataRecord.getFields(), hasSize(5));
SweField field1 = dataRecord.getFields().get(0);
SweField field2 = dataRecord.getFields().get(1);
SweField field3 = dataRecord.getFields().get(2);
SweField field4 = dataRecord.getFields().get(3);
SweField field5 = dataRecord.getFields().get(4);
errors.checkThat(field1.getElement().getDefinition(), is("http://example.tld/phenomenon/child/1"));
errors.checkThat(field2.getElement().getDefinition(), is("http://example.tld/phenomenon/child/2"));
errors.checkThat(field3.getElement().getDefinition(), is("http://example.tld/phenomenon/child/3"));
errors.checkThat(field4.getElement().getDefinition(), is("http://example.tld/phenomenon/child/4"));
errors.checkThat(field5.getElement().getDefinition(), is("http://example.tld/phenomenon/child/5"));
errors.checkThat(field1.getElement().getDataComponentType(), is(SweDataComponentType.Quantity));
errors.checkThat(field2.getElement().getDataComponentType(), is(SweDataComponentType.Boolean));
errors.checkThat(field3.getElement().getDataComponentType(), is(SweDataComponentType.Count));
errors.checkThat(field4.getElement().getDataComponentType(), is(SweDataComponentType.Text));
errors.checkThat(field5.getElement().getDataComponentType(), is(SweDataComponentType.Category));
}
Aggregations