Search in sources :

Example 26 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class SmlClassifierTest method shouldReturnTrueIfCodeSpaceIsSetAndNotEmpty.

@Test
public void shouldReturnTrueIfCodeSpaceIsSetAndNotEmpty() {
    final String codeSpace = "test-codespace";
    final SmlClassifier smlClassifier = new SmlClassifier("name", "definition", codeSpace, "value");
    assertThat(smlClassifier.isSetCodeSpace(), is(true));
    assertThat(smlClassifier.getCodeSpace(), is(codeSpace));
}
Also used : SmlClassifier(org.n52.shetland.ogc.sensorML.elements.SmlClassifier) Test(org.junit.Test)

Example 27 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class SmlClassifierTest method shouldReturnFalseIfDefinitionIsEmptyOrNotSet.

@Test
public void shouldReturnFalseIfDefinitionIsEmptyOrNotSet() {
    final String definition = null;
    final SmlClassifier smlClassifier = new SmlClassifier("name", definition, "codeSpace", "value");
    assertThat(smlClassifier.isSetDefinition(), is(false));
    smlClassifier.setDefinition("");
    assertThat(smlClassifier.isSetDefinition(), is(false));
}
Also used : SmlClassifier(org.n52.shetland.ogc.sensorML.elements.SmlClassifier) Test(org.junit.Test)

Example 28 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class SwesExtension method setValue.

@Override
public SwesExtension<T> setValue(T value) {
    this.value = value;
    if (value != null && value instanceof SweAbstractDataComponent) {
        SweAbstractDataComponent c = (SweAbstractDataComponent) value;
        setIdentifier(getIdentifier() == null && c.isSetIdentifier() ? c.getIdentifier() : getIdentifier());
        setDefinition(getDefinition() == null && c.isSetDefinition() ? c.getDefinition() : getDefinition());
    }
    return this;
}
Also used : SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent)

Example 29 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class SweHelper method getFieldForValue.

private SweField getFieldForValue(Value<?> iValue, String name) throws EncodingException {
    SweAbstractDataComponent value = getValue(iValue);
    value.setDefinition(name);
    return new SweField(name, value);
}
Also used : SweField(org.n52.shetland.ogc.swe.SweField) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent)

Example 30 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class SweHelper method createSosSweDataArray.

/**
 * Create {@link SweDataArray} from {@link OmObservation}
 *
 * @param sosObservation
 *            The {@link OmObservation} to create {@link SweDataArray} from
 *
 * @return Created {@link SweDataArray}
 *
 * @throws EncodingException
 *             If the service does not support the {@link SweDataArray}
 *             creation from value of {@link OmObservation}
 */
public SweDataArray createSosSweDataArray(OmObservation sosObservation) throws EncodingException {
    String observablePropertyIdentifier = sosObservation.getObservationConstellation().getObservableProperty().getIdentifier();
    SweDataArrayValue dataArrayValue = new SweDataArrayValue();
    SweDataArray dataArray = new SweDataArray();
    dataArray.setEncoding(createTextEncoding(sosObservation));
    dataArrayValue.setValue(dataArray);
    if (sosObservation.getValue() instanceof SingleObservationValue) {
        SingleObservationValue<?> singleValue = (SingleObservationValue<?>) sosObservation.getValue();
        if (singleValue.getValue() instanceof SweDataArrayValue) {
            return (SweDataArray) singleValue.getValue().getValue();
        } else {
            dataArray.setElementType(createElementType(singleValue, observablePropertyIdentifier));
            dataArrayValue.addBlock(createBlock(dataArray.getElementType(), sosObservation.getPhenomenonTime(), observablePropertyIdentifier, singleValue.getValue()));
        }
    } else if (sosObservation.getValue() instanceof MultiObservationValues) {
        MultiObservationValues<?> multiValue = (MultiObservationValues<?>) sosObservation.getValue();
        if (multiValue.getValue() instanceof SweDataArrayValue) {
            return ((SweDataArrayValue) multiValue.getValue()).getValue();
        } else if (multiValue.getValue() instanceof TVPValue) {
            TVPValue tvpValues = (TVPValue) multiValue.getValue();
            for (TimeValuePair timeValuePair : tvpValues.getValue()) {
                if (timeValuePair != null && timeValuePair.getValue() != null && timeValuePair.getValue().isSetValue()) {
                    if (!dataArray.isSetElementTyp()) {
                        dataArray.setElementType(createElementType(timeValuePair, observablePropertyIdentifier));
                    }
                    List<String> newBlock = createBlock(dataArray.getElementType(), timeValuePair.getTime(), observablePropertyIdentifier, timeValuePair.getValue());
                    dataArrayValue.addBlock(newBlock);
                }
            }
        }
    }
    return dataArray;
}
Also used : SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) TVPValue(org.n52.shetland.ogc.om.values.TVPValue) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) SweDataArrayValue(org.n52.shetland.ogc.om.values.SweDataArrayValue) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues) TimeValuePair(org.n52.shetland.ogc.om.TimeValuePair)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)28 Test (org.junit.Test)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)20 IoParameters (org.n52.io.request.IoParameters)19 SweField (org.n52.shetland.ogc.swe.SweField)16 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)13 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)13 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)12 List (java.util.List)9 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)9 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)7 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)7 CountValue (org.n52.shetland.ogc.om.values.CountValue)7 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)7 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)7 DecodingException (org.n52.svalbard.decode.exception.DecodingException)7 DateTime (org.joda.time.DateTime)6 ModelAndView (org.springframework.web.servlet.ModelAndView)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 ArrayList (java.util.ArrayList)5