Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/64949


Change subject: getInternalIdForEntity now takes an EntityId rather then its 
components
......................................................................

getInternalIdForEntity now takes an EntityId rather then its components

Change-Id: Ib476cc1eac306996823bfc15f7be73478985bcfe
---
M QueryEngine/includes/SQLStore/ClaimStore/ClaimRowBuilder.php
M QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
M QueryEngine/includes/SQLStore/EntityInserter.php
M QueryEngine/includes/SQLStore/InternalEntityIdTransformer.php
M QueryEngine/includes/SQLStore/SimpleEntityIdTransformer.php
M QueryEngine/includes/SQLStore/SnakStore/SnakRowBuilder.php
M QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php
M QueryEngine/tests/phpunit/SQLStore/SimpleEntityIdTransformerTest.php
8 files changed, 20 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/49/64949/1

diff --git a/QueryEngine/includes/SQLStore/ClaimStore/ClaimRowBuilder.php 
b/QueryEngine/includes/SQLStore/ClaimStore/ClaimRowBuilder.php
index f266b40..9bfbf00 100644
--- a/QueryEngine/includes/SQLStore/ClaimStore/ClaimRowBuilder.php
+++ b/QueryEngine/includes/SQLStore/ClaimStore/ClaimRowBuilder.php
@@ -53,10 +53,7 @@
        }
 
        protected function getInternalIdFor( EntityId $entityId ) {
-               return $this->idFinder->getInternalIdForEntity(
-                       $entityId->getEntityType(),
-                       $entityId->getNumericId()
-               );
+               return $this->idFinder->getInternalIdForEntity( $entityId );
        }
 
 }
\ No newline at end of file
diff --git a/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php 
b/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
index a4a2a49..5a45be0 100644
--- a/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
+++ b/QueryEngine/includes/SQLStore/Engine/DescriptionMatchFinder.php
@@ -114,10 +114,7 @@
        }
 
        protected function getInternalId( EntityId $id ) {
-               return $this->idFinder->getInternalIdForEntity(
-                       $id->getEntityType(),
-                       $id->getNumericId()
-               );
+               return $this->idFinder->getInternalIdForEntity( $id );
        }
 
        protected function getExtraConditions( SomeProperty $description, 
DataValueHandler $dvHandler ) {
diff --git a/QueryEngine/includes/SQLStore/EntityInserter.php 
b/QueryEngine/includes/SQLStore/EntityInserter.php
index a9f6086..7fd84ca 100644
--- a/QueryEngine/includes/SQLStore/EntityInserter.php
+++ b/QueryEngine/includes/SQLStore/EntityInserter.php
@@ -74,10 +74,7 @@
        }
 
        protected function getInternalId( EntityId $entityId ) {
-               return $this->idFinder->getInternalIdForEntity(
-                       $entityId->getEntityType(),
-                       $entityId->getNumericId()
-               );
+               return $this->idFinder->getInternalIdForEntity( $entityId );
        }
 
 }
diff --git a/QueryEngine/includes/SQLStore/InternalEntityIdTransformer.php 
b/QueryEngine/includes/SQLStore/InternalEntityIdTransformer.php
index ea721f5..189566d 100644
--- a/QueryEngine/includes/SQLStore/InternalEntityIdTransformer.php
+++ b/QueryEngine/includes/SQLStore/InternalEntityIdTransformer.php
@@ -2,6 +2,8 @@
 
 namespace Wikibase\QueryEngine\SQLStore;
 
+use Wikibase\EntityId;
+
 /**
  * Finds the internal entity id for the given external entity id.
  *
@@ -31,13 +33,10 @@
 interface InternalEntityIdTransformer {
 
        /**
-        * TODO: taking an EntityId would be a lot more convenient
-        *
-        * @param string $entityType
-        * @param int $entityNumber
+        * @param EntityId $entityId
         *
         * @return int
         */
-       public function getInternalIdForEntity( $entityType, $entityNumber );
+       public function getInternalIdForEntity( EntityId $entityId );
 
 }
diff --git a/QueryEngine/includes/SQLStore/SimpleEntityIdTransformer.php 
b/QueryEngine/includes/SQLStore/SimpleEntityIdTransformer.php
index bc0245a..fc58363 100644
--- a/QueryEngine/includes/SQLStore/SimpleEntityIdTransformer.php
+++ b/QueryEngine/includes/SQLStore/SimpleEntityIdTransformer.php
@@ -2,6 +2,8 @@
 
 namespace Wikibase\QueryEngine\SQLStore;
 
+use Wikibase\EntityId;
+
 /**
  * Transforms entity types and numbers into internal store ids.
  *
@@ -43,15 +45,14 @@
        /**
         * @see InternalEntityIdTransformer::getInternalIdForEntity
         *
-        * @param string $entityType
-        * @param int $entityNumber
+        * @param EntityId $entityId
         *
         * @return int
         */
-       public function getInternalIdForEntity( $entityType, $entityNumber ) {
-               $this->ensureEntityTypeIsKnown( $entityType );
+       public function getInternalIdForEntity( EntityId $entityId ) {
+               $this->ensureEntityTypeIsKnown( $entityId->getEntityType() );
 
-               return $this->getComputedId( $entityType, $entityNumber );
+               return $this->getComputedId( $entityId );
        }
 
        protected function ensureEntityTypeIsKnown( $entityType ) {
@@ -60,8 +61,8 @@
                }
        }
 
-       protected function getComputedId( $entityType, $entityNumber ) {
-               return $entityNumber * 10 + $this->idMap[$entityType];
+       protected function getComputedId( EntityId $entityId ) {
+               return $entityId->getNumericId() * 10 + 
$this->idMap[$entityId->getEntityType()];
        }
 
 }
diff --git a/QueryEngine/includes/SQLStore/SnakStore/SnakRowBuilder.php 
b/QueryEngine/includes/SQLStore/SnakStore/SnakRowBuilder.php
index 9339d74..1485da1 100644
--- a/QueryEngine/includes/SQLStore/SnakStore/SnakRowBuilder.php
+++ b/QueryEngine/includes/SQLStore/SnakStore/SnakRowBuilder.php
@@ -91,10 +91,7 @@
        }
 
        protected function getInternalIdFor( EntityId $entityId ) {
-               return $this->idFinder->getInternalIdForEntity(
-                       $entityId->getEntityType(),
-                       $entityId->getNumericId()
-               );
+               return $this->idFinder->getInternalIdForEntity( $entityId );
        }
 
 }
\ No newline at end of file
diff --git a/QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php 
b/QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php
index c23b763..546a291 100644
--- a/QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php
+++ b/QueryEngine/tests/phpunit/SQLStore/EntityInserterTest.php
@@ -79,8 +79,7 @@
                $idFinder->expects( $this->any() )
                        ->method( 'getInternalIdForEntity' )
                        ->with(
-                               $entity->getId()->getEntityType(),
-                               $entity->getId()->getNumericId()
+                               $entity->getId()
                        )
                        ->will( $this->returnValue( 1234 ) );
 
diff --git 
a/QueryEngine/tests/phpunit/SQLStore/SimpleEntityIdTransformerTest.php 
b/QueryEngine/tests/phpunit/SQLStore/SimpleEntityIdTransformerTest.php
index c1b7a6a..f8ec74a 100644
--- a/QueryEngine/tests/phpunit/SQLStore/SimpleEntityIdTransformerTest.php
+++ b/QueryEngine/tests/phpunit/SQLStore/SimpleEntityIdTransformerTest.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase\QueryEngine\Tests\SQLStore;
 
+use Wikibase\EntityId;
 use Wikibase\QueryEngine\SQLStore\SimpleEntityIdTransformer;
 
 /**
@@ -58,7 +59,7 @@
 
                $transformer = new SimpleEntityIdTransformer( $idMap );
 
-               $internalId = $transformer->getInternalIdForEntity( 
$entityType, $numericId );
+               $internalId = $transformer->getInternalIdForEntity( new 
EntityId( $entityType, $numericId ) );
 
                $this->assertInternalType( 'int', $internalId );
 
@@ -95,7 +96,7 @@
 
                $transformer = new SimpleEntityIdTransformer( array() );
 
-               $transformer->getInternalIdForEntity( $entityType, $numericId );
+               $transformer->getInternalIdForEntity( new EntityId( 
$entityType, $numericId ) );
        }
 
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/64949
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib476cc1eac306996823bfc15f7be73478985bcfe
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to