Batch Import API

Version 34.4 by slauriere on 2021/04/05 00:23

cogAllows to import data from CSV and Excel files in XWiki structured documents.
TypeJAR
Category
Developed by

Anca Paula Luca, Ludovic Dubost

Active Installs120
Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Installable with the Extension Manager

Description

This extension provides a service to import data from the rows of an MS Excel file or a CSV file into structured documents in the wiki.

An interface for this Batch Import API which provides a wizard to import data in applications created with AppWithinMinutes is provided by the Batch Import Application.

If Excel import is wanted, then the Excel plugin needs to be installed in the wiki. If CSV is needed, the open csv library needs to be installed (see installation instructions for more information). 

The import is done based on a mapping of the columns in the file to import and the fields of an XWiki Class and some document metadata that can be set for the document (document fullname, title, tags, etc). 

How to use

To use the batch import, you can use it either as a component from java code, by requesting an implementation of the BatchImport from the component manager, or as a service from velocity or groovy, as services.batchimport (which is backed by an instance of BatchImportService).

The complete javadoc of the batch import API can be found here.

Features

  • Data to be imported can be read from a page attachment, but also from any input stream.
  • CSV separators and text delimiters can be configured.
  • The locale can be specified for the numbers and dates in the source file, any date format can be specified as well as the multiple values separator (for lists of values).
  • Office files from a folder on the server file system can be imported in the content of the created documents, based on a mapping configured in the Excel or CSV file. Any file can be attached to the imported documents based on such a configuration.
  • Multiple data deduplication options can be configured for the import: behavior of the import when two rows in the imported file seem to be mapped on the same wiki document, or when an imported document would overwrite a document already existing in the wiki.
  • Automatic generation of document names can be done based on a user configured prefix.
  • An import preview can be done to verify the mapping and data conversion, as well a simulation of the import of the whole data set.
  • The batch import service provides functions to read the import configuration from the request or from an XWiki object, thus allowing to easily handle parameters configuration and persisting the configurations.
  • Since version 2.3, an option makes it possible to specify whether empty values in the input file should be handled as such and overwrite possibly non-empty values in object properties or document data (title, parent, content), or should be ignored. In previous versions, empty values were always honoured for document data, and ignored for object properties.
  • Detailed and internationalizable logging of the import result.
  • Extensible file readers system, with default implementation for Excel and CSV data source files.
  • Extensible logging system, allowing to write a different logger, if needed.
  • Although out of the scope of the batch import, a function to delete the existing instances of a class is provided, to facilitate the cleanup of the imported instances.

For developers

If you want to write a new connector to a new type of source file, it is enough to implement the ImportFileIterator interface and set the hint of this implementation as the type of import in the BatchImportConfiguration used by the import.

If you want to write a new logger of the import results, the interface to implement is BatchImportLog .

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager).

You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.

  • If Excel import is desired, the Excel Plugin needs to be installed and configured in the wiki.

Release Notes

v1.1

  • Update parent POM to XWiki Commons 4.5.4

Dependencies

Dependencies for this extension (org.xwiki.contrib:xwiki-batchimport-api 2.3):

Get Connected