@Test public void testRemove() throws Exception { AlertDefinitionEntity definition = helper.createAlertDefinition(clusterId); definition = dao.findById(definition.getDefinitionId()); assertNotNull(definition); dao.remove(definition); definition = dao.findById(definition.getDefinitionId()); assertNull(definition); }
@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); 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()); } } }
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); 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()); } } } }
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); 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()); } } }  }
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); 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()); } } }  @RequiresSession AlertDefinitionEntity findById(long definitionId); @RequiresSession AlertDefinitionEntity findByName(long clusterId, String definitionName); @RequiresSession List<AlertDefinitionEntity> findAll(); @RequiresSession List<AlertDefinitionEntity> findAll(long clusterId); @RequiresSession List<AlertDefinitionEntity> findAllEnabled(long clusterId); @RequiresSession List<AlertDefinitionEntity> findByIds(List<Long> definitionIds); @RequiresSession List<AlertDefinitionEntity> findByService(long clusterId,
      String serviceName); @RequiresSession List<AlertDefinitionEntity> findByServiceMaster(long clusterId,
      Set<String> services); @RequiresSession List<AlertDefinitionEntity> findByServiceComponent(long clusterId,
      String serviceName, String componentName); @RequiresSession List<AlertDefinitionEntity> findAgentScoped(long clusterId); @Transactional void create(AlertDefinitionEntity alertDefinition); @Transactional void refresh(AlertDefinitionEntity alertDefinition); @Transactional AlertDefinitionEntity merge(AlertDefinitionEntity alertDefinition); void createOrUpdate(AlertDefinitionEntity alertDefinition); @Transactional void remove(AlertDefinitionEntity alertDefinition); @Transactional void removeAll(long clusterId); }
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); 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()); } } }  @RequiresSession AlertDefinitionEntity findById(long definitionId); @RequiresSession AlertDefinitionEntity findByName(long clusterId, String definitionName); @RequiresSession List<AlertDefinitionEntity> findAll(); @RequiresSession List<AlertDefinitionEntity> findAll(long clusterId); @RequiresSession List<AlertDefinitionEntity> findAllEnabled(long clusterId); @RequiresSession List<AlertDefinitionEntity> findByIds(List<Long> definitionIds); @RequiresSession List<AlertDefinitionEntity> findByService(long clusterId,
      String serviceName); @RequiresSession List<AlertDefinitionEntity> findByServiceMaster(long clusterId,
      Set<String> services); @RequiresSession List<AlertDefinitionEntity> findByServiceComponent(long clusterId,
      String serviceName, String componentName); @RequiresSession List<AlertDefinitionEntity> findAgentScoped(long clusterId); @Transactional void create(AlertDefinitionEntity alertDefinition); @Transactional void refresh(AlertDefinitionEntity alertDefinition); @Transactional AlertDefinitionEntity merge(AlertDefinitionEntity alertDefinition); void createOrUpdate(AlertDefinitionEntity alertDefinition); @Transactional void remove(AlertDefinitionEntity alertDefinition); @Transactional void removeAll(long clusterId);  }