giuseta
giuseta

Reputation: 137

Upload triples into Fuseki dataset avoiding IRI clashes

I have created a dataset using the web GUI of Apache Jena Fuseki and now I would like to programmatically upload some triples into the remote dataset using RDFConnection.

The triples that I would like to upload come from different sources and I want to avoid creating RDF nodes that have IRIs already present in the remote dataset. Is there a way to do that without explicitly querying the remote dataset? Returning a list of all the IRIs is a waste of resources.

For instance, if I have this dataset (in Turtle syntax) in my remote triple store:

<iri_1> a foaf:Person
<iri_2> a foaf:Person
...
<iri_n> a foaf:Person

and I would like to add a new individual of foaf:Person which is not the same of the existing ones, how do I generate an IRI for the new individual without the risk of using one already existing in the remote dataset?

Upvotes: 0

Views: 211

Answers (1)

Thomas
Thomas

Reputation: 1020

From your example it looks like each subject is named after the number of occurrences of the class. To keep doing this, I would count the number of foaf:Persons there are (trivial and quick sparql query) and just offset new subjects from the count.

If you can't contact the database then I would just generate uuids, which should never clash. The subjects won't be visually appealing, but they certainly won't clash. You should be able to use UUID out of java.util. RDFUnit has an example of generating unique IRIs using JennaUUID, which should also work for you.

Upvotes: 0

Related Questions