class AlertDefinitionDAO {

  @Transactional
  public void remove(AlertDefinitionEntity alertDefinition) {
    dispatchDao.removeNoticeByDefinitionId(alertDefinition.getDefinitionId());
    alertsDao.removeByDefinitionId(alertDefinition.getDefinitionId());

    EntityManager entityManager = entityManagerProvider.get();

    alertDefinition = findById(alertDefinition.getDefinitionId());
    if (null != alertDefinition) {
      entityManager.remove(alertDefinition);

      // publish the alert definition removal
      AlertDefinition coerced = alertDefinitionFactory.coerce(alertDefinition);
      if (null != coerced) {
        AlertDefinitionDeleteEvent event = new AlertDefinitionDeleteEvent(
                alertDefinition.getClusterId(), coerced);

        eventPublisher.publish(event);
      } else {
        LOG.warn("Unable to broadcast alert removal event for {}",
                alertDefinition.getDefinitionName());
      }
    }
  }

}