Transforming Data¶
Data conversion — changing one format to another — is supported using the 'read then write' paradigm; this is where a DataReaderEngine reads Series and Observations, and passes the read information directly to the writer.
sdmx-core framework provides the DataTransformationUtil class to perform the copy function
DataReaderEngine dre = ...;
DataWriterEngine dwe = ...;
DataTransformationUtil.copyData(dre, dwe, DataTransformOptions.getInstance());
Or with the ISeriesObsDataWriterEngine interface
DataReaderEngine dre = ...;
ISeriesObsDataWriterEngine dwe = ...;
DataTransformationUtil.copyData(dre, dwe, DataTransformOptions.getInstance());
The default transformation options are to:
- Reset the DataReaderEngine before the copy, to ensure it is at the start
- NOT to copy the Message Header
- Copy all Datasets
- Copy all Series
- Copy all Observations
- Close the writer on completion
These options can be modified by setting the values on the DataTransformOptions.
DataReaderEngine dre = null;
DataWriterEngine dwe = null;
DataTransformOptions options = DataTransformOptions.getInstance()
.setCloseWriter(false)
.setDatasetLimit(1)
.setIncludeAttributes(false)
.setIncludeObs(false);
//Copy all series keys from source to target
//Ignore observations and all attributes
DataTransformationUtil.copyData(dre, dwe, options);