Suryansh
Suryansh

Reputation: 11

D2R 0.8.1 integration with Jena TDB

I am using D2R server for RDB to RDF conversion. Now I want to save this rdf into Jena TDB backed dataset while I am using D2R server. In short I want to integrate Jena TDB with D2R.

Code for RDB to RDF conversion is:

public static void main String(args[])
{

  String writeLocation="C:/Users/PJH/Desktop/Destination/";

    // Get the Jena Model view of the D2RQ RDF object.
    Model m = new ModelD2RQ("C:/Users/PJH/desktop/d2rq-0.8.1/d2rq-0.8.1/doc/example/mapping-iswc.ttl");


    //Writing into a file.
    // writeLocation="C:/Users/PJH/Desktop/Destination/";
    System.out.println("HIiiiiiiiiiiii");

    FileManager fm = FileManager.get();
    fm.addLocatorClassLoader(JenaD2RQClass.class.getClassLoader());

    // m=fm.get().loadModel(fileNmaeURI);
    FileOutputStream fout =new FileOutputStream(writeLocation+"D2RQCopy1234567.rdf");
    m.write(fout,"TURTLE");
}

How to store this D2RQ mapped model in Jena TDB backed dataset?

Upvotes: 1

Views: 228

Answers (1)

Rob Hall
Rob Hall

Reputation: 2823

ModelD2RQ allows you to query the D2RQ engine from Jena. D2R continues to store the information, because, the D2RQ-jena interface is merely an adapter for translating the stored information to triples.

Note that TDB is the storage system itself. It is unclear what you mean by "integrate Jena TDB with D2R". That is akin to saying "Integrate Oracle with MySQL". They each store data, and there is no meaningful inter-operation between the two systems actively running.

If I assume that you wish to take a snapshot of the current contents of your D2R server, and store that snapshot within TDB, then it can be quite simple to do so:

First, create a TDB Dataset with the TDB Java API, then add your ModelD2RQ to that Dataset.

final Model m = new ModelD2RQ("C:/Users/PJH/desktop/d2rq-0.8.1/d2rq-0.8.1/doc/example/mapping-iswc.ttl");
final Dataset dataset = TDBFactory.createDataset("MyDatabases/Dataset1") ;
dataset.getDefaultModel().add(m);

Upvotes: 1

Related Questions