stable

Clone or download

Read-only

refactor: build Initial changeset value outside of Field

part of story #24969 [modal] add and remove links (replace current artifact link) No functional change expected when creating a new artifact from REST. POST artifacts/:id should still allow those kind of payloads: - {"field_id": 543, "links": [], "parent": {"id": 6486}} - {"field_id": 543, "links": [{"id": 6524}]} - {"field_id": 543, "parent": {"id": 6486}} Conversion from REST value representation is now completely done outside of Tracker_FormElement_Field_ArtifactLink. This will allow us to also recognize reverse links and handle them separately of $fields_data. Only forward links should end up in $fields_data eventually. Separate objects are introduced for Initial changeset case. It has different business rules from "update case", such as "there are no existing links". This produces a cleaner API. For example, in the update scenario, there is always an Artifact, but there is never one in the create scenario. Trying to handle both (as we used to do) forces us to handle nullable parameters and enables cases that shouldn't be possible, for example an "update" payload with no Artifact. It is cleaner (and probably safer) to "Write Everything Twice" in this case. Change-Id: I754f82c7ce4f509ed546b0d4dab5263da5726c4b

Modified Files

Name
M plugins/agiledashboard/include/AgileDashboard/REST/v1/Kanban/KanbanItemsResource.php +3 −1 Go to diff View file
M plugins/taskboard/include/REST/v1/Card/CardPatcher.php +3 −1 Go to diff View file
M plugins/taskboard/include/REST/v1/Cell/CardMappedFieldUpdater.php +3 −1 Go to diff View file
M plugins/testmanagement/include/TestManagement/REST/v1/CampaignsResource.class.php +3 −1 Go to diff View file
M plugins/testmanagement/include/TestManagement/REST/v1/ExecutionsResource.class.php +5 −2 Go to diff View file
M plugins/tracker/include/REST/Artifact/ArtifactCreator.class.php +8 −5 Go to diff View file
M plugins/tracker/include/REST/Artifact/ChangesetValue/ArtifactLink/ArtifactLinksFieldUpdateValueBuilder.php +2 −2 Go to diff View file
A plugins/tracker/include/REST/Artifact/ChangesetValue/ArtifactLink/NewArtifactLinkInitialChangesetValueBuilder.php +93 −0 Go to diff View file
A plugins/tracker/include/REST/Artifact/ChangesetValue/ArtifactLink/RESTNewParentLinkProxy.php +57 −0 Go to diff View file
M plugins/tracker/include/REST/Artifact/ChangesetValue/FieldsDataBuilder.php +16 −6 Go to diff View file
M plugins/tracker/include/REST/v1/ArtifactsResource.class.php +5 −2 Go to diff View file
M plugins/tracker/include/Tracker/Artifact/ChangesetValue/ArtifactLink/ArtifactForwardLinksRetriever.php +1 −5 Go to diff View file
A plugins/tracker/include/Tracker/Artifact/ChangesetValue/ArtifactLink/NewArtifactLinkInitialChangesetValue.php +62 −0 Go to diff View file
A plugins/tracker/include/Tracker/Artifact/ChangesetValue/ArtifactLink/NewArtifactLinkInitialChangesetValueFormatter.php +40 −0 Go to diff View file
A plugins/tracker/include/Tracker/Artifact/ChangesetValue/ArtifactLink/NewParentLink.php +35 −0 Go to diff View file
M plugins/tracker/include/Tracker/Artifact/ChangesetValue/ArtifactLink/RetrieveForwardLinks.php +1 −1 Go to diff View file
A plugins/tracker/include/Tracker/Artifact/ChangesetValue/InitialChangesetValuesContainer.php +53 −0 Go to diff View file
M plugins/tracker/include/Tracker/FormElement/Tracker_FormElement_Field_ArtifactLink.php +1 −29 Go to diff View file
M plugins/tracker/tests/unit/REST/Artifact/ArtifactUpdaterTest.php +3 −1 Go to diff View file
M plugins/tracker/tests/unit/REST/Artifact/ChangesetValue/ArtifactLink/ArtifactLinksFieldUpdateValueBuilderTest.php +5 −5 Go to diff View file
A plugins/tracker/tests/unit/REST/Artifact/ChangesetValue/ArtifactLink/NewArtifactLinkInitialChangesetValueBuilderTest.php +134 −0 Go to diff View file
A plugins/tracker/tests/unit/REST/Artifact/ChangesetValue/ArtifactLink/RESTNewParentLinkProxyTest.php +68 −0 Go to diff View file
M plugins/tracker/tests/unit/REST/Artifact/ChangesetValue/FieldsDataBuilderTest.php +51 −10 Go to diff View file
A plugins/tracker/tests/unit/Stub/NewParentLinkStub.php +45 −0 Go to diff View file
M plugins/tracker/tests/unit/Stub/RetrieveForwardLinksStub.php +1 −1 Go to diff View file
M plugins/tracker/tests/unit/Tracker/Artifact/ChangesetValue/ArtifactLink/ArtifactForwardLinksRetrieverTest.php +6 −27 Go to diff View file
A plugins/tracker/tests/unit/Tracker/Artifact/ChangesetValue/ArtifactLink/NewArtifactLinkInitialChangesetValueFormatterTest.php +104 −0 Go to diff View file
A plugins/tracker/tests/unit/Tracker/Artifact/ChangesetValue/ArtifactLink/NewArtifactLinkInitialChangesetValueTest.php +48 −0 Go to diff View file
A plugins/tracker/tests/unit/Tracker/Artifact/ChangesetValue/InitialChangesetValuesContainerTest.php +72 −0 Go to diff View file
M plugins/tracker/tests/unit/Tracker/FormElement/Tracker_FormElement_Field_ArtifactLinkTest.php +0 −152 Go to diff View file