-
Notifications
You must be signed in to change notification settings - Fork 2
Jena TDB
Apache Jena includes a number of components;
RDF API - client API for dealing with RDF in Java
Class Model - a collection of RDF triples denoting an RDF (directed) graph. Can be used to adapt existing data sources as RDF. class Graph - a simpler abstraction for wrapping existing data stores
ARQ - Java Application API for SPQRQL queries
TDB - Triple DataBase - used for persisting RDF graphs
Fuseki2 - a SPARQL server integrated with TDB.
Here's some notes on experimenting with Fuseki2, installation, startup, and using typical access patterns that would be required by ldp-service.
./fuseki-server --update --loc=../mrm /mrm &
Starts the server on the /mrm DatasetPathName using the default port (3030) allowing SPARQL update
Fuseki Dataset Descriptions:
--mem Create an empty, in-memory (non-persistent) dataset.
--file=FILE Create an empty, in-memory (non-persistent) dataset, then load FILE into it.
--loc=DIR Use an existing TDB database. Create an empty one if it does not exist.
--desc=assemblerFile Construct a dataset based on the general assembler description.
--config=ConfigFile Construct one or more service endpoints based on the configuration description.
Provides these endpoints or dataset URIs:
- HTTP: http://localhost:3030/mrm/data
- Query: http://localhost:3030/mrm/query or http://localhost:3030/mrm/sparql
- Update: http://localhost:3030/mrm/update
Command line interface (CLI):
bin/soh VERB datasetURI graphName [file]
- VERB: post, get, head, put, delete
- databaseURI is http://localhost:3030/mrm (without data, query, or update)
- graphName is the URI of the graph or the word default for the default graph
- file is an RDF file for PUT and POST with the extension used to determine the HTTP content type
Implements the SPARQL 1.1 Graph Store HTTP Protocol
bin/soh post http://localhost:3030/mrm http://example/spc /Users/jamsden/Developer/oslc/spc.ttl
bin/soh post http://localhost:3030/mrm http://example/spc /Users/jamsden/Developer/oslc/spc.ttl
POST http://localhost:3030/mrm/update?graph=http://example/spc
Content-Type=text/turtle
bin/soh get http://localhost:3030/mrm http://example/spc
GET http://localhost:3030/mrm/data?graph=http://example/spc
Accept=application/ld+json, text/turtle, application/rdf+xml
bin/soh put http://localhost:3030/mrm http://example/spc /Users/jamsden/Developer/oslc/spc.ttl
PUT http://localhost:3030/mrm/update?graph=http://example/spc
Content-Type=text/turtle
Or use SPARQL update: s-update --service=endpointURL 'update string' s-update --service=endpointURL --update=updateFile.ru
bin/soh delete http://localhost:3030/mrm http://example/spc
DELETE http://localhost:3030/mrm/update?graph=http://example/spc
s-query --service=endpointURL 'query string'
bin/s-query --service=http://localhost:3030/mrm 'SELECT DISTINCT ?g WHERE {GRAPH ?g {?s ?p ?o }}'
bin/s-query --service=http://localhost:3030/mrm 'SELECT DISTINCT ?s ?p ?o WHERE {GRAPH ?g {?s ?p ?o }}'
Query Using POST Request, you can insert one of the following into the entity request body:
query=SELECT+%2A+%7B%3Fs+%3Fp+%3Fo%7D query=SELECT * {?s ?p ?o}
The Header needs to be customized to have Content-Type = application/x-www-form-urlencoded. The URL would be http://localhost:3030/mrm/query
I found this information when looking at one of the 's-' code. There is a method called cmd_sparql_query (line 497) that shows all types of options when calling s-query. There is an option called --post that forces the request to be a POST rather than a GET like usual. I implemented the POST and the header output was as follows:
SPARQL http://localhost:3030/ds/query
POST http://localhost:3030/ds/query
User-Agent: SOH/Fuseki 1.0.0
Accept: application/sparql-results+json , application/sparql-results+xml;q=0.9 , text/turtle;charset=utf-8 , application/n-triples;q=0.9 , application/rdf+xml;q=0.8 , application/ld+json;q=0.5 , */*;q=0.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 37
200 OK
Date: Fri, 27 May 2016 20:16:49 GMT
Fuseki-Request-Id: 10
Cache-Control: must-revalidate,no-cache,no-store
Pragma: no-cache`
Content-Type: application/sparql-results+json; charset=utf-8
Transfer-Encoding: chunked
Fuseki also supports Content-Type=application/sparql-query
POST http://localhost:3030/mrm/query
Content-Type=application/sparql-query
SELECT *
WHERE {GRAPH
{?s ?p ?o}
}