// Parse cluster info from Clusters table and // place all cluster=>plugin info into hashtable // Schema : // create table Clusters ( // Cluster String, // Plugin String // ); private void parseClusterInfo( Hashtable all_clusters, Statement stmt, String community, String node) throws SQLException { String sql = null; ResultSet rset; int number = 0; // Grab the plugin groups Hashtable plugInGroups = new Hashtable(); sql = "select GroupName, GroupSequence from GroupMaster"; number = 0; System.out.println(sql); rset = stmt.executeQuery(sql); while (rset.next()) { number++; String groupName = rset.getString("GroupName"); System.out.println(groupName); Integer index = new Integer(rset.getInt("GroupSequence")); System.out.println(index); plugInGroups.put(index, groupName); } System.out.println("Query returned " + number + " results"); // Grab the group definitions Hashtable groupDefinitions = new Hashtable(); for (int ind = 0; ind < plugInGroups.size(); ind++) { String group = (String) plugInGroups.get(new Integer(ind)); if (group != null) { sql = "select InGroupSequence, Plugin from GroupDefinitions" + " where GroupName='" + group + "'"; rset = stmt.executeQuery(sql); System.out.println(sql); groupDefinitions.put(group, new Hashtable()); number = 0; while (rset.next()) { number++; Hashtable plugins = (Hashtable) groupDefinitions.get(group); int index = rset.getInt("InGroupSequence"); String plugIn = rset.getString("Plugin"); plugins.put(new Integer(index), plugIn); } System.out.println("Query returned " + number + " results"); } else { break; } } // Add the plugIn groups per cluster to the plugIn vector number = 0; sql = "select Cluster, PluginGroup from GroupsInCluster"; if (community != null && node != null) { sql = sql + ", Organizations where Cluster=Organizations.Name and" + " Organizations.Community='" + community + "' and Organizations.Node='" + node + "'"; } else if (community != null) { sql = sql + ", Organizations where Cluster=Organizations.Name and" + " Organizations.Community='" + community + "'"; } else if (node != null) { sql = sql + ", Organizations where Organizations.Node='" + node + "'"; } System.out.println(sql); number = 0; rset = stmt.executeQuery(sql); while (rset.next()) { number++; String cluster_name = rset.getString("Cluster"); String pluginGroup = rset.getString("PluginGroup"); Vector current_cluster_plugins = (Vector) all_clusters.get(cluster_name); if (current_cluster_plugins == null) { current_cluster_plugins = new Vector(); all_clusters.put(cluster_name, current_cluster_plugins); } Hashtable groupPlugins = (Hashtable) groupDefinitions.get(pluginGroup); for (int ind = 0; ind < groupPlugins.size(); ind++) { current_cluster_plugins.addElement(groupPlugins.get(new Integer(ind))); } } System.out.println("Query returned " + number + " results"); // Grab the plugins that go in every community or every cluster within specific communities Vector mdbCommunities = new Vector(); sql = "select Community from CommunityMaster"; number = 0; System.out.println(sql); rset = stmt.executeQuery(sql); while (rset.next()) { number++; String community_name = rset.getString("Community"); mdbCommunities.addElement(community_name); } System.out.println("Query returned " + number + " results"); while (!mdbCommunities.isEmpty()) { number = 0; String sCommunity = (String) mdbCommunities.firstElement(); mdbCommunities.removeElementAt(0); sql = "select Organizations.Name, CommunityPlugins.Plugin from Organizations, CommunityPlugins" + " where CommunityPlugins.Community='" + sCommunity + "'"; if (!sCommunity.equals("Society")) { if (community != null) { if (!community.equals(sCommunity)) { continue; } } sql = sql + " and Organizations.Community='" + sCommunity + "'"; } else { if (community != null) { sql = sql + " and Organizations.Community='" + community + "'"; } } if (node != null) { sql = sql + " and Organizations.Node='" + node + "'"; } System.out.println(sql); number = 0; rset = stmt.executeQuery(sql); while (rset.next()) { number++; String cluster_name = rset.getString("Name"); String plugin = rset.getString("Plugin"); Vector current_cluster_plugins = (Vector) all_clusters.get(cluster_name); if (current_cluster_plugins == null) { current_cluster_plugins = new Vector(); all_clusters.put(cluster_name, current_cluster_plugins); } current_cluster_plugins.addElement(plugin); } System.out.println("Query returned " + number + " results"); } // Query for all Cluster/Plugin info and populate 'all_clusters' hashtable sql = "select Clusters.Cluster, Clusters.Plugin, Clusters.Parameters from Clusters, Organizations" + " where Clusters.Cluster=Organizations.Name"; if (community != null && node != null) { sql = sql + "and Organizations.Node='" + node + "'" + " and Organizations.Community='" + community + "'"; } else if (community != null) { sql = sql + " and Organizations.Community='" + community + "'"; } else if (node != null) { sql = sql + " and Organizations.Node='" + node + "'"; } System.out.println(sql); number = 0; rset = stmt.executeQuery(sql); while (rset.next()) { number++; String cluster_name = rset.getString("Cluster"); String plugin = rset.getString("Plugin"); String parameters = rset.getString("Parameters"); // put the parameters into the plugin if (parameters != null) { plugin = plugin + "(" + parameters + ")"; } Vector current_cluster_plugins = (Vector) all_clusters.get(cluster_name); if (current_cluster_plugins == null) { current_cluster_plugins = new Vector(); all_clusters.put(cluster_name, current_cluster_plugins); } current_cluster_plugins.addElement(plugin); } System.out.println("Query returned " + number + " results"); }