Skip to content

Commit

Permalink
REST: Add aliases to Property read model
Browse files Browse the repository at this point in the history
Bug: T342982
Change-Id: Iedc6ebff691f503a4a3b080022ca23db08970d9e
  • Loading branch information
jakobw committed Oct 10, 2023
1 parent a348256 commit 66f2522
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
8 changes: 7 additions & 1 deletion repo/rest-api/src/Domain/ReadModel/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
class Property {

private StatementList $statements;
private Aliases $aliases;

public function __construct( StatementList $statements ) {
public function __construct( Aliases $aliases, StatementList $statements ) {
$this->aliases = $aliases;
$this->statements = $statements;
}

public function getAliases(): Aliases {
return $this->aliases;
}

public function getStatements(): StatementList {
return $this->statements;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Wikibase\DataModel\Entity\Property as DataModelProperty;
use Wikibase\Repo\RestApi\Domain\Model\EditMetadata;
use Wikibase\Repo\RestApi\Domain\ReadModel\Aliases;
use Wikibase\Repo\RestApi\Domain\ReadModel\Property;
use Wikibase\Repo\RestApi\Domain\ReadModel\PropertyRevision;
use Wikibase\Repo\RestApi\Domain\ReadModel\StatementList;
Expand Down Expand Up @@ -39,6 +40,7 @@ public function update( DataModelProperty $property, EditMetadata $editMetadata

private function convertDataModelPropertyToReadModel( DataModelProperty $property ): Property {
return new Property(
Aliases::fromAliasGroupList( $property->getAliasGroups() ),
new StatementList(
...array_map(
[ $this->statementReadModelConverter, 'convert' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Wikibase\Repo\RestApi\Application\UseCases\AssertUserIsAuthorized;
use Wikibase\Repo\RestApi\Application\UseCases\UseCaseError;
use Wikibase\Repo\RestApi\Domain\Model\EditSummary;
use Wikibase\Repo\RestApi\Domain\ReadModel\Aliases;
use Wikibase\Repo\RestApi\Domain\ReadModel\Property;
use Wikibase\Repo\RestApi\Domain\ReadModel\PropertyRevision;
use Wikibase\Repo\RestApi\Domain\ReadModel\StatementList;
Expand Down Expand Up @@ -81,7 +82,11 @@ public function testAddStatement(): void {
),
$this->expectEquivalentMetadata( $editTags, $isBot, $comment, EditSummary::ADD_ACTION )
)
->willReturn( new PropertyRevision( new Property( new StatementList( $statementReadModel ) ), $lastModified, $revisionId ) );
->willReturn( new PropertyRevision(
new Property( new Aliases(), new StatementList( $statementReadModel ) ),
$lastModified,
$revisionId
) );

$response = $this->newUseCase()->execute(
new AddPropertyStatementRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Wikibase\Lib\Store\EntityRevision;
use Wikibase\Repo\RestApi\Domain\Model\EditMetadata;
use Wikibase\Repo\RestApi\Domain\Model\EditSummary;
use Wikibase\Repo\RestApi\Domain\ReadModel\Aliases;
use Wikibase\Repo\RestApi\Domain\ReadModel\Property;
use Wikibase\Repo\RestApi\Domain\ReadModel\StatementList;
use Wikibase\Repo\RestApi\Domain\Services\StatementReadModelConverter;
Expand Down Expand Up @@ -79,6 +80,7 @@ private function newEquivalentWriteAndReadModelProperty(): array {
new DataModelStatementList( $writeModelStatement )
),
new Property(
new Aliases(),
new StatementList( $readModelStatement )
),
];
Expand Down

0 comments on commit 66f2522

Please sign in to comment.