Search in sources :

Example 46 with SweField

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

Example 47 with SweField

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

Example 48 with SweField

use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.

the class FieldDecoderTest method testQuantityRange.

@Test
public void testQuantityRange() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.QUANTITY_RANGE_TYPE).put(JSONConstants.UOM, UOM);
    SweField field = checkCommon(json, false);
    assertThat(field.getElement(), is(instanceOf(SweQuantityRange.class)));
    SweQuantityRange swe = (SweQuantityRange) field.getElement();
    errors.checkThat(swe.getUom(), is(UOM));
    errors.checkThat(swe.getValue(), is(nullValue()));
}
Also used : SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) Test(org.junit.Test)

Example 49 with SweField

use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.

the class FieldDecoderTest method testCountWithValue.

@Test
public void testCountWithValue() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.COUNT_TYPE).put(JSONConstants.VALUE, COUNT_VALUE_START);
    SweField field = checkCommon(json, true);
    assertThat(field.getElement(), is(instanceOf(SweCount.class)));
    SweCount swe = (SweCount) field.getElement();
    errors.checkThat(swe.getValue(), is(COUNT_VALUE_START));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) Test(org.junit.Test)

Example 50 with SweField

use of org.n52.shetland.ogc.swe.SweField in project arctic-sea by 52North.

the class FieldDecoderTest method testBooleanWithValueFalse.

@Test
public void testBooleanWithValueFalse() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.BOOLEAN_TYPE).put(JSONConstants.VALUE, false);
    SweField field = checkCommon(json, true);
    assertThat(field.getElement(), is(instanceOf(SweBoolean.class)));
    SweBoolean swe = (SweBoolean) field.getElement();
    errors.checkThat(swe.getValue(), is(false));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) Test(org.junit.Test)

Aggregations

SweField (org.n52.shetland.ogc.swe.SweField)59 Test (org.junit.Test)42 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)34 XmlObject (org.apache.xmlbeans.XmlObject)20 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)19 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)19 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)12 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)12 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)11 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)11 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)11 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)10 SweSimpleDataRecord (org.n52.shetland.ogc.swe.SweSimpleDataRecord)10 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)9 DataRecordType (net.opengis.swe.x101.DataRecordType)9 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)9 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)9 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)8 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)7 DateTime (org.joda.time.DateTime)4