use of net.opengis.swe.x20.DataRecordDocument 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 net.opengis.swe.x20.DataRecordDocument in project arctic-sea by 52North.
the class GetResultTemplateResponseEncoder method createResultStructure.
private ResultStructure createResultStructure(SosResultStructure resultStructure) throws EncodingException {
// TODO move encoding to SWECommonEncoder
final DataRecordDocument dataRecordDoc;
if (resultStructure.isEncoded()) {
try {
dataRecordDoc = DataRecordDocument.Factory.parse(resultStructure.getXml().get());
} catch (XmlException ex) {
throw unsupportedResultStructure(ex);
}
} else {
XmlObject xml = encodeSwe(EncodingContext.of(XmlBeansEncodingFlags.DOCUMENT), resultStructure.get().get());
if (xml instanceof DataRecordDocument) {
dataRecordDoc = (DataRecordDocument) xml;
} else {
throw unsupportedResultStructure();
}
}
ResultStructure xbResultStructure = ResultStructure.Factory.newInstance(getXmlOptions());
xbResultStructure.addNewAbstractDataComponent().set(dataRecordDoc.getDataRecord());
XmlHelper.substituteElement(xbResultStructure.getAbstractDataComponent(), dataRecordDoc.getDataRecord());
return xbResultStructure;
}
use of net.opengis.swe.x20.DataRecordDocument in project arctic-sea by 52North.
the class SweCommonEncoderv101 method encode.
@Override
public XmlObject encode(Object element, EncodingContext context) throws EncodingException {
XmlObject encodedObject = null;
if (element instanceof SweAbstractSimpleType) {
encodedObject = createSimpleType((SweAbstractSimpleType<?>) element, context);
// }
// if (element instanceof SweBoolean) {
// encodedObject = createBoolean((SweBoolean) element);
// } else if (element instanceof SweCategory) {
// encodedObject = createCategory((SweCategory) element);
// } else if (element instanceof SweCount) {
// encodedObject = createCount((SweCount) element);
// } else if (element instanceof SweObservableProperty) {
// encodedObject = createObservableProperty((SweObservableProperty)
// element);
// } else if (element instanceof SweQuantity) {
// encodedObject = createQuantity((SweQuantity) element);
// } else if (element instanceof SweQuantityRange) {
// encodedObject = createQuantityRange((SweQuantityRange) element);
// } else if (element instanceof SweText) {
// encodedObject = createText((SweText) element);
// } else if (element instanceof SweTime) {
// encodedObject = createTime((SweTime) element);
// } else if (element instanceof SweTimeRange) {
// encodedObject = createTimeRange((SweTimeRange) element);
} else if (element instanceof SweCoordinate) {
encodedObject = createCoordinate((SweCoordinate<?>) element);
} else if (element instanceof SweDataArray) {
encodedObject = createDataArray((SweDataArray) element);
} else if (element instanceof SweDataRecord) {
DataRecordType drt = createDataRecord((SweDataRecord) element);
if (context.has(XmlBeansEncodingFlags.DOCUMENT)) {
DataRecordDocument drd = DataRecordDocument.Factory.newInstance(getXmlOptions());
drd.setDataRecord(drt);
encodedObject = drd;
} else {
encodedObject = drt;
}
} else if (element instanceof SweEnvelope) {
encodedObject = createEnvelope((SweEnvelope) element);
} else if (element instanceof SweSimpleDataRecord) {
encodedObject = createSimpleDataRecord((SweSimpleDataRecord) element);
} else if (element instanceof TimePeriod) {
encodedObject = createTimeGeometricPrimitivePropertyType((TimePeriod) element);
} else {
throw new UnsupportedEncoderInputException(this, element);
}
XmlHelper.validateDocument(encodedObject, EncodingException::new);
return encodedObject;
}
use of net.opengis.swe.x20.DataRecordDocument in project arctic-sea by 52North.
the class SweCommonEncoderv20 method asDocument.
private XmlObject asDocument(AbstractDataComponentType type) throws NotYetSupportedEncodingException {
if (type instanceof BooleanType) {
BooleanDocument document = BooleanDocument.Factory.newInstance();
document.setBoolean((BooleanType) type);
return document;
} else if (type instanceof CountType) {
CountDocument document = CountDocument.Factory.newInstance();
document.setCount((CountType) type);
return document;
} else if (type instanceof CountRangeType) {
CountRangeDocument document = CountRangeDocument.Factory.newInstance();
document.setCountRange((CountRangeType) type);
return document;
} else if (type instanceof QuantityType) {
QuantityDocument document = QuantityDocument.Factory.newInstance();
document.setQuantity((QuantityType) type);
return document;
} else if (type instanceof QuantityRangeType) {
QuantityRangeDocument document = QuantityRangeDocument.Factory.newInstance();
document.setQuantityRange((QuantityRangeType) type);
return document;
} else if (type instanceof TimeType) {
TimeDocument document = TimeDocument.Factory.newInstance();
document.setTime((TimeType) type);
return document;
} else if (type instanceof TimeRangeType) {
TimeRangeDocument document = TimeRangeDocument.Factory.newInstance();
document.setTimeRange((TimeRangeType) type);
return document;
} else if (type instanceof CategoryType) {
CategoryDocument document = CategoryDocument.Factory.newInstance();
document.setCategory((CategoryType) type);
return document;
} else if (type instanceof CategoryRangeType) {
CategoryRangeDocument document = CategoryRangeDocument.Factory.newInstance();
document.setCategoryRange((CategoryRangeType) type);
return document;
} else if (type instanceof MatrixType) {
MatrixDocument document = MatrixDocument.Factory.newInstance();
document.setMatrix((MatrixType) type);
return document;
} else if (type instanceof DataArrayType) {
DataArrayDocument document = DataArrayDocument.Factory.newInstance();
document.setDataArray1((DataArrayType) type);
return document;
} else if (type instanceof DataChoiceType) {
DataChoiceDocument document = DataChoiceDocument.Factory.newInstance();
document.setDataChoice((DataChoiceType) type);
return document;
} else if (type instanceof DataRecordType) {
DataRecordDocument document = DataRecordDocument.Factory.newInstance();
document.setDataRecord((DataRecordType) type);
return document;
} else if (type instanceof TextType) {
TextDocument document = TextDocument.Factory.newInstance();
document.setText((TextType) type);
return document;
} else if (type instanceof VectorType) {
VectorDocument document = VectorDocument.Factory.newInstance();
document.setVector((VectorType) type);
return document;
} else {
throw new NotYetSupportedEncodingException(type.getClass().getName(), type);
}
}
Aggregations