Extension:RDFIO

Current status: Now updated for SMW 1.8.x (MW 1.20.x)!
UPDATE, 20130517: RDFIO works properly with the new SMWSqlStore3, so no changes are needed for the default store!

UPDATE, 20130325: Updated to work with SMW 1.8 (And MW 1.20). Notice that to use RDFIO with versions to use another the "SMW_1.6" Github branch.

UPDATE, 20121122: Updated to work with MW 1.18.*, and SMW 1.6 (EDIT 18 Jan 2013: Does not seem to work with SMW 1.8 at the moment). Depends on Wiki Object Model now, instead of SMWWriter and Page Object Model extensions.

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 its accompanying SPARQL Endpoint) provided by the ARC2 library. For updating wiki pages with new triples on import/sparql update, the SMWWriter extension is used (which in turn makes use of the Page Object Model extension).

The RDF import stores the original URI of all imported RDF entities (in a special 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 Summer of Code 2010 project. The project description can be found here. See also the status page, with info on how you can follow the project.

Demo

 * Screencast: Demonstrating RDF import and SPARQL update with RDFIO
 * Screencast: Sensible wiki titles on RDF import with "pseudo RDF namespaces"

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).

Download
Git Checkout URL: git://github.com/samuell/RDFIO2.git

Installing MediaWiki

 * See https://www.mediawiki.org/wiki/Installation

Installing Semantic MediaWiki
/* Show the factbox on bottom of pages */ $smwgShowFactbox = SMW_FACTBOX_NONEMPTY;
 * See http://semantic-mediawiki.org/wiki/Help:Installation
 * To show the "Semantic factbox" on all pages, make sure to include this in your LocalSettings.php file:

Installing RDFIO
... assuming that you have a working Semantic MediaWiki installation (Tested with MW *1.18* and later).

It is STRONGLY recommended that you use the latest version from the svn trunk, since that is what this extension is tested against continually!

cd wiki/extensions svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/WikiObjectModel git clone git://github.com/samuell/RDFIO2.git RDFIO git checkout /* Wiki Object Model */ include_once("$IP/extensions/WikiObjectModel/WikiObjectModel.php");
 * Install Wiki Object Model and RDFIO, according to instructions on Wiki Object Model page, or run the following commands:
 * Add the following to LocalSettings.php, to activate Wiki Object Model:

LocalSettings.php configuration
/************************** *        RDF IO         * **************************/
 * Add the following lines to LocalSettings.php:

/* RDFIO */ include_once("$IP/extensions/RDFIO/RDFIO.php");


 * 1) Configuration ######################################
 * 2) You may modify the following settings to your liking #

$rdfiogBaseURIs = array;
 * 1) An associative array with base uris as keys and corresponding
 * 2) prefixes as the items. Example:
 * 3) array(
 * 4)       "http://example.org/someOntology#" => "ont1",
 * 5)       "http://example.org/anotherOntology#" => "ont2"

$rdfiogQueryByEquivURI = false; $rdfiogOutputEquivURIs = false;
 * 1) Query by /Output Equivalent URIs SPARQL Endpoint
 * 2) (overrides settings in HTML Form)

$rdfiogPropertiesToUseAsWikiTitle = array( 'http://semantic-mediawiki.org/swivt/1.0#page',  'http://www.w3.org/2000/01/rdf-schema#label',  'http://purl.org/dc/elements/1.1/title',  'http://www.w3.org/2004/02/skos/core#preferredLabel',  'http://xmlns.com/foaf/0.1/name',  'http://www.nmrshiftdb.org/onto#spectrumId' );

$smwgOWLFullExport = true;
 * 1) Needed in order to allow user defined properties for
 * 2) property articles (which is needed by the RDF import)

$rdfiogAllowRemoteEdit = false;
 * 1) Allow edit operations via SPARQL from remote services

cd wiki/extensions/SemanticMediaWiki/libs git clone https://github.com/semsol/arc2.git arc
 * Optional: Edit the $rdfiogPropertiesToUseAsWikiTitle array according to your liking.
 * Download the ARC2 library from here, then extract and place it in `wiki/extensions/SemanticMediaWiki/libs/arc`, so that the file `ARC2.php` is placed in the `arc` folder. Command line syntax (using the git client (In Ubuntu, install with sudo apt-get install git, if you don't have it)):
 * (RDFIO adds include lines for ARC)
 * Log in to your wiki as a super user
 * 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:
 * Semantic Tools
 * Special:ARC2Admin|ARC2 Admin
 * Special:RDFImport|RDF Import
 * Special:SPARQLEndpoint|SPARQL Endpoint
 * Browse to http://[your-domain]/wiki/Special:ARC2Admin (You can click the "ARC2 Admin" link in your menu, if you followed the point above!)
 * Click the "Setup" button is to set up the database tables.
 * Note: 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.
 * Create the article "MediaWiki:Smw_uri_blacklist" and make sure it is empty (you might need to add some nonsense content like { – }).
 * 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 `arc2store_triple`
 * Access the SPARQL endpoint at http://[url-to-your-wiki]/Special:SPARQLEndpoint
 * Access the RDF Import screen at http://[url-to-your-wiki]/Special:RDFImport

Dependencies

 * Semantic MediaWiki Extension
 * Wiki Object Model Extension
 * ARC2 RDF library for PHP.

Editing Semantic MediaWiki from Bioclipse
Chemists and biologists using Bioclipse can now take their working data and export it to a wiki where their peers can make corrections, before importing it again for further analysis, etc. This workflow is possible today, as hinted in this blog post / screencast, and is the focus of current research/development (progress documented on the blog) in the Bioclipse group of prof. Jarl Wikberg at [http://www.farmbio.uu.se/researchgroup.php?fg=1 Dept. of Pharm. biosciences], Uppsala University.

Bugs, new feature request and contact information
Please reports bugs and feature requests in Bugzilla.

Note: Please add my e-mail address, samuel.lampa[at]gmail.com as "assign-to" or "cc", so that I get notified, and add the string " " to the subject line, in order to make the issues easy to collect.

General feedback can be given here on the talk page.

Change Log

 * 1.9.? - 2013-05-17 - Works with the new SMWSQLStore3
 * 1.9.0 - 2012-11-22 - Updated to work with SMW 1.6 and later. Much refactored code base. Depends now only on Wiki Object Model, rather than SMWWriter and Page Object Model.
 * 0.5.0 - 2010-09-17 - Numerous fixes to make remote SPARQL querying work (See repository updates for a list of all commits).
 * Improved file hierarchy
 * Made querying and output of/querying by Original URIs and Equivalent URIs configurable from LocalSettings.php in SPARQL endpoint (So this can be turned on for remote queries too)
 * In total five new configurable settings for LocalSettings.php (see here for full list):
 * $rdfiogQueryByOrigURI = true;
 * $rdfiogOutputOrigURIs = true;
 * $rdfiogQueryByEquivURI = false;
 * $rdfiogOutputEquivURIs = false;
 * $rdfiogAllowRemoteEdit = false;
 * Lots of serious bug fixes encountered when making SPARQL querying from Bioclipse/Jena work
 * 0.4.0 - 2010-08-16
 * Support for configuring extra namespace prefixes in LocalSettings.php
 * More options in RDF Import screen
 * Output SPARQL resultset as default for remote queries, and HTML for form queries
 * Enable output as Original URI/Equivalent URI also for XML Resultset output format
 * Refactorings (Merged EquivalentURIHandler and SMWBatchWriter classes, Broke out RDFIOPageHandler in separate file)
 * Many bugfixes
 * 0.3.0 - 2010-07-30 - Added output filtering options and other improvements.
 * Option to query by Equivalent URI
 * Refined SPARQL Endpoint screen
 * Option to output all Equivalent URIs (For RDF/XML format only)
 * Option to filter properties by ontology (when outputting equivalent URIs) by specified an URL to an OWL ontology definition. (For RDF/XML format only).
 * Much improved processing of SPARQL queries
 * Various refactoring
 * Fixed various bugs
 * Initialize query variable (r150)
 * Don't delete Original URI properties etc when deleting other facts (r151)
 * Fixed error in isURL check (r153)
 * 0.2.0 - 2010-07-20 - Important security improvements
 * Checking for appropriate user rights on all special pages
 * Improved code structure and comments
 * Various small fixes
 * 0.1.0 - 2010-07-21 - First release