Search in sources :

Example 1 with SweAbstractDataRecord

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;
}
Also used : ComplexValue(org.n52.shetland.ogc.om.values.ComplexValue) SweAbstractDataRecord(org.n52.shetland.ogc.swe.SweAbstractDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 2 with SweAbstractDataRecord

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));
}
Also used : ComplexValue(org.n52.shetland.ogc.om.values.ComplexValue) SweAbstractDataRecord(org.n52.shetland.ogc.swe.SweAbstractDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) OmObservation(org.n52.shetland.ogc.om.OmObservation) XmlObject(org.apache.xmlbeans.XmlObject) XmlObject(org.apache.xmlbeans.XmlObject) Test(org.junit.Test)

Aggregations

ComplexValue (org.n52.shetland.ogc.om.values.ComplexValue)2 SweAbstractDataRecord (org.n52.shetland.ogc.swe.SweAbstractDataRecord)2 SweField (org.n52.shetland.ogc.swe.SweField)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 XmlObject (org.apache.xmlbeans.XmlObject)1 Test (org.junit.Test)1 OmObservation (org.n52.shetland.ogc.om.OmObservation)1