use of org.n52.shetland.ogc.swe.SweField 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.SweField in project arctic-sea by 52North.
the class AbstractSmlDataComponentContainer method getDataRecord.
/**
* @return the dataRecord
*/
public DataRecord getDataRecord() {
if (!isSetDataRecord() && isSetDataComponents()) {
SweSimpleDataRecord sdr = new SweSimpleDataRecord();
int counter = 1;
for (SweAbstractDataComponent element : abstractDataComponents) {
String n = "field_" + counter++;
if (element.isSetName()) {
n = element.getName().getValue();
}
SweField field = new SweField(n, element);
sdr.addField(field);
}
return sdr;
}
return dataRecord;
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class FieldDecoderTest method testQuantityRange.
@Test
public void testQuantityRange() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.QUANTITY_RANGE_TYPE).put(JSONConstants.UOM, UOM);
SweField field = checkCommon(json, false);
assertThat(field.getElement(), is(instanceOf(SweQuantityRange.class)));
SweQuantityRange swe = (SweQuantityRange) field.getElement();
errors.checkThat(swe.getUom(), is(UOM));
errors.checkThat(swe.getValue(), is(nullValue()));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class FieldDecoderTest method testCountWithValue.
@Test
public void testCountWithValue() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.COUNT_TYPE).put(JSONConstants.VALUE, COUNT_VALUE_START);
SweField field = checkCommon(json, true);
assertThat(field.getElement(), is(instanceOf(SweCount.class)));
SweCount swe = (SweCount) field.getElement();
errors.checkThat(swe.getValue(), is(COUNT_VALUE_START));
}
use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.
the class FieldDecoderTest method testBooleanWithValueFalse.
@Test
public void testBooleanWithValueFalse() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.BOOLEAN_TYPE).put(JSONConstants.VALUE, false);
SweField field = checkCommon(json, true);
assertThat(field.getElement(), is(instanceOf(SweBoolean.class)));
SweBoolean swe = (SweBoolean) field.getElement();
errors.checkThat(swe.getValue(), is(false));
}
Aggregations