private void updateLocation(final OnmsNode node) { if (node.getLocation() == null) { node.setLocation(m_monitoringLocationDao.getDefaultLocation()); } else { node.setLocation(createLocationIfNecessary(node.getLocation().getLocationName())); } }
/** {@inheritDoc} */ @Transactional @Override public OnmsNode getRequisitionedNode(final String foreignSource, final String foreignId) throws ForeignSourceRepositoryException { OnmsNodeRequisition nodeReq = null; try { nodeReq = m_foreignSourceRepository.getNodeRequisition(foreignSource, foreignId); } catch (ForeignSourceRepositoryException e) { // just fall through, nodeReq will be null } if (nodeReq == null) { LOG.warn("nodeReq for node {}:{} cannot be null!", foreignSource, foreignId); return null; } final OnmsNode node = nodeReq.constructOnmsNodeFromRequisition(); // fill in real database categories final HashSet<OnmsCategory> dbCategories = new HashSet<>(); for(final OnmsCategory category : node.getCategories()) { dbCategories.add(createCategoryIfNecessary(category.getName())); } node.setCategories(dbCategories); if (node.getLocation() == null || Strings.isNullOrEmpty(node.getLocation().getLocationName())) { node.setLocation(m_monitoringLocationDao.getDefaultLocation()); } // fill in real service types node.visit(new ServiceTypeFulfiller()); return node; }
/** {@inheritDoc} */ @Transactional @Override public OnmsNode getRequisitionedNode(final String foreignSource, final String foreignId) throws ForeignSourceRepositoryException { OnmsNodeRequisition nodeReq = null; try { nodeReq = m_foreignSourceRepository.getNodeRequisition(foreignSource, foreignId); } catch (ForeignSourceRepositoryException e) { // just fall through, nodeReq will be null } if (nodeReq == null) { LOG.warn("nodeReq for node {}:{} cannot be null!", foreignSource, foreignId); return null; } final OnmsNode node = nodeReq.constructOnmsNodeFromRequisition(); // fill in real database categories final HashSet<OnmsCategory> dbCategories = new HashSet<>(); for(final OnmsCategory category : node.getCategories()) { dbCategories.add(createCategoryIfNecessary(category.getName())); } node.setCategories(dbCategories); if (node.getLocation() == null || Strings.isNullOrEmpty(node.getLocation().getLocationName())) { node.setLocation(m_monitoringLocationDao.getDefaultLocation()); } // fill in real service types node.visit(new ServiceTypeFulfiller()); return node; }
private void updateLocation(final OnmsNode node) { if (node.getLocation() == null) { node.setLocation(m_monitoringLocationDao.getDefaultLocation()); } else { node.setLocation(createLocationIfNecessary(node.getLocation().getLocationName())); } }
@Before public void setUp() { // Async. m_eventMgr.setSynchronous(false); // Events need database IDs to make alarmd happy m_eventMgr.setEventWriter(m_database); // Events need to real nodes too OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), "node1"); node.setId(1); m_nodeDao.save(node); node = new OnmsNode(m_locationDao.getDefaultLocation(), "node2"); node.setId(2); m_nodeDao.save(node); node = new OnmsNode(m_locationDao.getDefaultLocation(), "node3"); node.setId(3); m_nodeDao.save(node); // Use a pseudo-clock m_droolsAlarmContext.setUsePseudoClock(true); // Drive the ticks ourselves m_droolsAlarmContext.setUseManualTick(true); // Set the behavior if (scenario.getLegacyAlarmBehavior()) { m_alarmPersister.setLegacyAlarmState(true); } // Start alarmd m_alarmd.start(); }
@Test @Transactional public void testValue() throws Exception { final OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), "node1"); node.setId(1); m_nodeDao.save(node);