Activatable Entity: ActivePropertyValidator to include DeactivatableDependencies for cascaded validation
Description
ActivePropertyValidator does not process @DeactivatableDependencies, which may be defined for an activatable entity being deactivated, for determining "cascaded" active dependencies. This leads to situations where entity deactivation is prevented not as the result of validation of its property active, but as the result of cascaded processing of dependencies upon entity saving.
Determining and displaying a complete list of dependencies that prevent deactivation, which would include dependencies stemming from entities specified in @DeactivatableDependencies, would present a more complete picture of the situation as part of validation.
For example, deactivating a Person with the following definition may not have direct dependencies that prevent deactivation, but may have dependencies for person's roles as InternalPerson, CustomerPerson, or ManagerPerson that would prevent deactivation.
@DeactivatableDependencies({ InternalPerson.class, CustomerPerson.class, ManagerPerson.class })
public class Person extends ActivatableAbstractEntity<String> {
...
The following needs to be implemented.
-
[ ] 1. Enhance
ActivePropertyValidatorto process entities from@DeactivatableDependenciesfor possible active dependencies that would prevent cascaded deactivation. Such entities may themselves have@DeactivatableDependenciesand so this information needs to be processed recursively. -
[ ] 2. The question of performance should be considered as such exhaustive search for active dependencies could require non-trivial computations, including execution of database queries. If performance testing would indicate issues, an approach where dependencies are computed and displayed for one entity at a time should be considered.
-
[ ] 3. Processing of entities to identify active dependencies should be happening using the breadth-first search.
-
[ ] 4. The presentation of active dependencies should be adjusted to accommodate situations where dependencies are displayed for several entities. Using the above example with
Person, the dependencies may involve up to 4 entities. The current implementation caters only for a single entity. The screenshot below shows a result forInternalPerson.
Implementation details
-
DomainEntitiesDependenciesUtilsis responsible for determining dependent entities and composing an EQL query that calculated the number of active dependencies. -
DomainEntityDependenciescaptures and refines the dependency information, which explicitly excludes deactivatable dependencies from consideration as those would be deactivated automatically (this is corrected and expected). However, it includes a set of deactivatable dependencies asautomaticallyDeactivatedDependencies, which can be used to extend the validation to those entities.
Expected outcome
A more complete list of active dependencies, preventing entity deactivation, displayed upon validation.