use of net.opengis.swe.x20.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();
Assert.assertThat(template.getResultStructure(), Matchers.notNullValue());
AbstractDataComponentType abstractDataComponent = template.getResultStructure().getAbstractDataComponent();
Assert.assertThat(abstractDataComponent, Matchers.notNullValue());
Assert.assertThat(abstractDataComponent, Matchers.instanceOf(DataRecordType.class));
DataRecordType xbResultStructure = (DataRecordType) abstractDataComponent;
Assert.assertThat(xbResultStructure.getFieldArray().length, Is.is(1));
Assert.assertThat(xbResultStructure.getFieldArray(0), Matchers.instanceOf(Field.class));
Assert.assertThat(xbResultStructure.getFieldArray(0).getName(), Is.is(field1Name));
Assert.assertThat(xbResultStructure.getFieldArray(0).getAbstractDataComponent(), Matchers.instanceOf(TimeType.class));
TimeType xbTime = (TimeType) xbResultStructure.getFieldArray(0).getAbstractDataComponent();
Assert.assertThat(xbTime.getDefinition(), Is.is(field1Definition));
Assert.assertThat(xbTime.getUom().getCode(), Is.is(field1Uom));
}
use of net.opengis.swe.x20.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;
}
use of net.opengis.swe.x20.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)));
}
}
Aggregations