Skip to content

Commit

Permalink
Merge "REST: Add Descriptions to Property read model"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Oct 11, 2023
2 parents f220947 + fc18f81 commit 8f9c6eb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
10 changes: 8 additions & 2 deletions repo/rest-api/src/Domain/ReadModel/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@
*/
class Property {

private StatementList $statements;
private Descriptions $descriptions;
private Aliases $aliases;
private StatementList $statements;

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

public function getDescriptions(): Descriptions {
return $this->descriptions;
}

public function getAliases(): Aliases {
return $this->aliases;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,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\Descriptions;
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 @@ -40,6 +41,7 @@ public function update( DataModelProperty $property, EditMetadata $editMetadata

private function convertDataModelPropertyToReadModel( DataModelProperty $property ): Property {
return new Property(
Descriptions::fromTermList( $property->getDescriptions() ),
Aliases::fromAliasGroupList( $property->getAliasGroups() ),
new StatementList(
...array_map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
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\Description;
use Wikibase\Repo\RestApi\Domain\ReadModel\Descriptions;
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 @@ -83,7 +85,11 @@ public function testAddStatement(): void {
$this->expectEquivalentMetadata( $editTags, $isBot, $comment, EditSummary::ADD_ACTION )
)
->willReturn( new PropertyRevision(
new Property( new Aliases(), new StatementList( $statementReadModel ) ),
new Property(
new Descriptions( new Description( 'en', 'English Description' ) ),
new Aliases(),
new StatementList( $statementReadModel )
),
$lastModified,
$revisionId
) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
use PHPUnit\Framework\TestCase;
use Wikibase\DataModel\Entity\Property as DataModelProperty;
use Wikibase\DataModel\Statement\StatementList as DataModelStatementList;
use Wikibase\DataModel\Term\Fingerprint;
use Wikibase\DataModel\Term\Term;
use Wikibase\DataModel\Term\TermList;
use Wikibase\DataModel\Tests\NewStatement;
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\Description;
use Wikibase\Repo\RestApi\Domain\ReadModel\Descriptions;
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 @@ -75,11 +80,12 @@ private function newEquivalentWriteAndReadModelProperty(): array {
return [
new DataModelProperty(
null,
null,
new Fingerprint( null, new TermList( [ new Term( 'en', 'English Description' ) ] ), null ),
'string',
new DataModelStatementList( $writeModelStatement )
),
new Property(
new Descriptions( new Description( 'en', 'English Description' ) ),
new Aliases(),
new StatementList( $readModelStatement )
),
Expand Down

0 comments on commit 8f9c6eb

Please sign in to comment.