In this post I will explain how I created a very useful reusable Mendix module for the following user story:
As an admin I want to export some of the application’s data, so that I can easily import it in other environments of the same application.
In Mendix, you can create specific export functionality for your entities, using Domain-to-XML-mappings. However, this is a lot of work for and you would need to develop this specifically to the domain model for each application (or even multiple exports within a single application). Another drawback of this approach is that you can only export a simple tree structure. More complex reference structures, like circular references, are not easy to do: to get an idea of what I mean, look at how the export/import functionality of the DBReplication module in the Mendix app store is implemented.
I wanted to create a generic way to export data. Simply selecting the entities and associations of the objects that you want to export should be enough.
The (meta-)domain model
I created the following domain model that will be used to contain the data for exporting and importing. It is basically an abstraction of the Mendix object model: