use of org.opennms.netmgt.model.OnmsServiceType in project opennms by OpenNMS.
the class ServiceTypeDaoIT method tweakSvcType.
private void tweakSvcType(String name) {
OnmsServiceType svcType = m_serviceTypeDao.findByName(name);
if (svcType == null)
m_serviceTypeDao.save(new OnmsServiceType(name));
else {
svcType.setName(svcType.getName() + '-' + svcType.getId());
m_serviceTypeDao.update(svcType);
}
m_serviceTypeDao.clear();
}
use of org.opennms.netmgt.model.OnmsServiceType in project opennms by OpenNMS.
the class MockMonitoredServiceDao method updateSubObjects.
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());
}
use of org.opennms.netmgt.model.OnmsServiceType in project opennms by OpenNMS.
the class AvailabilityDatabasePopulator method getServiceType.
private OnmsServiceType getServiceType(String name) {
OnmsServiceType serviceType = getServiceTypeDao().findByName(name);
if (serviceType == null) {
serviceType = new OnmsServiceType(name);
getServiceTypeDao().save(serviceType);
getServiceTypeDao().flush();
}
return serviceType;
}
use of org.opennms.netmgt.model.OnmsServiceType in project opennms by OpenNMS.
the class DatabasePopulator method doResetDatabase.
private void doResetDatabase() {
LOG.debug("==== DatabasePopulator Reset ====");
for (final OnmsOutage outage : m_outageDao.findAll()) {
m_outageDao.delete(outage);
}
for (final OnmsUserNotification not : m_userNotificationDao.findAll()) {
m_userNotificationDao.delete(not);
}
for (final OnmsNotification not : m_notificationDao.findAll()) {
m_notificationDao.delete(not);
}
for (final OnmsAlarm alarm : m_alarmDao.findAll()) {
m_alarmDao.delete(alarm);
}
for (final OnmsEvent event : m_eventDao.findAll()) {
m_eventDao.delete(event);
}
for (final OnmsSnmpInterface snmpIface : m_snmpInterfaceDao.findAll()) {
for (OnmsIpInterface eachIf : snmpIface.getIpInterfaces()) {
eachIf.setSnmpInterface(null);
snmpIface.getNode().getIpInterfaces().remove(eachIf);
}
snmpIface.getNode().getSnmpInterfaces().remove(snmpIface);
m_snmpInterfaceDao.delete(snmpIface);
}
for (final OnmsIpInterface iface : m_ipInterfaceDao.findAll()) {
iface.setSnmpInterface(null);
iface.getNode().getIpInterfaces().remove(iface);
m_ipInterfaceDao.delete(iface);
}
for (final OnmsNode node : m_nodeDao.findAll()) {
m_nodeDao.delete(node);
}
for (final OnmsServiceType service : m_serviceTypeDao.findAll()) {
m_serviceTypeDao.delete(service);
}
for (final OnmsMonitoringLocation location : m_monitoringLocationDao.findAll()) {
// Don't delete the default localhost monitoring location
if (!MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID.equals(location.getLocationName())) {
m_monitoringLocationDao.delete(location);
}
}
for (final OnmsCategory category : m_categoryDao.findAll()) {
m_categoryDao.delete(category);
}
LOG.debug("= DatabasePopulatorExtension Reset Starting =");
for (Extension eachExtension : extensions) {
DaoSupport daoSupport = eachExtension.getDaoSupport();
OnmsDao<?, ?> dao = daoSupport != null && daoSupport.getDaoClass() != null ? lookupDao(daoSupport.getDaoClass()) : null;
eachExtension.onShutdown(this, dao);
if (dao != null) {
dao.flush();
}
}
LOG.debug("= DatabasePopulatorExtension Reset Finished =");
m_outageDao.flush();
m_userNotificationDao.flush();
m_notificationDao.flush();
m_alarmDao.flush();
m_eventDao.flush();
m_snmpInterfaceDao.flush();
m_ipInterfaceDao.flush();
m_nodeDao.flush();
m_serviceTypeDao.flush();
LOG.debug("==== DatabasePopulator Reset Finished ====");
}
use of org.opennms.netmgt.model.OnmsServiceType in project opennms by OpenNMS.
the class DefaultCategoryStatusService method createCategory.
private StatusCategory createCategory(String category) {
Collection<OnmsOutage> outages;
CategoryBuilder categoryBuilder = new CategoryBuilder();
StatusCategory statusCategory = new StatusCategory();
Category categoryDetail = m_categoryConfigDao.getCategoryByLabel(category);
//statusCategory.setComment(categoryDetail.getCategoryComment());
statusCategory.setLabel(category);
ServiceSelector selector = new ServiceSelector(categoryDetail.getRule(), getServicesForCategory(categoryDetail));
outages = m_outageDao.matchingCurrentOutages(selector);
for (OnmsOutage outage : outages) {
OnmsMonitoredService monitoredService = outage.getMonitoredService();
OnmsServiceType serviceType = monitoredService.getServiceType();
OnmsIpInterface ipInterface = monitoredService.getIpInterface();
final String ipAddress = InetAddressUtils.str(ipInterface.getIpAddress());
categoryBuilder.addOutageService(monitoredService.getNodeId(), ipAddress, ipAddress, ipInterface.getNode().getLabel(), serviceType.getName());
}
for (StatusNode node : categoryBuilder.getNodes()) {
statusCategory.addNode(node);
}
return statusCategory;
}
Aggregations