Search in sources :

Example 11 with DataRecordType

use of net.opengis.swe.x20.DataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldBoolean.

@Test
public void should_encode_Datarecord_with_fieldBoolean() throws EncodingException {
    final String field1Name = "test-name";
    final boolean field1Value = true;
    final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweBoolean().setValue(field1Value))));
    assertThat(encode, is(instanceOf(DataRecordType.class)));
    final DataRecordType xbDataRecord = (DataRecordType) encode;
    final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
    assertThat(xbDataRecord.getFieldArray().length, is(1));
    assertThat(field1.isSetBoolean(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getBoolean().getValue(), is(field1Value));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) XmlObject(org.apache.xmlbeans.XmlObject) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) Test(org.junit.Test)

Example 12 with DataRecordType

use of net.opengis.swe.x20.DataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldCount.

@Test
public void should_encode_Datarecord_with_fieldCount() throws EncodingException {
    final String field1Name = "test-name";
    final int field1Value = 52;
    final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweCount().setValue(field1Value))));
    assertThat(encode, is(instanceOf(DataRecordType.class)));
    final DataRecordType xbDataRecord = (DataRecordType) encode;
    final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
    assertThat(xbDataRecord.getFieldArray().length, is(1));
    assertThat(field1.isSetCount(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getCount().getValue(), is(BigInteger.valueOf(field1Value)));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) XmlObject(org.apache.xmlbeans.XmlObject) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) Test(org.junit.Test)

Example 13 with DataRecordType

use of net.opengis.swe.x20.DataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_Datarecord_with_fieldTime.

@Test
public void should_encode_Datarecord_with_fieldTime() throws EncodingException {
    final String field1Name = "test-name";
    final DateTime field1Value = new DateTime(System.currentTimeMillis());
    final XmlObject encode = sweCommonEncoderv101.encode(new SweDataRecord().addField(new SweField(field1Name, new SweTime().setValue(field1Value))));
    assertThat(encode, is(instanceOf(DataRecordType.class)));
    final DataRecordType xbDataRecord = (DataRecordType) encode;
    final DataComponentPropertyType field1 = xbDataRecord.getFieldArray(0);
    assertThat(xbDataRecord.getFieldArray().length, is(1));
    assertThat(field1.isSetTime(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    final DateTime xbTime = new DateTime(((XmlCalendar) field1.getTime().getValue()).getTimeInMillis(), DateTimeZone.UTC);
    assertThat(xbTime.toDateTime(field1Value.getZone()), is(field1Value));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) XmlObject(org.apache.xmlbeans.XmlObject) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 14 with DataRecordType

use of net.opengis.swe.x20.DataRecordType in project arctic-sea by 52North.

the class SensorMLDecoderV101Test method should_decode_io_from_sml.

@Test
public void should_decode_io_from_sml() throws DecodingException {
    SensorMLDocument xbSmlDoc = getSensorMLDoc();
    SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
    InputList xbInputList = xbSystem.addNewInputs().addNewInputList();
    OutputList xbOutputList = xbSystem.addNewOutputs().addNewOutputList();
    IoComponentPropertyType input1 = xbInputList.addNewInput();
    input1.setName("input1");
    input1.addNewBoolean();
    IoComponentPropertyType input2 = xbInputList.addNewInput();
    input2.setName("input2");
    input2.addNewCount();
    IoComponentPropertyType output1 = xbOutputList.addNewOutput();
    output1.setName("output1");
    output1.addNewQuantity();
    IoComponentPropertyType output2 = xbOutputList.addNewOutput();
    output2.setName("output2");
    DataArrayType dataArray = getDataArray();
    output2.setAbstractDataArray1(dataArray);
    XmlHelper.substituteElement(output2.getAbstractDataArray1(), dataArray);
    IoComponentPropertyType output3 = xbOutputList.addNewOutput();
    output3.setName("output3");
    DataRecordType dataRecord = DataRecordType.Factory.newInstance();
    output3.setAbstractDataRecord(dataRecord);
    XmlHelper.substituteElement(output3.getAbstractDataRecord(), dataRecord);
    AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
    assertThat(absProcess.getInputs().get(0).getIoValue().getDataComponentType(), is(SweDataComponentType.Boolean));
    // assertThat(
    // ((SweAbstractSimpleType)absProcess.getInputs().get(0).getIoValue()).getDataComponentType(),
    // is (SweDataComponentType.Boolean));
    assertThat(absProcess.getInputs().get(1).getIoValue().getDataComponentType(), is(SweDataComponentType.Count));
    // assertThat(
    // ((SweAbstractSimpleType)absProcess.getInputs().get(1).getIoValue()).getDataComponentType(),
    // is (SweDataComponentType.Count));
    assertThat(absProcess.getOutputs().get(0).getIoValue().getDataComponentType(), is(SweDataComponentType.Quantity));
    // assertThat(
    // ((SweAbstractSimpleType)absProcess.getOutputs().get(0).getIoValue()).getDataComponentType(),
    // is (SweDataComponentType.Quantity));
    assertThat(absProcess.getOutputs().get(1).getIoValue().getDataComponentType(), is(SweDataComponentType.DataArray));
    assertThat(absProcess.getOutputs().get(2).getIoValue().getDataComponentType(), is(SweDataComponentType.DataRecord));
}
Also used : SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) DataRecordType(net.opengis.swe.x101.DataRecordType) InputList(net.opengis.sensorML.x101.InputsDocument.Inputs.InputList) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SystemType(net.opengis.sensorML.x101.SystemType) IoComponentPropertyType(net.opengis.sensorML.x101.IoComponentPropertyType) OutputList(net.opengis.sensorML.x101.OutputsDocument.Outputs.OutputList) DataArrayType(net.opengis.swe.x101.DataArrayType) Test(org.junit.Test)

Example 15 with DataRecordType

use of net.opengis.swe.x20.DataRecordType in project arctic-sea by 52North.

the class SweCommonEncoderv101 method createField.

private DataComponentPropertyType createField(SweField sweField) throws EncodingException {
    SweAbstractDataComponent sosElement = sweField.getElement();
    DataComponentPropertyType xbField = DataComponentPropertyType.Factory.newInstance(getXmlOptions());
    if (sweField.isSetName()) {
        xbField.setName(sweField.getName().getValue());
    }
    if (sosElement instanceof SweBoolean) {
        xbField.addNewBoolean().set(createSimpleType((SweBoolean) sosElement));
    } else if (sosElement instanceof SweCategory) {
        xbField.addNewCategory().set(createSimpleType((SweCategory) sosElement));
    } else if (sosElement instanceof SweCount) {
        xbField.addNewCount().set(createSimpleType((SweCount) sosElement));
    } else if (sosElement instanceof SweCountRange) {
        xbField.addNewCount().set(createSimpleType((SweCountRange) sosElement));
    } else if (sosElement instanceof SweQuantity) {
        xbField.addNewQuantity().set(createSimpleType((SweQuantity) sosElement));
    } else if (sosElement instanceof SweQuantityRange) {
        xbField.addNewQuantity().set(createSimpleType((SweQuantityRange) sosElement));
    } else if (sosElement instanceof SweText) {
        xbField.addNewText().set(createSimpleType((SweText) sosElement));
    } else if (sosElement instanceof SweTimeRange) {
        xbField.addNewTimeRange().set(createSimpleType((SweTimeRange) sosElement));
    } else if (sosElement instanceof SweTime) {
        xbField.addNewTime().set(createSimpleType((SweTime) sosElement));
    } else if (sosElement instanceof SweEnvelope) {
        EnvelopeType xbEnvelope = (EnvelopeType) xbField.addNewAbstractDataRecord().substitute(SweConstants.QN_ENVELOPE_SWE_101, EnvelopeType.type);
        xbEnvelope.set(createEnvelope((SweEnvelope) sosElement));
    } else if (sosElement instanceof SweDataRecord) {
        DataRecordType xbEnvelope = (DataRecordType) xbField.addNewAbstractDataRecord().substitute(SweConstants.QN_DATA_RECORD_SWE_101, DataRecordType.type);
        xbEnvelope.set(createDataRecord((SweDataRecord) sosElement));
    } else if (sosElement instanceof SweDataArray) {
        DataArrayType xbEnvelope = (DataArrayType) xbField.addNewAbstractDataRecord().substitute(SweConstants.QN_DATA_RECORD_SWE_101, DataArrayType.type);
        xbEnvelope.set(createDataArray((SweDataArray) sosElement).getDataArray1());
    } else {
        throw new EncodingException("The element type '%s' of the received '%s' is not supported by this encoder '%s'.", new Object[] { sosElement != null ? sosElement.getClass().getName() : null, sweField.getClass().getName(), getClass().getName() });
    }
    return xbField;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) DataRecordType(net.opengis.swe.x101.DataRecordType) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) EnvelopeType(net.opengis.swe.x101.EnvelopeType) EncodingException(org.n52.svalbard.encode.exception.EncodingException) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SweCountRange(org.n52.shetland.ogc.swe.simpleType.SweCountRange) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) DataArrayType(net.opengis.swe.x101.DataArrayType)

Aggregations

DataRecordType (net.opengis.swe.x101.DataRecordType)11 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)11 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)10 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)9 XmlObject (org.apache.xmlbeans.XmlObject)9 Test (org.junit.Test)9 SweField (org.n52.shetland.ogc.swe.SweField)9 DataRecordType (net.opengis.swe.x20.DataRecordType)4 TimeType (net.opengis.swe.x20.TimeType)4 NotYetSupportedEncodingException (org.n52.svalbard.encode.exception.NotYetSupportedEncodingException)4 BooleanType (net.opengis.swe.x20.BooleanType)3 CategoryType (net.opengis.swe.x20.CategoryType)3 CountRangeType (net.opengis.swe.x20.CountRangeType)3 CountType (net.opengis.swe.x20.CountType)3 DataArrayType (net.opengis.swe.x20.DataArrayType)3 QuantityRangeType (net.opengis.swe.x20.QuantityRangeType)3 QuantityType (net.opengis.swe.x20.QuantityType)3 TextType (net.opengis.swe.x20.TextType)3 TimeRangeType (net.opengis.swe.x20.TimeRangeType)3 VectorType (net.opengis.swe.x20.VectorType)3