Would the following work?
Create a new NPE called ExportedDataSource with the fields from all of the generalizations and specializations and an associated ExportedDataSources NPE.
Create the JSON structure below
{
"Name": "",
"ExportedDataSources": [
{
"Name": "",
"Delimiter": "",
"SheetName": ""
}
]
}
Import mapping below
Mapping microflow and sub microflow below
Then you can set the fields on the ExportedDataSource based on the specialization. If the specialization is a CSV entity then set the ExportedDataSource.SheetName field to the CSV.SheetName field.
It turns out Mendix can handle any number and combination of generalized, related objects. Unfortunately it doesn’t know how to do this via a message definition. So I created a JSON string like this (here you can see all 4 types (DB, API, CSV, and Excel)). Note that each data source expects a list. This allows for multiple for any data source but also is forgiving if there are none for any one data source (then it just generates an empty array [])
This allowed me to generate an export mapping pretty easily. I just had to add the generalized entities to each corresponding JSON object in the mapping (ignoring the empty objects it created). The import used the same JSON structure. Similarly (but slightly different) for the import I ignored the object name when selecting list elements.
Not 4! but only 4^2 combinations. But still a problem.
What mapping does mendix studio pro generate when you create a message_definition, add entity DataSource to it and create a mapping via button Generate Mappings?
Thanks for the feedback and correcting my math :) I did what you asked - certainly not what I expected - unfortunately I don't think this will help:
I was also curious so I tried with CSV entity as well:
If you’re not forced to use JSON, XML might be an option.
You can define an XML Schema with an xs:choice element. Then you can map the specialisations in an export mapping.
regards, Fabian