Search code examples
rdfjenaontologyapache-jena

Change localName of an individual using Jena


I need to change the name of an individual. I have found that using the getLocalName you manage to print the name, but is it possible to change the name of an existing individual and propagate it over the whole graph?

I have thought on using sameAs, but although it is similar, it is not the same as I don't one the original name to be kept.

Thanks.


Solution

  • To make a change, the app needs to remove all the old statements and add all new statements. There isn't a way to change-in-place a single node in the graph.

    There is a helper function for this ResourceUtils.renameResource.

    getLocal is a function on the URI of an RDF Term - the resources don't store the namespace/localname, just the URI.

    If you are doing this on a large database, it may be better to dump the database to N-Triples, run a text changing script, and reload the database.