Developer

Data Loaders

Last updated on 14-Oct-2018 by fnl

Loading Data

Data Loaders are used to load data from files into the Scifeon database. The data is often in a .csv file or similar.

For some data structures Scifeon is already capable of loading the data in. However, for structures not recognized by the default data loaders, a custom data loader has to be built.

Custom Data Loaders

To make an entity panel, a decorator is used. The decorator contains information about the name and type of the plugin.

The code contains the decorator for the fermentation online data loader.

There are several different types of plugins. For custom data loaders we use the DATA_LOADER type.

The match method decides when the panel is shown. The context variable contains information about the current page. If the match method returns true, the data loader can be used with the dataset.

This data loader can only be used if the current page in Scifeon is a fermentation experiment, only 1 file is selected for upload, and the file name contains a "fermentation" prefix and a ".csv" suffix.

The data loader class consists of 2 methods: an init converting the data in the file to Scifeon entities, and a getResult method which simply returns the entities.

Creating Scifeon Entities

The init method is called once a data loader is chosen. This method reads the file and translates it into Scifeon entities.

Below is a code snippet from the fermentation data loader:

Fermentation experiments create huge amounts of data. To save this efficiently in the database, each row of the data matrix is saved in the timeSeries list, which is then converted to a text string.

This is then added to the entity object:

When creating entities, some properties such as eClass and ID are mandatory while properties not present in the data model cannot be created. For a full list of properties, see the data model.

Returning The Entities

The getResult method is used by the view to get the entities meant for upload.