How to export/import from specializations

1
I have a module based on the Questionnaire module from the App Store and I would like to be able to export questionnaire configurations from one server to another. I have looked at the export/import functionality for templates in the Excel Importer module and tried to use similar workflow, with partial success. I created a temporaty web service to create an XSD for the QuestionnaireConfig and associated forms, and then created export and import mappings based on it. This partially works as I can export the XML file, then import it to create new records. However, the questionnaire ElementConfig records to be created should each be a specialization of the ElementConfig entity, based on the value in ElementConfigType attribute. I addressed this by using a microflow in the Import Mapping that looks at the value in the ElementConfigType data and creates the correct specialization - this also works OK. My problem is that the specializations have extra attributes that do not exist in the generalization (ElementConfig), such as Option values linked to List-type elements. This data does not exist in my Export mappings, so I cannot import it. Does anyone know how to address this issue - is there any way when defining the XML export template to include the extra attributes that are part of any specializations? Thanks for any suggestions. Update: I believe a new version (v3) of the Questionnaire module has been released today incorporating the new functionality I added to import and export questionnaire config templates.
asked
1 answers
5

I believe you'd have to modify the XSD manually according to your needs. Using the "choice" tag would allow the modeler to create import and export mappings with inheritance.

For example, if you consider the case where you have a general object Car and two specializations: SUV and Sedan

When you export the XSD that exposes a car, which will have a line like:

<xsd:element name="Car" minOccurs="0">...</xsd:element>

Inside these element tags you'll see each of the entity's attributes. Around the element tag, add the choice tag:

<xsd: choice>
   <xsd:element name="Car" minOccurs="0">...</xsd:element>
</xsd:choice>

Then you can add the specializations of Car. You could auto-generate the XSD schema for each of these elements using the modeler, or create them manually:

<xsd: choice>
   <xsd:element name="Car" minOccurs="0">...</xsd:element>
   <xsd:element name="SUV" minOccurs="0">...</xsd:element>
   <xsd:element name="Sedan" minOccurs="0">...</xsd:element>
</xsd:choice>

When you importing this XSD into the modeler and create an import or export mapping, the choice elements can be mapped using inheritance (note I excluded SUV here):

screenshot

answered