Deprecated. This material represents early efforts and may be of interest to historians. It doe not describe current VIVO efforts.
Deprecated. This material represents early efforts and may be of interest to historians. It doe not describe current VIVO efforts.
Permits external applications to add or remove specific triples from the VIVO data model. These changes use the standard data channels in VIVO, so the search index will be updated as appropriate, and the reasoner will add or remove inferences as needed.
Previous implementations of the Harvester and similar tools have written directly to the VIVO triple-store, bypassing the usual data channels in VIVO. After ingesting, it was necessary to rebuild the search index, and to run the reasoner to add or remove inferences. Since the search index and the reasoner were not aware of the exact changes, the entire data model was re-indexed and re-inferenced.
When the Harvester and other tools have been modified to use the SPARQL Update API, VIVO will ensure that the search index and inferences are kept in synchronization with the data.
This API permits ingest tools such as Karma to programmatically insert data into VIVO without requiring knowledge of VIVOs internal data structures.
Linked Open Data requests have permitted people to write Drupal applications (for example) that display data from VIVO. This API will permit such applications to accept user edits, and apply them back to VIVO.
[vivo]/api/sparqlUpdate
Examples:
http://vivo.cornell.edu/api/sparqlUpdate
http://localhost:8080/vivo/api/sparqlUpdate
The API supports only HTTP POST calls. GET, HEAD, and other methods are not supported, and will return a response code of 400 Bad Request
.
name | value |
---|---|
email | the email address of a VIVO adminstrator account |
password | the password of the VIVO administrator account |
update | A SPARQL Update request |
The syntax for a SPARQL Update request is described on the World Wide Web Consortium site at http://www.w3.org/TR/2013/REC-sparql11-update-20130321/
The API requires that you specify a GRAPH in your SPARQL update request. Insertions or deletions to the default graph are not supported.
Code | Reason |
---|---|
200 OK | SPARQL Update was successful. |
400 Bad Request | Incorrect HTTP method; only POST is accepted. |
HTTP request did not include an update parameter. | |
SPARQL Update request did not specify a GRAPH on which to operate. | |
SPARQL Update request was syntactically incorrect. | |
403 Forbidden | HTTP request did not include an email parameter. |
HTTP request did not include a password parameter. | |
The combination of email and password is not valid. | |
The selected VIVO account is not authorized to use the SPARQL Update API. | |
500 Internal Server Error | VIVO could not execute the request; internal code threw an exception. |
This example, written in Python, shows some INSERT and DELETE operations using the API. (Thanks to Ted Lawless of Brown University)
""" Examples of using the Vitro SPARQL update in development. https://jira.duraspace.org/browse/VIVO-101 http://www.w3.org/Submission/SPARQL-Update/ """ from SPARQLWrapper import SPARQLWrapper import time email = 'email@school.edu' password = 'password' endpoint = 'http://localhost:8080/vitro/sparql/' def do_update(query): params = { 'email': email, 'password': password, 'update': query } sparql = SPARQLWrapper(endpoint) sparql.customParameters = params sparql.method = 'GET' results = sparql.query() #print out the query url print results.response.geturl() #insert some data. q = """ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> INSERT DATA INTO <http://vitro.mannlib.cornell.edu/default/vitro-kb-2> { <http://vivo.school.edu/individual/n1234> rdfs:label "New Title" . } """ do_update(q) #for testing purposes only - delay to check data in web app time.sleep(5) #modify it q = """ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX bibo: <http://purl.org/ontology/bibo/> DELETE DATA FROM <http://vitro.mannlib.cornell.edu/default/vitro-kb-2> { <http://vivo.school.edu/individual/n1234> rdfs:label "New Title" . } INSERT DATA INTO <http://vitro.mannlib.cornell.edu/default/vitro-kb-2> { <http://vivo.school.edu/individual/n1234> rdfs:label "Second Title" . } """ do_update(q) time.sleep(5) #delete it q = """ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> DELETE DATA FROM <http://vitro.mannlib.cornell.edu/default/vitro-kb-2> { <http://vivo.school.edu/individual/n1234> rdfs:label "Second Title" . } """ do_update(q)