Commit in hps-java/src/main/java/org/lcsim/hps/conditions on MAIN
BadChannelConverter.java+4-111.3 -> 1.4
ecal/EcalCalibrationConverter.java+5-111.4 -> 1.5
    /EcalChannelMapConverter.java+4-101.2 -> 1.3
    /EcalGainConverter.java+5-81.5 -> 1.6
svt/PulseParametersConverter.java+7-151.2 -> 1.3
   /SvtCalibrationConverter.java+8-171.14 -> 1.15
+33-72
6 modified files
remove boilerplate db cleanup code from converters (for now)

hps-java/src/main/java/org/lcsim/hps/conditions
BadChannelConverter.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- BadChannelConverter.java	4 Oct 2013 06:02:19 -0000	1.3
+++ BadChannelConverter.java	11 Oct 2013 00:05:36 -0000	1.4
@@ -27,7 +27,7 @@
 
         // Get the ConditionsRecord with the meta-data, which will use the
         // current run number from the manager.
-        ConditionsRecord record = ConditionsRecord.find(manager, name);
+        ConditionsRecord record = ConditionsRecord.find(manager, name).get(0);
         
         // Get the table name, field name, and field value defining the
         // applicable conditions.
@@ -48,14 +48,10 @@
         } else {
             throw new IllegalArgumentException("Unknown conditions key for this converter: " + name);
         }
-
-        // Connect to the conditions database.
-        ConnectionManager connectionManager = getConnectionManager();
-        Connection connection = connectionManager.createConnection();
         
         // Query for getting back bad channel records.
-        String query = "SELECT " + idFieldName + " FROM " + database + "." + tableName + " WHERE " + fieldName + " = " + fieldValue + " ORDER BY id ASC";
-        ResultSet resultSet = ConnectionManager.getConnectionManager().query(connection, query);
+        String query = "SELECT " + idFieldName + " FROM " + tableName + " WHERE " + fieldName + " = " + fieldValue + " ORDER BY id ASC";
+        ResultSet resultSet = ConnectionManager.getConnectionManager().query(query);
 
         // Loop over the records.
         try {
@@ -65,10 +61,7 @@
             }
         } catch (SQLException x) {
             throw new RuntimeException(x);
-        } finally {
-            this.getConnectionManager().cleanup(resultSet);
-            this.getConnectionManager().cleanup(connection);
-        }
+        } 
 
         return badChannels;
     }

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalCalibrationConverter.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- EcalCalibrationConverter.java	4 Oct 2013 06:02:19 -0000	1.4
+++ EcalCalibrationConverter.java	11 Oct 2013 00:05:36 -0000	1.5
@@ -29,7 +29,7 @@
 
         // Get the ConditionsRecord with the meta-data, which will use the
         // current run number from the manager.
-        ConditionsRecord record = ConditionsRecord.find(manager, name);
+        ConditionsRecord record = ConditionsRecord.find(manager, name).get(0);
 
         // Get the table name, field name, and field value defining the
         // applicable conditions.
@@ -40,18 +40,14 @@
         // References to database objects.
         ResultSet resultSet = null;
         ConnectionManager connectionManager = getConnectionManager();
-        Connection connection = connectionManager.createConnection();
-
-        // Get the name of the current database being used.
-        String database = connectionManager.getConnectionParameters().getDatabase();
 
         // The query to get conditions.
         String query = "SELECT ecal_channel_id, pedestal, noise FROM " 
-                + database + "." + tableName + " WHERE " 
+                + tableName + " WHERE " 
                 + fieldName + " = " + fieldValue + " ORDER BY ecal_channel_id ASC";
 
         // Execute the query.
-        resultSet = connectionManager.query(connection, query);
+        resultSet = connectionManager.query(query);
 
         try {
             // Loop over the records.
@@ -64,10 +60,8 @@
             }
         } catch (SQLException x) {
             throw new RuntimeException("Database error.", x);
-        } finally {
-            connectionManager.cleanup(resultSet);
-            connectionManager.cleanup(connection);
-        }
+        } 
+        
         return calibrations;
     }
 

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalChannelMapConverter.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- EcalChannelMapConverter.java	4 Oct 2013 06:02:19 -0000	1.2
+++ EcalChannelMapConverter.java	11 Oct 2013 00:05:36 -0000	1.3
@@ -31,20 +31,16 @@
         // References to database objects.
         ResultSet resultSet = null;
         ConnectionManager connectionManager = getConnectionManager();
-        Connection connection = connectionManager.createConnection();
-
-        // Get the name of the current database being used.
-        String database = connectionManager.getConnectionParameters().getDatabase();
 
         // Assign default key name if none was given.
         if (name == null)
             name = ECAL_CHANNELS;
 
         // Query to retrieve channel data.
-        String query = "SELECT id, x, y, crate, slot, channel FROM " + database + "." + name;
+        String query = "SELECT id, x, y, crate, slot, channel FROM " + name;
 
         // Execute the query and get the results.
-        resultSet = connectionManager.query(connection, query);
+        resultSet = connectionManager.query(query);
 
         try {
             // Loop over the records.
@@ -61,10 +57,8 @@
             }
         } catch (SQLException x) {
             throw new RuntimeException("Database error.", x);
-        } finally {
-            connectionManager.cleanup(resultSet);
-            connectionManager.cleanup(connection);
-        }
+        } 
+        
         return channels;
     }
 

hps-java/src/main/java/org/lcsim/hps/conditions/ecal
EcalGainConverter.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- EcalGainConverter.java	4 Oct 2013 06:02:19 -0000	1.5
+++ EcalGainConverter.java	11 Oct 2013 00:05:36 -0000	1.6
@@ -27,7 +27,7 @@
 
         // Get the ConditionsRecord with the meta-data, which will use the
         // current run number from the manager.
-        ConditionsRecord record = ConditionsRecord.find(manager, name);
+        ConditionsRecord record = ConditionsRecord.find(manager, name).get(0);
 
         // Get the table name, field name, and field value defining the
         // applicable conditions.
@@ -37,18 +37,17 @@
 
         // References to database objects.
         ConnectionManager connectionManager = getConnectionManager();
-        Connection connection = connectionManager.createConnection();
 
         // Get the name of the current database being used.
         String database = connectionManager.getConnectionParameters().getDatabase();
 
         // Database query on ecal gain table.
         String query = "SELECT ecal_channel_id, gain FROM " 
-                + database + "." + tableName + " WHERE " 
+                + tableName + " WHERE " 
                 + fieldName + " = " + fieldValue + " ORDER BY id ASC";
 
         // Execute the query and get the results.
-        ResultSet resultSet = connectionManager.query(connection, query);
+        ResultSet resultSet = connectionManager.query(query);
 
         try {
             // Loop over the records.
@@ -60,10 +59,8 @@
             }
         } catch (SQLException x) {
             throw new RuntimeException("Database error.", x);
-        } finally {
-            connectionManager.cleanup(resultSet);
-            connectionManager.cleanup(connection);
-        }
+        } 
+        
         return gains;
     }
 

hps-java/src/main/java/org/lcsim/hps/conditions/svt
PulseParametersConverter.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- PulseParametersConverter.java	4 Oct 2013 06:02:19 -0000	1.2
+++ PulseParametersConverter.java	11 Oct 2013 00:05:36 -0000	1.3
@@ -19,18 +19,15 @@
 
     /**
      * Get the pulse parameters by channel for this run by named conditions set.
-     * 
-     * @param manager
-     *            The current conditions manager.
-     * @param name
-     *            The name of the conditions set.
+     * @param manager The current conditions manager.
+     * @param name The name of the conditions set.
      * @return The channel constants data.
      */
     public PulseParametersCollection getData(ConditionsManager manager, String name) {
 
         // Get the ConditionsRecord with the meta-data, which will use the
         // current run number from the manager.s
-        ConditionsRecord record = ConditionsRecord.find(manager, name);
+        ConditionsRecord record = ConditionsRecord.find(manager, name).get(0);
 
         // Get the table name, field name, and field value defining the
         // applicable conditions.
@@ -43,18 +40,17 @@
 
         // Connection objects.
         ConnectionManager connectionManager = getConnectionManager();
-        Connection connection = connectionManager.createConnection();
 
         // Get the name of the current database being used.
         String database = connectionManager.getConnectionParameters().getDatabase();
 
         // Construct the query to find matching calibration records.
         String query = "SELECT svt_channel_id, amplitude, t0, tp, chisq FROM " 
-                + database + "." + tableName + " WHERE " 
+                + tableName + " WHERE " 
                 + fieldName + " = " + fieldValue + " ORDER BY id ASC";
 
         // Execute the query and get the results.
-        ResultSet resultSet = connectionManager.query(connection, query);
+        ResultSet resultSet = connectionManager.query(query);
         
         try {
             // Loop over the calibration records.
@@ -69,19 +65,15 @@
             }
         } catch (SQLException x) {
             throw new RuntimeException("Database error.", x);
-        } finally {
-            connectionManager.cleanup(resultSet);
-            connectionManager.cleanup(connection);
         }
+        
         // Return the collection of channel constants to caller.
         return collection;
     }
 
     /**
      * Get the type handled by this converter.
-     * 
-     * @return The type handled by this converter, which is
-     *         <code>ConditionsRecordCollection</code>.
+     * @return The type handled by this converter, which is <code>ConditionsRecordCollection</code>.
      */
     public Class<PulseParametersCollection> getType() {
         return PulseParametersCollection.class;

hps-java/src/main/java/org/lcsim/hps/conditions/svt
SvtCalibrationConverter.java 1.14 -> 1.15
diff -u -r1.14 -r1.15
--- SvtCalibrationConverter.java	4 Oct 2013 06:02:19 -0000	1.14
+++ SvtCalibrationConverter.java	11 Oct 2013 00:05:36 -0000	1.15
@@ -27,19 +27,16 @@
     }
 
     /**
-     * Get the SVT channel constants for this run by named set.
-     * 
-     * @param manager
-     *            The current conditions manager.
-     * @param name
-     *            The name of the conditions set.
+     * Get the SVT channel constants for this run by named set.     
+     * @param manager The current conditions manager.
+     * @param name The name of the conditions set.
      * @return The channel constants data.
      */
     public SvtCalibrationCollection getData(ConditionsManager manager, String name) {
 
         // Get the ConditionsRecord with the meta-data, which will use the
         // current run number from the manager.
-        ConditionsRecord record = ConditionsRecord.find(manager, name);
+        ConditionsRecord record = ConditionsRecord.find(manager, name).get(0);
 
         // Get the table name, field name, and field value defining the
         // applicable conditions.
@@ -52,19 +49,15 @@
 
         // Get a connection from the manager.
         ConnectionManager connectionManager = getConnectionManager();
-        Connection connection = connectionManager.createConnection();
-
-        // Get the name of the current database being used.
-        String database = connectionManager.getConnectionParameters().getDatabase();
 
         // Construct the query to find matching calibration records using the ID
         // field.
         String query = "SELECT svt_channel_id, noise, pedestal FROM " 
-                + database + "." + tableName + " WHERE " 
+                + tableName + " WHERE " 
                 + fieldName + " = " + fieldValue + " ORDER BY svt_channel_id ASC";
 
         // Execute the query and get the results.
-        ResultSet resultSet = connectionManager.query(connection, query);
+        ResultSet resultSet = connectionManager.query(query);
 
         try {
             // Loop over the calibration records.
@@ -79,10 +72,8 @@
             }
         } catch (SQLException x) {
             throw new RuntimeException("Database error.", x);
-        } finally {
-            connectionManager.cleanup(resultSet);
-            connectionManager.cleanup(connection);
-        }
+        } 
+        
         // Return the collection of channel constants to caller.
         return collection;
     }
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1