r111237 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111236‎ | r111237 | r111238 >
Date:15:01, 11 February 2012
Author:mkroetzsch
Status:deferred
Tags:
Comment:
Support use of inverse properties when using SPARQL backend.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStoreQueryEngine.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php
@@ -233,7 +233,7 @@
234234 static public function getResourceElementForProperty( SMWDIProperty $diProperty, $helperProperty = false ) {
235235 $diWikiPage = $diProperty->getDiWikiPage();
236236 if ( is_null( $diWikiPage ) ) {
237 - throw new Exception( 'SMWExporter::getResourceElementForProperty() can only be used for user-defined properties.' );
 237+ throw new Exception( 'SMWExporter::getResourceElementForProperty() can only be used for non-inverse, user-defined properties.' );
238238 } elseif ( $helperProperty ) {
239239 return self::getResourceElementForWikiPage( $diWikiPage, 'aux' );
240240 } else {
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStoreQueryEngine.php
@@ -691,17 +691,20 @@
692692 if ( $diProperty->isInverse() ) { // don't check if this really makes sense
693693 $subjectName = $objectName;
694694 $objectName = '?' . $joinVariable;
 695+ $diNonInverseProperty = new SMWDIProperty( $diProperty->getKey(), false );
695696 } else {
696697 $subjectName = '?' . $joinVariable;
 698+ $diNonInverseProperty = $diProperty;
697699 }
698700
699701 //*** Build the condition ***//
700702 $typeId = $diProperty->findPropertyTypeID();
701703 $diType = SMWDataValueFactory::getDataItemId( $typeId );
 704+ // for types that use helper properties in encoding values, refer to this helper property:
702705 if ( SMWExporter::hasHelperExpElement( $diType ) ) {
703 - $propertyExpElement = SMWExporter::getResourceElementForProperty( $diProperty, true );
 706+ $propertyExpElement = SMWExporter::getResourceElementForProperty( $diNonInverseProperty, true );
704707 } else {
705 - $propertyExpElement = SMWExporter::getResourceElementForProperty( $diProperty );
 708+ $propertyExpElement = SMWExporter::getResourceElementForProperty( $diNonInverseProperty );
706709 }
707710 $propertyName = SMWTurtleSerializer::getTurtleNameForExpElement( $propertyExpElement );
708711 if ( $propertyExpElement instanceof SMWExpNsResource ) {