Extension:RDFIO

Update 31 July, 2017: RDFIO 2.2.2
RDFIO 2.2.2 was released, in addition to a number of intermediate releases, adding a new  maintenance script (in 2.2.0), better support for English language (2.2.1) and fixes to work with MW 1.27.x (2.2.2).

Update 8 May, 2017: RDFIO 2.1.0 - Updated variable names
RDFIO 2.1.0 was just released, containing many stability improvements, but also one API change: Updated config variables names, to make them shorter, to follow code recommendations:

$rdfiogPropertiesToUseAsWikiTitle --> $rogTitleProperties $rdfiogQueryByEquivURI           --> $rogQueryByEquivURI $rdfiogOutputEquivURIs           --> $rogOutputEquivURIs $rdfiogAllowRemoteEdit           --> $rogAllowRemoteEdit $rdfiogBaseURIs                  --> $rogBaseURIs

So, if you have an existing RDFIO installation and do install the 2.1.0 version, you will need to change the variable names in LocalSettings.php.

Introduction
This extension extends the RDF import and export functionality in Semantic MediaWiki by providing import of arbitrary RDF triples (not only OWL ontologies, as was the case before) and a SPARQL endpoint that allows write operations.

Technically, RDFIO implements the PHP/MySQL based triple store and accompanying SPARQL Endpoint provided by the ARC2 library.

The RDF import stores the original URI of all imported RDF entities in the Equivalent URI property, which can later be used by the SPARQL endpoint, instead of SMW's internal URIs, which thus allows to expose the imported RDF data "in its original formats", with its original URIs. This allows to use SMW as a collaborative RDF editor, in workflows together with other semantic tools, from which it is then possible to "export, collaboratively edit, and import again", to/from SMW.

This extensions was developed as part of a GSoC 2010 project, and later further extended as part of a Extension:RDFIO/Template_matching_for_RDFIO FOSS OPW 2014 project.

Vagrant box
The absolutely simplest way, is to use the RDFIO Vagrant box, which will automatically set up MediaWiki, SemanticMediaWiki and RDFIO in a virtual machine in under 20 minutes.

Dependencies
$smwgShowFactbox = SMW_FACTBOX_NONEMPTY;
 * Composer
 * See this page for installation instructions.
 * MediaWiki
 * See this page for installation instructions.
 * Semantic MediaWiki
 * See this page for installation instructions.
 * To show the "Semantic factbox" on all pages, make sure to include this in your LocalSettings.php file:

Installation steps
Assuming you have followed the steps above to install the dependencies for RDFIO:


 * Install RDFIO by executing the following commands in a terminal:

cd  composer require rdfio/rdfio --update-no-dev
 * Add the following option to the end of LocalSettings.php:

$smwgOWLFullExport = true; It allows user defined properties for property articles (which is needed by the RDF import)


 * Log in to your wiki as a super user
 * Browse to http://[your-domain]/wiki/Special:RDFIOAdmin
 * Click the "Setup" button to set up ARC2 database tables.
 * If you already have semantic annotations in your wiki, you need to go to the article "Special:SMWAdmin" in your wiki, and click "Start updating data", and let it complete, in order for the data to be available in the SPARQL endpoint.

Optional but recommended steps
* Semantic Tools ** Special:RDFIOAdmin|RDFIO Admin ** Special:RDFImport|RDF Import ** Special:SPARQLEndpoint|SPARQL Endpoint ** Special:SPARQLImport|SPARQL Import
 * Edit the MediaWiki:Sidebar page and add the following wiki snippet, as an extra menu (I use to place it before just the "* SEARCH" line), which will give you links to the main functionality with RDFIO from the main links in the left sidebar on the wiki:


 * Create the article "MediaWiki:Smw_uri_blacklist" and make sure it is empty (you might need to add some nonsense content like { – }).

Test that it works

 * Now, try adding some semantic data to wiki pages, and then check the database (using phpMyAdmin e.g.) to see if you get some triples in the table named.
 * Access the SPARQL endpoint at http://[url-to-your-wiki]/Special:SPARQLEndpoint
 * Access the RDF Import page at http://[url-to-your-wiki]/Special:RDFImport
 * Access the SPARQL Import page at http://[url-to-your-wiki]/Special:SPARQLImport

Additional configuration
These are some configuration options that you might want to adjust to your specific use case. That goes into your LocalSettings.php file. Find below a template with the default options, which you can start from, add to your LocalSettings.php file and modify to your liking:


 * 1)  RDFIO Configuration
 * 2) An associative array with base uris as keys and corresponding
 * 3) prefixes as the items. Example:
 * 4) array(
 * 5)       "http://example.org/someOntology#" => "ont1",
 * 6)       "http://example.org/anotherOntology#" => "ont2"
 * 7) $rogBaseURIs = array;
 * 8) Query by /Output Equivalent URIs SPARQL Endpoint
 * 9) (overrides settings in HTML Form)
 * 10) $rogQueryByEquivURI = false;
 * 11) $rogOutputEquivURIs = false;
 * 12) $rogTitleProperties = array(
 * 13)  'http://semantic-mediawiki.org/swivt/1.0#page',
 * 14)  'http://www.w3.org/2000/01/rdf-schema#label',
 * 15)  'http://purl.org/dc/elements/1.1/title',
 * 16)  'http://www.w3.org/2004/02/skos/core#preferredLabel',
 * 17)  'http://xmlns.com/foaf/0.1/name',
 * 18)  'http://www.nmrshiftdb.org/onto#spectrumId'
 * 19) Allow edit operations via SPARQL from remote services
 * 20) $rogAllowRemoteEdit = false;
 * 1)  'http://purl.org/dc/elements/1.1/title',
 * 2)  'http://www.w3.org/2004/02/skos/core#preferredLabel',
 * 3)  'http://xmlns.com/foaf/0.1/name',
 * 4)  'http://www.nmrshiftdb.org/onto#spectrumId'
 * 5) Allow edit operations via SPARQL from remote services
 * 6) $rogAllowRemoteEdit = false;
 * 1) Allow edit operations via SPARQL from remote services
 * 2) $rogAllowRemoteEdit = false;
 * 1) $rogAllowRemoteEdit = false;

Dependencies

 * Composer
 * Semantic MediaWiki Extension
 * ARC2 RDF library for PHP.

Basic Usage
User manual (under development)

Bugs, new feature request and contact information
Please use the issue tracker on GitHub for all issues, suggestions or general feedback!

Alternative triple store connectors / SPARQL Endpoints
One of the features of RDFIO is to connect Semantic MediaWiki with a triple store, and to provide a SPARQL Endpoint. There are (already) a few extensions that offer this feature. See this page for an overview of triple store connector features. (The idea behind RDFIO is mainly focusing on the RDF import functionality, and merge of some or all of the extensions is being discussed).