use of org.geotoolkit.swe.xml.v101.AbstractDataComponentType 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 AbstractEncodingType) {
SweAbstractEncoding absEncoding = parseEncoding((AbstractEncodingType) element);
TextEncodingDocument absEncodingDoc = TextEncodingDocument.Factory.newInstance(getXmlOptions());
absEncoding.setXml(absEncodingDoc.xmlText(getXmlOptions()));
return absEncoding;
} 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 org.geotoolkit.swe.xml.v101.AbstractDataComponentType in project arctic-sea by 52North.
the class SweCommonEncoderv101 method createFieldForSimpleDataRecord.
private AnyScalarPropertyType createFieldForSimpleDataRecord(SweField sweField) throws EncodingException {
SweAbstractDataComponent element = sweField.getElement();
AnyScalarPropertyType xbField = AnyScalarPropertyType.Factory.newInstance(getXmlOptions());
if (sweField.isSetName()) {
xbField.setName(sweField.getName().getValue());
}
AbstractDataComponentType xbDCD;
if (element != null) {
if (element instanceof SweBoolean) {
xbDCD = xbField.addNewBoolean();
xbDCD.set(createSimpleType((SweBoolean) element));
} else if (element instanceof SweCategory) {
xbDCD = xbField.addNewCategory();
xbDCD.set(createSimpleType((SweCategory) element));
} else if (element instanceof SweCount) {
xbDCD = xbField.addNewCount();
xbDCD.set(createSimpleType((SweCount) element));
} else if (element instanceof SweQuantity) {
xbDCD = xbField.addNewQuantity();
xbDCD.set(createSimpleType((SweQuantity) element));
} else if (element instanceof SweText) {
xbDCD = xbField.addNewText();
xbDCD.set(createSimpleType((SweText) element));
} else if (element instanceof SweTime) {
xbDCD = xbField.addNewTime();
xbDCD.set(createSimpleType((SweTime) element));
} else {
throw new EncodingException("The element type '%s' of the received %s is not supported by this encoder '%s'.", new Object[] { element.getClass().getName(), sweField.getClass().getName(), getClass().getName() });
}
}
return xbField;
}
use of org.geotoolkit.swe.xml.v101.AbstractDataComponentType in project arctic-sea by 52North.
the class InsertResultTemplateRequestEncoderTest method shouldEncodeResultStructure.
@Test
public void shouldEncodeResultStructure() throws EncodingException {
ResultTemplateType template = ((InsertResultTemplateDocument) encoder.create(request)).getInsertResultTemplate().getProposedTemplate().getResultTemplate();
assertThat(template.getResultStructure(), Matchers.notNullValue());
AbstractDataComponentType abstractDataComponent = template.getResultStructure().getAbstractDataComponent();
assertThat(abstractDataComponent, Matchers.notNullValue());
assertThat(abstractDataComponent, Matchers.instanceOf(DataRecordType.class));
DataRecordType xbResultStructure = (DataRecordType) abstractDataComponent;
assertThat(xbResultStructure.getFieldArray().length, Is.is(1));
assertThat(xbResultStructure.getFieldArray(0), Matchers.instanceOf(Field.class));
assertThat(xbResultStructure.getFieldArray(0).getName(), Is.is(field1Name));
assertThat(xbResultStructure.getFieldArray(0).getAbstractDataComponent(), Matchers.instanceOf(TimeType.class));
TimeType xbTime = (TimeType) xbResultStructure.getFieldArray(0).getAbstractDataComponent();
assertThat(xbTime.getDefinition(), Is.is(field1Definition));
assertThat(xbTime.getUom().getCode(), Is.is(field1Uom));
}
use of org.geotoolkit.swe.xml.v101.AbstractDataComponentType in project arctic-sea by 52North.
the class SensorMLEncoderv101 method addIoComponentPropertyType.
/**
* Adds a SOS SWE simple type to a XML SML IO component.
*
* @param ioComponentPropertyType
* SML IO component
* @param sosSMLIO
* SOS SWE simple type.
*
* @throws EncodingException
* if the encoding fails
*/
private void addIoComponentPropertyType(IoComponentPropertyType ioComponentPropertyType, SmlIo sosSMLIO) throws EncodingException {
ioComponentPropertyType.setName(sosSMLIO.getIoName());
if (sosSMLIO.isSetHref()) {
ioComponentPropertyType.setHref(sosSMLIO.getTitle());
if (sosSMLIO.isSetTitle()) {
ioComponentPropertyType.setTitle(sosSMLIO.getTitle());
}
} else {
XmlObject encodeObjectToXml;
XmlObject xml = encodeObjectToXml(SweConstants.NS_SWE_101, sosSMLIO.getIoValue());
if (xml instanceof DataArrayDocument) {
encodeObjectToXml = ((DataArrayDocument) xml).getDataArray1();
} else {
encodeObjectToXml = xml;
}
sosSMLIO.getIoValue().accept(new SweDataComponentAdder(ioComponentPropertyType)).map(h -> (AbstractDataComponentType) h.set(encodeObjectToXml)).ifPresent(h -> sosSMLIO.getIoValue().accept(new SweDataComponentSubstituter(h)));
}
}
use of org.geotoolkit.swe.xml.v101.AbstractDataComponentType in project arctic-sea by 52North.
the class SweCommonEncoderv101 method createSimpleType.
private AbstractDataComponentType createSimpleType(SweAbstractSimpleType<?> sosSimpleType, EncodingContext additionalValues) throws EncodingException {
AbstractDataComponentType abstractDataComponentType = null;
if (sosSimpleType instanceof SweBoolean) {
abstractDataComponentType = createBoolean((SweBoolean) sosSimpleType);
} else if (sosSimpleType instanceof SweCategory) {
abstractDataComponentType = createCategory((SweCategory) sosSimpleType);
} else if (sosSimpleType instanceof SweCount) {
abstractDataComponentType = createCount((SweCount) sosSimpleType);
} else if (sosSimpleType instanceof SweCountRange) {
abstractDataComponentType = createCountRange((SweCountRange) sosSimpleType);
} else if (sosSimpleType instanceof SweObservableProperty) {
abstractDataComponentType = createObservableProperty((SweObservableProperty) sosSimpleType);
} else if (sosSimpleType instanceof SweQuantity) {
abstractDataComponentType = createQuantity((SweQuantity) sosSimpleType);
} else if (sosSimpleType instanceof SweQuantityRange) {
abstractDataComponentType = createQuantityRange((SweQuantityRange) sosSimpleType);
} else if (sosSimpleType instanceof SweText) {
abstractDataComponentType = createText((SweText) sosSimpleType);
} else if (sosSimpleType instanceof SweTimeRange) {
abstractDataComponentType = createTimeRange((SweTimeRange) sosSimpleType);
} else if (sosSimpleType instanceof SweTime) {
abstractDataComponentType = createTime((SweTime) sosSimpleType);
} else {
throw new NotYetSupportedEncodingException(SweAbstractSimpleType.class.getSimpleName(), sosSimpleType);
}
addAbstractDataComponentValues(abstractDataComponentType, sosSimpleType);
return abstractDataComponentType;
}
Aggregations