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.
Note |
---|
By default, the SPARQL Update API is disabled in VIVO, for security reasons. See Enabling the API. |
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.
...
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 These examples use the UNIX curl
command to insert and delete data using the API. (Thanks to Ted Lawless of Brown University)
Code Block | ||
---|---|---|
| ||
| py
...
Note |
---|
Before enabling the SPARQL update handler, you should secure the URL |
By default, the SPARQL Update handler is disabled in VIVO. To enable it, you must create an RDF file in the [vivo]/rdf/auth/everytime
directory that will authorize your site administrators to use the API. Here is an example of such a filem using N3 syntax:
Code Block | ||
---|---|---|
| ||
@prefix auth: <http:// | true | """ 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/defaultns/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) |
...
/authorization#> .
@prefix simplePermission: <java:edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission#> .
# Authorize the ADMIN role to use the SPARQL Update API
auth:ADMIN auth:hasPermission simplePermission:UseSparqlUpdateApi .
|