Commit in hps-java/src/main/java/org/lcsim/hps/conditions on MAIN | |||
BadChannelConverter.java | +4 | -11 | 1.3 -> 1.4 |
ecal/EcalCalibrationConverter.java | +5 | -11 | 1.4 -> 1.5 |
/EcalChannelMapConverter.java | +4 | -10 | 1.2 -> 1.3 |
/EcalGainConverter.java | +5 | -8 | 1.5 -> 1.6 |
svt/PulseParametersConverter.java | +7 | -15 | 1.2 -> 1.3 |
/SvtCalibrationConverter.java | +8 | -17 | 1.14 -> 1.15 |
+33 | -72 |
remove boilerplate db cleanup code from converters (for now)
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; }
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; }
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; }
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; }
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;
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; }
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