tripti sinha
tripti sinha

Reputation: 149

Is there any class in dotNetRdf to upload the ontology in the remote server?

I am developing a .Net API and connecting it with RDF Triple Store, with the help of dotNetRdf library. I am successfully able to load the data and query rdf data from the remote serve. Is there any support in dotNetRdf to load the ttl file into the remote serve? I am trying to update the ontology in the real time, without doing it manually.

Upvotes: 1

Views: 357

Answers (1)

Kal
Kal

Reputation: 1932

Depending on the store that you are connecting to, you should be able to update the remote server using dotNetRDF's Triple Store integration. In particular you should be able to use the UpdateGraph method to add the triples in your TTL file (or if you want to completely overwrite the data on the server you could use the SaveGraph method with caution!).

You can see a list of the supported triple store integrations here. Note that it includes an integration that supports the SPARQL Graph Store Protocol which may cover you for the server you are connecting too even if it's not explicitly listed.

By the way, if you decide to use the UpdateGraph method you don't have to manually create the graph as is shown in the example, instead you can load your TTL file into a graph and then update the remote server using code something like this:

// Create a remote store connector. 
// The precise details will depend on which store you are connecting too.
var remoteStore = new SparqlHttpProtocolConnector(
  "http://example.org/store", // URL of the store's endpoint
  MimeTypesHelper.GetDefinitions("application/n-triples").First() // override the default use of RDF/XML for the upload
);
// Create a Graph and fill it with data we want to save
Graph g = new Graph();
g.LoadFromFile("data.ttl");

// Write triples from IGraph instance g into the named graph 
// http://example.org/graph on the remote store
remoteStore.UpdateGraph("http://example.org/graph", g.Triples, null);

Upvotes: 2

Related Questions