<?php /* This file contains the configuration for triplify in order to convert contents of UDD to RDF. * See https://picoforge.int-evry.fr/cgi-bin/twiki/view/Helios_wp3/Web/TriplifyUddToRdf * * Triplify rapidly simplifies the creation of structured content for Web 2.0 * mashups and Semantic Web applications. * * Triplyfy uses a number of SQL queries, whose results are converted into * either RDF/N3, JSON or Linked Data. * * @version $Id:$ * @license LGPL * @copyright 2008 Sören Auer (soeren.auer@gmail.com) for the original example config file * @copyright 2009 Olivier Berger for the UDD triplification */
/* Triplify uses a PDO object to connect to the database. * The following line creates an appropriate PDO object for a MySQL database. * Please adjust the values for database name, user and password. * For maximum security, you can create a database user specificially for * Triplify, which has solely readable access to the columns of your database * schema, which should be made public. Alternatively, you can include the * configuration of your Web application and reuse its credentials here. */ #$triplify['db']=new PDO('mysql:host=localhost;dbname=db','dbuser','dbpass');
include('config-db.inc.php');
/* Alternatively (e.g. when using PHP4) the db configuration value can point to * a mysql link resource */ #$triplify['db']=mysql_connect('localhost','dbuser','dbpass'); #mysql_select_db('db');
/* Triplify uses URIs to identify objects. In order to simplify their handling * you should define shortcuts (i.e. namespace prefixes) for all namespaces * from which you want to use URIs. * A 'vocabulary' entry entry is mandatory - it specifies, which default prefix * should be used for vocabulary elements such as classes and properties. Other * than the prefix for instances this prefix should be shared between different * installations of a certain Web application on the Web. */ $triplify['namespaces']=array( 'rdf'=>'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'foaf'=>'http://xmlns.com/foaf/0.1/', 'sioc'=>'http://rdfs.org/sioc/ns#', 'bom'=>'http://www.ifi.uzh.ch/ddis/evoont/2008/11/bom#', 'hel'=>'http://picoforge.int-evry.fr/projects/svn/helios_wp3/helios_bt.owl#', 'rdfs'=>'http://www.w3.org/2000/01/rdf-schema#', 'owl' =>'http://www.w3.org/2002/07/owl#', 'dc'=>'http://purl.org/dc/elements/1.1/' );
/* The core of triplify are SQL queries, which select the information to be made * available. * * You can provide a number of arbitrary queries. Each query, however, should * select information about an object of a certain type. This type, which serves * as an index in the associative queries configuration array, is also used to * construct corresponding URIs for the objects returned by the query. * * The first column returned by the query represents the ID of the object and * has to be named "id", all other columns represent characteristics (or * properties of this object). As column identifier you should reuse existing * vocabularies whenever possible. If your "user" table, for example, contains a * column named "first_name" this can be easily mapped to the corresponding FOAF * property using: "SELECT id,first_name AS 'foaf:firstName' FROM user". * * You can use the following column naming convention in order to inform * Triplify about the datatype or language of a column: * SELECT id,price AS 'price^^xsd:decimal',desc AS 'rdf:label@en' FROM products * However, Triplify tries to autodetect and convert timestamps appropriately. * * Similarly, you can indicate that a column represents an objectProperty * pointing to other objects (foreign key): * SELECT id,user_id 'sioc:has_creator->user' * * Only select information, which does not contain sensitive information and * can be made public. For example, email adresses and password (hashes) should * never be exposed. However, you can use the database function SHA to * mask email addresses, e.g.: * SELECT SHA(CONCAT('mailto:',email)) AS 'foaf:mbox_sha1sum' FROM users * * The following queries are example queries and have to be replaced by queries * suitable for your database schema. */ /*$triplify['queries']=array( 'project'=>array( "SELECT p.id AS id,p.title AS 'dc:title', p.description AS 'sioc:content', u.nickname AS 'sioc:has_creator', p.changed AS 'dcterms:modified', p.created AS 'dcterms:created',p.status FROM project p INNER JOIN user u ON(user_id=u.id)", "SELECT project_id id,label 'tag:taggedWithTag' FROM project_tag INNER JOIN tag ON(tag_id=id)"), 'user'=>"SELECT nickname id,SHA(CONCAT('mailto:',email)) AS 'foaf:mbox_sha1sum', profile AS 'profile@en' FROM user", 'update'=>"SELECT p.changed AS id,p.id AS 'update:updatedResource->project' FROM project p", ); */ $triplify['queries']=array(
// require TABLE tr_bug_submitters constructed as : // CREATE TABLE tr_bug_submitters AS SELECT DISTINCT submitter_email, sha1mailto(submitter_email) AS email_sha1 // FROM bugs WHERE submitter_email LIKE '%@%' (see https://picoforge.int-evry.fr/cgi-bin/twiki/view/Helios_wp3/Web/TriplifyUddToRdf)
'issue'=>array( 'SELECT b.id as id, b.id AS "bom:number", b.title AS "dc:title", '. "'http://bugs.debian.org/'" . '|| b.id AS "bom:bugURL", '. "'/bugs.debian.org/'" . '|| b.id AS "owl:sameAs", b.status AS "bom:hasState", b.email_sha1 AS "bom:hasReporter->user", '. "'Debian bug #'" . ' || b.id AS "rdfs:label", b.package AS "bom:isIssueOf->bpackage", b.arrival AS "bom:dateOpened", b.severity AS "bom:hasSeverity", b.last_modified AS "bom:lastModified", b.source AS "bom:isInProduct->spackage", b.u_id AS "owl:sameAs->forwardedupstream", b.u_id AS "rdfs:seeAlso->forwardedupstream" FROM ( SELECT b.bug_id as id, u.id as u_id, b.title, b.status, b.email_sha1, b.package, b.arrival, b.severity, b.last_modified, b.source FROM ( SELECT * FROM ( SELECT b.id AS bug_id, b.title, b.status, bp.package, bp.source, b.submitter_email, b.arrival, b.severity, b.last_modified, b.forwarded FROM bugs b, bugs_packages bp WHERE b.id = bp.id) b LEFT OUTER JOIN tr_bug_submitters s ON s.submitter_email = b.submitter_email) b LEFT OUTER JOIN bugs_usertags u ON (u.id = b.bug_id) WHERE (u.email = '."'bts-link-upstream@lists.alioth.debian.org' or u.email = 'bts-link-devel@lists.alioth.debian.org'".' OR u.email is null)) b WHERE b.id IS NOT NULL'),
'user'=>array( 'SELECT * from (SELECT s.email_sha1 AS id, s.email_sha1 AS "sioc:email_sha1", b.submitter_name AS "rdfs:label", s.email_sha1 AS "rdfs:seeAlso->submission", s.email_sha1 AS "owl:sameAs->submission" FROM tr_bug_submitters s, bugs b WHERE b.submitter_email = s.submitter_email) AS s WHERE s.id IS NOT NULL'),
'carnivore'=>array( 'SELECT c.id AS id, sha1mailto(c.email) AS "foaf:mbox_sha1sum", c.name AS "foaf:name", sha1mailto(c.email) AS "foaf:holdsAccount->user" FROM ( SELECT e.id AS id, e.email, n.name FROM carnivore_names n, carnivore_emails e WHERE e.id = n.id ) c WHERE id IS NOT NULL'),
'submission'=>array( 'SELECT * FROM (SELECT s.email_sha1 AS id, b.id AS "bom:isReporterOf->issue", s.email_sha1 AS "rdfs:seeAlso->user", s.email_sha1 AS "owl:sameAs->user" FROM tr_bug_submitters s, bugs b WHERE b.submitter_email = s.submitter_email) AS s WHERE s.id IS NOT NULL'), 'bpackage'=>array( 'SELECT * FROM (SELECT p.package as id, p.package ||'. "' Debian package'" . ' AS "rdfs:label", p.source AS "bom:isComponentOf->spackage", p.package AS "rdfs:seeAlso->bpackagebugs", p.package AS "owl:sameAs->bpackagebugs", '. "'http://packages.debian.org/'" . '||p.package AS "rdfs:seeAlso", '. "'/packages.debian.org/'" . '||p.package AS "owl:sameAs" FROM packages p) p WHERE p.id IS not null'), 'spackage'=>array( 'SELECT * FROM (SELECT s.source as id, s.source ||'. "' Debian source package'" . ' AS "rdfs:label", s.source AS "rdfs:seeAlso->binariesofsource", s.source AS "owl:samAs->binariesofsource", '. "'http://packages.qa.debian.org/'" . '||s.source AS "rdfs:seeAlso", '. "'/packages.qa.debian.org/'" . '||s.source AS "owl:sameAs" FROM sources s) s WHERE s.id IS not null'), 'bpackagebugs'=>array( 'SELECT * FROM (SELECT bp.package AS id, bp.id AS "bom:hasIssue->issue", bp.package AS "rdfs:seeAlso->bpackage", bp.package AS "owl:sameAs->bpackage" FROM bugs_packages bp ) AS p WHERE p.id IS NOT NULL'), 'binariesofsource'=>array( 'SELECT b.id AS id , b.package AS "bom:Component->bpackage", b.id AS "rdfs:seeAlso->spackage", b.id AS "owl:sameAs->spackage" FROM (SELECT DISTINCT source AS id, package FROM bugs_packages) b WHERE b.id IS NOT NULL'), 'forwardedupstream'=>array( "SELECT b.id, b.id AS \"rdfs:seeAlso->issue\", b.id AS \"owl:sameAs->issue\", b.forwarded AS \"hel:reportedUpstreamIn->\" FROM (SELECT u.id AS id, b.forwarded FROM bugs_usertags u, bugs b WHERE (email = 'bts-link-upstream@lists.alioth.debian.org' or email = 'bts-link-devel@lists.alioth.debian.org') AND b.id = u.id) b WHERE b.forwarded is not null"), );
/* For Postgres, we need to do :
CREATE OR REPLACE FUNCTION sha1(text) returns text AS $$ SELECT encode(digest($1, 'sha1'), 'hex') $$ LANGUAGE SQL STRICT IMMUTABLE;
which requires pgcrypto. In Debian : su - postgres $ psql UDD < /usr/share/postgresql/8.3/contrib/pgcrypto.sql */
/* Some of the columns of the Triplify queries will contain references to other * objects rather than literal values. The following configuration array * specifies, which columns are references to objects of which type. */ $triplify['objectProperties']=array( 'owl:sameAs'=>'http:', 'bom:hasState'=>'http://picoforge.int-evry.fr/projects/svn/helios_wp3/2009/07', 'bom:hasSeverity'=>'http://picoforge.int-evry.fr/projects/svn/helios_wp3/2009/07' );
/* Objects are classified according to their type. However, you can specify * a mapping here, if objects of a certain type should be associated with a * different class (e.g. classify all users as 'foaf:person'). If you are * unsure it is safe to leave this configuration array empty. */ $triplify['classMap']=array( 'issue'=>'bom:Issue', 'user'=>'sioc:User', 'submission'=>'sioc:User', 'carnivore'=>'foaf:Person', 'bpackage'=>'bom:Component', 'spackage'=>'bom:Product', 'bpackagebugs'=>'bom:Component', 'binariesofsource'=>'bom:Product', 'forwardedupstream'=>'bom:Issue' );
/* You can attach license information to your content. * A popular license is Creative Commons Attribution, which allows sharing and * remixing under the condition of attributing the original author. */ /*$triplify['license']='http://creativecommons.org/licenses/by/3.0/us/';*
/* Additional metadata * You can add arbitrary metadata. The keys of the following array are * properties, the values will be represented as respective property values. */ $triplify['metadata']=array( /* 'dc:title'=>'', 'dc:publisher'=>'' */ );
/* Set this to true in order to register your linked data endpoint with the * Triplify registry (http://triplify.org/Registry). * Registering is absolutely recommended, since that allows other Web sites * (e.g. peer Web applications, search engines and mashups) to easily find your * content. Requires PHP ini variable allow_url_fopen set to true. * You can also register your data source manually by accessing register.php in * the triplify folder, or at: http://triplify.org/Registry */ $triplify['register']=false;
/* You can specify for how long generated files should be cached. For smaller * Web applications it is save to disable caching by setting this value to zero. */ $triplify['TTL']=0;
/* Directory to be used for caching */ $triplify['cachedir']='cache/';
/* Linked Data Depth * * Specify on which URI level to expose the data - possible values are: * - Use 0 or ommit to expose all available content on the highest level * all content will be exposed when /triplify/ is accessed on your server * this configuration is recommended for small to medium websites. * - Use 1 to publish only links to the classes on the highest level and all * content will be exposed when for example /triplify/user/ is accessed. * - Use 2 to publish only links on highest and classes level and all * content will be exposed on the instance level, e.g. when /triplify/user/1/ * is accessed. */ $triplify['LinkedDataDepth']='2';
/* Callback Functions * * Some of the columns of the Triplify queries will contain data, which has to * be processed before exposed as RDF (literals). This configuration array maps * column names to respective functions, which have to take the data value as a * parameter and return it processed. */
function debianBugStatusTohasState ($string) { return 'helios_bt.owl#DebbugsState'.$string; }
function debianBugSeverityTohasSeverity ($string) { return 'helios_bt.owl#DebbugsSeverity'.$string; }
$triplify['CallbackFunctions']=array( 'bom:hasState' => 'debianBugStatusTohasState', 'bom:hasSeverity' => 'debianBugSeverityTohasSeverity' ); ?>
|