Reputation: 1430
D2RQ creates a RDF representation of the DB using a Jena model.
Model m = new ModelD2RQ("file:outfile2.ttl");
I know that the returned model is a "read-only" model.
Hence, if I try to add a resource to the model I get a "jena.shared.AddDeniedException" exception.
Resource r1=m.createResource("http://www.stackoverflow.com#34");
r1.addProperty(RDF.type, ...); <-throws the exception
How can I decouple the model m from the database so that I can modify it? I don't want to write the model back, I just use D2RQ to get an RDF based DB-dump which I want to process further (I know that extensions like D2RQ update enable the modification of the database by modifying the RDF graph but I don't want to modify the DB)
Thanks
Upvotes: 0
Views: 68
Reputation: 16630
Take a copy to disconnect the model from the database:
Model m = new ModelD2RQ("file:outfile2.ttl");
Model mCopy = ModelFactory.createDefaultModel() ;
mCopy.add(m) ;
mCopy.addProperty(...)
Another way is to have a union model, where the in-memory part is the first, and update-able, part of the union.
Model m = new ModelD2RQ("file:outfile2.ttl");
Model extra = ModelFactory.createDefaultModel() ;
Model m2 = ModelFactory.createUnion(exrta, m2) ;
...
Upvotes: 1