use of org.n52.shetland.ogc.swe.DataRecord in project arctic-sea by 52North.
the class SweDataRecordTest method getFieldIndexByIdentifier_should_not_fail_on_bad_input.
@Test
public void getFieldIndexByIdentifier_should_not_fail_on_bad_input() {
final SweDataRecord dataRecord = new SweDataRecord();
dataRecord.addField(new SweField("identifier", new SweBoolean()));
final SweBoolean b = new SweBoolean();
b.setDefinition("test-element-definition");
dataRecord.addField(new SweField("test-field-name", b));
assertThat(dataRecord.getFieldIndexByIdentifier(null), is(-1));
assertThat(dataRecord.getFieldIndexByIdentifier(""), is(-1));
}
use of org.n52.shetland.ogc.swe.DataRecord in project arctic-sea by 52North.
the class SweHelper method createElementType.
private SweAbstractDataComponent createElementType(TimeValuePair tvp, String name) throws EncodingException {
SweDataRecord dataRecord = new SweDataRecord();
dataRecord.addField(getPhenomenonTimeField(tvp.getTime()));
dataRecord.addField(getFieldForValue(tvp.getValue(), name));
return dataRecord;
}
use of org.n52.shetland.ogc.swe.DataRecord in project arctic-sea by 52North.
the class SensorMLDecoderV101 method parseCapabilities.
/**
* Parses the capabilities, processing and removing special insertion metadata
*
* @param abstractProcess The AbstractProcess to which capabilities and insertion metadata are added
* @param capabilitiesArray XML capabilities
*
* @throws DecodingException if an error occurs
*/
private void parseCapabilities(final AbstractProcess abstractProcess, final Capabilities[] capabilitiesArray) throws DecodingException {
for (final Capabilities xbcaps : capabilitiesArray) {
final SmlCapabilities caps = new SmlCapabilities();
if (xbcaps.isSetName()) {
caps.setName(xbcaps.getName());
}
if (xbcaps.isSetAbstractDataRecord()) {
final Object o = decodeXmlElement(xbcaps.getAbstractDataRecord());
if (o instanceof DataRecord) {
final DataRecord record = (DataRecord) o;
caps.setDataRecord(record).setName(xbcaps.getName());
} else {
throw new DecodingException(XmlHelper.getLocalName(xbcaps), "Error while parsing the capabilities of the SensorML (the " + "capabilities data record is not of type DataRecordPropertyType)!");
}
} else if (xbcaps.isSetHref()) {
caps.setHref(xbcaps.getHref());
if (xbcaps.isSetTitle()) {
caps.setTitle(xbcaps.getTitle());
}
}
if (caps.isSetName()) {
abstractProcess.addCapabilities(caps);
}
}
}
use of org.n52.shetland.ogc.swe.DataRecord in project arctic-sea by 52North.
the class WmlTDREncoderv20 method createDataRecord.
private XmlObject createDataRecord(SweQuantity quantity, String observationId) throws EncodingException {
SweField field = new SweField("observed_value", quantity);
SweDataRecord dataRecord = new SweDataRecord();
dataRecord.setIdentifier(DATA_RECORD_ID_PREFIX + observationId);
dataRecord.addField(field);
return encodeObjectToXml(SweConstants.NS_SWE_20, dataRecord, EncodingContext.of(XmlBeansEncodingFlags.FOR_OBSERVATION));
}
use of org.n52.shetland.ogc.swe.DataRecord in project arctic-sea by 52North.
the class OmDecoderV20Test method testComplexObservation.
@Test
public void testComplexObservation() throws XmlException, DecodingException {
XmlObject xml = XmlObject.Factory.parse(getComplexObservationXml());
// FIXME
// Object decoded = CodingHelper.decodeXmlObject(xml);
Object decoded = omDecoderv20.decode(xml);
assertThat(decoded, is(instanceOf(OmObservation.class)));
OmObservation observation = (OmObservation) decoded;
assertThat(observation.getValue(), is(instanceOf(SingleObservationValue.class)));
assertThat(observation.getValue().getValue(), is(instanceOf(ComplexValue.class)));
ComplexValue value = (ComplexValue) observation.getValue().getValue();
assertThat(value.getValue(), is(notNullValue()));
SweAbstractDataRecord dataRecord = value.getValue();
assertThat(dataRecord.getFields(), hasSize(5));
SweField field1 = dataRecord.getFields().get(0);
SweField field2 = dataRecord.getFields().get(1);
SweField field3 = dataRecord.getFields().get(2);
SweField field4 = dataRecord.getFields().get(3);
SweField field5 = dataRecord.getFields().get(4);
errors.checkThat(field1.getElement().getDefinition(), is("http://example.tld/phenomenon/child/1"));
errors.checkThat(field2.getElement().getDefinition(), is("http://example.tld/phenomenon/child/2"));
errors.checkThat(field3.getElement().getDefinition(), is("http://example.tld/phenomenon/child/3"));
errors.checkThat(field4.getElement().getDefinition(), is("http://example.tld/phenomenon/child/4"));
errors.checkThat(field5.getElement().getDefinition(), is("http://example.tld/phenomenon/child/5"));
errors.checkThat(field1.getElement().getDataComponentType(), is(SweDataComponentType.Quantity));
errors.checkThat(field2.getElement().getDataComponentType(), is(SweDataComponentType.Boolean));
errors.checkThat(field3.getElement().getDataComponentType(), is(SweDataComponentType.Count));
errors.checkThat(field4.getElement().getDataComponentType(), is(SweDataComponentType.Text));
errors.checkThat(field5.getElement().getDataComponentType(), is(SweDataComponentType.Category));
}
Aggregations