Skip to content

Ancestors tree endpoint for a sub-item may not return the correct order of children #458

@pjmonks

Description

@pjmonks

Description

Calling GET /api/tree/folders/{domain}/{id}/ancestors may return child items in a model in a non-specific order, thereby making it appear that the children could be swapped round.

As an example, look at this UI representation of a ancestor trail:

Image

In this case, ACTIVITY COUNT is a Data Element, and ACTIVITY is a Data Class. The way this should appear is that ACTIVITY should be before ACTIVITY COUNT, but they are rendered the wrong way round. This is because the JSON returned by the ancestors endpoint returns a flat, unordered list of children from the Data Model down:

{
    "id": "3cd10f35-9144-4449-9441-881a81b3353b",
    "domainType": "Folder",
    "label": "NHS Data Dictionary",
    "hasChildren": true,
    "availableActions": [
        "createFolder",
        "createModel",
        "createVersionedFolder",
        "delete",
        "moveToFolder",
        "softDelete"
    ],
    "path": "fo:NHS Data Dictionary",
    "deleted": false,
    "children": [
        {
            "id": "4dc0a847-b22e-405f-b40f-1dbcffaeff76",
            "domainType": "VersionedFolder",
            "label": "NHS Data Dictionary (November 2023)",
            "hasChildren": true,
            "availableActions": [
                "delete",
                "moveToFolder",
                "softDelete"
            ],
            "path": "fo:NHS Data Dictionary|vf:NHS Data Dictionary (November 2023)$2023.11.0",
            "deleted": false,
            "parentFolder": "3cd10f35-9144-4449-9441-881a81b3353b",
            "finalised": true,
            "documentationVersion": "1.0.0",
            "modelVersion": "2023.11.0",
            "modelVersionTag": "November 2023",
            "children": [
                {
                    "id": "e61e2fb7-035e-4b11-b6d1-21621c74fdd9",
                    "domainType": "DataModel",
                    "label": "Classes and Attributes",
                    "hasChildren": true,
                    "availableActions": [
                        "delete",
                        "moveToContainer",
                        "moveToFolder",
                        "softDelete"
                    ],
                    "path": "dm:Classes and Attributes$2023.11.0",
                    "deleted": false,
                    "finalised": true,
                    "superseded": false,
                    "documentationVersion": "1.0.0",
                    "folder": "4dc0a847-b22e-405f-b40f-1dbcffaeff76",
                    "type": "Data Standard",
                    "modelVersion": "2023.11.0",
                    "modelVersionTag": "November 2023",
                    "children": [
                        {
                            "id": "ff8f3686-5351-43c8-b49a-24b93a9304a7",
                            "domainType": "DataElement",
                            "label": "ACTIVITY COUNT",
                            "hasChildren": false,
                            "availableActions": [
                                "delete"
                            ],
                            "path": "dm:Classes and Attributes$2023.11.0|dc:ACTIVITY|de:ACTIVITY COUNT",
                            "modelId": "e61e2fb7-035e-4b11-b6d1-21621c74fdd9",
                            "parentId": "0a2216ca-1a23-47c9-bcbe-85955efe5298"
                        },
                        {
                            "id": "0a2216ca-1a23-47c9-bcbe-85955efe5298",
                            "domainType": "DataClass",
                            "label": "ACTIVITY",
                            "hasChildren": false,
                            "availableActions": [
                                "delete"
                            ],
                            "path": "dm:Classes and Attributes$2023.11.0|dc:ACTIVITY",
                            "modelId": "e61e2fb7-035e-4b11-b6d1-21621c74fdd9"
                        }
                    ]
                }
            ]
        }
    ]
}

Expected behavior

For consistency, either:

  1. Each children array should contain one item at most, so that there is only one level at each part of the ancestor trail. Or,
  2. For children of models (sub-items), they should always be ordered correctly to avoid ambiguity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions