Hi,

Literally hours after saying I didn't think any of my current ONMS hacks
where generic enough for submission upstream I found I needed the
foreignid information in the web-app for generating links to our cgi
scripts.

This patch makes it available. I have to admit the Node class looks a
little superfluous as it basically contains a subset of the information
in the OnmsNode class from where it can be populated. If anyone wants to
explain the reason for this I'm all ears. Anyway here is the patch:

>From be04431e302dff2733b7f4719c5758bd1810fdbf Mon Sep 17 00:00:00 2001
From: Alex Bennee <[EMAIL PROTECTED]>
Date: Thu, 21 Aug 2008 17:32:56 +0100
Subject: [PATCH] CBNL: Expose foreignsource and foreignid to the webapp

For our application some of the nodes have IP addresses which aren't a unique 
key. This makes it tricky to generate
links to our cgi scripts in the WebApp without nasty (breakable) hackery. 
Fortunatly we can import the nodes into
OpenNMS with a unique key known to OpenNMS as the foreignid. This patch makes 
these values available to the WebApp
---
 .../opennms/web/element/NetworkElementFactory.java |    8 ++++++--
 .../main/java/org/opennms/web/element/Node.java    |   18 +++++++++++++++++-
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git 
a/opennms-webapp/src/main/java/org/opennms/web/element/NetworkElementFactory.java
 
b/opennms-webapp/src/main/java/org/opennms/web/element/NetworkElementFactory.java
index c847845..0d2b631 100644
--- 
a/opennms-webapp/src/main/java/org/opennms/web/element/NetworkElementFactory.java
+++ 
b/opennms-webapp/src/main/java/org/opennms/web/element/NetworkElementFactory.java
@@ -951,7 +951,9 @@ public class NetworkElementFactory extends Object {
             node.m_nodeSysContact = rs.getString("nodeSysContact");
             node.m_label = rs.getString("nodelabel");
             node.m_operatingSystem = rs.getString("operatingsystem");
-
+            node.m_foreignSource = rs.getString("foreignsource");
+            node.m_foreignId = rs.getString("foreignid");
+            
             nodes.add(node);
         }
         
@@ -2462,7 +2464,9 @@ public class NetworkElementFactory extends Object {
                                     on.getSysLocation(),
                                     on.getSysContact(),
                                     on.getType().charAt(0),
-                                    on.getOperatingSystem()));
+                                    on.getOperatingSystem(),
+                                    on.getForeignSource(),
+                                    on.getForeignId()));
 
         }
         
diff --git a/opennms-webapp/src/main/java/org/opennms/web/element/Node.java 
b/opennms-webapp/src/main/java/org/opennms/web/element/Node.java
index 0cd73cd..4140319 100644
--- a/opennms-webapp/src/main/java/org/opennms/web/element/Node.java
+++ b/opennms-webapp/src/main/java/org/opennms/web/element/Node.java
@@ -59,12 +59,16 @@ public class Node implements Comparable<Node> {
 
     String m_operatingSystem;
 
+    String m_foreignSource;
+
+    String m_foreignId;
+    
     /* package-protected so only the NetworkElementFactory can instantiate */
     Node() {
     }
 
     /* package-protected so only the NetworkElementFactory can instantiate */
-    Node(int nodeId, int nodeParent, String label, String dpname, String 
nodeCreateTime, String nodeSysId, String nodeSysName, String nodeSysDescr, 
String nodeSysLocn, String nodeSysContact, char nodeType, String 
operatingSystem) {
+    Node(int nodeId, int nodeParent, String label, String dpname, String 
nodeCreateTime, String nodeSysId, String nodeSysName, String nodeSysDescr, 
String nodeSysLocn, String nodeSysContact, char nodeType, String 
operatingSystem, String foreignSource, String foreignId) {
         m_nodeId = nodeId;
         m_nodeParent = nodeParent;
         m_label = label;
@@ -77,6 +81,8 @@ public class Node implements Comparable<Node> {
         m_nodeSysContact = nodeSysContact;
         m_nodeType = nodeType;
         m_operatingSystem = operatingSystem;
+        m_foreignSource = foreignSource;
+        m_foreignId = foreignId;
     }
 
     public int getNodeId() {
@@ -127,6 +133,14 @@ public class Node implements Comparable<Node> {
         return Util.htmlify(m_operatingSystem);
     }
 
+    public String getForeignSource() {
+        return Util.htmlify(m_foreignSource);
+    }
+
+    public String getForeignId() {
+        return Util.htmlify(m_foreignId);
+    }
+
     public String toString() {
         StringBuffer str = new StringBuffer("Node Id = " + m_nodeId + "\n");
         str.append("Node Parent = " + m_nodeParent + "\n");
@@ -139,6 +153,8 @@ public class Node implements Comparable<Node> {
         str.append("Node Sys Contact = " + m_nodeSysContact + "\n");
         str.append("Node Sys Type = " + m_nodeType + "\n");
         str.append("Operating System = " + m_operatingSystem + "\n");
+        str.append("Foreign Source = " + m_foreignSource + "\n");
+        str.append("Foreign ID = " + m_foreignId + "\n");
         return str.toString();
     }
 
-- 
1.5.4.3

 

-- 
Alex Bennee, Software Engineer
Live long and prosper. -- Spock, "Amok Time", stardate 3372.7


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-devel mailing list

To *unsubscribe* or change your subscription options, see the bottom of this 
page:
https://lists.sourceforge.net/lists/listinfo/opennms-devel

Reply via email to