@Transactional private OnmsNode saveOrUpdate(final OnmsNode node) { final Set<OnmsCategory> updatedCategories = new HashSet<>(); for(final Iterator<OnmsCategory> it = node.getCategories().iterator(); it.hasNext(); ) { final OnmsCategory category = it.next(); if (category.getId() == null) { it.remove(); updatedCategories.add(createCategoryIfNecessary(category.getName())); } } node.getCategories().addAll(updatedCategories); m_nodeDao.saveOrUpdate(node); m_nodeDao.flush(); return node; }
@Transactional private OnmsNode saveOrUpdate(final OnmsNode node) { final Set<OnmsCategory> updatedCategories = new HashSet<>(); for(final Iterator<OnmsCategory> it = node.getCategories().iterator(); it.hasNext(); ) { final OnmsCategory category = it.next(); if (category.getId() == null) { it.remove(); updatedCategories.add(createCategoryIfNecessary(category.getName())); } } node.getCategories().addAll(updatedCategories); m_nodeDao.saveOrUpdate(node); m_nodeDao.flush(); return node; }
/** {@inheritDoc} */ @Transactional @Override public void deleteInterface(final Integer nodeId, final String ipAddr) { LOG.debug("deleteInterface: nodeId={}, addr={}", nodeId, ipAddr); final OnmsIpInterface iface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, ipAddr); if (iface != null) { final OnmsNode node = iface.getNode(); final boolean lastInterface = (node.getIpInterfaces().size() == 1); final DeleteEventVisitor visitor = new DeleteEventVisitor(m_eventForwarder); node.removeIpInterface(iface); m_nodeDao.saveOrUpdate(node); m_nodeDao.flush(); iface.visit(visitor); if (lastInterface) { LOG.debug("Deleting node {}", nodeId); m_nodeDao.delete(node); m_nodeDao.flush(); node.visit(visitor); } } }
/** {@inheritDoc} */ @Transactional @Override public void deleteInterface(final Integer nodeId, final String ipAddr) { LOG.debug("deleteInterface: nodeId={}, addr={}", nodeId, ipAddr); final OnmsIpInterface iface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, ipAddr); if (iface != null) { final OnmsNode node = iface.getNode(); final boolean lastInterface = (node.getIpInterfaces().size() == 1); final DeleteEventVisitor visitor = new DeleteEventVisitor(m_eventForwarder); node.removeIpInterface(iface); m_nodeDao.saveOrUpdate(node); m_nodeDao.flush(); iface.visit(visitor); if (lastInterface) { LOG.debug("Deleting node {}", nodeId); m_nodeDao.delete(node); m_nodeDao.flush(); node.visit(visitor); } } }
m_nodeDao.saveOrUpdate(node); m_nodeDao.flush(); service.visit(visitor); m_nodeDao.saveOrUpdate(node); m_nodeDao.flush(); iface.visit(visitor);
protected void updateGeolocation(GeolocationResolver geolocationResolver, OnmsNode node) { Objects.requireNonNull(geolocationResolver); Objects.requireNonNull(node); // Only resolve long/lat if not already set and an address is set final OnmsGeolocation geolocation = node.getAssetRecord().getGeolocation(); if (geolocation != null && geolocation.getLatitude() == null && geolocation.getLatitude() == null && !Strings.isNullOrEmpty(geolocation.asAddressString())) { final Coordinates coordinates = geolocationResolver.resolve(geolocation.asAddressString()); if (coordinates != null) { geolocation.setLongitude(coordinates.getLongitude()); geolocation.setLatitude(coordinates.getLatitude()); nodeDao.saveOrUpdate(node); } else { LOG.warn("Could not resolve address string '{}' for node with id {}", geolocation.asAddressString(), node.getId()); } } }
m_nodeDao.saveOrUpdate(node); m_nodeDao.flush(); service.visit(visitor); m_nodeDao.saveOrUpdate(node); m_nodeDao.flush(); iface.visit(visitor);
m_nodeDao.saveOrUpdate(node); m_nodeDao.flush();
m_nodeDao.saveOrUpdate(node); m_nodeDao.flush();
m_nodeDao.saveOrUpdate(node); m_nodeDao.flush();
m_nodeDao.saveOrUpdate(node); m_nodeDao.flush();
m_nodeDao.saveOrUpdate(node); m_nodeDao.flush();
m_nodeDao.saveOrUpdate(node); m_nodeDao.flush();