use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class SweCommonDecoderV101 method parseQuantityRange.
private SweQuantityRange parseQuantityRange(QuantityRange xbQuantityRange) throws DecodingException {
SweQuantityRange sosQuantityRange = new SweQuantityRange();
if (xbQuantityRange.isSetAxisID()) {
sosQuantityRange.setAxisID(xbQuantityRange.getAxisID());
}
if (xbQuantityRange.isSetDefinition()) {
sosQuantityRange.setDefinition(xbQuantityRange.getDefinition());
}
if (xbQuantityRange.isSetDescription()) {
sosQuantityRange.setDescription(xbQuantityRange.getDescription().getStringValue());
}
if (xbQuantityRange.isSetUom() && xbQuantityRange.getUom().isSetCode()) {
sosQuantityRange.setUom(xbQuantityRange.getUom().getCode());
}
if (xbQuantityRange.isSetValue()) {
try {
List<?> value = xbQuantityRange.getValue();
BigDecimal rangeStart = new BigDecimal(value.get(0).toString());
BigDecimal rangeEnd = new BigDecimal(value.get(1).toString());
sosQuantityRange.setValue(new RangeValue<>(rangeStart, rangeEnd));
} catch (final NumberFormatException | NullPointerException | IndexOutOfBoundsException nfe) {
throw createParsingException(nfe);
}
}
if (xbQuantityRange.isSetConstraint()) {
LOGGER.error("Decoding of swe:QuantityRange/swe:constraint is not implemented");
}
if (xbQuantityRange.getQualityArray() != null && xbQuantityRange.getQualityArray().length > 0) {
LOGGER.error("Decoding of swe:QuantityRange/swe:quality is not implemented");
}
return sosQuantityRange;
}
use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class SweCommonDecoderV101 method parseTimeRange.
private SweTimeRange parseTimeRange(TimeRange timeRange) throws DecodingException {
SweTimeRange sosTimeRange = new SweTimeRange();
if (timeRange.isSetValue()) {
RangeValue<DateTime> range = new RangeValue<>();
Iterator<?> iter = timeRange.getValue().iterator();
if (iter.hasNext()) {
range.setRangeStart(DateTimeHelper.parseIsoString2DateTime(iter.next().toString()));
while (iter.hasNext()) {
range.setRangeEnd(DateTimeHelper.parseIsoString2DateTime(iter.next().toString()));
}
}
sosTimeRange.setValue(range);
}
if (timeRange.getUom() != null) {
sosTimeRange.setUom(timeRange.getUom().getHref());
}
return sosTimeRange;
}
use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class SweCommonDecoderV20 method parseAbstractDataComponent.
private SweAbstractDataComponent parseAbstractDataComponent(AbstractDataComponentType abstractDataComponent) throws DecodingException {
SweAbstractDataComponent sosAbstractDataComponent = null;
if (abstractDataComponent instanceof BooleanType) {
sosAbstractDataComponent = parseBoolean((BooleanType) abstractDataComponent);
} else if (abstractDataComponent instanceof CategoryType) {
sosAbstractDataComponent = parseCategory((CategoryType) abstractDataComponent);
} else if (abstractDataComponent instanceof CountRangeType) {
sosAbstractDataComponent = parseCountRange((CountRangeType) abstractDataComponent);
} else if (abstractDataComponent instanceof CountType) {
sosAbstractDataComponent = parseCount((CountType) abstractDataComponent);
} else if (abstractDataComponent instanceof QuantityType) {
sosAbstractDataComponent = parseQuantity((QuantityType) abstractDataComponent);
} else if (abstractDataComponent instanceof QuantityRangeType) {
sosAbstractDataComponent = parseQuantityRange((QuantityRangeType) abstractDataComponent);
} else if (abstractDataComponent instanceof TextType) {
sosAbstractDataComponent = parseText((TextType) abstractDataComponent);
} else if (abstractDataComponent instanceof TimeType) {
sosAbstractDataComponent = parseTime((TimeType) abstractDataComponent);
} else if (abstractDataComponent instanceof TimeRangeType) {
sosAbstractDataComponent = parseTimeRange((TimeRangeType) abstractDataComponent);
} else if (abstractDataComponent instanceof VectorType) {
sosAbstractDataComponent = parseVector((VectorType) abstractDataComponent);
} else if (abstractDataComponent instanceof DataRecordType) {
SweDataRecord sosDataRecord = parseDataRecord((DataRecordType) abstractDataComponent);
DataRecordDocument dataRecordDoc = DataRecordDocument.Factory.newInstance(getXmlOptions());
dataRecordDoc.setDataRecord((DataRecordType) abstractDataComponent);
sosDataRecord.setXml(dataRecordDoc.xmlText(getXmlOptions()));
sosAbstractDataComponent = sosDataRecord;
} else if (abstractDataComponent instanceof DataArrayType) {
SweDataArray sosDataArray = parseDataArray((DataArrayType) abstractDataComponent);
DataArrayDocument dataArrayDoc = DataArrayDocument.Factory.newInstance(getXmlOptions());
dataArrayDoc.setDataArray1((DataArrayType) abstractDataComponent);
sosDataArray.setXml(dataArrayDoc.xmlText(getXmlOptions()));
sosAbstractDataComponent = sosDataArray;
} else {
throw new UnsupportedDecoderXmlInputException(this, abstractDataComponent);
}
if (sosAbstractDataComponent != null) {
if (abstractDataComponent.isSetDefinition()) {
sosAbstractDataComponent.setDefinition(abstractDataComponent.getDefinition());
}
if (abstractDataComponent.isSetDescription()) {
sosAbstractDataComponent.setDescription(abstractDataComponent.getDescription());
}
if (abstractDataComponent.isSetIdentifier()) {
sosAbstractDataComponent.setIdentifier(abstractDataComponent.getIdentifier());
}
if (abstractDataComponent.isSetLabel()) {
sosAbstractDataComponent.setLabel(abstractDataComponent.getLabel());
}
}
return sosAbstractDataComponent;
}
use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class SweCommonDecoderV20 method parseAbstractDataComponentDocument.
private Object parseAbstractDataComponentDocument(final AbstractDataComponentDocument abstractDataComponentDoc) throws DecodingException {
SweAbstractDataComponent sosAbstractDataComponent = parseAbstractDataComponent(abstractDataComponentDoc.getAbstractDataComponent());
sosAbstractDataComponent.setXml(abstractDataComponentDoc.xmlText(getXmlOptions()));
return sosAbstractDataComponent;
}
use of org.n52.svalbard.decode.exception.DecodingException 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);
}
}
Aggregations