Skip to main content

Import/Export CSV

It is possible to add functionality to import and/or export CSV files for each DataElement. Define the options csv.import and csv.export on the target DataElement, or on a Component or Application to provide the functionality to multiple DataElements.

These options add methods to import/export to the Agent:

StarshipAgent
ExportResult export(ExportQuery exportQuery) {}
ImportResult importFile(ImportFile importFile) {}
Option
csv.import ApplicationApplicationInstanceComponentDataElement

Adds functionality to import CSV files.

(Optionally) Add a value to provide a custom importer implementation. The referenced class should implement the net.democritus.upload.IImporter class.

<options>
<csv.import/>
</options>
<options>
<csv.import>net.demo.CustomStarshipCsvImporter</csv.import>
</options>
Option
csv.export ApplicationApplicationInstanceComponentDataElement

Adds functionality to export CSV files.

(Optionally) Add a value to provide a custom exporter implementation. The referenced class should implement the net.democritus.download.IExporter class.

<options>
<csv.export/>
</options>
<options>
<csv.export>net.demo.CustomStarshipCsvExporter</csv.export>
</options>

The options also add a /data page, where you can upload or download CSV files.

You can add this page to the menu with ref="{componentName}-{dataElementName}-io-page":

<menuitem ref='space-starship-io-page'/>

Export Button

Option
cruds.table.csvExportButton ApplicationApplicationInstanceComponentDataElement

Adds a button to export CSV files to the DataElement Table View.

<options>
<cruds.table.csvExportButton/>
</options>

Merging Behaviour

By default, the CSV import will create a new instance or, if an instance with the same name already exists, overwrite each field.

It is possible to change this behaviour to merge the imported fields with the already present values:

Option
csv.import.merge ApplicationApplicationInstance

Adds merging functionality to imports so that only columns provided in the CSV are updated.

<options>
<csv.import.merge/>
</options>

Disable CSV functionality

The base-components define several csv.import options to enable data provisioning. In case you wish to disable this functionality, use the csv.disable option.

Option
csv.disable ApplicationApplicationInstance

Disables CSV import and export features for the entire Application.

<options>
<csv.disable/>
</options>