Data loaders
Last updated on 13-May-2020 by Jakob Jakobsen Boysen

On this page
With this plugin you can create your own data loader for the Data Upload page and File Upload element on entity pages in Scifeon.
Definition
Data loaders are defined in the contributions.json
file. A data loader is described by the following JSON:
{
"id": "string", // required
"src": "string", // required
"description": "string" // optional
}
id
Used for referencing the data loader.src
The relative path to the data loader implementation.description
An optional description, mainly used for administrators.
A data loader must implement the interface DataLoader
.
Example
In this example a simple data loader accepting JSON-files where the filename starts with "result-" is built. In this implementation, the actual JSON-file is not parsed -- a simple result is just returned. See the custom data loader tutorial for an example of a real life implementation.
Implementation
src/data-loaders/custom-data-loader.ts:
import { DataLoaderPlugin } from 'scifeon-interfaces';
export class CustomDataLoader implements DataLoaderPlugin {
static isMatch(context) {
return context.category === 'JsonImport' && context.fileInfos.every(file => file.filename.startsWith('result-'));
}
getResult() {
return {
entities: [{
eClass: 'BioSequence',
seqData: 'ACGT',
type: 'DNA',
name: 'Custom DNA'
}]
};
}
}
contributions.json
contributions.json
The following snippet defines the data loader, thus making it available for data upload:
{
...
"plugins": [
{
"id": "customDataLoaderId",
"src": "src/dataLoader/custom-data-loader",
"description": "This is a custom data loader.",
"types": ["data_loader"]
}
]
}