# OMERO Import Library

The Import Library is a re-usable framework for building import clients. Several are provided by the OMERO team directly:

- the integrated importer

- Command Line Importer tool

## Components

The primary classes which make up the Import Library are:

- ImportLibrary.java itself, which is the main driver

- ImportCandidates.java which takes file paths and determines the proper files to import

- ImportConfig.java, an extensible mechanism for storing the properties used during import

- ImportEvent.java, the various events raised during import to `IObserver`and `IObservable` implementations

- OMEROMetadataStoreClient.java, the low-level connection to the server

- OMEROWrapper.java, the OMERO adapter for the Bio-Formats `ImageReaders` class

- In OMERO.insight, the main entry point is the importImage method of OMEROGateway.java

- In the CLI, the main entry point is the CommandLineImporter class

## Earlier Import Workflow

Prior to OMERO 5.0, the import workflow was very much client-side. Using the ImportLibrary a client would determine the import candidates and then import the image. The import phase would comprise copying the pixel data to the OMERO data directory, writing the metadata into the database, and optionally copying the original file to the OMERO data directory for archiving.

## FS Managed Repository Import Workflow

From 5.0 the workflow has changed. The client still determines the import candidates but the client-side import process simply uploads the original files to the OMERO data directory and then uses the ManagedRepository service to initiate a server-side import. On the server the import is then completed by writing the metadata into the database. After import, pixel data is accessed directly from the original files using Bio-Formats. This means that data files are no longer duplicated and any nested directory structure is preserved. It also allows OMERO to take advantage of pre-generated pyramids available in some formats e.g. dedicated whole slide imaging formats such as SVS (instead of generating OMERO pyramids).

For full details of the import workflow see Import under OMERO.fs.

## Example

The `CommandLineImporter.java` class shows a straightforward import. An `ErrorHandler` instance is passed both to the `ImportCandidates` constructor (since errors can occur while parsing a directory) and to the `ImportLibrary`. This and other handlers receive `ImportEvents` which notify listeners of the state of the current import.