OpenNMS API 1.2.9

## org.opennms.web.element
Class NetworkElementFactory

    java.lang.Object
      org.opennms.web.element.NetworkElementFactory

public class NetworkElementFactory
extends java.lang.Object

The source for all network element business objects (nodes, interfaces, services). Encapsulates all lookup functionality for the network element business objects in one place. To use this factory to lookup network elements, you must first initialize the Vault with the database connection manager * and JDBC URL it will use. Call the init method to initialize the factory. After that, you can call any lookup methods.

Author:
  Larry Karnowski , OpenNMS

Field Summary
`protected static java.util.Map` `serviceId2NameMap` A mapping of service identifiers (integers) to service names (strings).
`protected static java.util.Map` `serviceName2IdMap` A mapping of service names (strings) to service identifiers (integers).

Constructor Summary
`private` `NetworkElementFactory()` Private, empty constructor so that this class cannot be instantiated.

Method Summary
`protected static void` `augmentInterfacesWithSnmpData(Interface[] intfs, java.sql.Connection conn)`
`protected static void` `createServiceIdNameMaps()`
`static Interface[]` `getActiveInterfacesOnNode(int nodeId)`
`static Interface[]` `getAllInterfaces()`
`static Interface[]` `getAllInterfaces(boolean includeSNMP)`
`static Interface[]` `getAllInterfacesOnNode(int nodeId)`
`static Node[]` `getAllNodes()` Returns all non-deleted nodes.
`static Service[]` `getAllServices()`
`static java.lang.String` `getHostname(java.lang.String ipAddress)` Resolve an IP address to a DNS hostname via the database.
`static Interface` `getInterface(int nodeId, java.lang.String ipAddress)`
`static Interface` `getInterface(int nodeId, java.lang.String ipAddress, int ifindex)`
`static Interface[]` `getInterfacesWithIpAddress(java.lang.String ipAddress)`
`static Node` `getNode(int nodeId)`
`static java.lang.String` `getNodeLabel(int nodeId)` Translate a node id into a human-readable node label.
`static Node[]` `getNodesLike(java.lang.String nodeLabel)` Returns all non-deleted nodes that have the given nodeLabel substring somewhere in their nodeLabel.
`static Node[]` `getNodesWithIpLike(java.lang.String iplike)` Returns all non-deleted nodes with an IP address like the rule given.
`static Node[]` `getNodesWithService(int serviceId)` Returns all non-deleted nodes that have the given service.
`static Service` `getService(int nodeId, java.lang.String ipAddress, int serviceId)` Return the service specified by the node identifier, IP address, and service identifier.
`static int` `getServiceIdFromName(java.lang.String serviceName)`
`static java.util.Map` `getServiceIdToNameMap()`
`static java.lang.String` `getServiceNameFromId(int serviceId)`
`static java.util.Map` `getServiceNameToIdMap()`
`static Service[]` `getServicesOnInterface(int nodeId, java.lang.String ipAddress)`
`static Service[]` `getServicesOnInterface(int nodeId, java.lang.String ipAddress, boolean includeDeletions)`
`static Service[]` `getServicesOnNode(int nodeId)` Get the list of all services on a given node.
`static Service[]` `getServicesOnNode(int nodeId, int serviceId)` Get the list of all instances of a specific service on a given node.
`protected static Interface[]` `rs2Interfaces(java.sql.ResultSet rs)` This method returns the data from the result set as an vector of ipinterface objects.
`protected static Node[]` `rs2Nodes(java.sql.ResultSet rs)` This method returns the data from the result set as an array of Node objects.
`protected static Service[]` `rs2Services(java.sql.ResultSet rs)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### serviceName2IdMap

    protected static java.util.Map serviceName2IdMap

  A mapping of service names (strings) to service identifiers (integers).

### serviceId2NameMap

    protected static java.util.Map serviceId2NameMap

  A mapping of service identifiers (integers) to service names (strings).

Constructor Detail

### NetworkElementFactory

    private NetworkElementFactory()

  Private, empty constructor so that this class cannot be instantiated. All of its methods should static and accessed through the class name.

Method Detail

### getNodeLabel

    public static java.lang.String getNodeLabel(int nodeId)
                                         throws java.sql.SQLException

  Translate a node id into a human-readable node label. Note these values are not cached.

  Returns:
    A human-readable node name or null if the node id given does not specify a real node.
  Throws:
    `java.sql.SQLException`

### getNode

    public static Node getNode(int nodeId)
                        throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getAllNodes

    public static Node[] getAllNodes()
                              throws java.sql.SQLException

  Returns all non-deleted nodes.

  Throws:
    `java.sql.SQLException`

### getNodesLike

    public static Node[] getNodesLike(java.lang.String nodeLabel)
                               throws java.sql.SQLException

  Returns all non-deleted nodes that have the given nodeLabel substring somewhere in their nodeLabel.

  Throws:
    `java.sql.SQLException`

### getNodesWithIpLike

    public static Node[] getNodesWithIpLike(java.lang.String iplike)
                                     throws java.sql.SQLException

  Returns all non-deleted nodes with an IP address like the rule given.

  Throws:
    `java.sql.SQLException`

### getNodesWithService

    public static Node[] getNodesWithService(int serviceId)
                                      throws java.sql.SQLException

  Returns all non-deleted nodes that have the given service.

  Throws:
    `java.sql.SQLException`

### getHostname

    public static java.lang.String getHostname(java.lang.String ipAddress)
                                        throws java.sql.SQLException

  Resolve an IP address to a DNS hostname via the database. If no hostname can be found, the given IP address is returned.

  Throws:
    `java.sql.SQLException`

### getInterface

    public static Interface getInterface(int nodeId,
                                         java.lang.String ipAddress)
                                  throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getInterface

    public static Interface getInterface(int nodeId,
                                         java.lang.String ipAddress,
                                         int ifindex)
                                  throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getInterfacesWithIpAddress

    public static Interface[] getInterfacesWithIpAddress(java.lang.String ipAddress)
                                                  throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getAllInterfacesOnNode

    public static Interface[] getAllInterfacesOnNode(int nodeId)
                                              throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getActiveInterfacesOnNode

    public static Interface[] getActiveInterfacesOnNode(int nodeId)
                                                 throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getAllInterfaces

    public static Interface[] getAllInterfaces()
                                        throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getAllInterfaces

    public static Interface[] getAllInterfaces(boolean includeSNMP)
                                        throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getService

    public static Service getService(int nodeId,
                                     java.lang.String ipAddress,
                                     int serviceId)
                              throws java.sql.SQLException

  Return the service specified by the node identifier, IP address, and service identifier.

  Note that if there are both an active service and historically deleted services with this (nodeid, ipAddress, serviceId) key, then the active service will be returned. If there are only deleted services, then the first deleted service will be returned.

  Throws:
    `java.sql.SQLException`

### getAllServices

    public static Service[] getAllServices()
                                    throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getServicesOnInterface

    public static Service[] getServicesOnInterface(int nodeId,
                                                   java.lang.String ipAddress)
                                            throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getServicesOnInterface

    public static Service[] getServicesOnInterface(int nodeId,
                                                   java.lang.String ipAddress,
                                                   boolean includeDeletions)
                                            throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getServicesOnNode

    public static Service[] getServicesOnNode(int nodeId)
                                       throws java.sql.SQLException

  Get the list of all services on a given node.

  Throws:
    `java.sql.SQLException`

### getServicesOnNode

    public static Service[] getServicesOnNode(int nodeId,
                                              int serviceId)
                                       throws java.sql.SQLException

  Get the list of all instances of a specific service on a given node.

  Throws:
    `java.sql.SQLException`

### rs2Nodes

    protected static Node[] rs2Nodes(java.sql.ResultSet rs)
                              throws java.sql.SQLException

  This method returns the data from the result set as an array of Node objects.

  Throws:
    `java.sql.SQLException`

### rs2Interfaces

    protected static Interface[] rs2Interfaces(java.sql.ResultSet rs)
                                        throws java.sql.SQLException

  This method returns the data from the result set as an vector of ipinterface objects.

  Throws:
    `java.sql.SQLException`

### augmentInterfacesWithSnmpData

    protected static void augmentInterfacesWithSnmpData(Interface[] intfs,
                                                        java.sql.Connection conn)
                                                 throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### rs2Services

    protected static Service[] rs2Services(java.sql.ResultSet rs)
                                    throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getServiceNameFromId

    public static java.lang.String getServiceNameFromId(int serviceId)
                                                 throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getServiceIdFromName

    public static int getServiceIdFromName(java.lang.String serviceName)
                                    throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getServiceIdToNameMap

    public static java.util.Map getServiceIdToNameMap()
                                               throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getServiceNameToIdMap

    public static java.util.Map getServiceNameToIdMap()
                                               throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### createServiceIdNameMaps

    protected static void createServiceIdNameMaps()
                                           throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.