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));
}
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));
}
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;
}
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);
}
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;
}
Aggregations