Search in sources :

Example 1 with EventDeleteFailedHasChildrenException

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());
        }
    }
}
Also used : EventDeleteFailedHasChildrenException(eu.bcvsolutions.idm.core.api.exception.EventDeleteFailedHasChildrenException) IdmEntityStateFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

IdmEntityStateFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter)1 EventDeleteFailedHasChildrenException (eu.bcvsolutions.idm.core.api.exception.EventDeleteFailedHasChildrenException)1 Transactional (org.springframework.transaction.annotation.Transactional)1