use of org.n52.shetland.ogc.swe.DataRecord in project arctic-sea by 52North.
the class SweHelper method createElementType.
private SweAbstractDataComponent createElementType(SingleObservationValue<?> sov, String name) throws EncodingException {
SweDataRecord dataRecord = new SweDataRecord();
dataRecord.addField(getPhenomenonTimeField(sov.getPhenomenonTime()));
dataRecord.addField(getFieldForValue(sov.getValue(), name));
return dataRecord;
}
use of org.n52.shetland.ogc.swe.DataRecord in project arctic-sea by 52North.
the class SweDataRecordTest method getFieldIndexByIdentifier_should_return_one.
@Test
public void getFieldIndexByIdentifier_should_return_one() {
final SweDataRecord dataRecord = new SweDataRecord();
dataRecord.addField(new SweField("identifier", new SweBoolean()));
final SweBoolean b = new SweBoolean();
final String definition = "test-element-definition";
b.setDefinition(definition);
final String name = "test-field-name";
dataRecord.addField(new SweField(name, b));
assertThat(dataRecord.getFieldIndexByIdentifier(definition), is(1));
assertThat(dataRecord.getFieldIndexByIdentifier(name), is(1));
}
use of org.n52.shetland.ogc.swe.DataRecord in project arctic-sea by 52North.
the class ProfileLevel method valueAsDataRecord.
public SweDataRecord valueAsDataRecord(SweDataRecord dataRecord) {
int counter = 0;
for (Value<?> v : getValue()) {
if (v instanceof SweAbstractDataComponent) {
SweAbstractDataComponent adc = (SweAbstractDataComponent) v;
String name;
if (adc.isSetName()) {
name = adc.getName().getValue();
} else if (adc.isSetDefinition()) {
name = adc.getDefinition();
} else {
name = "component_" + counter++;
}
dataRecord.addField(new SweField(name, adc));
}
}
return dataRecord;
}
use of org.n52.shetland.ogc.swe.DataRecord 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.DataRecord 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;
}
Aggregations