r87829 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87828‎ | r87829 | r87830 >
Date:17:38, 10 May 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
+support for namespace queries
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStoreQueryEngine.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStoreQueryEngine.php
@@ -479,7 +479,7 @@
480480 if ( $description instanceof SMWSomeProperty ) {
481481 return $this->buildPropertyCondition( $description, $joinVariable, $orderByProperty );
482482 } elseif ( $description instanceof SMWNamespaceDescription ) {
483 - return new SMWSparqlTrueCondition(); ///TODO Implement namespace filtering
 483+ return $this->buildNamespaceCondition( $description, $joinVariable, $orderByProperty );
484484 } elseif ( $description instanceof SMWConjunction ) {
485485 return $this->buildConjunctionCondition( $description, $joinVariable, $orderByProperty );
486486 } elseif ( $description instanceof SMWDisjunction ) {
@@ -742,6 +742,27 @@
743743 }
744744
745745 /**
 746+ * Create an SMWSparqlCondition from an SMWNamespaceDescription.
 747+ *
 748+ * @param $description SMWNamespaceDescription
 749+ * @param $joinVariable string name, see buildSparqlCondition()
 750+ * @param $orderByProperty mixed SMWDIProperty or null, see buildSparqlCondition()
 751+ * @return SMWSparqlCondition
 752+ */
 753+ protected function buildNamespaceCondition( SMWNamespaceDescription $description, $joinVariable, $orderByProperty ) {
 754+ $nspropExpElement = SMWExporter::getSpecialNsResource( 'swivt', 'wikiNamespace' );
 755+ $nsExpElement = new SMWExpLiteral( $description->getNamespace(), 'http://www.w3.org/2001/XMLSchema#integer' );
 756+ $nsName = SMWTurtleSerializer::getTurtleNameForExpElement( $nsExpElement );
 757+ $condition = "{ ?$joinVariable " . $nspropExpElement->getQName() . " $nsName . }\n";
 758+
 759+ $result = new SMWSparqlWhereCondition( $condition, true, array() );
 760+
 761+ $this->addOrderByDataForProperty( $result, $joinVariable, $orderByProperty, SMWDataItem::TYPE_WIKIPAGE );
 762+
 763+ return $result;
 764+ }
 765+
 766+ /**
746767 * Create an SMWSparqlCondition from an SMWValueDescription.
747768 *
748769 * @param $description SMWValueDescription

Status & tagging log