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;
}
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));
}
}
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));
}
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));
}
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)));
}
Aggregations