@Override protected Integer getId(final OnmsAssetRecord asset) { return asset.getId(); }
@Override protected Integer getId(final OnmsAssetRecord asset) { return asset.getId(); }
/** * Simply replaces the current asset record with the new record * * @param scannedNode a {@link org.opennms.netmgt.model.OnmsNode} object. */ public void replaceCurrentAssetRecord(OnmsNode scannedNode) { scannedNode.getAssetRecord().setId(this.getAssetRecord().getId()); scannedNode.setId(this.m_id); //just in case this.setAssetRecord(scannedNode.getAssetRecord()); }
@Override protected OnmsNode doUpdate(final OnmsNode dbNode) { dbNode.setLocation(createLocationIfNecessary(node.getLocation() == null ? null : node.getLocation().getLocationName())); LOG.debug("Associating node {}/{}/{} with location: {}", dbNode.getId(), dbNode.getForeignSource(), dbNode.getForeignId(), dbNode.getLocation()); final EventAccumulator accumulator = new EventAccumulator(m_eventForwarder); final boolean changed = handleCategoryChanges(dbNode); dbNode.mergeNodeAttributes(node, accumulator); node.getAssetRecord().setId(dbNode.getAssetRecord().getId()); node.setId(dbNode.getId()); dbNode.mergeAssets(node); updateNodeHostname(dbNode); final OnmsNode ret = saveOrUpdate(dbNode); if (changed) { accumulator.sendNow(EventUtils.createNodeCategoryMembershipChangedEvent("Provisiond", ret.getId(), ret.getLabel(), m_categoriesAdded.toArray(new String[0]), m_categoriesDeleted.toArray(new String[0]))); LOG.debug("Node {}/{}/{} categories changed: {}", dbNode.getId(), dbNode.getForeignSource(), dbNode.getForeignId(), getCategoriesForNode(dbNode)); } else { LOG.debug("Node {}/{}/{} categories unchanged: {}", dbNode.getId(), dbNode.getForeignSource(), dbNode.getForeignId(), getCategoriesForNode(dbNode)); } accumulator.flush(); return ret; }
@Override protected OnmsNode doUpdate(final OnmsNode dbNode) { dbNode.setLocation(createLocationIfNecessary(node.getLocation() == null ? null : node.getLocation().getLocationName())); LOG.debug("Associating node {}/{}/{} with location: {}", dbNode.getId(), dbNode.getForeignSource(), dbNode.getForeignId(), dbNode.getLocation()); final EventAccumulator accumulator = new EventAccumulator(m_eventForwarder); final boolean changed = handleCategoryChanges(dbNode); dbNode.mergeNodeAttributes(node, accumulator); node.getAssetRecord().setId(dbNode.getAssetRecord().getId()); node.setId(dbNode.getId()); dbNode.mergeAssets(node); updateNodeHostname(dbNode); final OnmsNode ret = saveOrUpdate(dbNode); if (changed) { accumulator.sendNow(EventUtils.createNodeCategoryMembershipChangedEvent("Provisiond", ret.getId(), ret.getLabel(), m_categoriesAdded.toArray(new String[0]), m_categoriesDeleted.toArray(new String[0]))); LOG.debug("Node {}/{}/{} categories changed: {}", dbNode.getId(), dbNode.getForeignSource(), dbNode.getForeignId(), getCategoriesForNode(dbNode)); } else { LOG.debug("Node {}/{}/{} categories unchanged: {}", dbNode.getId(), dbNode.getForeignSource(), dbNode.getForeignId(), getCategoriesForNode(dbNode)); } accumulator.flush(); return ret; }