@Test @Transactional public void testFindStatusChangesForNodeForUniqueMonitorAndInterface() { m_databasePopulator.populateDatabase(); OnmsLocationMonitor monitor1 = new OnmsLocationMonitor(); monitor1.setDefinitionName("Outer Space"); m_locationMonitorDao.save(monitor1); OnmsLocationMonitor monitor2 = new OnmsLocationMonitor(); monitor2.setDefinitionName("Really Outer Space"); m_locationMonitorDao.save(monitor2); OnmsNode node1 = m_nodeDao.get(1); assertNotNull("node 1 should not be null", node1); OnmsNode node2 = m_nodeDao.get(2); assertNotNull("node 2 should not be null", node2); addStatusChangesForMonitorAndService(monitor1, node1.getIpInterfaceByIpAddress("192.168.1.1").getMonitoredServices()); addStatusChangesForMonitorAndService(monitor1, node1.getIpInterfaceByIpAddress("192.168.1.2").getMonitoredServices()); addStatusChangesForMonitorAndService(monitor2, node1.getIpInterfaceByIpAddress("192.168.1.1").getMonitoredServices()); addStatusChangesForMonitorAndService(monitor1, node1.getIpInterfaceByIpAddress("fe80::aaaa:bbbb:cccc:dddd%5").getMonitoredServices()); addStatusChangesForMonitorAndService(monitor1, node2.getIpInterfaceByIpAddress("192.168.2.1").getMonitoredServices()); addStatusChangesForMonitorAndService(monitor1, node1.getIpInterfaceByIpAddress("192.168.1.1").getMonitoredServices()); Collection<LocationMonitorIpInterface> statuses = m_locationMonitorDao.findStatusChangesForNodeForUniqueMonitorAndInterface(1); assertEquals("number of statuses found", 4, statuses.size()); }
public Collection<LocationMonitorIpInterface> findStatusChangesForNodeForUniqueMonitorAndInterface(final int nodeId) { @SuppressWarnings("unchecked") final List<Object[]> l = getHibernateTemplate().find( "select distinct status.locationMonitor, status.monitoredService.ipInterface from OnmsLocationSpecificStatus as status " + "where status.monitoredService.ipInterface.node.id = ?", nodeId ); final HashSet<LocationMonitorIpInterface> ret = new HashSet<LocationMonitorIpInterface>(); for (Object[] tuple : l) { OnmsLocationMonitor mon = (OnmsLocationMonitor) tuple[0]; OnmsIpInterface ip = (OnmsIpInterface) tuple[1]; ret.add(new LocationMonitorIpInterface(mon, ip)); } return ret; }
LocationMonitorDaoHibernate extends AbstractDaoHibernate<OnmsLocationMonitor, Integer> implements
        LocationMonitorDao { public Collection<LocationMonitorIpInterface> findStatusChangesForNodeForUniqueMonitorAndInterface(final int nodeId) { @SuppressWarnings("unchecked") final List<Object[]> l = getHibernateTemplate().find( "select distinct status.locationMonitor, status.monitoredService.ipInterface from OnmsLocationSpecificStatus as status " + "where status.monitoredService.ipInterface.node.id = ?", nodeId ); final HashSet<LocationMonitorIpInterface> ret = new HashSet<LocationMonitorIpInterface>(); for (Object[] tuple : l) { OnmsLocationMonitor mon = (OnmsLocationMonitor) tuple[0]; OnmsIpInterface ip = (OnmsIpInterface) tuple[1]; ret.add(new LocationMonitorIpInterface(mon, ip)); } return ret; } }
LocationMonitorDaoHibernate extends AbstractDaoHibernate<OnmsLocationMonitor, Integer> implements
        LocationMonitorDao { public Collection<LocationMonitorIpInterface> findStatusChangesForNodeForUniqueMonitorAndInterface(final int nodeId) { @SuppressWarnings("unchecked") final List<Object[]> l = getHibernateTemplate().find( "select distinct status.locationMonitor, status.monitoredService.ipInterface from OnmsLocationSpecificStatus as status " + "where status.monitoredService.ipInterface.node.id = ?", nodeId ); final HashSet<LocationMonitorIpInterface> ret = new HashSet<LocationMonitorIpInterface>(); for (Object[] tuple : l) { OnmsLocationMonitor mon = (OnmsLocationMonitor) tuple[0]; OnmsIpInterface ip = (OnmsIpInterface) tuple[1]; ret.add(new LocationMonitorIpInterface(mon, ip)); } return ret; } LocationMonitorDaoHibernate(); }
LocationMonitorDaoHibernate extends AbstractDaoHibernate<OnmsLocationMonitor, Integer> implements
        LocationMonitorDao { public Collection<LocationMonitorIpInterface> findStatusChangesForNodeForUniqueMonitorAndInterface(final int nodeId) { @SuppressWarnings("unchecked") final List<Object[]> l = getHibernateTemplate().find( "select distinct status.locationMonitor, status.monitoredService.ipInterface from OnmsLocationSpecificStatus as status " + "where status.monitoredService.ipInterface.node.id = ?", nodeId ); final HashSet<LocationMonitorIpInterface> ret = new HashSet<LocationMonitorIpInterface>(); for (Object[] tuple : l) { OnmsLocationMonitor mon = (OnmsLocationMonitor) tuple[0]; OnmsIpInterface ip = (OnmsIpInterface) tuple[1]; ret.add(new LocationMonitorIpInterface(mon, ip)); } return ret; } LocationMonitorDaoHibernate(); List<OnmsMonitoringLocationDefinition> findAllMonitoringLocationDefinitions(); void saveMonitoringLocationDefinitions(final Collection<OnmsMonitoringLocationDefinition> onmsDefs); void saveMonitoringLocationDefinition(final OnmsMonitoringLocationDefinition onmsDef); Collection<OnmsMonitoringLocationDefinition> findAllLocationDefinitions(); Resource getMonitoringLocationConfigResource(); void setMonitoringLocationConfigResource(final Resource monitoringLocationResource); OnmsMonitoringLocationDefinition findMonitoringLocationDefinition(final String monitoringLocationDefinitionName); OnmsLocationSpecificStatus getMostRecentStatusChange(final OnmsLocationMonitor locationMonitor, final OnmsMonitoredService monSvc); void saveStatusChange(final OnmsLocationSpecificStatus statusChange); Collection<OnmsLocationMonitor> findByApplication(final OnmsApplication application); Collection<OnmsLocationMonitor> findByLocationDefinition(final OnmsMonitoringLocationDefinition locationDefinition); Collection<OnmsLocationSpecificStatus> getAllMostRecentStatusChanges(); Collection<OnmsLocationSpecificStatus> getAllStatusChangesAt(final Date timestamp); Collection<OnmsLocationSpecificStatus> getStatusChangesBetween(final Date startDate, final Date endDate); Collection<OnmsLocationSpecificStatus> getStatusChangesForLocationBetween(final Date startDate, final Date endDate, final String locationName); Collection<OnmsLocationSpecificStatus> getStatusChangesForApplicationBetween(final Date startDate, final Date endDate, final String applicationName); Collection<OnmsLocationSpecificStatus> getStatusChangesBetweenForApplications(final Date startDate, final Date endDate, final Collection<String> applicationNames); Collection<OnmsLocationSpecificStatus> getMostRecentStatusChangesForLocation(final String locationName); Collection<LocationMonitorIpInterface> findStatusChangesForNodeForUniqueMonitorAndInterface(final int nodeId); void pauseAll(); void resumeAll(); }
LocationMonitorDaoHibernate extends AbstractDaoHibernate<OnmsLocationMonitor, Integer> implements
        LocationMonitorDao { public Collection<LocationMonitorIpInterface> findStatusChangesForNodeForUniqueMonitorAndInterface(final int nodeId) { @SuppressWarnings("unchecked") final List<Object[]> l = getHibernateTemplate().find( "select distinct status.locationMonitor, status.monitoredService.ipInterface from OnmsLocationSpecificStatus as status " + "where status.monitoredService.ipInterface.node.id = ?", nodeId ); final HashSet<LocationMonitorIpInterface> ret = new HashSet<LocationMonitorIpInterface>(); for (Object[] tuple : l) { OnmsLocationMonitor mon = (OnmsLocationMonitor) tuple[0]; OnmsIpInterface ip = (OnmsIpInterface) tuple[1]; ret.add(new LocationMonitorIpInterface(mon, ip)); } return ret; } LocationMonitorDaoHibernate(); List<OnmsMonitoringLocationDefinition> findAllMonitoringLocationDefinitions(); void saveMonitoringLocationDefinitions(final Collection<OnmsMonitoringLocationDefinition> onmsDefs); void saveMonitoringLocationDefinition(final OnmsMonitoringLocationDefinition onmsDef); Collection<OnmsMonitoringLocationDefinition> findAllLocationDefinitions(); Resource getMonitoringLocationConfigResource(); void setMonitoringLocationConfigResource(final Resource monitoringLocationResource); OnmsMonitoringLocationDefinition findMonitoringLocationDefinition(final String monitoringLocationDefinitionName); OnmsLocationSpecificStatus getMostRecentStatusChange(final OnmsLocationMonitor locationMonitor, final OnmsMonitoredService monSvc); void saveStatusChange(final OnmsLocationSpecificStatus statusChange); Collection<OnmsLocationMonitor> findByApplication(final OnmsApplication application); Collection<OnmsLocationMonitor> findByLocationDefinition(final OnmsMonitoringLocationDefinition locationDefinition); Collection<OnmsLocationSpecificStatus> getAllMostRecentStatusChanges(); Collection<OnmsLocationSpecificStatus> getAllStatusChangesAt(final Date timestamp); Collection<OnmsLocationSpecificStatus> getStatusChangesBetween(final Date startDate, final Date endDate); Collection<OnmsLocationSpecificStatus> getStatusChangesForLocationBetween(final Date startDate, final Date endDate, final String locationName); Collection<OnmsLocationSpecificStatus> getStatusChangesForApplicationBetween(final Date startDate, final Date endDate, final String applicationName); Collection<OnmsLocationSpecificStatus> getStatusChangesBetweenForApplications(final Date startDate, final Date endDate, final Collection<String> applicationNames); Collection<OnmsLocationSpecificStatus> getMostRecentStatusChangesForLocation(final String locationName); Collection<LocationMonitorIpInterface> findStatusChangesForNodeForUniqueMonitorAndInterface(final int nodeId); void pauseAll(); void resumeAll();  }