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  June 2015

HPS-SVN June 2015

Subject:

r3194 - /java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBiasConditionsLoader.java

From:

[log in to unmask]

Reply-To:

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

Date:

Wed, 24 Jun 2015 21:40:43 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (122 lines)

Author: [log in to unmask]
Date: Wed Jun 24 14:40:32 2015
New Revision: 3194

Log:
Fix db record structure

Modified:
    java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBiasConditionsLoader.java

Modified: java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBiasConditionsLoader.java
 =============================================================================
--- java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBiasConditionsLoader.java	(original)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBiasConditionsLoader.java	Wed Jun 24 14:40:32 2015
@@ -6,6 +6,7 @@
 import hep.aida.*;
 
 import java.io.File;
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashSet;
@@ -206,9 +207,7 @@
 
         
         // Load in CSV records from the exported run spreadsheet.
-        final String path = cl.getOptionValue("c");
-        
-        RunMap runmap = getRunMapFromSpreadSheet(path);
+        RunMap runmap = getRunMapFromSpreadSheet(cl.getOptionValue("c"));
         
 
         // Load MYA dump
@@ -276,6 +275,9 @@
         // Create a new collection for each run
         List<Integer> runsadded = new ArrayList<Integer>();
         
+        
+        
+        
         for(SvtBiasRunRange range : ranges) {
             logger.info("Loading " + range.toString());
             RunData rundata = range.getRun();
@@ -284,9 +286,38 @@
                 throw new RuntimeException("Run " + Integer.toString(rundata.getRun()) + " was already added?");
             }
             runsadded.add(rundata.getRun());
+
+            if(range.getRanges().isEmpty()) {
+                logger.info("No bias range for run " + range.getRun().getRun());
+                continue;
+            }
+            
+            int collectionId = -1;
+            try {
+                collectionId = MANAGER.addCollection("svt_bias_constants", "whatever that is fine","run ranges for SVT HV bias ON");
+            } catch (SQLException e1) {
+               throw new RuntimeException(e1);
+            }
+            
+            //create a collection
+            SvtBiasConstantCollection collection = new SvtBiasConstantCollection();
+            try {
+                collection.setCollectionId(collectionId);
+            } catch (ConditionsObjectException e1) {
+                throw new RuntimeException("cant set collection id",e1);
+            }
+            
+            final ConditionsRecord condition = new ConditionsRecord();
+            condition.setFieldValue("run_start", rundata.getRun());
+            condition.setFieldValue("run_end", rundata.getRun());
+            condition.setFieldValue("name", "svt_bias");
+            condition.setFieldValue("table_name", "svt_bias_constants");
+            condition.setFieldValue("notes", "constants from mya");
+            condition.setFieldValue("created", new Date());
+            condition.setFieldValue("created_by", System.getProperty("user.name"));            
+            condition.setFieldValue("collection_id", collectionId);
+            
             for (SvtBiasMyaRange biasRange : range.getRanges()) {
-                //create a collection
-                SvtBiasConstantCollection collection = new SvtBiasConstantCollection();
                 //create a constant and add to the collection
                 final SvtBiasConstant constant = new SvtBiasConstant();
                 constant.setFieldValue("start", biasRange.getStartDate());
@@ -294,25 +325,20 @@
                 constant.setFieldValue("value", biasRange.getStart().getValue());
                 collection.add(constant);
                 
-                final ConditionsRecord condition = new ConditionsRecord();
-                condition.setFieldValue("run_start", rundata.getRun());
-                condition.setFieldValue("run_end", rundata.getRun());
-                condition.setFieldValue("name", "svt_bias");
-                condition.setFieldValue("table_name", "svt_bias_constants");
-                condition.setFieldValue("notes", "constants from mya");
-                condition.setFieldValue("created", new Date());
-                condition.setFieldValue("created_by", System.getProperty("user.name"));
-                
-                condition.setFieldValue("collection_id", collection.getCollectionId());
-                
                 logger.info(condition.toString());
-
-                if(doIt) {
+            }
+            
+            if(doIt) {
+                try {
                     try {
-                        condition.insert();
-                    } catch (ConditionsObjectException e) {
-                        throw new RuntimeException(e);
+                        collection.insert();
+                    } catch (SQLException e) {
+                        throw new RuntimeException("cant instert collection", e);
                     }
+                    condition.insert();
+                    
+                } catch (ConditionsObjectException e) {
+                    throw new RuntimeException(e);
                 }
             }
         }

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