LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  March 2015

HPS-SVN March 2015

Subject:

r2364 - in /java/branches/prod: ./ conditions/src/main/java/org/hps/conditions/cli/ conditions/src/main/java/org/hps/conditions/database/ integration-tests/ integration-tests/src/test/resources/org/hps/steering/test/

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Sun, 8 Mar 2015 01:21:23 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (258 lines)

Author: [log in to unmask]
Date: Sat Mar  7 17:21:17 2015
New Revision: 2364

Log:
Merge r2359 through r2363 into prod branch.

Modified:
    java/branches/prod/   (props changed)
    java/branches/prod/conditions/src/main/java/org/hps/conditions/cli/AddCommand.java
    java/branches/prod/conditions/src/main/java/org/hps/conditions/cli/LoadCommand.java
    java/branches/prod/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java
    java/branches/prod/integration-tests/   (props changed)
    java/branches/prod/integration-tests/src/test/resources/org/hps/steering/test/MockDataReconTest.lcsim

Modified: java/branches/prod/conditions/src/main/java/org/hps/conditions/cli/AddCommand.java
 =============================================================================
--- java/branches/prod/conditions/src/main/java/org/hps/conditions/cli/AddCommand.java	(original)
+++ java/branches/prod/conditions/src/main/java/org/hps/conditions/cli/AddCommand.java	Sat Mar  7 17:21:17 2015
@@ -6,6 +6,7 @@
 import org.hps.conditions.api.ConditionsObjectException;
 import org.hps.conditions.api.ConditionsRecord;
 import org.hps.conditions.api.FieldValueMap;
+import org.hps.conditions.database.DatabaseConditionsManager;
 
 /**
  * This is a command for the conditions CLI that will add a conditions record,
@@ -19,52 +20,114 @@
     PrintStream ps = System.out;
     
     AddCommand() {
-        super("add", "Add a conditions record");
-        options.addOption("r", true, "The starting run number");
+        super("add", "Add a conditions record to associate a collection to a run range");
+        options.addOption("r", true, "The starting run number (required)");
         options.getOption("r").setRequired(true);
-        options.addOption("e", true, "The ending run number");
-        options.addOption("k", true, "The conditions key");
-        options.addOption("t", true, "The table name");
+        options.addOption("e", true, "The ending run number (default is starting run number)");
+        options.addOption("t", true, "The table name (required)");
         options.getOption("t").setRequired(true);
-        options.addOption("T", true, "A tag value");
-        options.addOption("u", true, "Your user name");
-        options.addOption("c", true, "The collection ID");
+        options.addOption("c", true, "The collection ID (required)");
         options.getOption("c").setRequired(true);
-        options.addOption("m", true, "The notes");
+        options.addOption("T", true, "A tag value (optional)");
+        options.addOption("u", true, "Your user name (optional)");
+        options.addOption("m", true, "The notes about this conditions set (optional)");
     }
        
     void execute(String[] arguments) {
         super.execute(arguments);
-                
-        int runStart = Integer.parseInt(commandLine.getOptionValue("r"));
+        
+        // This command has 3 required options.
+        if (commandLine.getOptions().length == 0) {
+            this.printUsage();
+            System.exit(1);
+        }
+
+        // Run start (required).
+        int runStart;        
+        if (commandLine.hasOption("r")) {
+            runStart = Integer.parseInt(commandLine.getOptionValue("r"));
+        } else {
+            throw new RuntimeException("Missing required -r option with run number.");
+        }
+        
+        // Run end.
         int runEnd = runStart;
         if (commandLine.hasOption("e")) {
             runEnd = Integer.parseInt(commandLine.getOptionValue("e"));
         }
-        
-        String tableName = commandLine.getOptionValue("t");
+
+        // Name of table (required).
+        String tableName;
+        if (commandLine.hasOption("t")) {
+            tableName = commandLine.getOptionValue("t");
+        } else {
+            throw new RuntimeException("Missing required -t argument with table name");
+        }        
         String name = tableName;
-        if (commandLine.hasOption("k")) {
-            name = commandLine.getOptionValue("k");
+
+        // Collection ID (required).
+        int collectionId;
+        if (commandLine.hasOption("c")) {
+            collectionId = Integer.parseInt(commandLine.getOptionValue("c"));
+        } else {
+            throw new RuntimeException("Missing required -c argument with collection ID");
         }
         
+        // User name.
         String createdBy = System.getProperty("user.name");
         if (commandLine.hasOption("u")) {
             createdBy = commandLine.getOptionValue("u");
         }
         
+        // Tag to assign (optional).
         String tag = null;
         if (commandLine.hasOption("T")) {
             tag = commandLine.getOptionValue("T");
         }
         
+        // Notes (optional).
         String notes = null;
         if (commandLine.hasOption("m")) {
             notes = commandLine.getOptionValue("m");
         }
         
-        int collectionId = Integer.parseInt(commandLine.getOptionValue("c"));
+        // Create the conditions record to insert.
+        ConditionsRecord conditionsRecord = createConditionsRecord(
+                runStart, 
+                runEnd, 
+                tableName, 
+                name, 
+                collectionId, 
+                createdBy, 
+                tag, 
+                notes);       
+        try {
+            boolean createdConnection = false;
+            DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance();
+            if (!DatabaseConditionsManager.getInstance().isConnected()) {
+                createdConnection = manager.openConnection();
+            }
+            conditionsRecord.insert();
+            manager.closeConnection(createdConnection);
+        } catch (ConditionsObjectException e) {
+            throw new RuntimeException("An error occurred while adding a conditions record.", e);
+        }
+        ps.println("successfully added conditions record ...");
+        ps.println(conditionsRecord);
+    }
 
+    /**
+     * @param runStart
+     * @param runEnd
+     * @param tableName
+     * @param name
+     * @param collectionId
+     * @param createdBy
+     * @param tag
+     * @param notes
+     * @return
+     */
+    private ConditionsRecord createConditionsRecord(int runStart, int runEnd, String tableName, String name, int collectionId, String createdBy, String tag, String notes) {
         ConditionsRecord conditionsRecord = new ConditionsRecord();
         FieldValueMap fieldValues = new FieldValueMap();
         fieldValues.put("run_start", runStart);
@@ -81,13 +144,6 @@
         }
         conditionsRecord.setFieldValues(fieldValues);
         fieldValues.put("created", new Date());
-        try {
-            conditionsRecord.insert();
-        } catch (ConditionsObjectException e) {
-            throw new RuntimeException("An error occurred while adding a conditions record.", e);
-        }
-        ps.println("successfully added conditions record ...");
-        ps.println(conditionsRecord);
+        return conditionsRecord;
     }
-
-}
+}

Modified: java/branches/prod/conditions/src/main/java/org/hps/conditions/cli/LoadCommand.java
 =============================================================================
--- java/branches/prod/conditions/src/main/java/org/hps/conditions/cli/LoadCommand.java	(original)
+++ java/branches/prod/conditions/src/main/java/org/hps/conditions/cli/LoadCommand.java	Sat Mar  7 17:21:17 2015
@@ -42,7 +42,7 @@
     @Override
     public void execute(String[] arguments) {
         super.execute(arguments);
-        
+               
         String fileName = commandLine.getOptionValue("f");
         if (fileName == null) {
             throw new IllegalArgumentException("Missing file argument.");
@@ -58,6 +58,11 @@
 
         DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance();
 
+        boolean openedConnection = false;
+        if (!conditionsManager.isConnected()) {
+            openedConnection = conditionsManager.openConnection();
+        }
+        
         int collectionID;
         if (commandLine.getOptionValue("c") != null) {
             collectionID = Integer.parseInt(commandLine.getOptionValue("c"));
@@ -78,6 +83,7 @@
         // FIXME: This call should go through an object API like ConditionsObjectCollection.insert rather than the manager directly.
         List<Integer> IDs = conditionsManager.updateQuery(insertSql);
         System.out.println("Inserted " + IDs.size() + " new rows into table " + tableName + " with collection_id " + collectionID);
+        conditionsManager.closeConnection(openedConnection);
     }
 
     void parseFile(String fileName, List<String> columnNames, List<List<String>> rows) {

Modified: java/branches/prod/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java
 =============================================================================
--- java/branches/prod/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java	(original)
+++ java/branches/prod/conditions/src/main/java/org/hps/conditions/database/DatabaseConditionsManager.java	Sat Mar  7 17:21:17 2015
@@ -369,9 +369,6 @@
      */
     public int getNextCollectionID(String tableName) {
         boolean openedConnection = openConnection();
-        TableMetaData tableData = tableRegistry.findByTableName(tableName);
-        if (tableData == null)
-            throw new IllegalArgumentException("There is no meta data for table " + tableName);
         ResultSet resultSet = selectQuery("SELECT MAX(collection_id)+1 FROM " + tableName);
         int collectionId = 1;
         try {

Modified: java/branches/prod/integration-tests/src/test/resources/org/hps/steering/test/MockDataReconTest.lcsim
 =============================================================================
--- java/branches/prod/integration-tests/src/test/resources/org/hps/steering/test/MockDataReconTest.lcsim	(original)
+++ java/branches/prod/integration-tests/src/test/resources/org/hps/steering/test/MockDataReconTest.lcsim	Sat Mar  7 17:21:17 2015
@@ -10,8 +10,6 @@
     </control>
     <execute>
         <driver name="EventMarkerDriver"/>
-        <driver name="ConditionsDriver" />
-        <driver name="SvtSensorSetup" />
         <driver name="RawTrackerHitSensorSetup"/>
         <driver name="RawTrackerHitFitterDriver" />
         <driver name="TrackerHitDriver"/>
@@ -26,10 +24,8 @@
         <driver name="CleanupDriver"/>
     </execute>    
     <drivers>    
-        <driver name="ConditionsDriver" type="org.hps.conditions.ConditionsDriver" />
-        <driver name="SvtSensorSetup" type="org.hps.recon.tracking.SvtSensorSetup" />   
         <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver">
-            <eventInterval>10</eventInterval>
+            <eventInterval>1</eventInterval>
         </driver>        
         <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup"/>
         <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver">
@@ -55,7 +51,6 @@
             <isMC>false</isMC>
             <gblFileName></gblFileName>
         </driver>
-
         <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver">
             <ecalCollectionName>EcalCalHits</ecalCollectionName>
             <use2014Gain>true</use2014Gain>

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use