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 |
1 | 46 | + native |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php |
— | — | @@ -198,6 +198,7 @@ |
199 | 199 | $wgAutoloadClasses['SMWRecordFieldDescription'] = $smwgIP . 'includes/SMW_Record_Descriptions.php'; |
200 | 200 | |
201 | 201 | $wgAutoloadClasses['SMWSparqlDatabase'] = $smwgIP . 'includes/sparql/SMW_SparqlDatabase.php'; |
| 202 | + $wgAutoloadClasses['SMWSparqlDatabase4Store'] = $smwgIP . 'includes/sparql/SMW_SparqlDatabase4Store.php'; |
202 | 203 | $wgAutoloadClasses['SMWSparqlDatabaseError'] = $smwgIP . 'includes/sparql/SMW_SparqlDatabase.php'; |
203 | 204 | $wgAutoloadClasses['SMWSparqlResultWrapper'] = $smwgIP . 'includes/sparql/SMW_SparqlResultWrapper.php'; |
204 | 205 | $wgAutoloadClasses['SMWSparqlResultParser'] = $smwgIP . 'includes/sparql/SMW_SparqlResultParser.php'; |
— | — | @@ -221,6 +222,7 @@ |
222 | 223 | $wgAutoloadClasses['SMWSQLStore2Table'] = $stoDir . 'SMW_SQLStore2Table.php'; |
223 | 224 | $wgAutoloadClasses['SMWSQLHelpers'] = $stoDir . 'SMW_SQLHelpers.php'; |
224 | 225 | $wgAutoloadClasses['SMWSparqlStore'] = $stoDir . 'SMW_SparqlStore.php'; |
| 226 | + $wgAutoloadClasses['SMWSparqlBuilder'] = $stoDir . 'SMW_SparqlBuilder.php'; |
225 | 227 | |
226 | 228 | // To ensure SMW remains compatible with pre 1.16. |
227 | 229 | if ( !class_exists( 'Html' ) ) { |