r86850 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86849‎ | r86850 | r86851 >
Date:12:18, 25 April 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
custom SPARQL binding implementation for 4Store
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/sparql/SMW_SparqlDatabase4Store.php (added) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/sparql/SMW_SparqlDatabase4Store.php
@@ -0,0 +1,44 @@
 2+<?php
 3+/**
 4+ * 4Store specific adjustments for SMWSparqlDatabase
 5+ *
 6+ * @file
 7+ * @ingroup SMWSparql
 8+ *
 9+ * @author Markus Krötzsch
 10+ */
 11+
 12+/**
 13+ * Specific modifications of the SPARQL database implementation for 4Store.
 14+ *
 15+ * @ingroup SMWSparql
 16+ *
 17+ * @author Markus Krötzsch
 18+ */
 19+class SMWSparqlDatabase4Store extends SMWSparqlDatabase {
 20+
 21+ /**
 22+ * ASK wrapper.
 23+ * "ASK" is buggy in 4Store and must be avoided.
 24+ *
 25+ * @note This does not avoid the 4Store bug: all SPARQL queries are
 26+ * potentially answered incorrectly by 4Store v.1.1.2. Nothing we can
 27+ * do.
 28+ *
 29+ * @see SMWSparqlDatabase::ask
 30+ * @param $where string WHERE part of the query, without surrounding { }
 31+ * @param $extraNamespaces array (associative) of namespaceId => namespaceUri
 32+ * @return SMWSparqlResultWrapper
 33+ */
 34+ public function ask( $where, $extraNamespaces = array() ) {
 35+ $sparql = self::getPrefixString( $extraNamespaces ) . "SELECT * WHERE {\n" . $where . "\n} LIMIT 1";
 36+ $result = $this->doQuery( $sparql );
 37+ if ( $result->numRows() > 0 ) {
 38+ $expLiteral = new SMWExpLiteral( 'true', 'http://www.w3.org/2001/XMLSchema#boolean' );
 39+ } else {
 40+ $expLiteral = new SMWExpLiteral( 'false', 'http://www.w3.org/2001/XMLSchema#boolean' );
 41+ }
 42+ return new SMWSparqlResultWrapper( array( '' => 0 ), array( array( $expLiteral ) ) );
 43+ }
 44+
 45+}
\ No newline at end of file
Property changes on: trunk/extensions/SemanticMediaWiki/includes/sparql/SMW_SparqlDatabase4Store.php
___________________________________________________________________
Added: svn:eol-style
146 + native
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php
@@ -198,6 +198,7 @@
199199 $wgAutoloadClasses['SMWRecordFieldDescription'] = $smwgIP . 'includes/SMW_Record_Descriptions.php';
200200
201201 $wgAutoloadClasses['SMWSparqlDatabase'] = $smwgIP . 'includes/sparql/SMW_SparqlDatabase.php';
 202+ $wgAutoloadClasses['SMWSparqlDatabase4Store'] = $smwgIP . 'includes/sparql/SMW_SparqlDatabase4Store.php';
202203 $wgAutoloadClasses['SMWSparqlDatabaseError'] = $smwgIP . 'includes/sparql/SMW_SparqlDatabase.php';
203204 $wgAutoloadClasses['SMWSparqlResultWrapper'] = $smwgIP . 'includes/sparql/SMW_SparqlResultWrapper.php';
204205 $wgAutoloadClasses['SMWSparqlResultParser'] = $smwgIP . 'includes/sparql/SMW_SparqlResultParser.php';
@@ -221,6 +222,7 @@
222223 $wgAutoloadClasses['SMWSQLStore2Table'] = $stoDir . 'SMW_SQLStore2Table.php';
223224 $wgAutoloadClasses['SMWSQLHelpers'] = $stoDir . 'SMW_SQLHelpers.php';
224225 $wgAutoloadClasses['SMWSparqlStore'] = $stoDir . 'SMW_SparqlStore.php';
 226+ $wgAutoloadClasses['SMWSparqlBuilder'] = $stoDir . 'SMW_SparqlBuilder.php';
225227
226228 // To ensure SMW remains compatible with pre 1.16.
227229 if ( !class_exists( 'Html' ) ) {

Status & tagging log