Package org.opennms.netmgt.dao.hibernate
Class NodeLabelDaoImpl
- java.lang.Object
-
- org.opennms.netmgt.dao.hibernate.NodeLabelDaoImpl
-
- All Implemented Interfaces:
NodeLabel
public class NodeLabelDaoImpl extends Object implements NodeLabel
This class contains convenience functions for retrieving and modifying the label associated with a managed node. The 'node' table contains a 'nodelabel' and 'nodelabelsource' field. The 'nodelabel' is a user-friendly name associated with the node. This name can be user-defined (via the WEB UI) or can be auto-generated based on what OpenNMS knows about the node and its interfaces. The 'nodelabelsource' field is a single character flag which indicates what the source for the node label was.
Valid values for node label source are: 'U' User defined 'H' Primary interface's IP host name 'S' Node's MIB-II sysName 'A' Primary interface's IP address
-
-
Field Summary
-
Fields inherited from interface org.opennms.netmgt.dao.api.NodeLabel
DEFAULT_SELECT_METHOD, MAX_NODE_LABEL_LENGTH, PROP_PRIMARY_INTERFACE_SELECT_METHOD, SELECT_METHOD_MAX, SELECT_METHOD_MIN
-
-
Constructor Summary
Constructors Constructor Description NodeLabelDaoImpl()
Default constructorNodeLabelDaoImpl(String nodeLabel, OnmsNode.NodeLabelSource nodeLabelSource)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
assignLabel(int nodeID, NodeLabel nodeLabel)
Deprecated.Use aNodeDao#update(org.opennms.netmgt.model.OnmsNode)
method call insteadNodeLabel
computeLabel(int nodeID)
This method determines what label should be associated with a particular node.String
getLabel()
Returns the node label .OnmsNode.NodeLabelSource
getSource()
Returns the node label source flag .NodeLabel
retrieveLabel(int nodeID)
Deprecated.Use aNodeDao#load(Integer)
method call insteadString
toString()
This method is responsible for returning a String object which represents the content of this NodeLabel.
-
-
-
Constructor Detail
-
NodeLabelDaoImpl
public NodeLabelDaoImpl()
Default constructor
-
NodeLabelDaoImpl
public NodeLabelDaoImpl(String nodeLabel, OnmsNode.NodeLabelSource nodeLabelSource)
Constructor- Parameters:
nodeLabel
- Node labelnodeLabelSource
- Flag indicating source of node label
-
-
Method Detail
-
getLabel
public String getLabel()
Returns the node label .
-
getSource
public OnmsNode.NodeLabelSource getSource()
Returns the node label source flag .
-
retrieveLabel
public NodeLabel retrieveLabel(int nodeID) throws SQLException
Deprecated.Use aNodeDao#load(Integer)
method call insteadThis method queries the 'node' table for the value of the 'nodelabel' and 'nodelabelsource' fields for the node with the provided nodeID. A NodeLabel object is returned initialized with the retrieved values.- Specified by:
retrieveLabel
in interfaceNodeLabel
- Parameters:
nodeID
- Unique ID of node whose label info is to be retrieveddbConnection
- SQL database connection- Returns:
- object initialized with node label & source flag
- Throws:
SQLException
- if any.
-
assignLabel
@Transactional public void assignLabel(int nodeID, NodeLabel nodeLabel) throws SQLException
Deprecated.Use aNodeDao#update(org.opennms.netmgt.model.OnmsNode)
method call insteadThis method updates the 'nodelabel' and 'nodelabelsource' fields of the 'node' table for the specified nodeID. If nodeLabel parameter is NULL the method will first call computeLabel() and use the resulting NodeLabel object to update the database.- Specified by:
assignLabel
in interfaceNodeLabel
- Parameters:
nodeID
- Unique identifier of the node to be updated.nodeLabel
- Object containing label and source values.dbConnection
- SQL database connection- Throws:
SQLException
- if any.
-
computeLabel
public NodeLabel computeLabel(int nodeID) throws SQLException
This method determines what label should be associated with a particular node. Algorithm for determining a node's label is as follows: 1) If node has a NetBIOS name associated with it, the NetBIOS name is used as the node's label. 2) If no NetBIOS name available, retrieve all the 'ipinterface' table entries associated with the node with an 'isManaged' field value of 'M' 3) Find the primary interface where "primary" is defined as the managed interface with the smallest IP address (each IP address is converted to an integer value -- the IP address with the smallest integer value wins). 4) IF the primary interface's IP host name is known it becomes the node's label. ELSE IF the node's MIB-II sysName value is known it becomes the node's label ELSE the primary interface's IP address becomes the node's label. NOTE: If for some reason a node has no "managed" interfaces null is returned for the NodeLabel.- Specified by:
computeLabel
in interfaceNodeLabel
- Parameters:
nodeID
- Unique identifier of the node to be updated.dbConnection
- SQL database connection- Returns:
- NodeLabel Object containing label and source values or null if node does not have a primary interface.
- Throws:
SQLException
- if any.
-
toString
public String toString()
This method is responsible for returning a String object which represents the content of this NodeLabel. Primarily used for debugging purposes.
-
-