Denny Vrandecic has submitted this change and it was merged. Change subject: Added SnakRemover ......................................................................
Added SnakRemover Change-Id: I01266d0f964186b539f45db7fc2fe1e0586d7fd2 --- A QueryEngine/includes/SQLStore/SnakStore/SnakRemover.php M QueryEngine/includes/SQLStore/SnakStore/SnakStore.php M QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php M QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php A QueryEngine/tests/phpunit/SQLStore/SnakStore/SnakRemoverTest.php 5 files changed, 152 insertions(+), 0 deletions(-) Approvals: Denny Vrandecic: Looks good to me, approved jenkins-bot: Verified diff --git a/QueryEngine/includes/SQLStore/SnakStore/SnakRemover.php b/QueryEngine/includes/SQLStore/SnakStore/SnakRemover.php new file mode 100644 index 0000000..bb7b400 --- /dev/null +++ b/QueryEngine/includes/SQLStore/SnakStore/SnakRemover.php @@ -0,0 +1,63 @@ +<?php + +namespace Wikibase\QueryEngine\SQLStore\SnakStore; + +use RuntimeException; +use Wikibase\Snak; + +/** + * Use case for removing snaks from the store. + * + * TODO: this can be made more efficient by providing the list of snaks + * the entity has, so deletes can be run just against the relevant + * data value type specific tables. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @since 0.1 + * + * @file + * @ingroup WikibaseSQLStore + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class SnakRemover { + + /** + * @var SnakStore[] + */ + protected $snakStores; + + /** + * @param SnakStore[] $snakStores + */ + public function __construct( array $snakStores ) { + $this->snakStores = $snakStores; + } + + /** + * @since 0.1 + * + * @param int $internalSubjectId + */ + public function removeSnaksOfSubject( $internalSubjectId ) { + foreach ( $this->snakStores as $snakStore ) { + $snakStore->removeSnaksOfSubject( $internalSubjectId ); + } + } + +} diff --git a/QueryEngine/includes/SQLStore/SnakStore/SnakStore.php b/QueryEngine/includes/SQLStore/SnakStore/SnakStore.php index 05524a9..ca71d8a 100644 --- a/QueryEngine/includes/SQLStore/SnakStore/SnakStore.php +++ b/QueryEngine/includes/SQLStore/SnakStore/SnakStore.php @@ -44,4 +44,11 @@ */ public abstract function storeSnakRow( SnakRow $snakRow ); + /** + * @since 0.1 + * + * @param int $internalSubjectId + */ + public abstract function removeSnaksOfSubject( $internalSubjectId ); + } diff --git a/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php b/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php index b61c18e..b0fcc15 100644 --- a/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php +++ b/QueryEngine/includes/SQLStore/SnakStore/ValueSnakStore.php @@ -97,4 +97,8 @@ ); } + public function removeSnaksOfSubject( $internalSubjectId ) { + + } + } diff --git a/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php b/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php index 30f8166..0959559 100644 --- a/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php +++ b/QueryEngine/includes/SQLStore/SnakStore/ValuelessSnakStore.php @@ -64,4 +64,8 @@ ); } + public function removeSnaksOfSubject( $internalSubjectId ) { + + } + } diff --git a/QueryEngine/tests/phpunit/SQLStore/SnakStore/SnakRemoverTest.php b/QueryEngine/tests/phpunit/SQLStore/SnakStore/SnakRemoverTest.php new file mode 100644 index 0000000..985927b --- /dev/null +++ b/QueryEngine/tests/phpunit/SQLStore/SnakStore/SnakRemoverTest.php @@ -0,0 +1,74 @@ +<?php + +namespace Wikibase\QueryEngine\Tests\SQLStore; + +use Wikibase\Database\FieldDefinition; +use Wikibase\Database\TableDefinition; +use Wikibase\QueryEngine\SQLStore\DataValueTable; +use Wikibase\QueryEngine\SQLStore\SnakStore\SnakRemover; + +/** + * @covers Wikibase\QueryEngine\SQLStore\SnakRemover + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @since 0.1 + * + * @ingroup WikibaseQueryEngineTest + * + * @group Wikibase + * @group WikibaseQueryEngine + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class SnakRemoverTest extends \PHPUnit_Framework_TestCase { + + /** + * @dataProvider subjectIdProvider + */ + public function testRemoveSnaksOfSubject( $internalSubjectId ) { + $valuelessStore = $this->getMockBuilder( 'Wikibase\QueryEngine\SQLStore\SnakStore\ValuelessSnakStore' ) + ->disableOriginalConstructor()->getMock(); + $valueStore = $this->getMockBuilder( 'Wikibase\QueryEngine\SQLStore\SnakStore\ValueSnakStore' ) + ->disableOriginalConstructor()->getMock(); + + $valuelessStore->expects( $this->once() ) + ->method( 'removeSnaksOfSubject' ) + ->with( $this->equalTo( $internalSubjectId ) ); + + $valueStore->expects( $this->once() ) + ->method( 'removeSnaksOfSubject' ) + ->with( $this->equalTo( $internalSubjectId ) ); + + $snakRemover = new SnakRemover( array( $valuelessStore, $valueStore ) ); + + $snakRemover->removeSnaksOfSubject( $internalSubjectId ); + } + + public function subjectIdProvider() { + $argLists = array(); + + $argLists[] = array( 1 ); + $argLists[] = array( 10 ); + $argLists[] = array( 11 ); + $argLists[] = array( 4242 ); + + return $argLists; + } + +} -- To view, visit https://gerrit.wikimedia.org/r/65552 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I01266d0f964186b539f45db7fc2fe1e0586d7fd2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Anja Jentzsch <a...@anjeve.de> Gerrit-Reviewer: Ataherivand <abraham.taheriv...@wikimedia.de> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Daniel Werner <daniel.wer...@wikimedia.de> Gerrit-Reviewer: Denny Vrandecic <denny.vrande...@wikimedia.de> Gerrit-Reviewer: Henning Snater <henning.sna...@wikimedia.de> Gerrit-Reviewer: Jens Ohlig <jens.oh...@wikimedia.de> Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: John Erling Blad <jeb...@gmail.com> Gerrit-Reviewer: Lydia Pintscher <lydia.pintsc...@wikimedia.de> Gerrit-Reviewer: Markus Kroetzsch <mar...@semantic-mediawiki.org> Gerrit-Reviewer: Nikola Smolenski <smole...@eunet.rs> Gerrit-Reviewer: Silke Meyer <silke.me...@wikimedia.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits