Search in sources :

Example 1 with DataRecord

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));
}
Also used : SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) Test(org.junit.Test)

Example 2 with DataRecord

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;
}
Also used : SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord)

Example 3 with 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);
        }
    }
}
Also used : SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) Capabilities(net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) DataRecord(org.n52.shetland.ogc.swe.DataRecord)

Example 4 with DataRecord

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));
}
Also used : SweField(org.n52.shetland.ogc.swe.SweField) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord)

Example 5 with DataRecord

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));
}
Also used : ComplexValue(org.n52.shetland.ogc.om.values.ComplexValue) SweAbstractDataRecord(org.n52.shetland.ogc.swe.SweAbstractDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) OmObservation(org.n52.shetland.ogc.om.OmObservation) XmlObject(org.apache.xmlbeans.XmlObject) XmlObject(org.apache.xmlbeans.XmlObject) Test(org.junit.Test)

Aggregations

SweField (org.n52.shetland.ogc.swe.SweField)5 Test (org.junit.Test)4 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)4 XmlObject (org.apache.xmlbeans.XmlObject)2 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)2 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)2 Capabilities (net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities)1 InputList (net.opengis.sensorML.x101.InputsDocument.Inputs.InputList)1 IoComponentPropertyType (net.opengis.sensorML.x101.IoComponentPropertyType)1 OutputList (net.opengis.sensorML.x101.OutputsDocument.Outputs.OutputList)1 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)1 SystemType (net.opengis.sensorML.x101.SystemType)1 DataArrayType (net.opengis.swe.x101.DataArrayType)1 DataRecordType (net.opengis.swe.x101.DataRecordType)1 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)1 AbstractPhenomenon (org.n52.shetland.ogc.om.AbstractPhenomenon)1 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)1 OmObservation (org.n52.shetland.ogc.om.OmObservation)1 ComplexValue (org.n52.shetland.ogc.om.values.ComplexValue)1 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)1