We'd like to have a consistent and safe way for study designers (almost always the implementers, so people with the DEVELOPER role) to delete and remove things as they set up a study. Often out deletes actually remove things from the database, and so those calls are only accessible to administrators for test clean-up.
...
- If item is already logically deleted, throw an EntityNotFoundException
- If item is not marked deleted, mark it as deleted
...
- If item is not in database, throw an EntityNotFoundException
- If item is in database but logically deleted, this should physically delete the item
...
- If the referencing object is logically deleted, the dependent object can be logically deleted;
- If the referencing object is logically deleted, the dependent object cannot be physically deleted;
- If the referencing object is physically deleted, then the there isn't a problem anymore. The dependent object can be logically or physically deleted (no longer any constraints).