Hi I have created a java program where I take a ttl file and update the turtle statements. Since I have a web interface that connects to fuseki to query the ttl file, I would like to reupload the ttl file with the new data. Is there a way to do this programatically instead of the Fuseki interface?
What I am trying is to access the command prompt from java and using the s-put command but I am getting a No such file or directory error:
public void updateFuseki() throws IOException{
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("s-put http://localhost:3030/Test/ default Definitions.graph.ttl");
}
I have currently only one dataset called Test in fuseki and Definitions.graph.ttl is in the same package as Jena
Fuseki's API for remote-uploading data is the SPARQL Graph Store HTTP Protocol, which is part of the SPARQL standard. The s-put
command is a simple client application (written in Ruby) that uses this API.
Since your application is written in Java, it would be better to use a Java client for this API.
You've tagged your question with jena
, so I'm assuming your Java app already uses Jena? Jena includes a client library for the Graph Store Protocol. A simple use would be something like this:
String serviceURL = "http://localhost:3030/Test/";
try (RDFConnection conn = RDFConnectionFactory.connect(serviceURL)) {
conn.put("Definitions.graph.ttl");
}