Search in sources :

Example 26 with SweDataRecord

use of org.n52.shetland.ogc.swe.SweDataRecord in project arctic-sea by 52North.

the class ProfileValue method asDataRecord.

public SweDataRecord asDataRecord() {
    SweDataRecord dataRecord = new SweDataRecord();
    if (isSetIdentifier()) {
        dataRecord.setIdentifier(getIdentifier());
    }
    if (isSetName()) {
        dataRecord.setName(getName());
    }
    if (isSetDescription()) {
        dataRecord.setDescription(getDescription());
    }
    int counter = 0;
    for (ProfileLevel level : getValue()) {
        dataRecord.addField(new SweField("level_" + counter++, level.asDataRecord()));
    }
    return dataRecord;
}
Also used : SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField)

Example 27 with SweDataRecord

use of org.n52.shetland.ogc.swe.SweDataRecord in project arctic-sea by 52North.

the class GetResultTemplateResponseEncoder method encodeSweDataRecord.

private void encodeSweDataRecord(SweAbstractDataComponent structure, ObjectNode node) throws EncodingException {
    SweDataRecord sweDataRecord = (SweDataRecord) structure;
    ArrayNode fields = node.putArray(JSONConstants.FIELDS);
    for (SweField field : sweDataRecord.getFields()) {
        fields.add(encodeObjectToJson(field));
    }
}
Also used : SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 28 with SweDataRecord

use of org.n52.shetland.ogc.swe.SweDataRecord in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldText.

@Test
public void should_encode_Datarecord_with_fieldText() throws EncodingException {
    final String field1Name = "test-name";
    final String field1Value = "test-value";
    final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweText().setValue(field1Value))));
    assertThat(encode, is(instanceOf(DataRecordType.class)));
    final DataRecordType xbDataRecord = (DataRecordType) encode;
    final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
    assertThat(xbDataRecord.getFieldArray().length, is(1));
    assertThat(field1.isSetText(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getText().getValue(), is(field1Value));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) XmlObject(org.apache.xmlbeans.XmlObject) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) Test(org.junit.Test)

Example 29 with SweDataRecord

use of org.n52.shetland.ogc.swe.SweDataRecord in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldBoolean.

@Test
public void should_encode_Datarecord_with_fieldBoolean() throws EncodingException {
    final String field1Name = "test-name";
    final boolean field1Value = true;
    final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweBoolean().setValue(field1Value))));
    assertThat(encode, is(instanceOf(DataRecordType.class)));
    final DataRecordType xbDataRecord = (DataRecordType) encode;
    final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
    assertThat(xbDataRecord.getFieldArray().length, is(1));
    assertThat(field1.isSetBoolean(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getBoolean().getValue(), is(field1Value));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) XmlObject(org.apache.xmlbeans.XmlObject) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) Test(org.junit.Test)

Example 30 with SweDataRecord

use of org.n52.shetland.ogc.swe.SweDataRecord in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldCount.

@Test
public void should_encode_Datarecord_with_fieldCount() throws EncodingException {
    final String field1Name = "test-name";
    final int field1Value = 52;
    final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweCount().setValue(field1Value))));
    assertThat(encode, is(instanceOf(DataRecordType.class)));
    final DataRecordType xbDataRecord = (DataRecordType) encode;
    final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
    assertThat(xbDataRecord.getFieldArray().length, is(1));
    assertThat(field1.isSetCount(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getCount().getValue(), is(BigInteger.valueOf(field1Value)));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) XmlObject(org.apache.xmlbeans.XmlObject) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) Test(org.junit.Test)

Aggregations

SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)29 SweField (org.n52.shetland.ogc.swe.SweField)21 XmlObject (org.apache.xmlbeans.XmlObject)14 Test (org.junit.Test)13 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)11 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)10 DataRecordType (net.opengis.swe.x101.DataRecordType)10 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)7 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)6 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)6 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)6 SweDataArray (org.n52.shetland.ogc.swe.SweDataArray)5 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)5 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)5 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)5 EncodingException (org.n52.svalbard.encode.exception.EncodingException)5 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)4 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3 XmlException (org.apache.xmlbeans.XmlException)3 DateTime (org.joda.time.DateTime)3