Thiemo Mättig (WMDE) has submitted this change and it was merged.

Change subject: Stop using ApiWikibase
......................................................................


Stop using ApiWikibase

Change-Id: I2b83d2f6e3cb29c4256c51d4f008ad53c045c2dd
---
M api/RunCrossCheck.php
1 file changed, 43 insertions(+), 17 deletions(-)

Approvals:
  Thiemo Mättig (WMDE): Looks good to me, approved
  jenkins-bot: Verified



diff --git a/api/RunCrossCheck.php b/api/RunCrossCheck.php
index 521fd57..31d94f0 100755
--- a/api/RunCrossCheck.php
+++ b/api/RunCrossCheck.php
@@ -2,10 +2,15 @@
 
 namespace WikibaseQuality\ExternalValidation\Api;
 
+use ApiBase;
 use ApiMain;
 use DataValues\Serializers;
-use Wikibase\Api\ApiWikibase;
+use RequestContext;
+use Wikibase\Repo\Api\ApiErrorReporter;
+use Wikibase\Repo\Api\ApiHelperFactory;
+use Wikibase\Repo\Api\ResultBuilder;
 use Wikibase\DataModel\Entity\EntityId;
+use Wikibase\DataModel\Entity\EntityIdParser;
 use Wikibase\Lib\ClaimGuidValidator;
 use Wikibase\Repo\WikibaseRepo;
 use WikibaseQuality\ExternalValidation\CrossCheck\CrossCheckInteractor;
@@ -22,7 +27,7 @@
  * @author BP2014N1
  * @license GNU GPL v2+
  */
-class RunCrossCheck extends ApiWikibase {
+class RunCrossCheck extends ApiBase {
 
        /**
         * @var ClaimGuidValidator
@@ -38,6 +43,21 @@
         * @var SerializerFactory
         */
        private $serializerFactory;
+
+       /**
+        * @var ApiErrorReporter
+        */
+       private $errorReporter;
+
+       /**
+        * @var ResultBuilder
+        */
+       private $resultBuilder;
+
+       /**
+        * @var EntityIdParser
+        */
+       private $idParser;
 
        /**
         * Creates new instance from global state.
@@ -57,7 +77,9 @@
                        $prefix,
                        $repo->getClaimGuidValidator(),
                        $externalValidationServices->getCrossCheckInteractor(),
-                       $externalValidationServices->getSerializerFactory()
+                       $externalValidationServices->getSerializerFactory(),
+                       $repo->getApiHelperFactory( RequestContext::getMain() ),
+                       $repo->getEntityIdParser()
                );
        }
 
@@ -67,12 +89,16 @@
         * @param string $prefix
         */
        public function __construct( ApiMain $main, $name, $prefix = '', 
ClaimGuidValidator $claimGuidValidator,
-                                                                
CrossCheckInteractor $crossCheckInteractor, SerializerFactory 
$serializerFactory ) {
+                                                                
CrossCheckInteractor $crossCheckInteractor, SerializerFactory 
$serializerFactory,
+                                                                
ApiHelperFactory $apiHelperFactory, EntityIdParser $idParser ) {
                parent::__construct( $main, $name, $prefix );
 
                $this->claimGuidValidator = $claimGuidValidator;
                $this->crossCheckInteractor = $crossCheckInteractor;
                $this->serializerFactory = $serializerFactory;
+               $this->errorReporter = $apiHelperFactory->getErrorReporter( 
$this );
+               $this->resultBuilder = $apiHelperFactory->getResultBuilder( 
$this );
+               $this->idParser = $idParser;
        }
 
        /**
@@ -82,7 +108,7 @@
                $params = $this->extractRequestParams();
 
                if ( $params['entities'] && $params['claims'] ) {
-                       $this->dieError(
+                       $this->errorReporter->dieError(
                                'Either provide the ids of entities or ids of 
claims, that should be cross-checked.',
                                'param-invalid'
                        );
@@ -99,7 +125,7 @@
                        $this->assertAreValidClaimGuids( $claimGuids );
                        $resultLists = 
$this->crossCheckInteractor->crossCheckStatements( $claimGuids );
                } else {
-                       $this->dieError(
+                       $this->errorReporter->dieError(
                                'Either provide the ids of entities or ids of 
claims, that should be cross-checked.',
                                'param-missing'
                        );
@@ -116,7 +142,7 @@
         */
        private function parseEntityIds( array $entityIds ) {
                return array_map(
-                       array( $this->getIdParser(), 'parse' ),
+                       array( $this->idParser, 'parse' ),
                        $entityIds
                );
        }
@@ -127,7 +153,7 @@
        private function assertAreValidClaimGuids( array $claimGuids ) {
                foreach ( $claimGuids as $claimGuid ) {
                        if ( $this->claimGuidValidator->validateFormat( 
$claimGuid ) === false ) {
-                               $this->dieError( 'Invalid claim guid.', 
'invalid-guid' );
+                               $this->errorReporter->dieError( 'Invalid claim 
guid.', 'invalid-guid' );
                        }
                }
        }
@@ -164,7 +190,7 @@
 
                $this->getResult()->setIndexedTagName( $output, 'entity' );
                $this->getResult()->addValue( null, 'results', $output );
-               $this->getResultBuilder()->markSuccess( 1 );
+               $this->resultBuilder->markSuccess( 1 );
        }
 
        /**
@@ -174,20 +200,20 @@
         * @codeCoverageIgnore
         */
        public function getAllowedParams() {
-               return array_merge( parent::getAllowedParams(), array(
+               return array(
                        'entities' => array(
-                               ApiWikibase::PARAM_TYPE => 'string',
-                               ApiWikibase::PARAM_ISMULTI => true
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_ISMULTI => true
                        ),
                        'properties' => array(
-                               ApiWikibase::PARAM_TYPE => 'string',
-                               ApiWikibase::PARAM_ISMULTI => true
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_ISMULTI => true
                        ),
                        'claims' => array(
-                               ApiWikibase::PARAM_TYPE => 'string',
-                               ApiWikibase::PARAM_ISMULTI => true
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_ISMULTI => true
                        )
-               ) );
+               );
        }
 
        /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2b83d2f6e3cb29c4256c51d4f008ad53c045c2dd
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/WikibaseQualityExternalValidation
Gerrit-Branch: v1
Gerrit-Owner: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Bene <benestar.wikime...@gmail.com>
Gerrit-Reviewer: Hoo man <h...@online.de>
Gerrit-Reviewer: JanZerebecki <jan.wikime...@zerebecki.de>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to