Import Using the koLibRI JAR Fileยถ

Java Versionยถ

Java8 JDK is recommended to use right from the start!

Downloading the Softwareยถ

  1. Please download at first the configuration and folder ZIP file, where all the needed config files and templates are stored in, and extract it to your preferred working folder.

  2. Furthermore you will need the koLibRI Command Line Java Application prepared for TextGrid import usage. Please put the following JAR into your working folder (please change the filename of the JAR file to kolibri-cli-9.4.2-SNAPSHOT.jar, if not already downloaded as it):

You now should have a folder structure like the following (files concerning import only):

๐Ÿ“ kolibri-addon-textgrid-import
๐Ÿ“ config
๐Ÿ“ koLibRI
  ๐Ÿ“ rewrite
  ๐Ÿ“ transformation
  ๐Ÿ“„ textgrid_metadata_template.xml
  ๐Ÿ“„ tglab_config_test.xml
  ๐Ÿ“„ tglab_config.xml
  ๐Ÿ“„ tgrep_config_test.xml
  ๐Ÿ“„ tgrep_config.xml
๐Ÿ“ folders
  ๐Ÿ“ hotfolder
    ๐Ÿ“ data
  ๐Ÿ“ log
  ๐Ÿ“ metadata-responses
  ๐Ÿ“ temp
๐Ÿ“„ kolibri-cli-9.4.2-SNAPSHOT.jar
๐Ÿ“„ koLiGO.bat
๐Ÿ“„ version.txt

The file version.txt contains the current version of the koLibRI import tool: kolibri-addon-textgrid-import-9.4.2-SNAPSHOT.

Testing the Installationยถ

Step-by-step – testing the test server:

  1. Open the TG-lab and set the confserv to (see Preferences > TextGridLab Server / Proxy > Configuration Service URI) and let the TG-lab restart.
  2. Login to the newly restarted TG-lab and get a Session ID for the test server (see Help > Authentication > The current session ID) and copy the ID, should be something like: JTSFa5Gw4s2SAasi6Efo69V3r3j9oRH6zC9SxtaZatbMKQhxHm2RVDRym34AQNM3HG79JkI3x91g1580379448667661.
  3. Create a new project in the TG-lab (File > New Project) and also copy the project ID, should be something like: TGPR-8514a3cf-c880-4338-8f3c-5e32b3ed678e.
  4. Copy the two values to your TG-lab import configuration file tglab_config_test.xml and put them as values under projectId and rbacSessionId (see PLEASE INSERT PROJECT ID HERE and PLEASE INSERT RBAC SESSION ID HERE).
  5. Copy a file or a folder as test data into the folders/hotfolder/data folder. Your files will only be available for you and all the persons that you added to your project using the User Management of the TG-lab.
  6. Start the import as described in Starting the koLibRI Workflow Tool.
  7. The console messages should be like:
[INFO]     <DONE>     data  -->  All files have been sucessfully submitted in 41 seconds
[INFO]     The process queue has been processed. Total time elapsed: 837 milliseconds
[INFO]     Everything has been done! This process was logged to file ./kolibri-addon-textgrid-import/folders/log/kolibri.log

If you get no ERRORs in the console output, you should see all the imported files and folders in the TG-lab’s Navigator as objects of your project.


Chosing Configuration File from Templateยถ

There are four template configuration files in the config/ folder, please choose one of the files according to your import plans:


is to be used to import data into the TG-lab, so you can work with your data inside the chosen TextGrid project. The data will not be visible to users other than you and the users you decide to share it with using the TG-lab project management. All non-public services are preconfigured in this file.


is to be used to import directly to the TG-rep. Your data is visible to the public immediately (at first in the TextGrid Repository Sandbox only, and after finally publishing for everyone and everywhere). All public services are preconfigured in this file.

The two _test files please use to import to the test server All public resp. non-public services of the test server are preconfigured in this files.

Editing the Config Fileยถ

Commonly Used Settingsยถ

In the <common><property> section you find the commonly used settings. Please set the config values below accordingly.


Setting the import policy: The parameter defaultPolicyName can address the following policies. Edit the tgrep or tglab config file (tglab_config.xml or tgrep_config.xml) of your choice, and chose a value. Depending on your import policy, other configuration values have to be set, please see below. aggregation_import is the default value and already set.

This policy is used to automatically create TextGrid metadata for each file out of the file name and the detected file format. For every folder a TextGrid aggregation is created and imported, so the folder structure will appear in TextGrid the same as in the import folder itself.
Does everything as aggregation_import. Gets URIs from TG-crud, creates aggregations for every folder, and generates PIDs (if configured so, please only use for public TG-rep). Aggregations and object metadata files can be taken from the appropriate temp folder and then be edited (please DO NOT change filenames of the data and metadata files!) and afterwards put into a new hotfolder and then be imported to the TG-rep or TG-lab using the policy continue_import. You also can change the format of the aggregations to edition or collection. Please refer to the TextGrid Metadata Schema!
If you use this policy, all given files simply are imported, no additional metadata is created, so you need to have a complete set of TextGrid objects including TextGrid metadata. TextGrid URIs are taken from TG-crud whenever needed, so your files must be linked to each other (such as aggregation references) by local file pathes. File extensions for existing TextGrid editions, collections, works, aggregations, XML and metadata files can be configured if needed, but it is recommended to use the default ones and not change them.
Use this policy to continue a broken or stopped import (e.g. in case of an error). Just configure the hotfolder to be the temp folder, the files were processed in.
An already imported set of objects can be deleted from the sandbox again. Uses the TG-crud service directly. This can be used with an URI list (as a file) or by giving a root URI. Please see configuration of the class DeleteFiles.
An already imported set of objects will be finally published. Uses the TG-publish service. This can be used with an URI list (as a file) or by giving a root URI. Please see configuration of the class PublishFiles.
Takes as input one (or more) DFG Viewer METS file according to the DFG Viewer METS Specification and creates a folder structure from the physical and logical StructMap, that then is imported into the TextGrid. MODS and/or TEI metadata will be mapped to TextGrid metadata via existing MODS/TEI XSL transformation files, or can be done via custom XSL files.

<field>rbacSessionId</field> and <field>projectId</field>

Authentication and project settings: Please add the two values with your TextGrid Project ID (projectId) and your Session ID (rbacSessionId).

The TextGrid Session ID you get if you log in to the TextGridLab and chose Help and then Authentication from the TextGridLab’s menu bar. Just copy The current session ID.

A TextGrid project ID you get if you do create a project within the TextGridLab, please chose File and New Project from the menu bar and add project’s name and description. You can then copy the project ID (something like TGPR-aafea537-4daa-358a-c446-5901ee71d8d2) from the newly opened User Management view.

Aggregation Import Configurationยถ

If you are using aggregation_import, just set the data as described above and run the koLibRI.


Choosing a hotfolder: As hotfolder ./folders/hotfolder/ is pre-configured. Just copy your data to publish into the data/ folder. The data is copied before processing starts, so the original data will not be touched. If chosen aggregation_import as policy, please put only ONE folder in the hotfolder containing files and folders to import 8this would be the already existing data/ folder). All those files will be imported in ONE TextGrid project as files and aggregations.

Complete Import Configurationยถ

If you are using complete_import, just set the data as described above and run the koLibRI.


Choosing a hotfolder: As hotfolder ./folders/hotfolder/ is pre-configured. Just copy your data to publish in the data/ folder. The data is copied before processing starts, so the original data will not be touched. All data will exactly be imported as prepared by the user. Please note that you do also need metadata files according to the TextGrid Metadata Schema. Everything else works according to the aggregation import hotfolderDir documentation.


Set this flag to true if you want to import new revisions of all your (existing) files to TG-lab or TG-rep. It is recommended testing this on the test system first, it is not yet deployed on the productive system. Some issues to be noted:

  • At revision import all objects must have TextGrid URIs instead of local file pathes. You need to have revision URIs!
  • Only the existing files can be revisioned, new files must still be coped with
  • Old PIDs are being replaced by new ones for each to be revisioned
  • PIDs must still be added to the TEI files. Where could we do that? Maybe koLibRI could add them to each TEI file? Or just add the TextGrid URI to the corresponding file and rewriting in koLibRI does the rest (GetPidsAndRewrite)?
  • Navigator doesn’t show revisioned objects correctly right now
  • Revisions also will not be displayed correctly in the TG-lab’s revision view (right click on Show Revisions)

DFG Viewer METS Import Configurationยถ

If you are using dfgviewermets_import, just set the data as described above and run the koLibRI.


Choosing a hotfolder: As hotfolder ./folders/hotfolder/ is pre-configured. Put all your METS files directly into the hotfolder/ folder. For each METS file there will be created a root Aggregation/Edition/Collection, please see below. It is possible to put more than one METS file into the hotfolder. koLibRI then processes the import concurrently with a configurable number of threads (please see general configuration options in the koLibRI configuration file).


DFG Viewer aggregations: For DFG Viewer Import you can chose the format of your root aggregation (there is one root aggregation for every METS file). It can be chosen to be imported as a TextGrid Aggregation (text/tg.aggregation+xml), Edition (text/tg.edition+tg.aggregation+xml) or Collection (text/tg.collection+tg.aggregation+xml).

Please note: Custom XSLT stylesheets for metadata creation can be specified in the properties of <class name=”actionmodule.textgrid.DfgViewerMetadataProcessor”>.

Publish Configurationยถ

In <modules><class name=”actionmodule.textgrid.PublishFiles”> you can find the configuration for the final publishing process of sand-boxed objects. To finally publish your objects after sandbox publishing - every koLibRI import is published to the sandbox first - you must use the policy publish_import.


Please use import mapping file location, project ID, or root URI of TextGrid object to assemble TextGrid objects to be published, please use one of the following:

<value>file:./folders/temp/1470065621459_data_URI.imex</value> (URI mapping file)
<value>file:./folders/temp/1470065621459_data_PID.imex</value> (PID mapping file)
<value>textgrid:12345.0</value> (TextGrid URI)
<value>project:TGPR-f1867520-4a53-9ced-9da5-503762ba0f61</value> (project ID)

If you are using a TextGrid URI as an object URI, all objects of an edition or collection are being published, including the collection itself. If a single TextGrid item is referenced (no aggregation), only this item will be published.


Use to check what will happen before publishing anything (recommended)! Will not publish anything unless set to false.

Delete Configurationยถ

In <modules><class name=”actionmodule.textgrid.DeleteFiles”> you can find the configuration for the deletion of objects. Already published data can still be deleted, if it was imported into the TextGrid Sandbox and has not yet been finally published using the publish_import policy. To delete objects (in general or from the sandbox), change the policy to delete_import.


Please use import mapping file, project ID, or root URI of TextGrid object to assemble TextGrid objects to be deleted, please use one of the following:

<value>file:./folders/temp/1470065621459_data_URI.imex</value> (URI mapping file)
<value>file:./folders/temp/1470065621459_data_PID.imex</value> (PID mapping file)
<value>textgrid:12345.0</value> (TextGrid URI)
<value>project:TGPR-f1867520-4a53-9ced-9da5-503762ba0f61</value> (project ID)

If using TextGrid URI as object URI, all objects of an edition or collection are being deleted, including the collection itself. If a single TextGrid item is referenced (no aggregation), only this item will be deleted.


Use to check what will happen before deleting anything. Will not delete anything unless set to false (recommended)!

Configuring Rewriting of local file pathes and TextGrid URIsยถ

In two modules local file pathes are rewritten to TextGrid URIs (RenameAndRewrite) respective TextGrid URIs to Handle PIDs (GetPidsAndRewrite) in TEI files. This TEI file rewrite can now be configured via custom rewrite files (such as config/rewrite/grenzboten-tei.xml). You can now specify an XML configuration in your rewrite file and address it in the import configuration field teiRewriteSpec as value file:./config/rewrite/grenzboten-tei.xml#tei. The <rw:xmlConfiguration xml:id=”tei” ...> is now used for rewriting local file pathes or TextGrid URIs to TextGrid URIs or Handle PIDs.

Editing the Metadata Template Fileยถ

The config file for the metadata generation used by some policies such as aggregation_import and dfgviewermets_import in module textgrid.TextgridMetadataProcessor (textgrid_metadata_template.xml) is used for the creation of metadata for every file to be imported! The metadata stated in this file is used for metadata file creation and can be edited according to the TextGrid Metadata Schema. Metadata not fitting in the schema will not be accepted.

Logging and Keepingยถ

All imports are logged to the file /folders/log/kolibri.log. Please keep all the folders in the /folders/temp/ folder, and especially all the files with suffix _URI.imex for later publication or deletion policies. If PIDs are created, the PID mapping is stored to _PID.imex files. These files format is also being used in the TG-lab import and export module.

Change More Parameters?ยถ


There is some more information for every config file value in the description tags of each value in the config file’s module class definitions. But: Do not change anything else unless you are REALLY sure about it!

Hints and Tricksยถ

If as hotfolder is given a directory with files contained only the import will do nothing, because the koLibRI will import the one and only directory from WITHIN the hotfolder. If you want to import the files contained in the hotfolder, too, just set the readDirectoriesOnly flag of the processstarter.MonitorHotfolder to FALSE! Beware: All rewriting will be restricted to single files now (so no rewriting will happen at all!) because every file will be handled one after another!

Starting the koLibRI Workflow Toolยถ

If everything is configured correctly and all the data is copied, koLibRI can be started. Change into your work directory kolibri-addon-textgrid-import containing the JAR file, the config and folder directories and the koLiGO scripts and type

./ config/tglab_config.xml

in a Linux console and MAX OS terminal or

koLiGO.bat config\tglab_config.xml

in a Windows/DOS command shell.

You can use a special Linux Bash import script that shows console progress bars for the aggregation_import policy, very useful to monitor the progress of the import of a large amount of data respective a huge amount of files. The process is logged to a file nohup.out then and uses the output for showing the progress bars. Please use it as follows instead of the script:

nohup ./ config/tgrep_config.xml & sleep 2; ./

Please do not forget to delete old nohup.out files bofore starting a new import process!

If you do need more memory for your koLibRI import, you possibly get an error like java.lang.OutOfMemoryError: GC overhead limit exceeded, then please increase the -Xmx value of your koLiGO script. This depends on your computer’s memory, please just try to use 4096M or even more...

You can check the status of your imports either in the TextGridLab’s project you imported in or in the TextGridRep Sandbox, depending on your configuration. For using the correct charsets (depending on your local charset configuration some special chars, such as รถ, รค, รผ, may not be correctly processed), the -D trigger in the koLiGO scripts already are set to UTF-8. Furthermore you are allowed to use more then the default 50.000 XML child objects, so we set this to 500.000, as needed for handling projects with many objects.