0

I am currently working on a project where there is an initial .owl file that contains the base schema for our ontology. We load this file using the Jena API and perform different manipulations on it, such as adding ontology classes and individuals.

We seek to migrate the system to a triple store meaning that, instead of reading and writing .owl files all the time, we wish to load the initial .owl file once and then perform further operations on a server.

I did not quite grasp the concepts explained by the Jena documentation, because they seem to diverge in all directions; what I understood, however, is that we must use Fuseki embedded and Jena TDB for this. I tried the following code (the OntModel parameter in this case contains the schema for our ontology):

public Store(OntModel model) {
    Dataset ds = DatasetFactory.assemble(model);
    File dsDir = new File(ClassLoader.getSystemClassLoader().getResource("ds/")
            .getFile());

    ds.begin(ReadWrite.WRITE);

    server = FusekiServer.create().add(dsDir.getAbsolutePath(), ds).build();
}

This gives me the following error: org.apache.jena.sparql.ARQException: No root found for type <http://jena.hpl.hp.com/2005/11/Assembler#RDFDataset>. Please provide me with some examples of usage.

vladek
  • 577
  • 1
  • 4
  • 17

1 Answers1

2

DatasetFactory.assemble means construct a new model from a description which is also held in RDF (these are called assemblers in Jena).

If you want a Fuseki server, start one and use the UI to create dataset and load a file.

OR

To load data:

Create and load a TDB dataset using the command line tdbloader into a directory "DIRECTORY_NAME". This needs doing only once.

To run the server each time:

Dataset ds = TDBFactory.createDataset("DIRECTORY_NAME");
FusekiServer server = FusekiServer.create().add("/myName", ds).build();
server.start();

and the dataset HTTP SPARQL interface (programmatic) is available at http://localhost:3030/myName.

If you want a query UI, use the full Fuseki server.

AndyS
  • 16,345
  • 17
  • 21
  • I need a triple store but only locally. Do I still need to use Fuseki? Is there a way to use TDB without? – vladek Aug 01 '18 at 12:38
  • Use the dataset `ds` directly (with transactions - see `Txn`). – AndyS Aug 01 '18 at 13:45
  • I still can't manage to load my file. Let's forget it for a second: I have an `OntModel` that contains all the triples and I want all of these triples into my triple store. How do I do it? Please provide an explicit example. – vladek Aug 02 '18 at 08:49
  • An in-process "triple store" is class "Dataset". See "DatasetFactory". – AndyS Aug 02 '18 at 12:30