Before you get started you will need the data from someone who has it. That is, you will need to get
hold of the Postgres db dump of an OHRM or OHRMs. Unpack those files in the folder ./data
which is
mounted into the container /srv/data
.
docker compose up -d
docker exec -it ohrm-jsonld-exporter-db-1 /bin/bash
psql postgres
create database dhra;
./data/DHRA-sql
(this is on your computer; not inside the container). Inside the container do
the following:
cd /srv/data/DHRA-sql
psql dhra < initialiseDHRA.sql
The OHRM data is now in the database. As the container is backed by a persistent volume in docker you will not need to do these steps again the next time you start the DB unless you remove that volume. Repeat these steps to load more OHRM datasets into this database instance.
To work with the DHRA OHRM:
start the database server if required: docker compose up -d
in one terminal connect to the DB container and then the database:
docker exec -it ohrm-jsonld-exporter-db-1 /bin/bash
psql dhra
in another terminal exec into the linux container that has been started:
docker exec -it ohrm-jsonld-exporter-exporter-1 /bin/bash
npm install
export DB_DATABASE='dhra'
node . -o ./data/dhra-jsonld
node .
./models
folder../exporters
folder. The structure of these is
the same.
export
that
iterates over the rows of the table and writes out a JSON-LD snippet with the data. Those
snippets are then returned back to the main module to insert into the ro crate.for (let row of await models.entity.findAll({ limit: pageSize, offset })) {
const properties = [
...
"elegalno",
["estartdate", 'dateCreated' ],
"esdatemod",
...
In this example the data in the estartdate
column will be written out to a field called
dateCreated
in the JSON-LD snippet.
./index.js
which first runs all of the exporters
and then goes through linking the relationship entities to the respective targets.The repo contains a python script for automatically processing all the OHRMs in a directory, and uploading them to figshare.
The script is designed to work with conda. Create a conda environment using the conda-env.yml
like so:
conda env create --name ohrm-exporter --file=conda-env.yml
conda activate ohrm-exporter
Once you have configured the environment, you can run the script. It requires three pieces of information, the figshare api endpoint, the directory where the OHRMs are stored, and your figshare API token. You can either provide these in the command line, or create a file called .python-config.yml
and store the information there using the following template:
figshare_token: your api token
figshare_endpoint: https://api.figshare.com/v2
ohrm_directory: path/to/ohrms/