perfsonar-dev - r1776 - branches/ulisseskan/src/org/perfsonar/service/topologyService
Subject: perfsonar development work
List archive
- From:
- To:
- Subject: r1776 - branches/ulisseskan/src/org/perfsonar/service/topologyService
- Date: Thu, 23 Nov 2006 07:16:04 -0500
Author: rodriguez
Date: 2006-11-23 07:16:03 -0500 (Thu, 23 Nov 2006)
New Revision: 1776
Modified:
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsDownloadAction.java
Log:
It includes more information such as location data
Modified:
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsDownloadAction.java
===================================================================
---
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsDownloadAction.java
2006-11-23 11:03:18 UTC (rev 1775)
+++
branches/ulisseskan/src/org/perfsonar/service/topologyService/TopsDownloadAction.java
2006-11-23 12:16:03 UTC (rev 1776)
@@ -17,7 +17,10 @@
import org.ggf.ns.nmwg.base.v2_0.Message;
import org.ggf.ns.nmwg.base.v2_0.Metadata;
import org.ggf.ns.nmwg.base.v2_0.Parameters;
+import org.ggf.ns.nmwg.topology.base.v3_0.Country;
import org.ggf.ns.nmwg.topology.base.v3_0.HostName;
+import org.ggf.ns.nmwg.topology.base.v3_0.Institution;
+import org.ggf.ns.nmwg.topology.base.v3_0.Location;
import org.ggf.ns.nmwg.topology.base.v3_0.Node;
import org.ggf.ns.nmwg.topology.l3.v3_0.Capacity;
import org.ggf.ns.nmwg.topology.l3.v3_0.IfDescription;
@@ -309,19 +312,21 @@
if (rs_nodes.getString(6) != null) { // Type is optional
org.ggf.ns.nmwg.topology.base.v3_0.Type type=
new org.ggf.ns.nmwg.topology.base.v3_0.Type();
-
type.setType(rs_nodes.getString(6));
node.setTypeElement(type);
}
if (rs_nodes.getString(7) != null) { // Name is optional
org.ggf.ns.nmwg.topology.base.v3_0.Name name=
new org.ggf.ns.nmwg.topology.base.v3_0.Name();
-
+
name.setType(convertUsageTypeToDescription(rs_nodes.getString(6)));
name.setName(rs_nodes.getString(7));
node.setNameElement(name);
}
node_id= rs_nodes.getInt(8); // object_id
+ if (rs_nodes.getString(3) != null) {
+
setLocationOfNode(node,rs_nodes.getString(3),domain_id);
+ }
setInterfaceOfNode(node,node_id);
nodesData.setChild(node);
@@ -338,10 +343,47 @@
logger.error(m);
throw new SystemException("error.tops.fetching", m);
}
-
- return;
- }
+ }
+ private void setLocationOfNode(Node node, String locationId, String
domainId) throws SQLException {
+ // Get the location field
+ Location location=new Location();
+ String select_location= "SELECT description " +
+ "FROM location " +
+ "WHERE id=" + locationId;
+
+ Statement st_location = jdbc.createStatement();
+ logger.debug(ROOT_LOG+"executing query: "+select_location);
+ ResultSet rs_location= st_location.executeQuery(select_location);
+
+ if (rs_location.getString(1) != null) {
+ location.setLocation(rs_location.getString(1));
+ }
+
+ String select_domain= "SELECT domain_name,
country_iso3166_code " +
+ "FROM domain" +
+ "WHERE domain_id=" + domainId;
+
+ Statement st_domain= jdbc.createStatement();
+ logger.debug(ROOT_LOG+"executing query: "+select_domain);
+ ResultSet rs_domain= st_domain.executeQuery(select_domain);
+
+ if (rs_domain.getString(1) != null) {
+ Institution institution=new Institution();
+ institution.setInstitution(rs_domain.getString(1));
+ location.setInstitutionElement(institution);
+ }
+
+ if (rs_domain.getString(2) != null) {
+ Country country=new Country();
+ country.setCountry(rs_domain.getString(2));
+ location.setCountryElement(country);
+ }
+
+ // --FIXME: check what happens if an empty location is
inserted in the node
+ node.setLocationElement(location);
+ }
+
private void setInterfaceOfNode(Node node,int node_id) throws
SQLException{
String interface_ref;
Integer i;
@@ -401,7 +443,39 @@
protected String convertIfTypeToDescription(int ifType) {
String desc=interfacesDesc.getProperty(String.valueOf(ifType));
if (desc==null)
- desc=interfacesDesc.getProperty("0");
+ desc=interfacesDesc.getProperty("1");
return desc;
}
+
+ protected String convertUsageTypeToDescription(String usageType) {
+ /*
+ This is a kind of hack in the database, the IDs where
+ not specified when the Tops was developed, we specify the
meaning here:
+
+ from CNM GWIN:
+ core router
+ access router
+ other router
+
+ We add an additional code for "unspecified"
+ */
+ String conv[] = {
+ "unspecified",
+ "core router",
+ "access router",
+ "other router"
+ };
+ try {
+ int usage_type=Integer.parseInt(usageType);
+
+ if ((usage_type < 0) || (usage_type > conv.length)) {
+ return conv[0]; // return "unspecified"
+ }
+
+ return conv[usage_type];
+ } catch (NumberFormatException e) {
+ return conv[0];
+ }
+ }
+
}
- r1776 - branches/ulisseskan/src/org/perfsonar/service/topologyService, svnlog, 11/23/2006
Archive powered by MHonArc 2.6.16.