Getting RDF out of Ingestion 2

Here's a cookbook for getting Turtle-format (ttl) RDF data out of Ingestion 2, one file per record. This is useful for moving data to other systems; for example, Ingestion 3.

Assumptions:

  • You can use the Krikri Rails console, and have already used the necessary comands to find the Activity that represents the records that you want.
  • You can create a directory on the Heidrun application server's filesystem, like /var/tmp/rdf-files and make it owned by the Heidrun application's user.

Modify this as necessary and then copy and paste it into the Rails console:

# Here the example activity is 220, a mapping.
Krikri::Activity.find(220).entity_uris.take(1000).each { |u|
  agg = DPLA::MAP::Aggregation.new(u)
  agg.get
  id = agg.id.split('/').last
  # Assume /var/tmp/rdf-files has been created and is owned by dpla:dpla
  File.open("/var/tmp/rdf-files/#{id}.ttl", 'w') { |file|
    file.write(agg.to_ttl)
    file.close
  }
}