In this section you will learn
tdt/triples is a repository that hooks into The DataTank core application, and provides the functionality to build your URI space through the configuration of semantic resources, in addition to the URI space of The DataTank.
It reads the triples from the semantic sources, and by default it stores them into a local simulated triple store based on MySQL. Therefore it needs a MySQL database, so make sure your datatank project is configured with a MySQL connection.
Also note that for this kind of "triple caching", it uses the semsol/arc2 library which works on PHP 5.3 and 5.4. From 5.5 the MySQL driver that semsol/arc2 uses is deprecated. This can be solved by creating a different TriplesRepository instance that uses a genuine triplestore (or other solutions) to store triples in. Because we've built this type of caching with dependency injection, it makes it easy to provide your own triple caching.
The core application allows for the RESTful publication of data sources, from any machine readable format, to web-ready formats. (e.g. SPARQL, SHP, CSV, XLS, ... to JSON-LD, JSON, XML, PHP, RDF/XML, RDF/JSON, and even map visualizations)
Each datasource that is published by the core application has its own URI, and represents a certain chunk of data. Now, to allow for automatic configuration of your URI space from linked data sources and take a step towards the semantic web, the tdt/triples package was created.
This package allows for a set of semantic sources to be added to the datatank, from which the subject of the triples are used to fill in URIs that have not been used in the datatank core. Let's take a look at an example.
The DataTank has 2 published datasources:
Now if an organization has a set of semantic data that is pointing towards their domain (the domain that has the datatank instance installed), they would have to manually publish the different semantic sources under corresponding (or not) URIs. This is where tdt/triples comes in. By adding the semantic datasources to the datatank, while this package is installed, the subject URIs of the triples that are present in the semantic sources will be dereferenced automatically. No need to publish the different triples to corresponding URI's by hand.
For example, if you configure a turtle file that has triples with a subject of http://foo.bar/demography/2013, then that URI will automatically be dereferenced by the datatank. Upon making a request, all triples that can be found in the configured semantic sources, with a subject similar to the URI of the request will be returned.
How it works
The current supported semantic sources are Turtle files, RDF files, LDF servers and SPARQL-endpoints. When tdt/triples is installed the following workflow is applied:
- Request URI serves as an identifier
- The datatank checks if no datasource is published on the identifier by the main (core) application
- If the identifier is not used by core, then all semantic sources are scanned for triples with a subject matching the URI
- If triples are found with the subject, they are returned, if not a 404 is given
An admin user can interact with this package through api/triples, check the /discovery document to see which functionalities are available, or go to the admin interface to interact with the package through a UI.
This package works with version 4.3 or higher ( if 4.3 is not available, try the development branch) of the datatank core. If you have remarks, suggestions, issues, etc. please don't hesitate to log it on the github repository.
1) Edit composer.json
Edit your composer.json file, and add tdt/triples as a dependency:
After that run the composer update command.
$ composer update
The package needs a few extra datatables for its configuration, so go ahead and run the migration command!
$ php artisan migrate --package=tdt/triples
4) Notify core
Let the core application know you have added functionality it should take into account. Do this by adding 'Tdt\Triples\TriplesServiceProvider' to the app.php file located in the app/config folder.
Next, tell the core application it has new UI (CSS and JS) assets it has to take into account, do this by the following command:
$ php artisan asset:publish tdt/triples
You're ready to start using tdt/triples. Each api resource in the datatank is located under