Search code examples
rdfowlsesamerdf4j

RDF4J Workbench Add RDF: How do I add multiple files?


I'm using RDF4J Workbench 2.1.2.

System Information
Application Information
Application Name    RDF4J Workbench
Version 2.1.2
Runtime Information
Operating System    Windows 10 10.0 (amd64)
Java Runtime    Oracle Corporation Java HotSpot(TM) 64-Bit Server VM (1.8.0_111)
Process User    gwcox
Memory
Used    315 MB
Maximum 889 MB

I have a set of RDF files containing ontologies I'm working on. Some RDF files import others. For example, my instantiations ontology/RDF file imports the several ontologies defining my classes and relationships.

The RDF files are stored locally, not at the URIs used to identify them. I often need to clear my repository and re-load my ontologies in the process of development and debugging. At present, a half-dozen ontologies need to be loaded for full functionality.

How can I load multiple ontologies stored as local files into my active repository in RDF4J workbench? I can use RDF4J workbench itself or a command line script to do the loading. I know I can manually use the Modify/Add command from the workbench multiple times, but I'd like to reduce it to one command to save time and avoid errors.

Thanks.


Solution

  • RDF4J Workbench itself has no functionality to add multiple files in one go.

    However, if this is something that you need to repeatedly execute, a simple approach is to use the Console, and write a short batch script for it. The script is simply a text file with successive Console commands (one per line). For example:

    open myRepository
    clear
    load /path/to/file1.rdf into urn:context1
    load /path/to/file2.rdf into urn:context2
    

    Then you can simply execute this by doing (from the command line):

    cat script.txt | ./console.sh 
    

    Another way to achieve what you want is to use curl, and to access the RDF4J Server directly via its REST API. For example, to upload a Turtle file to your repository using curl, you'd do something like this:

    curl -X POST -H "Content-type: text/turtle" --data-binary @file.ttl http://localhost:8080/rdf4j-server/repositories/myRepo/statements
    

    Finally, you could of course also write a short Java program, using the RDF4J Repository API to communicate with the server.