use of org.n52.shetland.ogc.swe.simpleType.SweText in project arctic-sea by 52North.
the class OmEncoderv20Test method createComplexObservation.
protected OmObservation createComplexObservation() {
DateTime now = new DateTime(DateTimeZone.UTC);
TimeInstant resultTime = new TimeInstant(now);
TimeInstant phenomenonTime = new TimeInstant(now);
TimePeriod validTime = new TimePeriod(now.minusMinutes(5), now.plusMinutes(5));
OmObservation observation = new OmObservation();
OmObservationConstellation observationConstellation = new OmObservationConstellation();
observationConstellation.setFeatureOfInterest(new SamplingFeature(new CodeWithAuthority("feature", CODE_SPACE)));
OmCompositePhenomenon observableProperty = new OmCompositePhenomenon(PARENT_OBSERVABLE_PROPERTY);
observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_1));
observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_2));
observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_3));
observableProperty.addPhenomenonComponent(new OmObservableProperty(CHILD_OBSERVABLE_PROPERTY_4));
observationConstellation.setObservableProperty(observableProperty);
observationConstellation.setObservationType(OmConstants.OBS_TYPE_COMPLEX_OBSERVATION);
observationConstellation.addOffering(OFFERING);
AbstractFeature procedure = new SosProcedureDescriptionUnknownType(PROCEDURE);
// procedure.setIdentifier(new CodeWithAuthority(PROCEDURE, CODE_SPACE));
observationConstellation.setProcedure(procedure);
observation.setObservationConstellation(observationConstellation);
observation.setParameter(null);
observation.setResultTime(resultTime);
observation.setTokenSeparator(TOKEN_SEPERATOR);
observation.setTupleSeparator(TUPLE_SEPERATOR);
observation.setValidTime(validTime);
ComplexValue complexValue = new ComplexValue();
SweDataRecord sweDataRecord = new SweDataRecord();
SweQuantity sweQuantity = new SweQuantity();
sweQuantity.setDefinition(CHILD_OBSERVABLE_PROPERTY_1);
sweQuantity.setUom("unit");
sweQuantity.setValue(42.0);
sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_1_NAME, sweQuantity));
SweBoolean sweBoolean = new SweBoolean();
sweBoolean.setValue(Boolean.TRUE);
sweBoolean.setDefinition(CHILD_OBSERVABLE_PROPERTY_2);
sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_2_NAME, sweBoolean));
SweCount sweCount = new SweCount();
sweCount.setDefinition(CHILD_OBSERVABLE_PROPERTY_3);
sweCount.setValue(42);
sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_3_NAME, sweCount));
SweText sweText = new SweText();
sweText.setDefinition(CHILD_OBSERVABLE_PROPERTY_4);
sweText.setValue("42");
sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_4_NAME, sweText));
SweCategory sweCategory = new SweCategory();
sweCategory.setDefinition(CHILD_OBSERVABLE_PROPERTY_5);
sweCategory.setCodeSpace(CODE_SPACE);
sweCategory.setValue("52");
sweDataRecord.addField(new SweField(CHILD_OBSERVABLE_PROPERTY_5_NAME, sweCategory));
complexValue.setValue(sweDataRecord);
observation.setValue(new SingleObservationValue<>(phenomenonTime, complexValue));
return observation;
}
use of org.n52.shetland.ogc.swe.simpleType.SweText in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldText.
@Test
public void should_encode_simpleDatarecord_with_fieldText() throws EncodingException {
final String field1Name = "field-1";
final String field1Value = "field-1-value";
final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(field1Name, new SweText().setValue(field1Value))));
assertThat(encode, instanceOf(SimpleDataRecordType.class));
final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
assertThat(field1.isSetText(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getText().getValue(), is(field1Value));
}
use of org.n52.shetland.ogc.swe.simpleType.SweText in project arctic-sea by 52North.
the class SweCommonEncoderv20Test method shouldEncodeDataRecordWithSweTextField.
@Test
public void shouldEncodeDataRecordWithSweTextField() throws OwsExceptionReport, EncodingException {
final SweDataRecord record = new SweDataRecord();
record.addField(new SweField("text", new SweText().setValue("textValue").setDefinition("textDef")));
record.addField(new SweField("count", new SweCount().setValue(2).setDefinition("countDef")));
final XmlObject encoded = sweCommonEncoderv20.encode(record);
// validateDocument throws exceptions if the document is invalid
XmlHelper.validateDocument(encoded, EncodingException::new);
}
use of org.n52.shetland.ogc.swe.simpleType.SweText in project arctic-sea by 52North.
the class SweCommonDecoderV101Test method should_decode_Count_with_Quality_Text.
@Test
public void should_decode_Count_with_Quality_Text() throws DecodingException {
final CountDocument xbCount = CountDocument.Factory.newInstance();
final String textValue = "quality-text";
xbCount.addNewCount().addNewQuality().addNewText().setValue(textValue);
final Object decodedObject = new SweCommonDecoderV101().decode(xbCount);
assertThat(decodedObject, is(instanceOf(SweCount.class)));
final SweCount sweCount = (SweCount) decodedObject;
assertThat(sweCount.isSetQuality(), is(true));
assertThat(sweCount.getQuality().size(), is(1));
assertThat(sweCount.getQuality().iterator().next(), is(instanceOf(SweText.class)));
assertThat(((SweText) sweCount.getQuality().iterator().next()).getValue(), is(textValue));
}
use of org.n52.shetland.ogc.swe.simpleType.SweText in project arctic-sea by 52North.
the class FieldDecoderTest method testText.
@Test
public void testText() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.TEXT_TYPE);
SweField field = checkCommon(json, false);
assertThat(field.getElement(), is(instanceOf(SweText.class)));
SweText swe = (SweText) field.getElement();
errors.checkThat(swe.getValue(), is(nullValue()));
}
Aggregations