The Data Exchange API¶
The following functions you can use within your model, are exposed by the Data Exchange library.
-
dex::AddMapping
(mappingName, mappingFile)¶ Parses
mappingFile
to create a mapping calledmappingName
.- Arguments
mappingName – the name of the mapping to be created
mappingFile – the relative path to the mapping file to be parsed.
-
dex::ReadFromFile
(dataFile, mappingName, emptyIdentifiers, emptySets, resetCounters)¶ Reads data from file
dataFile
into model identifiers using mappingmappingName
. Note that the identifiers used in theincluded-mapping
andwrite-filter
will not be emptied, regardless of theemptyIdentifiers
argument. When the mapping contains an theincluded-mapping
or theiterative-existing
attributes, emptying sets is likely to cause problems, unless the domain sets referred in these attributes are defined.- Arguments
dataFile – the relative path to the data file to be read
mappingName – the name of the mapping to be used
emptyIdentifiers – indicates whether all identifiers referred in the mapping should be emptied prior to reading the file
emptySets – indicates whether all domain and range sets referred in the mapping should be emptied prior to reading the file
resetCounters – indicates whether to reset all counters for
iterative-binds-to
indices prior to reading the file
-
dex::WriteToFile
(dataFile, mappingName, pretty)¶ Writes file
dataFile
from data in model identifiers using mappingmappingName
.- Arguments
dataFile – the relative path to the data file to write to
mappingName – the name of the mapping to be used for writing
pretty – indicates whether to use a pretty writer (enhances readibility at the cost of bigger file size)
-
dex::ReadAllMappings
()¶ Read all mappings contained in the folder
Mappings
and store all successfully read mappings in the setdex::Mappings
.
-
dex::ReadAnnotations
()¶ Read all
dex::Dataset
,dex::TableName
, anddex::ColumnName
annotations specified in the model, and use these annotations to fill the identifiersdex::Datasets
dex::Tables
dex::Columns
dex::DatasetTableMapping
dex::ColumnName
dex::DatasetTableColumnName
dex::DatasetTableColumnIndex
dex::DatasetTableColumnIdentifier
When every table can needs to be included in just a single dataset, you can uniquely specify the dataset-table mapping using annotations only. If tables need to be included in multiple datasets, you can manually modify the identifier
dex::DatasetTableMapping
to add any table to the datasets you wish to include them in.
-
dex::GenerateDatasetMappings
()¶ Generate standardized table and Excel sheet mappings based on the
dex::Dataset
,dex::TableName
, anddex::ColumnName
annotations. The generated mappings will be stored in theMappings/Generated
subfolder of the project folder. All generated mappings will automatically be added to the set of available mappings, and can be directly used to read and write the standardized JSON, XML, CSV or Excel data sources based on the data exchange annotations.You can influence how mappings will be generated through:
dex::DatasetDenseMappings
: when a row will be written, determines wither all columns in that row will be written (default), or only the columns containing a non-default valuedex::DatasetXMLAttributeMappings
: determines whether the generated XML format will write all values as XML attribute values (default) or as element values. Indices will always be written as XML attributes.
You can use the generated mappings directly with the functions
dex::WriteToFile()
anddex::ReadFromFile()
as with any manually created mapping.