/** * Constructor for AbstractSaveOrUpdateOperation. * * @param nodeId a {@link java.lang.Integer} object. * @param foreignSource a {@link java.lang.String} object. * @param foreignId a {@link java.lang.String} object. * @param nodeLabel a {@link java.lang.String} object. * @param building a {@link java.lang.String} object. * @param city a {@link java.lang.String} object. */ public AbstractSaveOrUpdateOperation( final Integer nodeId, final String foreignSource, final String foreignId, final String nodeLabel, final String building, final String city) { m_node = new OnmsNode(); m_node.setId(nodeId); m_node.setLabel(nodeLabel); m_node.setLabelSource(NodeLabelSource.USER); m_node.setType(NodeType.ACTIVE); m_node.setForeignSource(foreignSource); m_node.setForeignId(foreignId); m_node.getAssetRecord().setBuilding(building); m_node.getAssetRecord().setCity(city); }
/** * mergeNodeAttributes * * @param scannedNode a {@link org.opennms.netmgt.model.OnmsNode} object. */ public void mergeNodeAttributes(OnmsNode scannedNode, EventForwarder eventForwarder) { final String scannedLabel = scannedNode.getLabel(); boolean send = false; if (m_oldLabel != null || m_oldLabelSource != null) { send = true; } else if (hasNewValue(scannedLabel, getLabel())) { m_oldLabel = getLabel(); m_oldLabelSource = getLabelSource(); send = true; } if (send) { LOG.debug("mergeNodeAttributes(): sending NODE_LABEL_CHANGED_EVENT_UEI"); // Create a NODE_LABEL_CHANGED_EVENT_UEI event final EventBuilder bldr = new EventBuilder( EventConstants.NODE_LABEL_CHANGED_EVENT_UEI, "OnmsNode.mergeNodeAttributes"); bldr.setNodeid(scannedNode.getId()); bldr.setHost("host"); if (m_oldLabel != null) { bldr.addParam(EventConstants.PARM_OLD_NODE_LABEL, m_oldLabel); if (m_oldLabelSource != null) { bldr.addParam(EventConstants.PARM_OLD_NODE_LABEL_SOURCE, m_oldLabelSource.toString()); } } if (scannedLabel != null) { bldr.addParam(EventConstants.PARM_NEW_NODE_LABEL, scannedLabel); if (scannedNode.getLabelSource() != null) { bldr.addParam( EventConstants.PARM_NEW_NODE_LABEL_SOURCE, scannedNode.getLabelSource().toString()); } } m_oldLabel = null; m_oldLabelSource = null; eventForwarder.sendNow(bldr.getEvent()); // Update the node label value m_label = scannedLabel; } else { LOG.debug("mergeNodeAttributes(): skipping event."); } if (hasNewValue(scannedNode.getForeignSource(), getForeignSource())) { setForeignSource(scannedNode.getForeignSource()); } if (hasNewValue(scannedNode.getForeignId(), getForeignId())) { setForeignId(scannedNode.getForeignId()); } if (hasNewValue(scannedNode.getLabelSource(), getLabelSource())) { setLabelSource(scannedNode.getLabelSource()); } if (hasNewValue(scannedNode.getNetBiosName(), getNetBiosDomain())) { setNetBiosName(scannedNode.getNetBiosDomain()); } if (hasNewValue(scannedNode.getNetBiosDomain(), getNetBiosDomain())) { setNetBiosDomain(scannedNode.getNetBiosDomain()); } if (hasNewValue(scannedNode.getOperatingSystem(), getOperatingSystem())) { setOperatingSystem(scannedNode.getOperatingSystem()); } mergeAgentAttributes(scannedNode); mergeAdditionalCategories(scannedNode); }