[umbrella]: Fix delete stakeholder in order to remove from umbrella dashboards when it is deleted.

This commit is contained in:
Konstantinos Triantafyllou 2024-06-11 20:17:39 +03:00
parent ab33c2ec45
commit 1bc576ea69
1 changed files with 7 additions and 0 deletions

View File

@ -200,6 +200,13 @@ public class StakeholderService {
public String delete(String id) { public String delete(String id) {
Stakeholder stakeholder = this.findByPath(id); Stakeholder stakeholder = this.findByPath(id);
if (this.commonService.hasDeleteAuthority(stakeholder.getType())) { if (this.commonService.hasDeleteAuthority(stakeholder.getType())) {
this.dao.umbrellaStakeholders().forEach(umbrellaStakeholder -> {
StakeholderType type = StakeholderType.valueOf(stakeholder.getType());
List<String> ids = umbrellaStakeholder.getUmbrella().getChildren().get(type);
if(ids != null && ids.contains(stakeholder.getId())) {
this.removeChild(umbrellaStakeholder.getId(), StakeholderType.valueOf(stakeholder.getType()), stakeholder.getId());
}
});
this.dao.findByDefaultIdAndCopyIsTrue(stakeholder.getId()).forEach(child -> { this.dao.findByDefaultIdAndCopyIsTrue(stakeholder.getId()).forEach(child -> {
this.delete(child.getId()); this.delete(child.getId());
}); });