Enterprise Architect comes standard with an Find Orphans search, which is supposed to give you a list of all elements that are no longer used in the model, and thus better be removed from the model altogether.
The problem with this search is that it will only report elements that are not shown on a diagram; which should not be the only criterion to determine if an element is an orphan or not. Not being on a diagram is just fine. I have lots of elements in my model that are not on a diagram, that doesn’t mean they are not used anymore.
If you are going to delete all elements reported in the standard orphans search you might do serious damage to your model.
So in order to aid with the maintenance of a large model I wrote the following SQL Search.
This search will look for all elements that
- Are located in the currently selected package branch
- Are not a package or a model document (section in a virtual document)
- Are not used on a diagram
- Are not used as the Classifier of an instance
- Are not referenced by any tagged value
- Are not used as the source or target of any relation
- Are not used as the type of an attribute
- Are not used as the return type of an operation
- Are not used as the type of a parameter
- Do not own any other elements
Elements that show up in this search are most probably real orphans that clutter your model and can be safely deleted.
Of course, before you delete anything from the model, make sure you have a backup!
In order to use this search create a new search of type SQL and paste the above query into the query builder field.
If you find anything that should be added to this search please let me know.