New option to delete also referencing/referenced (thus "related") artefacts
Add 2 new sub-menu options to the "delete structure" context menu, replacing its current functionality with:
- "without related structures": same deletion behaviour as today - just delete the current artefact
- "and/or related structures": see below.
NOTE: In SDMX:
- a parent is an artefact that references another artefact
- a child is an artefact that is being referenced by another artefact
e.g.
- ContentConstraint
- Dataflow
- DSD
- ConceptScheme
- Codelist A
- Codelist A
- Codelist B
- ConceptScheme
- DSD
- Dataflow
The same child can be referenced by different parents. More information on the SDMX artefact dependency can be found here: https://github.com/sdmx-twg/sdmx-rest/blob/master/v2_1/ws/rest/docs/4_3_structural_queries.md#applicability-and-meaning-of-references-attribute
However, in the context of the deletion of artefacts in the DLM and the need to delete referencing artefacts first, the hierarchy tree is inverse.
#180 (closed))
Mechanism to retrieve close structural artefact dependencies (see:Recursively starting from the selected artefact the DLM finds and lists in a DLM dependency tree all the related artefacts of the current artefact using the query syntax: http://sdmx-sercice-root/[ArtefactType]/[Agency]/[Id]/[Version]?references=all, e.g. a query for a dataflow would return also the related codelists, conceptschemes, DSD and contentconstraints.
- if the DLM dependency tree contains any other artefacts than the original one (because there are related artefacts) then the DLM verifies if those are being referenced by artefacts that are not in the list (through executing the query http://sdmx-sercice-root/[ArtefactType]/[Agency]/[Id]/[Version]?references=parents for each of those), e.g. a by the original DSD referenced codelist might also be referenced by another DSDs.
- if any under (a) analysed artefacts is being referenced by non-listed artefacts, and this analysed artefact is at a higher or same DLM-tree-level than the original artefact (means "is being referenced" by the original artefact), then the DLM marks this analysed artefact as non-delete-able and remembers this reason for later display (remember the details of the additional children).
- if any under (a) analysed artefacts is being referenced by non-listed artefacts, and this analysed artefact is at a lower DLM-tree-level than the original artefact (means "is referencing" the original artefact), then the DLM adds these yet non-listed artefacts to the list (at the appropriate level) and recursively re-executes the query http://sdmx-sercice-root/[ArtefactType]/[Agency]/[Id]/[Version]?references=parents on all newly added artefacts to find and add also all its DLM-tree lower-level artefacts until all the lowest reachable DLM-tree-leaves have been added to the list.
Display of dependency tree
The DLM displays in a popup all the listed artefacts using a tree control with selectable items with vertical scroll, showing the artefact type, name, ID, version, "finality" and agency (using the standard DLM styles).
- The original item is pre-selected as well as all below items.
- Non-delete-able artefacts (see point 2 above) are marked as such (replace the selection box by a MaterialUI red-coloured "RemoveCircle" item: ). A tooltip on the icon explains the reason and solution: "Cannot be deleted since referenced by: XXXX, XXXX. First delete those structures and then try again.".
- The "Close" button allows closing the popup.
- The "Delete selected structures" changes the text of the "Close" button to "Cancel", inactivates the "Delete selected structures" button and then deletes all structures (one by one) starting from the lowest levels and indicating (one by one) the outcome for each structure as follow:
- success: green-coloured bin icon (same icon as in title bar and delete menu) which replaces the selection box
- failure: red-coloured MaterialUI icon "DeleteForever" (replaces selection box) with the mouseover showing the error message.
The "Cancel" button interrupts the deletion process, then changes its text to "Close" and re-activates the "Delete selected structures" button.
Once the deletion actions are completed, the "Delete selected structures" button becomes hidden and the "Cancel" button changes the text back to "Close".
- The "Close" button allows closing the popup.
Additional requirement when deleting a dataflow:
When a dataflow is deleted then:
- before deleting the dataflow, transparently immediately run the
/cleanup/mappingsets
method of the transfer service, e.g.
curl -X DELETE "http://transfer-qa-oecd.redpelicans.com/1.2/cleanup/mappingsets" -H "accept: application/json" -H "authorization: Bearer XXXXX" -H "Content-Type: multipart/form-data" -d {"dataspace":"qa:reset","dataflow":"IT1:264D_264_SALDI2_2(2.0)"}
- then retrieve the query outcome (200: success, anything else: failure) and the message content from the transfer response
{
"success": true,
"message": "All the automatically generated mapping sets of the dataflow IT1:264D_264_SALDI2_2(2.0) were successfully deleted from the mapping store database.",
"detail": null
}
and integrate the success message (here "All the automatically generated mapping sets of the dataflow IT1:264D_264_SALDI2_2(2.0) were successfully deleted from the mapping store database.") or the error message in the message displayed to the user.
- if this previous cleanup step was successful (200) then delete also the dataflow otherwise stop.