Force full name reconstruction for taxon tree

Hi @NielsKlazenga,

The “Repair Tree” option only rebuilds the node numbers for the selected tree, not the full names. It might just be the right place to integrate this functionality into the UI!


Technical Details

When you click Repair Tree in the User Tools menu, it runs two functions to renumber the tree and validate that the numbering is correct.

renumber_tree function

This function repairs or rebuilds the tree numbering system by:

  • Updating each node’s rank to match its full name definition in the tree schema
  • Checking for and warning about invalid parent-child rank relationships
  • Creating a complete path enumeration for each node in the tree
  • Assigning new node numbers based on the hierarchical paths
  • Setting proper highest child node numbers for parent nodes
  • Clearing any maintenance flags in the system related to tree nodes

validate_tree_numbering function

This function checks if the hierarchical tree structure is valid by:

  • Verifying that all nodes have nodenumber and highestchildnodenumber set
  • Ensuring children have higher ranks than their parents (maintaining proper hierarchy)
  • Confirming that child node numbers are properly nested within their parent’s range
Code References

specify7/specifyweb/specify/tree_views.py at f9cb3421767993a8c0ff504f86e94187d79a3dd9 · specify/specify7 · GitHub
specify7/specifyweb/specify/tree_extras.py at f9cb3421767993a8c0ff504f86e94187d79a3dd9 · specify/specify7 · GitHub