use of eu.bcvsolutions.idm.core.api.exception.EventDeleteFailedHasChildrenException in project CzechIdMng by bcvsolutions.
the class DefaultIdmEntityEventService method deleteInternal.
@Override
@Transactional
public void deleteInternal(IdmEntityEventDto dto) {
if (repository.countByParentId(dto.getId()) > 0) {
throw new EventDeleteFailedHasChildrenException(dto);
}
// delete states
IdmEntityStateFilter filter = new IdmEntityStateFilter();
filter.setEventId(dto.getId());
entityStateService.find(filter, null).forEach(state -> {
entityStateService.delete(state);
});
//
// TODO: delete confidential properties
//
super.deleteInternal(dto);
// delete parent if children count is one (=> removed dto only)
if (dto.getParent() != null) {
if (repository.countByParentId(dto.getParent()) == 0) {
// delete parent
deleteById(dto.getParent());
}
}
}
Aggregations