Page MenuHomePhabricator

๐Ÿ“š๏ธ Use read models instead of DataModel entities in all use case responses
Closed, ResolvedPublic

Description

By introducing read models we hope to achieve a better separation of data required for creating or updating ("writing"), and data to be used in responses ("reading"). We will for now consider DataModel entities write models, and will create corresponding read models for the REST API.

Needed read models:

  • ItemData (already exists)
  • StatementList
  • Statement
    • includes all parts of the statement, except those not defined by Wikibase itself (e.g. DataValue objects)
    • major goal: include the property data type for statement properties, qualifier properties, and reference proeprties. This will make ADR 4 obsolete, and means that we no longer need to look up the data type at serialization time.
  • labels, descriptions, aliases
  • sitelinks

ACs:

  • document the decision in an ADR
  • create and use read models
  • (disallow DataModel objects in Wikibase\Repo\RestApi\UseCases\*\*Response classes via PHPat?)

Related Objects

Event Timeline

Restricted Application added a subscriber: Aklapper. ยท View Herald TranscriptDec 16 2022, 12:12 PM

Notes from task breakdown:

  • create PropertyValuePair read model consisting of - @Jakob_WMDE creates ticket
    • property id
    • property data type
    • the value (remains a DataValue objects) unless it is "novalue" or "somevalue"
  • adjust PropertyValuePairSerializer to serialize the new read model instead of the Snak in the serialize method - @Silvan_WMDE creates ticket
    • rename the existing serialize method to serializeSnak (to be deleted later once the whole task is done)
  • create a self-validating value object for Rank - @Muhammad_Yasser_Jazirahly_WMDE creates ticket
  • use PropertyValuePair as the main snak in Statement - @WMDE_Norman creates ticket
    • adjust Statement read model accordingly
    • adjust StatementReadModelConverter accordingly (including data type lookup)
    • adjust StatementSerializer to serialize the new main PropertyValuePair using the new serializer
  • use PropertyValuePair array for qualifiers in Statement - @Jakob_WMDE creates ticket
    • adjust Statement read model accordingly
    • adjust StatementReadModelConverter accordingly (including data type lookup)
    • adjust StatementSerializer to serialize the qualifiers using the new serializer
  • use PropertyValuePair array for references in Statement - @Silvan_WMDE creates ticket
    • adjust Statement read model accordingly
    • adjust StatementReadModelConverter accordingly (including data type lookup)
    • adjust StatementSerializer to serialize the references using the new serializer
Jakob_WMDE claimed this task.
Jakob_WMDE removed Jakob_WMDE as the assignee of this task.
Jakob_WMDE moved this task from To Do to Done on the Wikibase Product Platform (v1) (Sprint 26) board.