private OnmsServiceType getService(final String serviceName) { OnmsServiceType service = m_serviceTypeDao.findByName(serviceName); if (service == null) { service = new OnmsServiceType(serviceName); m_serviceTypeDao.save(service); m_serviceTypeDao.flush(); } return service; }
@Transactional(readOnly=true) private Map<String, OnmsServiceType> loadServiceTypeMap() { final HashMap<String, OnmsServiceType> serviceTypeMap = new HashMap<String, OnmsServiceType>(); for (final OnmsServiceType svcType : m_serviceTypeDao.findAll()) { serviceTypeMap.put(svcType.getName(), svcType); } return serviceTypeMap; }
@Override protected OnmsServiceType query() { return m_serviceTypeDao.findByName(serviceName); }
private void updateSubObjects(final OnmsMonitoredService svc) { final OnmsServiceType serviceType = svc.getServiceType(); final OnmsServiceType existingServiceType = getServiceTypeDao().findByName(serviceType.getName()); if (existingServiceType != null && existingServiceType.getId() != serviceType.getId()) { svc.setServiceType(existingServiceType); } getServiceTypeDao().saveOrUpdate(svc.getServiceType()); }
private void updateSubObjects(final OnmsAlarm alarm) { // Assume that the system ID is the ID of an OpenNMS system // instead of a Minion or Remote Poller getDistPollerDao().save((OnmsDistPoller)alarm.getDistPoller()); getEventDao().save(alarm.getLastEvent()); getNodeDao().save(alarm.getNode()); getServiceTypeDao().save(alarm.getServiceType()); }
@Override protected OnmsServiceType query() { return m_serviceTypeDao.findByName(serviceName); }
private void updateSubObjects(final OnmsMonitoredService svc) { final OnmsServiceType serviceType = svc.getServiceType(); final OnmsServiceType existingServiceType = getServiceTypeDao().findByName(serviceType.getName()); if (existingServiceType != null && existingServiceType.getId() != serviceType.getId()) { svc.setServiceType(existingServiceType); } getServiceTypeDao().saveOrUpdate(svc.getServiceType()); }
private void updateSubObjects(final OnmsAlarm alarm) { // Assume that the system ID is the ID of an OpenNMS system // instead of a Minion or Remote Poller getDistPollerDao().save((OnmsDistPoller)alarm.getDistPoller()); getEventDao().save(alarm.getLastEvent()); getNodeDao().save(alarm.getNode()); getServiceTypeDao().save(alarm.getServiceType()); }
private OnmsServiceType getServiceType(String name) { OnmsServiceType serviceType = m_serviceTypeDao.findByName(name); if (serviceType == null) { serviceType = new OnmsServiceType(name); m_serviceTypeDao.save(serviceType); m_serviceTypeDao.flush(); } return serviceType; }
/** {@inheritDoc} */ @Override public synchronized int getServiceId(String serviceName) throws DataAccessException { Assert.notNull(serviceName, "The serviceName argument must not be null"); if (m_serviceMap.containsKey(serviceName)) { return m_serviceMap.get(serviceName).intValue(); } else { LOG.debug("Could not find entry for '{}' in service name cache. Looking up in database.", serviceName); OnmsServiceType serviceType = m_serviceTypeDao.findByName(serviceName); if (serviceType == null) { LOG.debug("Did not find entry for '{}' in database.", serviceName); return -1; } LOG.debug("Found entry for '{}' (ID {}) in database. Adding to service name cache.", serviceName, serviceType.getId()); m_serviceMap.put(serviceType.getName(), serviceType.getId()); return serviceType.getId(); } }
@Transactional(readOnly=true) private Map<String, OnmsServiceType> loadServiceTypeMap() { final HashMap<String, OnmsServiceType> serviceTypeMap = new HashMap<String, OnmsServiceType>(); for (final OnmsServiceType svcType : m_serviceTypeDao.findAll()) { serviceTypeMap.put(svcType.getName(), svcType); } return serviceTypeMap; }
public OnmsEvent buildEvent(final OnmsDistPoller distPoller) { final OnmsEvent event = new OnmsEvent(); event.setDistPoller(distPoller); event.setEventCreateTime(new Date(1437061537126L)); event.setEventDescr("This is the description of a test event."); event.setEventDisplay("Y"); event.setEventHost("127.0.0.1"); // TODO: Figure out exactly what this field is storing event.setEventLog("Y"); event.setEventLogMsg("Test Event Log Message"); event.setEventParameters(Lists.newArrayList(new OnmsEventParameter(event, "testParm", "HelloWorld", "string"))); event.setEventSeverity(OnmsSeverity.INDETERMINATE.getId()); event.setEventSource("test"); event.setEventTime(new Date(1437061537105L)); event.setEventUei("uei.opennms.org/test"); event.setIpAddr(InetAddressUtils.getInetAddress("192.168.1.1")); event.setNode(m_node1); event.setServiceType(m_serviceTypeDao.findByName("ICMP")); return event; }
/** * <p>dataSourceSync</p> */ @Override public synchronized void dataSourceSync() { m_serviceMap.clear(); for (OnmsServiceType serviceType : m_serviceTypeDao.findAll()) { m_serviceMap.put(serviceType.getName(), serviceType.getId()); } }
private OnmsAlarm buildAlarm(final OnmsEvent event) { // TODO: Add reductionKey, suppressedTime, suppressedUntil to this object? final OnmsAlarm alarm = new OnmsAlarm(); alarm.setDistPoller(getDistPollerDao().whoami()); alarm.setUei(event.getEventUei()); alarm.setAlarmType(OnmsAlarm.PROBLEM_TYPE); alarm.setNode(m_node1); alarm.setDescription("This is a test alarm"); alarm.setLogMsg("this is a test alarm log message"); alarm.setCounter(1); alarm.setIpAddr(InetAddressUtils.getInetAddress("192.168.1.1")); alarm.setSeverity(OnmsSeverity.NORMAL); alarm.setFirstEventTime(event.getEventTime()); alarm.setLastEvent(event); alarm.setServiceType(m_serviceTypeDao.findByName("ICMP")); return alarm; }
ovent.setServiceType(serviceTypeDao.findByName(event.getService()));
ovent.setServiceType(serviceTypeDao.findByName(event.getService()));
oe.setEventPathOutage(event.getPathoutage()); try { oe.setServiceType(m_serviceTypeDao.findByName(event.getService())); } catch (final DataAccessException e) { throw new EventProcessorException(e);