Optimal Sync source
This article is meant to describe the source of Optimal Sync, a data migration and transformation utility.
Optimal sync dictionary
- References - A reference means a reference to position in a dataset where a specific data field is found.
In an XML-file, it is an XPath, like /customers@id. In a database it is the column name CustomerId. In a spreadsheet, "Column_1".
Initialization - optimal_sync.py
optimal_sync.py is the main file. It can either either be run as a CLI script or a GUI application.
- Parses input arguments
- It then either runs a specified merge(qal.tools.merge) operation, or launches the GUI to let the user define one.
GUI - main_tk_replicator.py
The main GUI-class is the gui.main_tk_replicator.ReplicatorMain class and is instantiated by the aforementioned main script. It is responsible for loading and saving, and creating all static widgets(see the init_GUI()-function).
To help the user make the correct mappings and transformations, the data is displayed with the metadata as soon as it has been loaded. The system will not attempt to load the data unless check_prerequisites_for_reload() returns true.
So first, there is the actual data from the source and destination datasets(ReplicatorMain.fr_*_dataset.dataset). This data is shown in the mapping frames and refreshed by the update_data() function, which also update mappings and executes transformations for the current data row.
Secondly, there is the metadata:
- Source and destination dataset settings(database name/file name, credentials and so on).
- Field mappings - Contain mappings between references in the source and destination datasets.
- Transformations - Holds the rules for a data transformation.
All dataset frames inherit their base behaviour from gui.frame_dataset_custom.FrameCustomDataset.
The gui.frame_mapping.FrameMapping class holds the mappings. Their content is seen in the mappings list.
All transformation frames inherit their base behaviour from gui.frame_transformations.FrameTransformationCustom. Aside from general settings, they have a status field that reports the result of the operation, that is inherited from gui.frame_list.FrameCustomItem
The gui.frame_list.FrameList class is used for all lists in the application that contains frames. Each item in the list consists of a FrameListItem that holds a frame with, for example, the property frame(fr_item). Also it has a fr_control property that holds the navigation widgets. FrameList have several events that are implemented by a master widget, lige on_delete and so forth.