use of net.opengis.swe.x20.BooleanPropertyType in project arctic-sea by 52North.
the class SweCommonDecoderV20 method decode.
@Override
public Object decode(Object element) throws DecodingException {
if (element instanceof DataArrayPropertyType) {
final DataArrayPropertyType dataArrayPropertyType = (DataArrayPropertyType) element;
return parseAbstractDataComponent(dataArrayPropertyType.getDataArray1());
} else if (element instanceof DataRecordPropertyType) {
final DataRecordPropertyType dataRecordPropertyType = (DataRecordPropertyType) element;
return parseAbstractDataComponent(dataRecordPropertyType.getDataRecord());
} else if (element instanceof AbstractDataComponentDocument) {
return parseAbstractDataComponentDocument((AbstractDataComponentDocument) element);
} else if (element instanceof AbstractDataComponentType) {
return parseAbstractDataComponent((AbstractDataComponentType) element);
} else if (element instanceof Coordinate[]) {
return parseCoordinates((Coordinate[]) element);
} else if (element instanceof AnyScalarPropertyType[]) {
return parseAnyScalarPropertyTypeArray((AnyScalarPropertyType[]) element);
} else if (element instanceof TextEncodingDocument) {
final TextEncodingDocument textEncodingDoc = (TextEncodingDocument) element;
final SweTextEncoding sosTextEncoding = parseTextEncoding(textEncodingDoc.getTextEncoding());
sosTextEncoding.setXml(textEncodingDoc.xmlText(getXmlOptions()));
return sosTextEncoding;
} else if (element instanceof TextEncodingType) {
TextEncodingDocument textEncodingDoc = TextEncodingDocument.Factory.newInstance(getXmlOptions());
TextEncodingType textEncoding = (TextEncodingType) element;
textEncodingDoc.setTextEncoding(textEncoding);
SweTextEncoding sosTextEncoding = parseTextEncoding(textEncoding);
sosTextEncoding.setXml(textEncodingDoc.xmlText(getXmlOptions()));
return sosTextEncoding;
} else if (element instanceof TextPropertyType) {
return parseAbstractDataComponent(((TextPropertyType) element).getText());
} else if (element instanceof CountPropertyType) {
return parseAbstractDataComponent(((CountPropertyType) element).getCount());
} else if (element instanceof BooleanPropertyType) {
return parseAbstractDataComponent(((BooleanPropertyType) element).getBoolean());
} else if (element instanceof CategoryPropertyType) {
return parseAbstractDataComponent(((CategoryPropertyType) element).getCategory());
} else if (element instanceof QuantityPropertyType) {
return parseAbstractDataComponent(((QuantityPropertyType) element).getQuantity());
} else if (element instanceof DataStreamPropertyType) {
return parseDataStream(((DataStreamPropertyType) element).getDataStream());
} else if (element instanceof DataStreamType) {
return parseDataStream((DataStreamType) element);
} else if (element instanceof DataStreamDocument) {
return parseDataStream(((DataStreamDocument) element).getDataStream());
} else if (element instanceof XmlObject) {
throw new UnsupportedDecoderXmlInputException(this, (XmlObject) element);
} else {
throw new UnsupportedDecoderInputException(this, element);
}
}
use of net.opengis.swe.x20.BooleanPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv20 method asPropertyType.
private XmlObject asPropertyType(AbstractDataComponentType type) throws NotYetSupportedEncodingException {
if (type instanceof BooleanType) {
BooleanPropertyType propertyType = BooleanPropertyType.Factory.newInstance();
propertyType.setBoolean((BooleanType) type);
return propertyType;
} else if (type instanceof CountType) {
CountPropertyType propertyType = CountPropertyType.Factory.newInstance();
propertyType.setCount((CountType) type);
return propertyType;
} else if (type instanceof CountRangeType) {
CountRangePropertyType propertyType = CountRangePropertyType.Factory.newInstance();
propertyType.setCountRange((CountRangeType) type);
return propertyType;
} else if (type instanceof QuantityType) {
QuantityPropertyType propertyType = QuantityPropertyType.Factory.newInstance();
propertyType.setQuantity((QuantityType) type);
return propertyType;
} else if (type instanceof QuantityRangeType) {
QuantityRangePropertyType propertyType = QuantityRangePropertyType.Factory.newInstance();
propertyType.setQuantityRange((QuantityRangeType) type);
return propertyType;
} else if (type instanceof TimeType) {
TimePropertyType propertyType = TimePropertyType.Factory.newInstance();
propertyType.setTime((TimeType) type);
return propertyType;
} else if (type instanceof TimeRangeType) {
TimeRangePropertyType propertyType = TimeRangePropertyType.Factory.newInstance();
propertyType.setTimeRange((TimeRangeType) type);
return propertyType;
} else if (type instanceof CategoryType) {
CategoryPropertyType propertyType = CategoryPropertyType.Factory.newInstance();
propertyType.setCategory((CategoryType) type);
return propertyType;
} else if (type instanceof CategoryRangeType) {
CategoryRangePropertyType propertyType = CategoryRangePropertyType.Factory.newInstance();
propertyType.setCategoryRange((CategoryRangeType) type);
return propertyType;
} else if (type instanceof MatrixType) {
MatrixPropertyType propertyType = MatrixPropertyType.Factory.newInstance();
propertyType.setMatrix((MatrixType) type);
return propertyType;
} else if (type instanceof DataArrayType) {
DataArrayPropertyType propertyType = DataArrayPropertyType.Factory.newInstance();
propertyType.setDataArray1((DataArrayType) type);
return propertyType;
} else if (type instanceof DataChoiceType) {
DataChoicePropertyType propertyType = DataChoicePropertyType.Factory.newInstance();
propertyType.setDataChoice((DataChoiceType) type);
return propertyType;
} else if (type instanceof DataRecordType) {
DataRecordPropertyType propertyType = DataRecordPropertyType.Factory.newInstance();
propertyType.setDataRecord((DataRecordType) type);
return propertyType;
} else if (type instanceof TextType) {
TextPropertyType propertyType = TextPropertyType.Factory.newInstance();
propertyType.setText((TextType) type);
return propertyType;
} else if (type instanceof VectorType) {
VectorPropertyType propertyType = VectorPropertyType.Factory.newInstance();
propertyType.setVector((VectorType) type);
return propertyType;
} else {
throw new NotYetSupportedEncodingException(type.getClass().getName(), type);
}
}
use of net.opengis.swe.x20.BooleanPropertyType in project arctic-sea by 52North.
the class InsertObservationRequestEncoderTest method shouldEncodeSwesExtensions.
@Test
public void shouldEncodeSwesExtensions() throws InvalidSridException, ParseException, EncodingException, DecodingException {
String definition = Sos2Constants.Extensions.SplitDataArrayIntoObservations.name();
boolean value = true;
SweBoolean sweBoolean = new SweBoolean();
sweBoolean.setValue(value);
sweBoolean.setDefinition(definition);
SwesExtension<SweBoolean> swesExtension = new SwesExtension<>();
swesExtension.setValue(sweBoolean);
InsertObservationRequest request = createInsertObservationRequest();
request.addExtension(swesExtension);
XmlObject encodedRequest = encoder.create(request);
encodedRequest.xmlText();
XmlHelper.validateDocument(encodedRequest);
InsertObservationType insertObservation = ((InsertObservationDocument) encodedRequest).getInsertObservation();
Assert.assertThat(insertObservation.sizeOfExtensionArray(), Is.is(1));
XmlObject xbExtension = insertObservation.getExtensionArray(0);
Assert.assertThat(xbExtension, Matchers.instanceOf(BooleanPropertyType.class));
BooleanType xbBoolean = ((BooleanPropertyType) xbExtension).getBoolean();
Assert.assertThat(xbBoolean.getDefinition(), Is.is(definition));
Assert.assertThat(xbBoolean.getValue(), Is.is(value));
// no check for observation values, because that MUST be part of OmEncoderv20Test
}
use of net.opengis.swe.x20.BooleanPropertyType in project arctic-sea by 52North.
the class SwesExtensionEncoderv20Test method shouldEncodeSweTypeBoolean.
@Test
public void shouldEncodeSweTypeBoolean() throws EncodingException {
String identifier = "test-identifier";
String definition = "test-definition";
Boolean value = Boolean.TRUE;
SweBoolean sweBoolean = new SweBoolean();
sweBoolean.setDefinition(definition);
sweBoolean.setIdentifier(identifier);
sweBoolean.setValue(value);
SwesExtension<SweBoolean> extension = new SwesExtension<>();
extension.setValue(sweBoolean);
XmlObject encodedObject = encoder.encode(extension);
Assert.assertThat(encodedObject, Matchers.instanceOf(BooleanPropertyType.class));
BooleanType xbBoolean = ((BooleanPropertyType) encodedObject).getBoolean();
Assert.assertThat(xbBoolean.getDefinition(), Is.is(definition));
Assert.assertThat(xbBoolean.getIdentifier(), Is.is(identifier));
Assert.assertThat(xbBoolean.getValue(), Is.is(value));
}
Aggregations