use of org.opennms.netmgt.model.EntityVisitor in project opennms by OpenNMS.
the class DefaultProvisionService method updateNode.
/**
* {@inheritDoc}
*/
@Transactional
@Override
public void updateNode(final OnmsNode node, String rescanExisting) {
updateLocation(node);
final OnmsNode dbNode = m_nodeDao.getHierarchy(node.getId());
// on an update, leave categories alone, let the NodeScan handle applying requisitioned categories
node.setCategories(dbNode.getCategories());
final EventAccumulator accumulator = new EventAccumulator(m_eventForwarder);
dbNode.mergeNode(node, accumulator, false);
updateNodeHostname(dbNode);
m_nodeDao.update(dbNode);
m_nodeDao.flush();
accumulator.flush();
final EntityVisitor eventAccumlator = new UpdateEventVisitor(m_eventForwarder, rescanExisting);
dbNode.visit(eventAccumlator);
}
use of org.opennms.netmgt.model.EntityVisitor in project opennms by OpenNMS.
the class DefaultProvisionService method insertNode.
/**
* {@inheritDoc}
*/
@Transactional
@Override
public void insertNode(final OnmsNode node) {
updateLocation(node);
m_nodeDao.save(node);
m_nodeDao.flush();
final EntityVisitor visitor = new AddEventVisitor(m_eventForwarder);
node.visit(visitor);
}
use of org.opennms.netmgt.model.EntityVisitor in project opennms by OpenNMS.
the class FilterResourceWalker method walk.
/**
* <p>walk</p>
*/
public void walk() {
EntityVisitor visitor = new AbstractEntityVisitor() {
@Override
public void visitNode(OnmsNode node) {
walk(node);
}
};
SortedMap<Integer, String> map = getFilterDao().getNodeMap(m_filter);
for (final Integer nodeId : map.keySet()) {
final OnmsNode node = getNodeDao().load(nodeId);
visitor.visitNode(node);
}
}
use of org.opennms.netmgt.model.EntityVisitor in project opennms by OpenNMS.
the class JdbcFilterDaoIT method testWalkNodes.
@Test
public void testWalkNodes() throws Exception {
final List<OnmsNode> nodes = new ArrayList<>();
EntityVisitor visitor = new AbstractEntityVisitor() {
@Override
public void visitNode(OnmsNode node) {
nodes.add(node);
}
};
FilterWalker walker = new FilterWalker();
walker.setFilterDao(m_dao);
walker.setNodeDao(m_nodeDao);
walker.setFilter("ipaddr == '10.1.1.1'");
walker.setVisitor(visitor);
walker.walk();
assertEquals("node list size", 1, nodes.size());
}
Aggregations