Search in sources :

Example 11 with SimpleDataRecordType

use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_simpleDataRecordWithFields.

@Test
public void should_encode_simpleDataRecordWithFields() throws EncodingException {
    final String field0Value = "field-0-value";
    final String field0Name = "field-0";
    final String field1Name = "field-1";
    final Boolean field1Value = Boolean.TRUE;
    final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(field0Name, new SweText().setValue(field0Value))).addField(new SweField(field1Name, new SweBoolean().setValue(field1Value))));
    assertThat(encode, instanceOf(SimpleDataRecordType.class));
    final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
    final AnyScalarPropertyType field0 = xbSimpleDataRecord.getFieldArray(0);
    final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(1);
    assertThat(xbSimpleDataRecord.getFieldArray().length, is(2));
    assertThat(field0.isSetText(), is(TRUE));
    assertThat(field0.getName(), is(field0Name));
    assertThat(field0.getText().getValue(), is(field0Value));
    assertThat(field1.isSetBoolean(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getBoolean().getValue(), is(field1Value));
}
Also used : SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.Test)

Example 12 with SimpleDataRecordType

use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.

the class SensorMLDecoderV101Test method addCapabilitiesInsertionMetadata.

private void addCapabilitiesInsertionMetadata(SimpleDataRecordType xbSimpleDataRecord, String value, String name) {
    AnyScalarPropertyType xbField = xbSimpleDataRecord.addNewField();
    xbField.setName(name);
    xbField.addNewText().setValue(value);
    xbField.getText().addNewName().setStringValue(name);
}
Also used : AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType)

Example 13 with SimpleDataRecordType

use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.

the class SensorMLDecoderV101Test method should_decode_parent_procedures_from_sml.

@Test
public void should_decode_parent_procedures_from_sml() throws DecodingException {
    SensorMLDocument xbSmlDoc = getSensorMLDoc();
    SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
    Capabilities xbCapabilities = xbSystem.addNewCapabilities();
    xbCapabilities.setName(SensorMLConstants.ELEMENT_NAME_PARENT_PROCEDURES);
    SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) xbCapabilities.addNewAbstractDataRecord().substitute(SweConstants.QN_SIMPLEDATARECORD_SWE_101, SimpleDataRecordType.type);
    addCapabilitiesInsertionMetadata(xbSimpleDataRecord, TEST_ID_1, TEST_NAME_1);
    addCapabilitiesInsertionMetadata(xbSimpleDataRecord, TEST_ID_2, TEST_NAME_2);
    AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
    // assertThat(absProcess.getParentProcedures().size(), is(2));
    assertThat(absProcess.getCapabilities().size(), is(1));
// List<String> parentProcedures = new ArrayList<String>(absProcess.getParentProcedures());
// Collections.sort(parentProcedures);
// assertThat(parentProcedures.get(0), is(TEST_ID_1));
// assertThat(parentProcedures.get(1), is(TEST_ID_2));
}
Also used : SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) Capabilities(net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities) SystemType(net.opengis.sensorML.x101.SystemType) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.Test)

Example 14 with SimpleDataRecordType

use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.

the class SensorMLDecoderV101Test method should_decode_offerings_from_sml.

@Test
public void should_decode_offerings_from_sml() throws DecodingException {
    SensorMLDocument xbSmlDoc = getSensorMLDoc();
    SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
    Capabilities xbCapabilities = xbSystem.addNewCapabilities();
    xbCapabilities.setName(SensorMLConstants.ELEMENT_NAME_OFFERINGS);
    SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) xbCapabilities.addNewAbstractDataRecord().substitute(SweConstants.QN_SIMPLEDATARECORD_SWE_101, SimpleDataRecordType.type);
    addCapabilitiesInsertionMetadata(xbSimpleDataRecord, TEST_ID_1, TEST_NAME_1);
    addCapabilitiesInsertionMetadata(xbSimpleDataRecord, TEST_ID_2, TEST_NAME_2);
    AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
    // assertThat(absProcess.getOfferings().size(), is(2));
    assertThat(absProcess.getCapabilities().size(), is(1));
// List<SosOffering> sosOfferings = new ArrayList<SosOffering>(absProcess.getOfferings());
// Collections.sort(sosOfferings);
// assertThat(sosOfferings.get(0).getIdentifier(), is(TEST_ID_1));
// assertThat(sosOfferings.get(0).getOfferingName(), is(TEST_NAME_1));
// assertThat(sosOfferings.get(1).getIdentifier(), is(TEST_ID_2));
// assertThat(sosOfferings.get(1).getOfferingName(), is(TEST_NAME_2));
}
Also used : SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) Capabilities(net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities) SystemType(net.opengis.sensorML.x101.SystemType) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.Test)

Example 15 with SimpleDataRecordType

use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.

the class SensorMLEncoderv101 method createCharacteristics.

/**
 * Creates the characteristics section of the SensorML description.
 *
 * @param smlCharacteristics
 *            SOS characteristics list
 *
 * @return XML Characteristics array
 *
 * @throws EncodingException
 *             If an error occurs
 */
private Characteristics[] createCharacteristics(final List<SmlCharacteristics> smlCharacteristics) throws EncodingException {
    final List<Characteristics> characteristicsList = Lists.newArrayListWithExpectedSize(smlCharacteristics.size());
    for (final SmlCharacteristics sosSMLCharacteristics : smlCharacteristics) {
        final Characteristics xbCharacteristics = Characteristics.Factory.newInstance(getXmlOptions());
        if (sosSMLCharacteristics.isSetName()) {
            xbCharacteristics.setName(sosSMLCharacteristics.getName());
        }
        if (sosSMLCharacteristics.isSetAbstractDataRecord()) {
            if (sosSMLCharacteristics.getDataRecord() instanceof SweSimpleDataRecord) {
                final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) xbCharacteristics.addNewAbstractDataRecord().substitute(SweConstants.QN_SIMPLEDATARECORD_SWE_101, SimpleDataRecordType.type);
                if (sosSMLCharacteristics.isSetTypeDefinition()) {
                    xbSimpleDataRecord.setDefinition(sosSMLCharacteristics.getTypeDefinition());
                }
                if (sosSMLCharacteristics.getDataRecord().isSetFields()) {
                    for (final SweField field : sosSMLCharacteristics.getDataRecord().getFields()) {
                        final AnyScalarPropertyType xbField = xbSimpleDataRecord.addNewField();
                        xbField.setName(field.getName().getValue());
                        addSweSimpleTypeToField(xbField, field.getElement());
                    }
                }
            } else if (sosSMLCharacteristics.getDataRecord() instanceof SweDataRecord) {
                throw unsupportedCharacteristicsType(SweAggregateType.DataRecord);
            } else {
                throw unsupportedCharacteristicsType(sosSMLCharacteristics.getDataRecord().getClass().getName());
            }
        } else if (sosSMLCharacteristics.isSetHref()) {
            if (sosSMLCharacteristics.isSetName()) {
                xbCharacteristics.setName(sosSMLCharacteristics.getName());
            }
            xbCharacteristics.setHref(sosSMLCharacteristics.getHref());
            if (sosSMLCharacteristics.isSetTitle()) {
                xbCharacteristics.setTitle(sosSMLCharacteristics.getTitle());
            }
        }
        characteristicsList.add(xbCharacteristics);
    }
    return characteristicsList.toArray(new Characteristics[characteristicsList.size()]);
}
Also used : SmlCharacteristics(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) Characteristics(net.opengis.sensorML.x101.CharacteristicsDocument.Characteristics) SmlCharacteristics(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics) SweField(org.n52.shetland.ogc.swe.SweField) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType)

Aggregations

SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)14 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)11 Test (org.junit.Test)11 SweField (org.n52.shetland.ogc.swe.SweField)10 SweSimpleDataRecord (org.n52.shetland.ogc.swe.SweSimpleDataRecord)9 XmlObject (org.apache.xmlbeans.XmlObject)8 Capabilities (net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities)4 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)3 SystemType (net.opengis.sensorML.x101.SystemType)3 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)3 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)2 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)2 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)2 StringOrRefType (net.opengis.gml.StringOrRefType)1 Characteristics (net.opengis.sensorML.x101.CharacteristicsDocument.Characteristics)1 DateTime (org.joda.time.DateTime)1 SmlCharacteristics (org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics)1 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)1 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)1 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)1