Search in sources :

Example 6 with DataRecordType

use of net.opengis.swe.x20.DataRecordType in project arctic-sea by 52North.

the class InsertResultTemplateRequestEncoderTest method shouldEncodeResultStructure.

@Test
public void shouldEncodeResultStructure() throws EncodingException {
    ResultTemplateType template = ((InsertResultTemplateDocument) encoder.create(request)).getInsertResultTemplate().getProposedTemplate().getResultTemplate();
    Assert.assertThat(template.getResultStructure(), Matchers.notNullValue());
    AbstractDataComponentType abstractDataComponent = template.getResultStructure().getAbstractDataComponent();
    Assert.assertThat(abstractDataComponent, Matchers.notNullValue());
    Assert.assertThat(abstractDataComponent, Matchers.instanceOf(DataRecordType.class));
    DataRecordType xbResultStructure = (DataRecordType) abstractDataComponent;
    Assert.assertThat(xbResultStructure.getFieldArray().length, Is.is(1));
    Assert.assertThat(xbResultStructure.getFieldArray(0), Matchers.instanceOf(Field.class));
    Assert.assertThat(xbResultStructure.getFieldArray(0).getName(), Is.is(field1Name));
    Assert.assertThat(xbResultStructure.getFieldArray(0).getAbstractDataComponent(), Matchers.instanceOf(TimeType.class));
    TimeType xbTime = (TimeType) xbResultStructure.getFieldArray(0).getAbstractDataComponent();
    Assert.assertThat(xbTime.getDefinition(), Is.is(field1Definition));
    Assert.assertThat(xbTime.getUom().getCode(), Is.is(field1Uom));
}
Also used : DataRecordType(net.opengis.swe.x20.DataRecordType) SweField(org.n52.shetland.ogc.swe.SweField) Field(net.opengis.swe.x20.DataRecordType.Field) AbstractDataComponentType(net.opengis.swe.x20.AbstractDataComponentType) ResultTemplateType(net.opengis.sos.x20.ResultTemplateType) InsertResultTemplateType(net.opengis.sos.x20.InsertResultTemplateType) InsertResultTemplateDocument(net.opengis.sos.x20.InsertResultTemplateDocument) TimeType(net.opengis.swe.x20.TimeType) Test(org.junit.Test)

Example 7 with DataRecordType

use of net.opengis.swe.x20.DataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldQuantity.

@Test
public void should_encode_Datarecord_with_fieldQuantity() throws EncodingException {
    final String field1Name = "test-name";
    final double field1Value = 52.0;
    final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweQuantity().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.isSetQuantity(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getQuantity().getValue(), is(field1Value));
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) 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) Test(org.junit.Test)

Example 8 with DataRecordType

use of net.opengis.swe.x20.DataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldCategory.

@Test
public void should_encode_Datarecord_with_fieldCategory() throws EncodingException {
    final String field1Name = "test-name";
    final String field1Value = "test-value";
    final String codeSpace = "test-codespace";
    final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweCategory().setCodeSpace(codeSpace).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.isSetCategory(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getCategory().getValue(), is(field1Value));
    assertThat(field1.getCategory().getCodeSpace().getHref(), is(codeSpace));
}
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) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) XmlObject(org.apache.xmlbeans.XmlObject) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) Test(org.junit.Test)

Example 9 with DataRecordType

use of net.opengis.swe.x20.DataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldTimeRange.

@Test
public void should_encode_Datarecord_with_fieldTimeRange() throws EncodingException {
    final String field1Name = "test-name";
    final RangeValue<DateTime> field1Value = new RangeValue<DateTime>();
    final long now = System.currentTimeMillis();
    final DateTime rangeStart = new DateTime(now - 1000);
    final DateTime rangeEnd = new DateTime(now + 1000);
    field1Value.setRangeStart(rangeStart);
    field1Value.setRangeEnd(rangeEnd);
    final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweTimeRange().setValue(field1Value))));
    assertThat(encode, is(instanceOf(DataRecordType.class)));
    final DataRecordType xbDataRecord = (DataRecordType) encode;
    assertThat(xbDataRecord.getFieldArray().length, is(1));
    final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
    assertThat(field1.isSetTimeRange(), is(TRUE));
    final DateTime xbTimeRangeStart = new DateTime(((XmlCalendar) field1.getTimeRange().getValue().get(0)).getTimeInMillis());
    final DateTime xbTimeRangeEnd = new DateTime(((XmlCalendar) field1.getTimeRange().getValue().get(1)).getTimeInMillis());
    assertThat(field1.getName(), is(field1Name));
    assertThat(xbTimeRangeStart, is(field1Value.getRangeStart()));
    assertThat(xbTimeRangeEnd, is(field1Value.getRangeEnd()));
}
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) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) DateTime(org.joda.time.DateTime) RangeValue(org.n52.shetland.ogc.swe.RangeValue) Test(org.junit.Test)

Example 10 with DataRecordType

use of net.opengis.swe.x20.DataRecordType 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)

Aggregations

DataRecordType (net.opengis.swe.x101.DataRecordType)11 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)11 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)10 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)9 XmlObject (org.apache.xmlbeans.XmlObject)9 Test (org.junit.Test)9 SweField (org.n52.shetland.ogc.swe.SweField)9 DataRecordType (net.opengis.swe.x20.DataRecordType)4 TimeType (net.opengis.swe.x20.TimeType)4 NotYetSupportedEncodingException (org.n52.svalbard.encode.exception.NotYetSupportedEncodingException)4 BooleanType (net.opengis.swe.x20.BooleanType)3 CategoryType (net.opengis.swe.x20.CategoryType)3 CountRangeType (net.opengis.swe.x20.CountRangeType)3 CountType (net.opengis.swe.x20.CountType)3 DataArrayType (net.opengis.swe.x20.DataArrayType)3 QuantityRangeType (net.opengis.swe.x20.QuantityRangeType)3 QuantityType (net.opengis.swe.x20.QuantityType)3 TextType (net.opengis.swe.x20.TextType)3 TimeRangeType (net.opengis.swe.x20.TimeRangeType)3 VectorType (net.opengis.swe.x20.VectorType)3