Author: [log in to unmask]
Date: Mon Apr 27 18:51:19 2015
New Revision: 2840
Log:
Apply code formatting.
Modified:
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/AbstractConditionsObjectConverter.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/AbstractIdentifier.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObject.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObjectCollection.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectException.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsRecord.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsSeries.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/TableMetaData.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/package-info.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/beam/BeamConditions.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/beam/BeamCurrent.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/beam/package-info.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/AbstractCommand.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/CommandLineTool.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/LoadCommand.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/RunSummaryCommand.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/package-info.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/ConditionsRecordConverter.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/Field.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/MultipleCollectionsAction.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/Table.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/package-info.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/EcalLedCalibration.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/package-info.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/package-info.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtConditions.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtDaqMapping.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtT0Shift.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtBadChannel.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtCalibration.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsConverter.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtConfiguration.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtDetectorSetup.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtGain.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditionsConverter.java
java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/package-info.java
java/branches/HPSJAVA-488/conditions/src/test/java/org/hps/conditions/database/CollectionIdTest.java
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/AbstractConditionsObjectConverter.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/AbstractConditionsObjectConverter.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/AbstractConditionsObjectConverter.java Mon Apr 27 18:51:19 2015
@@ -27,10 +27,10 @@
* @return the conditions object collection
* @throws ConditionsObjectException if there is a problem creating the collection
*/
- static final BaseConditionsObjectCollection<?> createCollection(final DatabaseConditionsManager manager,
+ private static final ConditionsObjectCollection<?> createCollection(final DatabaseConditionsManager manager,
final ConditionsRecord conditionsRecord, final TableMetaData tableMetaData)
throws ConditionsObjectException {
- BaseConditionsObjectCollection<?> collection;
+ ConditionsObjectCollection<?> collection;
try {
collection = tableMetaData.getCollectionClass().newInstance();
if (conditionsRecord != null) {
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/AbstractIdentifier.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/AbstractIdentifier.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/AbstractIdentifier.java Mon Apr 27 18:51:19 2015
@@ -1,8 +1,7 @@
package org.hps.conditions.api;
/**
- * This class is a simplistic representation of a packaged identifier for use in
- * the conditions system.
+ * This class is a simplistic representation of a packaged identifier for use in the conditions system.
*
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
*/
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObject.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObject.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObject.java Mon Apr 27 18:51:19 2015
@@ -41,7 +41,7 @@
final StringBuffer sb = new StringBuffer();
sb.append("id: " + object.getRowId() + ", ");
for (final String field : object.getFieldValues().getFieldNames()) {
- sb.append(field + "=" + object.getFieldValue(Object.class, field) + ", ");
+ sb.append(field + ": " + object.getFieldValue(Object.class, field) + ", ");
}
sb.setLength(sb.length() - 2);
sb.append('\n');
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObjectCollection.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObjectCollection.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/BaseConditionsObjectCollection.java Mon Apr 27 18:51:19 2015
@@ -24,8 +24,16 @@
private final Set<ObjectType> objects = new LinkedHashSet<ObjectType>();
private TableMetaData tableMetaData;
private boolean isDirty;
+ private Class<ObjectType> type;
protected BaseConditionsObjectCollection() {
+ }
+
+ public BaseConditionsObjectCollection(final Connection connection, final TableMetaData tableMetaData)
+ throws SQLException, DatabaseObjectException {
+ this.connection = connection;
+ this.tableMetaData = tableMetaData;
+ this.type = (Class<ObjectType>) tableMetaData.getObjectClass();
}
public BaseConditionsObjectCollection(final Connection connection, final TableMetaData tableMetaData,
@@ -36,6 +44,7 @@
if (collectionId != -1) {
select(collectionId);
}
+ this.type = (Class<ObjectType>) tableMetaData.getObjectClass();
}
@Override
@@ -428,12 +437,12 @@
}
return exists;
}
-
+
protected Set<ObjectType> getObjects() {
- return this.objects;
- }
-
+ return this.objects;
+ }
+
protected void setIsDirty(boolean isDirty) {
- this.isDirty = isDirty;
+ this.isDirty = isDirty;
}
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectException.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectException.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsObjectException.java Mon Apr 27 18:51:19 2015
@@ -1,9 +1,7 @@
package org.hps.conditions.api;
-
/**
- * Thrown by methods of {@link ConditionsObject} or other associated classes
- * such as converters and collections.
+ * Thrown by methods of {@link ConditionsObject} or other associated classes such as converters and collections.
*/
@SuppressWarnings("serial")
public final class ConditionsObjectException extends Exception {
@@ -45,6 +43,7 @@
/**
* Get the associated conditions object to the error.
+ *
* @return the object associated with the error
*/
public ConditionsObject getConditionsObject() {
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsRecord.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsRecord.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsRecord.java Mon Apr 27 18:51:19 2015
@@ -37,7 +37,7 @@
}
return added;
}
-
+
/**
* Compare conditions records by creation date.
*/
@@ -202,22 +202,22 @@
public final ConditionsRecordCollection sortedByUpdated() {
return (ConditionsRecordCollection) sorted(new UpdatedComparator());
}
-
+
/**
* Find a sub-set of the records with matching key name.
*/
public ConditionsRecordCollection findByKey(String key) {
- ConditionsRecordCollection collection = new ConditionsRecordCollection();
- for (ConditionsRecord record : this) {
- if (record.getName().equals(key)) {
- try {
- collection.add(record);
- } catch (ConditionsObjectException e) {
- throw new RuntimeException("Error adding record to new collection.", e);
- }
- }
- }
- return collection;
+ ConditionsRecordCollection collection = new ConditionsRecordCollection();
+ for (ConditionsRecord record : this) {
+ if (record.getName().equals(key)) {
+ try {
+ collection.add(record);
+ } catch (ConditionsObjectException e) {
+ throw new RuntimeException("Error adding record to new collection.", e);
+ }
+ }
+ }
+ return collection;
}
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsSeries.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsSeries.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsSeries.java Mon Apr 27 18:51:19 2015
@@ -10,8 +10,7 @@
* @param <CollectionType> the type of the conditions collection
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
*/
-@SuppressWarnings({ "serial" })
-public class
- ConditionsSeries<ObjectType extends ConditionsObject, CollectionType extends ConditionsObjectCollection<ObjectType>>
- extends ArrayList<ConditionsObjectCollection<ObjectType>> {
+@SuppressWarnings({"serial"})
+public class ConditionsSeries<ObjectType extends ConditionsObject, CollectionType extends ConditionsObjectCollection<ObjectType>>
+ extends ArrayList<ConditionsObjectCollection<ObjectType>> {
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/TableMetaData.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/TableMetaData.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/TableMetaData.java Mon Apr 27 18:51:19 2015
@@ -118,7 +118,7 @@
*
* @return the collection class
*/
- public Class<? extends BaseConditionsObjectCollection<?>> getCollectionClass() {
+ public Class<? extends ConditionsObjectCollection<?>> getCollectionClass() {
return this.collectionClass;
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/package-info.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/package-info.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/package-info.java Mon Apr 27 18:51:19 2015
@@ -1,7 +1,6 @@
/**
- * This package contains interfaces and abstract classes, along with some
- * implementations, of the database conditions API for HPS. These classes
- * include simple ORM between conditions objects and the database.
+ * This package contains interfaces and abstract classes, along with some implementations, of the database conditions
+ * API for HPS. These classes include simple ORM between conditions objects and the database.
*
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
* @see ConditionsObject
@@ -10,3 +9,4 @@
* @see ConditionsRecord
*/
package org.hps.conditions.api;
+
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/beam/BeamConditions.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/beam/BeamConditions.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/beam/BeamConditions.java Mon Apr 27 18:51:19 2015
@@ -8,11 +8,9 @@
import org.hps.conditions.database.Table;
/**
- * Beam-related detector conditions, including current, position
- * in X and Y, and energy.
+ * Beam-related detector conditions, including current, position in X and Y, and energy.
* <p>
- * Unless otherwise stated, these are assumed to be average values
- * for an entire run.
+ * Unless otherwise stated, these are assumed to be average values for an entire run.
*
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
*/
@@ -34,9 +32,9 @@
}
/**
- * Get the average beam current (nA).
- * A value of 0 indicates there was no beam.
- * A null value means it was not recorded.
+ * Get the average beam current (nA). A value of 0 indicates there was no beam. A null value means it was not
+ * recorded.
+ *
* @return the beam current (nA)
*/
@Field(names = {"current"})
@@ -46,6 +44,7 @@
/**
* Get the average beam position in X (mm).
+ *
* @return the beam position (mm)
*/
@Field(names = {"position_x"})
@@ -55,6 +54,7 @@
/**
* Get the average beam position in Y (mm).
+ *
* @return the beam position (mm)
*/
@Field(names = {"position_y"})
@@ -63,9 +63,8 @@
}
/**
- * Get the beam energy (GeV).
- * A value of 0 indicates there was no beam.
- * A null value means it was not recorded.
+ * Get the beam energy (GeV). A value of 0 indicates there was no beam. A null value means it was not recorded.
+ *
* @return the beam energy
*/
@Field(names = {"energy"})
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/beam/BeamCurrent.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/beam/BeamCurrent.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/beam/BeamCurrent.java Mon Apr 27 18:51:19 2015
@@ -25,10 +25,11 @@
/**
* Get the integrated beam current.
+ *
* @return the integrated beam current
*/
@Field(names = {"beam_current"})
- public double getIntegratedBeamCurrent() {
+ public Double getIntegratedBeamCurrent() {
return getFieldValue("beam_current");
}
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/beam/package-info.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/beam/package-info.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/beam/package-info.java Mon Apr 27 18:51:19 2015
@@ -4,3 +4,4 @@
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
*/
package org.hps.conditions.beam;
+
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/AbstractCommand.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/AbstractCommand.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/AbstractCommand.java Mon Apr 27 18:51:19 2015
@@ -8,8 +8,7 @@
import org.apache.commons.cli.PosixParser;
/**
- * This is the API that sub-commands such as 'load' or 'print' must implement
- * in the conditions command line interface.
+ * This is the API that sub-commands such as 'load' or 'print' must implement in the conditions command line interface.
*
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
*/
@@ -37,6 +36,7 @@
/**
* Class constructor.
+ *
* @param name the string that invokes this command
* @param description the description of this command
* @param options the command's options (Apache CLI)
@@ -49,6 +49,7 @@
/**
* Get the name of this command.
+ *
* @return the name of this command
*/
final String getName() {
@@ -57,6 +58,7 @@
/**
* Get the description of this command.
+ *
* @return the description of this command
*/
protected final String getDescription() {
@@ -65,6 +67,7 @@
/**
* Get the <code>Options</code> for this command (Apache CLI).
+ *
* @return the <code>Options</code> object for this command
*/
protected final Options getOptions() {
@@ -81,6 +84,7 @@
/**
* Parse the sub-command's options.
+ *
* @param arguments the sub-command's arguments
* @return the parsed command line
*/
@@ -100,6 +104,7 @@
/**
* The sub-command execution method that should be implemented by sub-classes.
+ *
* @param arguments The command's argument list.
*/
abstract void execute(final String[] arguments);
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/CommandLineTool.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/CommandLineTool.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/CommandLineTool.java Mon Apr 27 18:51:19 2015
@@ -31,17 +31,17 @@
* Setup logging.
*/
private static final Logger LOGGER = LogUtil.create(CommandLineTool.class);
-
+
private static Options OPTIONS = new Options();
-
+
static {
- OPTIONS.addOption(new Option("h", false, "print help"));
- OPTIONS.addOption(new Option("d", true, "detector name"));
- OPTIONS.addOption(new Option("r", true, "run number"));
- OPTIONS.addOption(new Option("p", true, "database connection properties file"));
- OPTIONS.addOption(new Option("x", true, "conditions XML configuration file"));
- OPTIONS.addOption(new Option("t", true, "conditions tag to use for filtering records"));
- OPTIONS.addOption(new Option("l", true, "log level of the conditions manager (INFO, FINE, etc.)"));
+ OPTIONS.addOption(new Option("h", false, "print help"));
+ OPTIONS.addOption(new Option("d", true, "detector name"));
+ OPTIONS.addOption(new Option("r", true, "run number"));
+ OPTIONS.addOption(new Option("p", true, "database connection properties file"));
+ OPTIONS.addOption(new Option("x", true, "conditions XML configuration file"));
+ OPTIONS.addOption(new Option("t", true, "conditions tag to use for filtering records"));
+ OPTIONS.addOption(new Option("l", true, "log level of the conditions manager (INFO, FINE, etc.)"));
}
/**
@@ -141,7 +141,7 @@
printUsage();
exit(0);
}
-
+
// Setup conditions manager from command line options.
setupConditionsManager(commandLine);
@@ -177,14 +177,14 @@
// Create new manager.
this.conditionsManager = DatabaseConditionsManager.getInstance();
-
+
// Set the conditions manager log level (does not affect logger of this class or sub-commands).
if (commandLine.hasOption("l")) {
- Level level = Level.parse(commandLine.getOptionValue("l"));
- conditionsManager.setLogLevel(level);
- LOGGER.config("conditions manager log level will be set to " + level.toString());
- }
-
+ Level level = Level.parse(commandLine.getOptionValue("l"));
+ conditionsManager.setLogLevel(level);
+ LOGGER.config("conditions manager log level will be set to " + level.toString());
+ }
+
// Connection properties.
if (commandLine.hasOption("p")) {
final File connectionPropertiesFile = new File(commandLine.getOptionValue("p"));
@@ -198,26 +198,28 @@
this.conditionsManager.setXmlConfig(xmlConfigFile);
LOGGER.config("using XML config " + xmlConfigFile.getPath());
}
-
+
// User specified tag of conditions records.
if (commandLine.hasOption("t")) {
- String tag = commandLine.getOptionValue("t");
+ String tag = commandLine.getOptionValue("t");
conditionsManager.setTag(tag);
LOGGER.config("using tag " + tag);
}
// If there is a run number or detector number then attempt to initialize the conditions system.
if (commandLine.hasOption("r") || commandLine.hasOption("d")) {
-
- if (!commandLine.hasOption("r")) {
- // Missing run number.
- throw new RuntimeException("Missing -r option with run number which must be given when detector name is used.");
- }
-
- if (!commandLine.hasOption("d")) {
- // Missing detector name.
- throw new RuntimeException("Missing -d option with detector name which must be given when run number is used.");
- }
+
+ if (!commandLine.hasOption("r")) {
+ // Missing run number.
+ throw new RuntimeException(
+ "Missing -r option with run number which must be given when detector name is used.");
+ }
+
+ if (!commandLine.hasOption("d")) {
+ // Missing detector name.
+ throw new RuntimeException(
+ "Missing -d option with detector name which must be given when run number is used.");
+ }
// Set detector name.
String detectorName = null;
@@ -239,14 +241,15 @@
// Setup the conditions manager with user detector name and run number.
try {
- LOGGER.config("Initializing conditions manager with detector " + detectorName + " and run " + run + " ...");
+ LOGGER.config("Initializing conditions manager with detector " + detectorName + " and run " + run
+ + " ...");
DatabaseConditionsManager.getInstance().setDetector(detectorName, run);
LOGGER.config("Conditions manager was initialized successfully!");
LOGGER.getHandlers()[0].flush();
} catch (final ConditionsNotFoundException e) {
throw new RuntimeException("Error setting up the conditions manager.", e);
}
- }
+ }
LOGGER.info("Done setting up the conditions manager!");
}
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/LoadCommand.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/LoadCommand.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/LoadCommand.java Mon Apr 27 18:51:19 2015
@@ -43,11 +43,11 @@
*/
final class LoadCommand extends AbstractCommand {
- /**
- * The default separator for making tokens from input data.
- */
- private static final String DEFAULT_FIELD_SEPARATOR = " \t";
-
+ /**
+ * The default separator for making tokens from input data.
+ */
+ private static final String DEFAULT_FIELD_SEPARATOR = " \t";
+
/**
* Setup the logger.
*/
@@ -73,7 +73,28 @@
LoadCommand() {
super("load", "Create a new conditions collection in the database from an input text file", OPTIONS);
}
-
+
+ /**
+ * Convert from a raw string into a specific type.
+ *
+ * @param type the target type
+ * @param value the raw value
+ * @return the value converter to the given type
+ */
+ Object convertValue(final Class<?> type, final String value) {
+ if (Integer.class.equals(type)) {
+ return Integer.parseInt(value);
+ } else if (Double.class.equals(type)) {
+ return Double.parseDouble(value);
+ } else if (Float.class.equals(type)) {
+ return Float.parseFloat(value);
+ } else if (Boolean.class.equals(type)) {
+ return Boolean.parseBoolean(value);
+ } else {
+ return value;
+ }
+ }
+
/**
* Execute the <i>load</i> command with the given arguments.
*
@@ -108,64 +129,67 @@
if (commandLine.hasOption("d")) {
description = commandLine.getOptionValue("d");
}
-
+
String separator = DEFAULT_FIELD_SEPARATOR;
if (commandLine.hasOption("s")) {
- separator = commandLine.getOptionValue("s");
- LOGGER.info("using separator character <" + separator + ">");
- }
-
- TableMetaData tableMetaData = conditionsManager.findTableMetaData(tableName);
+ separator = commandLine.getOptionValue("s");
+ LOGGER.info("using separator character <" + separator + ">");
+ }
+
+ final TableMetaData tableMetaData = conditionsManager.findTableMetaData(tableName);
BaseConditionsObjectCollection<ConditionsObject> newCollection = null;
try {
- // Create a new collection. We don't use the specific type here because that won't work later when adding objects to it.
- newCollection = new BaseConditionsObjectCollection<ConditionsObject>(conditionsManager.getConnection(), tableMetaData);
+ // Create a new collection. We don't use the specific type here because that won't work later when adding
+ // objects to it.
+ newCollection = new BaseConditionsObjectCollection<ConditionsObject>(conditionsManager.getConnection(),
+ tableMetaData);
} catch (SQLException | DatabaseObjectException e) {
- throw new RuntimeException("Error creating new collection.", e);
+ throw new RuntimeException("Error creating new collection.", e);
}
LOGGER.info("getting new collection ID ...");
-
- try {
- conditionsManager.getCollectionId(newCollection, description);
- } catch (SQLException e) {
- throw new RuntimeException("Error getting collection ID.", e);
- }
-
+
+ try {
+ conditionsManager.getCollectionId(newCollection, description);
+ } catch (final SQLException e) {
+ throw new RuntimeException("Error getting collection ID.", e);
+ }
+
LOGGER.info("collection was assigned ID " + newCollection.getCollectionId());
-
+
LOGGER.info("parsing input file " + fileName + " ...");
this.parseFile(fileName, newCollection, separator);
LOGGER.info("Done parsing input file!");
-
- try {
- LOGGER.info("Inserting collection ...");
- newCollection.insert();
- LOGGER.info("Done inserting collection!");
+
+ try {
+ LOGGER.info("Inserting collection ...");
+ newCollection.insert();
+ LOGGER.info("Done inserting collection!");
} catch (SQLException | DatabaseObjectException e) {
- throw new RuntimeException("Error getting collection ID.", e);
- }
-
+ throw new RuntimeException("Error getting collection ID.", e);
+ }
+
conditionsManager.closeConnection(openedConnection);
}
-
+
/**
* Parse an input text file and create conditions objects from its row data.
*
* @param fileName the name of the text file
* @param collection the collection into which objects will be inserted
*/
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private final void parseFile(final String fileName, final ConditionsObjectCollection collection, final String seperator) {
-
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private final void parseFile(final String fileName, final ConditionsObjectCollection collection,
+ final String seperator) {
+
BufferedReader reader = null;
-
- try {
- final File inputFile = new File(fileName);
+
+ try {
+ final File inputFile = new File(fileName);
reader = new BufferedReader(new FileReader(inputFile));
-
+
LOGGER.info("reading in header line ...");
-
+
// Read in the header line with column names.
final String headerLine = reader.readLine();
LOGGER.info("got header line: " + headerLine);
@@ -173,89 +197,89 @@
throw new IllegalArgumentException("The file is empty.");
}
StringTokenizer tokenizer = new StringTokenizer(headerLine, seperator);
- List<String> columnNames = new ArrayList<String>();
+ final List<String> columnNames = new ArrayList<String>();
while (tokenizer.hasMoreTokens()) {
- String columnName = tokenizer.nextToken().trim();
- LOGGER.info("read column name: " + columnName);
+ final String columnName = tokenizer.nextToken().trim();
+ LOGGER.info("read column name: " + columnName);
columnNames.add(columnName);
}
if (columnNames.isEmpty()) {
- throw new RuntimeException("No column names found in file.");
- }
-
+ throw new RuntimeException("No column names found in file.");
+ }
+
// Get table info.
- TableMetaData tableMetaData = collection.getTableMetaData();
- Class<? extends ConditionsObject> objectClass = tableMetaData.getObjectClass();
-
+ final TableMetaData tableMetaData = collection.getTableMetaData();
+ final Class<? extends ConditionsObject> objectClass = tableMetaData.getObjectClass();
+
// Get the field names from the table info.
- List<String> fieldNames = new ArrayList<String>(Arrays.asList(tableMetaData.getFieldNames()));
+ final List<String> fieldNames = new ArrayList<String>(Arrays.asList(tableMetaData.getFieldNames()));
fieldNames.remove("collection_id");
-
+
// Check that the column names which were read in from the header row are valid.
- for (String columnName : columnNames) {
- LOGGER.info("checking column: " + columnName);
- if (!fieldNames.contains(columnName)) {
- throw new RuntimeException("Unknown column name: " + columnName);
- }
- }
-
+ for (final String columnName : columnNames) {
+ LOGGER.info("checking column: " + columnName);
+ if (!fieldNames.contains(columnName)) {
+ throw new RuntimeException("Unknown column name: " + columnName);
+ }
+ }
+
// Read lines from the file.
String line = null;
- int lineNumber = 1;
+ int lineNumber = 1;
while ((line = reader.readLine()) != null) {
-
- LOGGER.info("reading line " + lineNumber);
-
- // Create a new conditions object for the row.
- ConditionsObject object;
- try {
- object = objectClass.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- throw new RuntimeException("Error creating new object.", e);
- }
-
- // Parse the line.
+
+ LOGGER.info("reading line " + lineNumber);
+
+ // Create a new conditions object for the row.
+ ConditionsObject object;
+ try {
+ object = objectClass.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new RuntimeException("Error creating new object.", e);
+ }
+
+ // Parse the line.
tokenizer = new StringTokenizer(line, " \t");
- int tokens = tokenizer.countTokens();
-
+ final int tokens = tokenizer.countTokens();
+
// Check that the number of data items is correct.
if (tokens != columnNames.size()) {
- throw new RuntimeException("Row " + lineNumber + " has wrong number of data items.");
- }
-
+ throw new RuntimeException("Row " + lineNumber + " has wrong number of data items.");
+ }
+
// Iterate over the tokens.
for (int i = 0; i < tokens; i++) {
-
- LOGGER.info("proc token " + i);
-
- // Get the column name.
- String columnName = columnNames.get(i);
-
- // Get the column type.
- Class<?> columnType = tableMetaData.getFieldType(columnName);
-
- // Get the value of the cell.
- String value = tokenizer.nextToken();
-
- LOGGER.info("columnName: " + columnName);
- LOGGER.info("columnType: " + columnType.getName());
- LOGGER.info("value: " + value);
-
- // Convert the value to a specific type and set the value on the object.
- object.setFieldValue(columnNames.get(i), convertValue(columnType, value));
-
- // Add the object to the collection.
- LOGGER.info("adding conditions object: " + object);
- collection.add(object);
+
+ LOGGER.info("proc token " + i);
+
+ // Get the column name.
+ final String columnName = columnNames.get(i);
+
+ // Get the column type.
+ final Class<?> columnType = tableMetaData.getFieldType(columnName);
+
+ // Get the value of the cell.
+ final String value = tokenizer.nextToken();
+
+ LOGGER.info("columnName: " + columnName);
+ LOGGER.info("columnType: " + columnType.getName());
+ LOGGER.info("value: " + value);
+
+ // Convert the value to a specific type and set the value on the object.
+ object.setFieldValue(columnNames.get(i), this.convertValue(columnType, value));
+
+ // Add the object to the collection.
+ LOGGER.info("adding conditions object: " + object);
+ collection.add(object);
}
++lineNumber;
}
- } catch (FileNotFoundException e) {
- throw new RuntimeException("The input file does not exist.", e);
- } catch (IOException e) {
- throw new RuntimeException("Error reading from the file.", e);
- } catch (ConditionsObjectException e) {
- throw new RuntimeException("Error adding object to collection.", e);
+ } catch (final FileNotFoundException e) {
+ throw new RuntimeException("The input file does not exist.", e);
+ } catch (final IOException e) {
+ throw new RuntimeException("Error reading from the file.", e);
+ } catch (final ConditionsObjectException e) {
+ throw new RuntimeException("Error adding object to collection.", e);
} finally {
if (reader != null) {
try {
@@ -263,28 +287,7 @@
} catch (final IOException e) {
e.printStackTrace();
}
- }
- }
- }
-
- /**
- * Convert from a raw string into a specific type.
- *
- * @param type the target type
- * @param value the raw value
- * @return the value converter to the given type
- */
- Object convertValue(Class<?> type, String value) {
- if (Integer.class.equals(type)) {
- return Integer.parseInt(value);
- } else if (Double.class.equals(type)) {
- return Double.parseDouble(value);
- } else if (Float.class.equals(type)) {
- return Float.parseFloat(value);
- } else if (Boolean.class.equals(type)) {
- return Boolean.parseBoolean(value);
- } else {
- return value;
- }
- }
+ }
+ }
+ }
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java Mon Apr 27 18:51:19 2015
@@ -172,10 +172,10 @@
final StringBuffer buffer = new StringBuffer();
for (final Object object : collection) {
for (final String columnName : collection.getTableMetaData().getFieldNames()) {
- if (!"collection_id".equals(columnName)) {
- buffer.append(((ConditionsObject) object).getFieldValue(columnName));
- buffer.append(this.fieldDelimiter);
- }
+ if (!"collection_id".equals(columnName)) {
+ buffer.append(((ConditionsObject) object).getFieldValue(columnName));
+ buffer.append(this.fieldDelimiter);
+ }
}
buffer.setLength(buffer.length() - 1);
buffer.append('\n');
@@ -191,10 +191,9 @@
* @param collection the collection
*/
private void printCollectionHeader(final ConditionsObjectCollection<?> collection) {
- LOGGER.info('\n' + "--------------------------------------" + '\n'
- + "table: " + collection.getTableMetaData().getTableName() + '\n'
- + "collection ID: " + collection.getCollectionId() + '\n'
- + "--------------------------------------");
+ LOGGER.info('\n' + "--------------------------------------" + '\n' + "table: "
+ + collection.getTableMetaData().getTableName() + '\n' + "collection ID: "
+ + collection.getCollectionId() + '\n' + "--------------------------------------");
}
/**
@@ -226,10 +225,10 @@
this.ps.print(this.fieldDelimiter);
}
for (final String columnName : tableMetaData.getFieldNames()) {
- if (!"collection_id".equals(columnName)) {
- this.ps.print(columnName);
- this.ps.print(this.fieldDelimiter);
- }
+ if (!"collection_id".equals(columnName)) {
+ this.ps.print(columnName);
+ this.ps.print(this.fieldDelimiter);
+ }
}
this.ps.println();
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/RunSummaryCommand.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/RunSummaryCommand.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/RunSummaryCommand.java Mon Apr 27 18:51:19 2015
@@ -18,21 +18,21 @@
import org.lcsim.util.log.MessageOnlyLogFormatter;
/**
- * This is a sub-command to print out collection meta data for the current conditions configuration
- * of tag, detector model and run number, which are given as arguments to the conditions command line
- * front-end. It does not print out any conditions objects, only the collection information.
- * By default it will print information about the single collection found for a given type, which is
- * by convention the last one updated. The <code>-a</code> option can be used to print out all collection information.
- *
+ * This is a sub-command to print out collection meta data for the current conditions configuration of tag, detector
+ * model and run number, which are given as arguments to the conditions command line front-end. It does not print out
+ * any conditions objects, only the collection information. By default it will print information about the single
+ * collection found for a given type, which is by convention the last one updated. The <code>-a</code> option can be
+ * used to print out all collection information.
+ *
* @author @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
- *
*/
final class RunSummaryCommand extends AbstractCommand {
-
- /**
+
+ /**
* Setup logger.
*/
- private static final Logger LOGGER = LogUtil.create(RunSummaryCommand.class, new MessageOnlyLogFormatter(), Level.INFO);
+ private static final Logger LOGGER = LogUtil.create(RunSummaryCommand.class, new MessageOnlyLogFormatter(),
+ Level.INFO);
/**
* Define command options.
@@ -42,14 +42,14 @@
options.addOption(new Option("h", false, "Show help for run-summary command"));
options.addOption(new Option("a", false, "Print all collections found for the run"));
}
-
+
/**
* Class constructor.
*/
RunSummaryCommand() {
super("run-summary", "Print the run summary", options);
}
-
+
/**
* Print out the run summary information.
*
@@ -65,50 +65,55 @@
if (!conditionsManager.isInitialized()) {
throw new RuntimeException("The conditions system is not initialized.");
}
-
+
final int run = conditionsManager.getRun();
-
+
boolean printAll = commandLine.hasOption("a");
if (printAll) {
- LOGGER.info("All collections will be printed.");
+ LOGGER.info("All collections will be printed.");
}
-
+
// Get all the conditions records from the manager including those that overlap in time validity.
- ConditionsRecordCollection conditionsRecords = conditionsManager.getConditionsRecords();
+ ConditionsRecordCollection conditionsRecords = conditionsManager.getConditionsRecords();
LOGGER.info('\n' + "Run " + run + " has " + conditionsRecords.size() + " conditions records.");
-
+
// Get the list of unique conditions keys and sort them.
List<String> conditionsKeys = new ArrayList<String>(conditionsRecords.getConditionsKeys());
Collections.sort(conditionsKeys);
LOGGER.info('\n' + "Found these unique conditions keys for the run ...");
for (String key : conditionsKeys) {
- LOGGER.info(key);
+ LOGGER.info(key);
}
LOGGER.info("");
-
+
// Loop over all the conditions keys that apply to this run.
for (String key : conditionsKeys) {
-
- // Get the table meta data for the key.
- TableMetaData tableMetaData = conditionsManager.findTableMetaData(key);
-
- // Get all the conditions records that match this key.
- ConditionsRecordCollection collectionRecords = conditionsRecords.findByKey(key);
-
- // Get the table name.
- final String tableName = tableMetaData.getTableName();
-
- if (!printAll) {
- // Print out the single collection that will be used if retrieved through the converter.
- ConditionsObjectCollection<?> collection = conditionsManager.getCachedConditions(tableMetaData.getCollectionClass(), key).getCachedData();
- LOGGER.info(tableMetaData.getObjectClass().getSimpleName() + " collection " + collection.getCollectionId() + " in " + tableName + " with " + collection.size() + " rows.");
- } else {
- // Print out information about all applicable collections for this key, without figuring out which would be used.
- LOGGER.info(tableMetaData.getObjectClass().getSimpleName() + " has " + collectionRecords.size() + " collection(s) in " + tableName + " for run.");
- for (ConditionsRecord record : collectionRecords) {
- LOGGER.info(" collection " + record.getCollectionId().toString() + " created on " + record.getCreated().toString());
- }
- }
+
+ // Get the table meta data for the key.
+ TableMetaData tableMetaData = conditionsManager.findTableMetaData(key);
+
+ // Get all the conditions records that match this key.
+ ConditionsRecordCollection collectionRecords = conditionsRecords.findByKey(key);
+
+ // Get the table name.
+ final String tableName = tableMetaData.getTableName();
+
+ if (!printAll) {
+ // Print out the single collection that will be used if retrieved through the converter.
+ ConditionsObjectCollection<?> collection = conditionsManager.getCachedConditions(
+ tableMetaData.getCollectionClass(), key).getCachedData();
+ LOGGER.info(tableMetaData.getObjectClass().getSimpleName() + " collection "
+ + collection.getCollectionId() + " in " + tableName + " with " + collection.size() + " rows.");
+ } else {
+ // Print out information about all applicable collections for this key, without figuring out which would
+ // be used.
+ LOGGER.info(tableMetaData.getObjectClass().getSimpleName() + " has " + collectionRecords.size()
+ + " collection(s) in " + tableName + " for run.");
+ for (ConditionsRecord record : collectionRecords) {
+ LOGGER.info(" collection " + record.getCollectionId().toString() + " created on "
+ + record.getCreated().toString());
+ }
+ }
}
LOGGER.info('\n' + "Done printing run summary!");
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/package-info.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/package-info.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/cli/package-info.java Mon Apr 27 18:51:19 2015
@@ -4,3 +4,4 @@
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
*/
package org.hps.conditions.cli;
+
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/ConditionsRecordConverter.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/ConditionsRecordConverter.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/ConditionsRecordConverter.java Mon Apr 27 18:51:19 2015
@@ -4,8 +4,8 @@
import java.sql.SQLException;
import org.hps.conditions.api.AbstractConditionsObjectConverter;
-import org.hps.conditions.api.BaseConditionsObjectCollection;
import org.hps.conditions.api.ConditionsObject;
+import org.hps.conditions.api.ConditionsObjectCollection;
import org.hps.conditions.api.ConditionsObjectException;
import org.hps.conditions.api.ConditionsRecord;
import org.hps.conditions.api.ConditionsRecord.ConditionsRecordCollection;
@@ -52,7 +52,7 @@
final ResultSet resultSet = databaseConditionsManager.selectQuery(query);
// Create a collection to return.
- BaseConditionsObjectCollection collection;
+ ConditionsObjectCollection collection;
try {
collection = tableMetaData.getCollectionClass().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java Mon Apr 27 18:51:19 2015
@@ -279,51 +279,6 @@
}
/**
- * Add a row for a new collection and return the new collection ID assigned to it.
- *
- * @param tableName the name of the table
- * @param comment an optional comment about this new collection
- * @return the collection's ID
- * @throws SQLException
- */
- public synchronized int getCollectionId(final ConditionsObjectCollection<?> collection, final String description)
- throws SQLException {
-
- final String caller = Thread.currentThread().getStackTrace()[2].getClassName();
- final String log = caller + " created by " + System.getProperty("user.name");
- final boolean opened = this.openConnection();
- PreparedStatement statement = null;
- ResultSet resultSet = null;
- int collectionId = -1;
- try {
- statement = this.connection.prepareStatement(
- "INSERT INTO collections (table_name, log, description, created) VALUES (?, ?, ?, NOW())",
- Statement.RETURN_GENERATED_KEYS);
- statement.setString(1, collection.getTableMetaData().getTableName());
- statement.setString(2, log);
- if (description == null) {
- statement.setNull(3, java.sql.Types.VARCHAR);
- } else {
- statement.setString(3, description);
- }
- statement.execute();
- resultSet = statement.getGeneratedKeys();
- resultSet.next();
- collectionId = resultSet.getInt(1);
- } finally {
- if (resultSet != null) {
- resultSet.close();
- }
- if (statement != null) {
- statement.close();
- }
- this.closeConnection(opened);
- }
- collection.setCollectionId(collectionId);
- return collectionId;
- }
-
- /**
* Cache conditions sets for all known tables.
*/
private void cacheConditionsSets() {
@@ -484,6 +439,52 @@
}
/**
+ * Add a row for a new collection and return the new collection ID assigned to it.
+ *
+ * @param tableName the name of the table
+ * @param comment an optional comment about this new collection
+ * @return the collection's ID
+ * @throws SQLException
+ */
+ public synchronized int getCollectionId(final ConditionsObjectCollection<?> collection, final String description)
+ throws SQLException {
+
+ final String caller = Thread.currentThread().getStackTrace()[2].getClassName();
+ final String log = caller.substring(caller.lastIndexOf('.') + 1) + " created by "
+ + System.getProperty("user.name");
+ final boolean opened = this.openConnection();
+ PreparedStatement statement = null;
+ ResultSet resultSet = null;
+ int collectionId = -1;
+ try {
+ statement = this.connection.prepareStatement(
+ "INSERT INTO collections (table_name, log, description, created) VALUES (?, ?, ?, NOW())",
+ Statement.RETURN_GENERATED_KEYS);
+ statement.setString(1, collection.getTableMetaData().getTableName());
+ statement.setString(2, log);
+ if (description == null) {
+ statement.setNull(3, java.sql.Types.VARCHAR);
+ } else {
+ statement.setString(3, description);
+ }
+ statement.execute();
+ resultSet = statement.getGeneratedKeys();
+ resultSet.next();
+ collectionId = resultSet.getInt(1);
+ } finally {
+ if (resultSet != null) {
+ resultSet.close();
+ }
+ if (statement != null) {
+ statement.close();
+ }
+ this.closeConnection(opened);
+ }
+ collection.setCollectionId(collectionId);
+ return collectionId;
+ }
+
+ /**
* Get a list of all the {@link ConditionsRecord} objects.
*
* @return the list of all the {@link ConditionsRecord} objects
@@ -542,8 +543,8 @@
* @return the JDBC connection
*/
public Connection getConnection() {
- if (!isConnected()) {
- openConnection();
+ if (!this.isConnected()) {
+ this.openConnection();
}
return this.connection;
}
@@ -634,7 +635,7 @@
* @return <code>true</code> if a conditions record exists with the given name
*/
public boolean hasConditionsRecord(final String name) {
- return findConditionsRecords(name).size() != 0;
+ return this.findConditionsRecords(name).size() != 0;
}
/**
@@ -735,7 +736,7 @@
tableMetaData = metaDataList.get(0);
}
if (collection.getCollectionId() == -1) {
- collection.setCollectionId(this.getCollectionId(collection, null));
+ collection.setCollectionId(this.getCollectionId(collection, null));
}
logger.info("inserting collection with ID " + collection.getCollectionId() + " and key "
@@ -906,6 +907,40 @@
return this.tag.equals(recordTag);
}
+ public <CollectionType extends ConditionsObjectCollection<?>> CollectionType newCollection(
+ final Class<CollectionType> collectionType) {
+ final List<TableMetaData> tableMetaDataList = TableRegistry.getTableRegistry().findByCollectionType(
+ collectionType);
+ if (tableMetaDataList.size() > 1) {
+ throw new RuntimeException("More than one table meta data object returned for type: "
+ + collectionType.getName());
+ }
+ final TableMetaData tableMetaData = tableMetaDataList.get(0);
+ CollectionType collection;
+ try {
+ collection = collectionType.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new RuntimeException("Error creating new collection.", e);
+ }
+ collection.setTableMetaData(tableMetaData);
+ collection.setConnection(this.getConnection());
+ return collection;
+ }
+
+ public <CollectionType extends ConditionsObjectCollection<?>> CollectionType newCollection(
+ final Class<CollectionType> collectionType, final String tableName) {
+ final TableMetaData tableMetaData = TableRegistry.getTableRegistry().findByTableName(tableName);
+ CollectionType collection;
+ try {
+ collection = collectionType.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new RuntimeException("Error creating new collection.", e);
+ }
+ collection.setTableMetaData(tableMetaData);
+ collection.setConnection(this.getConnection());
+ return collection;
+ }
+
/**
* Open the database connection.
*
@@ -1177,34 +1212,4 @@
this.closeConnection(openedConnection);
return keys;
}
-
- public <CollectionType extends ConditionsObjectCollection<?>> CollectionType newCollection(Class<CollectionType> collectionType) {
- List<TableMetaData> tableMetaDataList = TableRegistry.getTableRegistry().findByCollectionType(collectionType);
- if (tableMetaDataList.size() > 1) {
- throw new RuntimeException("More than one table meta data object returned for type: " + collectionType.getName());
- }
- TableMetaData tableMetaData = tableMetaDataList.get(0);
- CollectionType collection;
- try {
- collection = collectionType.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- throw new RuntimeException("Error creating new collection.", e);
- }
- collection.setTableMetaData(tableMetaData);
- collection.setConnection(this.getConnection());
- return collection;
- }
-
- public <CollectionType extends ConditionsObjectCollection<?>> CollectionType newCollection(Class<CollectionType> collectionType, String tableName) {
- TableMetaData tableMetaData = TableRegistry.getTableRegistry().findByTableName(tableName);
- CollectionType collection;
- try {
- collection = collectionType.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- throw new RuntimeException("Error creating new collection.", e);
- }
- collection.setTableMetaData(tableMetaData);
- collection.setConnection(this.getConnection());
- return collection;
- }
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/Field.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/Field.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/Field.java Mon Apr 27 18:51:19 2015
@@ -6,11 +6,10 @@
import java.lang.annotation.Target;
/**
- * This is a java <code>Annotation</code> for assigning a "get" method
- * to one or more database table columns.
+ * This is a java <code>Annotation</code> for assigning a "get" method to one or more database table columns.
*/
@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
+@Target(ElementType.METHOD)
public @interface Field {
/**
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/MultipleCollectionsAction.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/MultipleCollectionsAction.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/MultipleCollectionsAction.java Mon Apr 27 18:51:19 2015
@@ -1,9 +1,8 @@
package org.hps.conditions.database;
/**
- * This is the action that should be used to pick a conditions set
- * if there are multiple conditions sets returned from a query on
- * type and name.
+ * This is the action that should be used to pick a conditions set if there are multiple conditions sets returned from a
+ * query on type and name.
*
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
*/
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/Table.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/Table.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/Table.java Mon Apr 27 18:51:19 2015
@@ -6,17 +6,17 @@
import java.lang.annotation.Target;
/**
- * This annotation can be used to assign a class to one
- * or more database tables.
+ * This annotation can be used to assign a class to one or more database tables.
*
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
*/
@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
+@Target(ElementType.TYPE)
public @interface Table {
/**
* Get the names of the tables.
+ *
* @return the names of the tables
*/
String[] names() default "";
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/package-info.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/package-info.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/package-info.java Mon Apr 27 18:51:19 2015
@@ -1,7 +1,6 @@
/**
- * This package contains classes for converting database information
- * into conditions classes as well as updating the records from the
- * objects.
+ * This package contains classes for converting database information into conditions classes as well as updating the
+ * records from the objects.
*
* @see DatabaseConditionsManager
* @see TableMetaData
@@ -10,3 +9,4 @@
* @author Jeremy McCormick <[log in to unmask]>
*/
package org.hps.conditions.database;
+
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/EcalConditionsUtil.java Mon Apr 27 18:51:19 2015
@@ -7,8 +7,7 @@
import org.lcsim.detector.identifier.Identifier;
/**
- * This is a set of utility methods for the ECAL that use the database
- * conditions system.
+ * This is a set of utility methods for the ECAL that use the database conditions system.
*
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
*/
@@ -21,6 +20,7 @@
/**
* Constructor which uses external reference to conditions object.
+ *
* @param conditions the ECAL conditions object
*/
public EcalConditionsUtil(final EcalConditions conditions) {
@@ -28,8 +28,7 @@
}
/**
- * Constructor which will find the ECAL conditions from the static
- * conditions manager instance.
+ * Constructor which will find the ECAL conditions from the static conditions manager instance.
*/
public EcalConditionsUtil() {
conditions = DatabaseConditionsManager.getInstance().getEcalConditions();
@@ -37,6 +36,7 @@
/**
* Find a channel object from a cell ID, e.g. from a <code>CalorimeterHit</code>.
+ *
* @param helper the identifier helper of the hit
* @param cellId the cell ID of the hit
* @return the corresponding ECAL channel found from the physical (geometric) ID information
@@ -52,7 +52,7 @@
final int y = helper.getValue(id, "iy");
// Create an ID to searching in the channel collection.
- final GeometryId geometryId = new GeometryId(helper, new int[] { system, x, y });
+ final GeometryId geometryId = new GeometryId(helper, new int[] {system, x, y});
// Find and return the channel object.
return conditions.getChannelCollection().findChannel(geometryId);
@@ -60,6 +60,7 @@
/**
* Get the DAQ crate number from a cell ID.
+ *
* @param helper the identifier helper of the hit
* @param cellId the cell ID of the hit
* @return the crate number of the channel
@@ -70,6 +71,7 @@
/**
* Get the DAQ slot number from a cell ID.
+ *
* @param helper the identifier helper of the hit
* @param cellId the cell ID of the hit
* @return the slot number of the channel
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/EcalLedCalibration.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/EcalLedCalibration.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/EcalLedCalibration.java Mon Apr 27 18:51:19 2015
@@ -47,7 +47,7 @@
*
* @return The ECAL channel ID.
*/
- @Field(names = { "ecal_channel_id" })
+ @Field(names = {"ecal_channel_id"})
public Integer getEcalChannelId() {
return getFieldValue("ecal_channel_id");
}
@@ -57,7 +57,7 @@
*
* @return the average LED response
*/
- @Field(names = { "led_response" })
+ @Field(names = {"led_response"})
public Double getLedResponse() {
return getFieldValue("led_response");
}
@@ -67,7 +67,7 @@
*
* @return the RMS of the LED response
*/
- @Field(names = { "rms" })
+ @Field(names = {"rms"})
public Integer getRms() {
return getFieldValue("rms");
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/TestRunEcalConditionsConverter.java Mon Apr 27 18:51:19 2015
@@ -9,8 +9,7 @@
import org.hps.conditions.ecal.EcalTimeShift.EcalTimeShiftCollection;
/**
- * This class loads all Test Run ECAL conditions into an {@link EcalConditions} object
- * from the database.
+ * This class loads all Test Run ECAL conditions into an {@link EcalConditions} object from the database.
* <p>
* The default names are overridden to use tables that contain only Test Run data.
*
@@ -21,41 +20,49 @@
/**
* Get the {@link EcalChannel} collection for Test Run.
+ *
* @param manager the conditions manager
* @return the Test Run ECAL channel collection
*/
protected EcalChannelCollection getEcalChannelCollection(DatabaseConditionsManager manager) {
return manager.getCachedConditions(EcalChannelCollection.class, "test_run_ecal_channels").getCachedData();
}
+
/**
* Get the {@link EcalGain} collection for Test Run.
+ *
* @param manager the conditions manager
* @return the Test Run ECAL gain collection
- */
+ */
protected EcalGainCollection getEcalGainCollection(DatabaseConditionsManager manager) {
return manager.getCachedConditions(EcalGainCollection.class, "test_run_ecal_gains").getCachedData();
}
-
+
/**
* Get the collections of {@link EcalBadChannel} objects for Test Run.
+ *
* @param manager the conditions manager
* @return the Test Run bad channel collections
*/
- protected ConditionsSeries<EcalBadChannel, EcalBadChannelCollection> getEcalBadChannelSeries(DatabaseConditionsManager manager) {
+ protected ConditionsSeries<EcalBadChannel, EcalBadChannelCollection> getEcalBadChannelSeries(
+ DatabaseConditionsManager manager) {
return manager.getConditionsSeries(EcalBadChannelCollection.class, "test_run_ecal_bad_channels");
}
/**
* Get the {@link EcalCalibration} collection for Test Run.
+ *
* @param manager the conditions manager
- * @return the Test Run ECAL calibration collection
+ * @return the Test Run ECAL calibration collection
*/
protected EcalCalibrationCollection getEcalCalibrationCollection(DatabaseConditionsManager manager) {
- return manager.getCachedConditions(EcalCalibrationCollection.class, "test_run_ecal_calibrations").getCachedData();
+ return manager.getCachedConditions(EcalCalibrationCollection.class, "test_run_ecal_calibrations")
+ .getCachedData();
}
/**
* Get the {@link EcalTimeShift} collection for Test Run.
+ *
* @param manager the conditions manager
* @return the Test Run ECAL time shift collection
*/
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/package-info.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/package-info.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/ecal/package-info.java Mon Apr 27 18:51:19 2015
@@ -4,23 +4,22 @@
* <p>
* Each {@link EcalChannel} represents one physical crystal in the detector.
* <p>
- * The {@link EcalBadChannel} is a channel that is malfunctioning or dead and should not
- * be used for reconstruction. It is up to the reconstruction Drivers to filter out
- * these channels.
+ * The {@link EcalBadChannel} is a channel that is malfunctioning or dead and should not be used for reconstruction. It
+ * is up to the reconstruction Drivers to filter out these channels.
* <p>
- * The {@link EcalCalibration} contains the pedestal and noise values for a channel,
- * which are the mean and the standard deviation of the digitized preamplifier output.
+ * The {@link EcalCalibration} contains the pedestal and noise values for a channel, which are the mean and the standard
+ * deviation of the digitized preamplifier output.
* <p>
* The {@link EcalGain} is the channel gain in units of MeV/ADC counts.
* <p>
* The {@link EcalTimeShift} is a time shift in the electronics response.
* <p>
- * The {@link EcalLedCalibration} is calibration information for the LED attached to
- * an ECAL channel.
+ * The {@link EcalLedCalibration} is calibration information for the LED attached to an ECAL channel.
* <p>
- * The energy of a hit is reconstructed by multiplying the gain by the pedestal-subtracted
- * ADC integral (e.g. in Test Run 2012 data).
+ * The energy of a hit is reconstructed by multiplying the gain by the pedestal-subtracted ADC integral (e.g. in Test
+ * Run 2012 data).
*
* @author Jeremy McCormick <[log in to unmask]>
*/
package org.hps.conditions.ecal;
+
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/package-info.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/package-info.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/package-info.java Mon Apr 27 18:51:19 2015
@@ -1,10 +1,11 @@
/**
- * The HPS conditions module provides facilities for accessing time dependent conditions for a detector at runtime
- * using a framework built on the LCSim conditions system. The {@link DatabaseConditionsReader} has a set of
- * converters for reading data from tables using SQL queries and creating appropriate, typed objects for them.
+ * The HPS conditions module provides facilities for accessing time dependent conditions for a detector at runtime using
+ * a framework built on the LCSim conditions system. The {@link DatabaseConditionsReader} has a set of converters for
+ * reading data from tables using SQL queries and creating appropriate, typed objects for them.
*
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
* @see org.hps.conditions.api
* @see org.hps.conditions.database
*/
package org.hps.conditions;
+
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtConditions.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtConditions.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtConditions.java Mon Apr 27 18:51:19 2015
@@ -17,8 +17,7 @@
/**
* A map between the channel object and its conditions constants.
*/
- private Map<AbstractSvtChannel, ChannelConstants> channelData =
- new HashMap<AbstractSvtChannel, ChannelConstants>();
+ private Map<AbstractSvtChannel, ChannelConstants> channelData = new HashMap<AbstractSvtChannel, ChannelConstants>();
/**
* The time shift collection.
@@ -46,9 +45,8 @@
public abstract AbstractSvtDaqMappingCollection<? extends AbstractSvtDaqMapping> getDaqMap();
/**
- * Get the conditions constants for a specific channel. These will be
- * created if they do not exist for the given channel, BUT only channels in
- * the current channel map are allowed as an argument.
+ * Get the conditions constants for a specific channel. These will be created if they do not exist for the given
+ * channel, BUT only channels in the current channel map are allowed as an argument.
*
* @param channel the SVT channel of interest
* @return the conditions constants for the given channel
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtDaqMapping.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtDaqMapping.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtDaqMapping.java Mon Apr 27 18:51:19 2015
@@ -20,7 +20,7 @@
*/
@SuppressWarnings("serial")
public static abstract class AbstractSvtDaqMappingCollection<T extends AbstractSvtDaqMapping> extends
- BaseConditionsObjectCollection<T> {
+ BaseConditionsObjectCollection<T> {
/**
* Get a DAQ pair for the given {@link HpsSiSensor}.
@@ -66,7 +66,7 @@
*
* @return SVT sensor layer number
*/
- @Field(names = { "layer" })
+ @Field(names = {"layer"})
public final int getLayerNumber() {
return getFieldValue("layer");
}
@@ -78,7 +78,7 @@
* @see STEREO
* @return the orientation of the SVT sensor
*/
- @Field(names = { "orientation" })
+ @Field(names = {"orientation"})
public final String getOrientation() {
return getFieldValue("orientation");
}
@@ -88,7 +88,7 @@
*
* @return SVT half (TOP or BOTTOM)
*/
- @Field(names = { "svt_half" })
+ @Field(names = {"svt_half"})
public final String getSvtHalf() {
return getFieldValue("svt_half");
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtT0Shift.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtT0Shift.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/AbstractSvtT0Shift.java Mon Apr 27 18:51:19 2015
@@ -6,8 +6,8 @@
import org.hps.util.Pair;
/**
- * Abstract class providing some of the basic functionality used to relate a t0
- * shift value with either a FEB ID/FEB hybrid ID or an FPGA ID/hybrid ID.
+ * Abstract class providing some of the basic functionality used to relate a t0 shift value with either a FEB ID/FEB
+ * hybrid ID or an FPGA ID/hybrid ID.
*
* @author <a href="mailto:[log in to unmask]">Omar Moreno</a>
*/
@@ -19,8 +19,8 @@
* @param <T> the type of the object in this collection which extends {@link AbstractSvtT0Shift}
*/
@SuppressWarnings("serial")
- public static abstract class AbstractSvtT0ShiftCollection<T extends AbstractSvtT0Shift>
- extends BaseConditionsObjectCollection<T> {
+ public static abstract class AbstractSvtT0ShiftCollection<T extends AbstractSvtT0Shift> extends
+ BaseConditionsObjectCollection<T> {
/**
* Get the t0 shift associated with a given DAQ pair
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java Mon Apr 27 18:51:19 2015
@@ -193,7 +193,7 @@
*
* @return the alignment constant's key
*/
- @Field(names = { "parameter" })
+ @Field(names = {"parameter"})
public String getParameter() {
return getFieldValue("parameter");
}
@@ -222,7 +222,7 @@
*
* @return the alignment constant's value as a double
*/
- @Field(names = { "value" })
+ @Field(names = {"value"})
public Double getValue() {
return getFieldValue("value");
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtBadChannel.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtBadChannel.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtBadChannel.java Mon Apr 27 18:51:19 2015
@@ -8,9 +8,8 @@
import org.hps.conditions.database.Table;
/**
- * Represents a channel that has been flagged as bad, which should not
- * be used for physics reconstructions. This might be done if the
- * channel is extremely noisy, etc.
+ * Represents a channel that has been flagged as bad, which should not be used for physics reconstructions. This might
+ * be done if the channel is extremely noisy, etc.
*
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
*/
@@ -27,6 +26,7 @@
/**
* Get the channel ID.
+ *
* @return the channel ID
*/
@Field(names = {"svt_channel_id"})
@@ -36,6 +36,7 @@
/**
* Get a note about the bad channel.
+ *
* @return a note about the bad channel
*/
@Field(names = {"notes"})
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtCalibration.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtCalibration.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtCalibration.java Mon Apr 27 18:51:19 2015
@@ -38,7 +38,7 @@
* @param channelID the SVT channel ID
*/
public SvtCalibration(final int channelID) {
- this.setChannelID(channelID);
+ this.setChannelID(channelID);
}
/**
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsConverter.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsConverter.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtConditionsConverter.java Mon Apr 27 18:51:19 2015
@@ -7,8 +7,8 @@
import org.lcsim.conditions.ConditionsManager;
/**
- * This class creates an {@link SvtConditions} object from the database, based
- * on the current run number known by the conditions manager.
+ * This class creates an {@link SvtConditions} object from the database, based on the current run number known by the
+ * conditions manager.
*
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
* @author <a href="mailto:[log in to unmask]">Omar Moreno</a>
@@ -34,21 +34,21 @@
final DatabaseConditionsManager dbConditionsManager = (DatabaseConditionsManager) manager;
// Get the channel map from the conditions database
- final SvtChannelCollection channels = dbConditionsManager.getCachedConditions(
- SvtChannelCollection.class, "svt_channels").getCachedData();
+ final SvtChannelCollection channels = dbConditionsManager.getCachedConditions(SvtChannelCollection.class,
+ "svt_channels").getCachedData();
// Create the SVT conditions object to use to encapsulate SVT condition
// collections
conditions.setChannelMap(channels);
// Get the DAQ map from the conditions database
- final SvtDaqMappingCollection daqMap = dbConditionsManager.getCachedConditions(
- SvtDaqMappingCollection.class, "svt_daq_map").getCachedData();
+ final SvtDaqMappingCollection daqMap = dbConditionsManager.getCachedConditions(SvtDaqMappingCollection.class,
+ "svt_daq_map").getCachedData();
conditions.setDaqMap(daqMap);
// Get the collection of T0 shifts from the conditions database
- final SvtT0ShiftCollection t0Shifts = dbConditionsManager.getCachedConditions(
- SvtT0ShiftCollection.class, "svt_t0_shifts").getCachedData();
+ final SvtT0ShiftCollection t0Shifts = dbConditionsManager.getCachedConditions(SvtT0ShiftCollection.class,
+ "svt_t0_shifts").getCachedData();
conditions.setT0Shifts(t0Shifts);
conditions = super.getData(manager, name);
@@ -58,6 +58,7 @@
/**
* Get the type handled by this converter.
+ *
* @return The type handled by this converter.
*/
@Override
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtConfiguration.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtConfiguration.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtConfiguration.java Mon Apr 27 18:51:19 2015
@@ -22,7 +22,7 @@
*
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
*/
-@Table(names = { "svt_configurations" })
+@Table(names = {"svt_configurations"})
@Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_UPDATED)
public final class SvtConfiguration extends BaseConditionsObject {
@@ -38,7 +38,7 @@
*
* @return The filename associated with the configuration.
*/
- @Field(names = { "filename" })
+ @Field(names = {"filename"})
public String getFileName() {
return getFieldValue("filename");
}
@@ -48,7 +48,7 @@
*
* @return the content of the XML file as a byte array
*/
- @Field(names = { "content" })
+ @Field(names = {"content"})
public byte[] getContent() {
return getFieldValue("content");
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtDetectorSetup.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtDetectorSetup.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtDetectorSetup.java Mon Apr 27 18:51:19 2015
@@ -20,7 +20,6 @@
import org.lcsim.geometry.compact.Subdetector;
import org.lcsim.util.log.LogUtil;
-
/**
* This class puts {@link SvtConditions} data onto <code>HpsSiSensor</code> objects.
*
@@ -56,6 +55,7 @@
/**
* Constructor that takes name of SVT.
+ *
* @param svtName the name of the SVT subdetector
*/
public SvtDetectorSetup(final String svtName) {
@@ -64,6 +64,7 @@
/**
* Set the name of the SVT in the detector model.
+ *
* @param svtName the name of the SVt in the detector model.
*/
public void setSvtName(final String svtName) {
@@ -72,6 +73,7 @@
/**
* Set whether this class is enabled to be activated on conditions changes.
+ *
* @param enabled <code>true</code> to enable
*/
public void setEnabled(final boolean enabled) {
@@ -80,6 +82,7 @@
/**
* Set the log level.
+ *
* @param level the log level
*/
public void setLogLevel(final Level level) {
@@ -99,12 +102,12 @@
final Subdetector subdetector = manager.getDetectorObject().getSubdetector(svtName);
if (subdetector != null) {
if (manager.isTestRun()) {
- final TestRunSvtConditions svtConditions = manager.getCachedConditions(
- TestRunSvtConditions.class, "test_run_svt_conditions").getCachedData();
+ final TestRunSvtConditions svtConditions = manager.getCachedConditions(TestRunSvtConditions.class,
+ "test_run_svt_conditions").getCachedData();
loadTestRun(subdetector, svtConditions);
} else {
- final SvtConditions svtConditions = manager.getCachedConditions(
- SvtConditions.class, "svt_conditions").getCachedData();
+ final SvtConditions svtConditions = manager.getCachedConditions(SvtConditions.class,
+ "svt_conditions").getCachedData();
loadDefault(subdetector, svtConditions);
}
} else {
@@ -203,9 +206,10 @@
sensor.setT0Shift(sensorT0Shift.getT0Shift());
}
}
-
+
/**
* Load conditions from Test Run detector.
+ *
* @param subdetector the SVT subdetector object
* @param conditions the Test Run conditions
*/
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtGain.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtGain.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtGain.java Mon Apr 27 18:51:19 2015
@@ -12,7 +12,7 @@
*
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
*/
-@Table(names = { "svt_gains", "test_run_svt_gains" })
+@Table(names = {"svt_gains", "test_run_svt_gains"})
@Converter(multipleCollectionsAction = MultipleCollectionsAction.LAST_CREATED)
public final class SvtGain extends BaseConditionsObject {
@@ -28,7 +28,7 @@
*
* @return The channel ID.
*/
- @Field(names = { "svt_channel_id" })
+ @Field(names = {"svt_channel_id"})
public Integer getChannelID() {
return getFieldValue(Integer.class, "svt_channel_id");
}
@@ -38,7 +38,7 @@
*
* @return The gain value.
*/
- @Field(names = { "gain" })
+ @Field(names = {"gain"})
public Double getGain() {
return getFieldValue(Double.class, "gain");
}
@@ -48,7 +48,7 @@
*
* @return The offset value.
*/
- @Field(names = { "offset" })
+ @Field(names = {"offset"})
public Double getOffset() {
return getFieldValue(Double.class, "offset");
}
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditionsConverter.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditionsConverter.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/TestRunSvtConditionsConverter.java Mon Apr 27 18:51:19 2015
@@ -31,10 +31,9 @@
* @param manager the conditions manager
* @return the Test Run {@link SvtShapeFitParametersCollection}
*/
- protected SvtShapeFitParametersCollection getSvtShapeFitParametersCollection(
- final DatabaseConditionsManager manager) {
- return manager.getCachedConditions(SvtShapeFitParametersCollection.class,
- "test_run_svt_shape_fit_parameters").getCachedData();
+ protected SvtShapeFitParametersCollection getSvtShapeFitParametersCollection(final DatabaseConditionsManager manager) {
+ return manager.getCachedConditions(SvtShapeFitParametersCollection.class, "test_run_svt_shape_fit_parameters")
+ .getCachedData();
}
/**
@@ -104,6 +103,7 @@
/**
* Get the type handled by this converter.
+ *
* @return The type handled by this converter.
*/
@Override
Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/package-info.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/package-info.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/package-info.java Mon Apr 27 18:51:19 2015
@@ -14,3 +14,4 @@
* @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a>
*/
package org.hps.conditions.svt;
+
Modified: java/branches/HPSJAVA-488/conditions/src/test/java/org/hps/conditions/database/CollectionIdTest.java
=============================================================================
--- java/branches/HPSJAVA-488/conditions/src/test/java/org/hps/conditions/database/CollectionIdTest.java (original)
+++ java/branches/HPSJAVA-488/conditions/src/test/java/org/hps/conditions/database/CollectionIdTest.java Mon Apr 27 18:51:19 2015
@@ -45,13 +45,14 @@
* @throws SQLException if there is an error executing SQL queries
*/
public void testCollectionId() throws SQLException {
-
- DummyConditionsObjectCollection collection = manager.newCollection(DummyConditionsObjectCollection.class);
-
- int collectionId = this.manager.getCollectionId(collection, "test add", "foo bar baz");
+
+ final DummyConditionsObjectCollection collection = this.manager
+ .newCollection(DummyConditionsObjectCollection.class);
+
+ int collectionId = this.manager.getCollectionId(collection, "foo bar baz");
System.out.println("created new collection " + collectionId);
- collectionId = this.manager.getCollectionId(collection, null, null);
+ collectionId = this.manager.getCollectionId(collection, null);
System.out.println("created new collection " + collectionId);
}
}
|