Skip to content

Commit

Permalink
Merge "REST: Make GetPropertyStatementRequest extend GetStatementRequ…
Browse files Browse the repository at this point in the history
…est"
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Sep 18, 2023
2 parents 7f14d4a + 41c775a commit c956aff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Wikibase\Repo\RestApi\Application\UseCases\AssertPropertyExists;
use Wikibase\Repo\RestApi\Application\UseCases\GetStatement\GetStatement;
use Wikibase\Repo\RestApi\Application\UseCases\GetStatement\GetStatementRequest;
use Wikibase\Repo\RestApi\Application\UseCases\GetStatement\GetStatementResponse;
use Wikibase\Repo\RestApi\Application\UseCases\UseCaseError;

Expand Down Expand Up @@ -32,18 +31,17 @@ public function __construct(
*/
public function execute( GetPropertyStatementRequest $request ): GetStatementResponse {
$deserializedRequest = $this->validator->validateAndDeserialize( $request );
$getStatementRequest = new GetStatementRequest( $request->getStatementId() );

$this->assertPropertyExists->execute( $deserializedRequest->getPropertyId() );

if ( !$deserializedRequest->getStatementId()->getEntityId()->equals( $deserializedRequest->getPropertyId() ) ) {
throw new UseCaseError(
UseCaseError::STATEMENT_NOT_FOUND,
"Could not find a statement with the ID: {$request->getStatementId()}"
"Could not find a statement with the ID: {$deserializedRequest->getStatementId()}"
);
}

return $this->getStatement->execute( $getStatementRequest );
return $this->getStatement->execute( $request );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,22 @@

namespace Wikibase\Repo\RestApi\Application\UseCases\GetPropertyStatement;

use Wikibase\Repo\RestApi\Application\UseCases\GetStatement\GetStatementRequest;
use Wikibase\Repo\RestApi\Application\UseCases\PropertyIdRequest;
use Wikibase\Repo\RestApi\Application\UseCases\StatementIdRequest;
use Wikibase\Repo\RestApi\Application\UseCases\UseCaseRequest;

/**
* @license GPL-2.0-or-later
*/
class GetPropertyStatementRequest implements UseCaseRequest, PropertyIdRequest, StatementIdRequest {
class GetPropertyStatementRequest extends GetStatementRequest implements PropertyIdRequest {

private string $propertyId;
private string $statementId;

public function __construct( string $propertyId, string $statementId ) {
parent::__construct( $statementId );
$this->propertyId = $propertyId;
$this->statementId = $statementId;
}

public function getPropertyId(): string {
return $this->propertyId;
}

public function getStatementId(): string {
return $this->statementId;
}
}

0 comments on commit c956aff

Please sign in to comment.