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

HPS-SVN September 2015

Subject:

r3733 - /java/trunk/run-database/src/main/java/org/hps/run/database/RunManager.java

From:

[log in to unmask]

Reply-To:

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

Date:

Tue, 29 Sep 2015 20:07:38 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (454 lines)

Author: [log in to unmask]
Date: Tue Sep 29 13:07:36 2015
New Revision: 3733

Log:
Add additional methods to run db manager.

Modified:
    java/trunk/run-database/src/main/java/org/hps/run/database/RunManager.java

Modified: java/trunk/run-database/src/main/java/org/hps/run/database/RunManager.java
 =============================================================================
--- java/trunk/run-database/src/main/java/org/hps/run/database/RunManager.java	(original)
+++ java/trunk/run-database/src/main/java/org/hps/run/database/RunManager.java	Tue Sep 29 13:07:36 2015
@@ -21,24 +21,20 @@
  * @author Jeremy McCormick, SLAC
  */
 public final class RunManager implements ConditionsListener {
-    
+
     /**
      * Simple class for caching data.
      */
     private class DataCache {
+
+        List<EpicsData> epicsData;
+        RunSummary fullRunSummary;
         Boolean runExists;
+        RunSummary runSummary;
+        List<ScalerData> scalerData;
         TriggerConfig triggerConfig;
-        List<EpicsData> epicsData;
-        List<ScalerData> scalerData;
-        RunSummary runSummary;
-        RunSummary fullRunSummary;
-    }
-    
-    /**
-     * The data cache of run information.
-     */
-    private DataCache dataCache;
-   
+    }
+
     /**
      * The default connection parameters for read-only access to the run database.
      */
@@ -78,33 +74,47 @@
     private final ConnectionParameters connectionParameters = DEFAULT_CONNECTION_PARAMETERS;
 
     /**
+     * The data cache of run information.
+     */
+    private DataCache dataCache;
+
+    /**
+     * Factory for creating database API objects.
+     */
+    private final RunDatabaseDaoFactory factory;
+
+    /**
      * The run number; the -1 value indicates that this has not been set externally yet.
      */
     private Integer run = null;
 
-    /**
-     * Factory for creating database API objects.
-     */
-    private RunDatabaseDaoFactory factory;
-    
-    /**
-     * Class constructor.
-     * 
-     * @param connection the database connection
-     */
-    public RunManager(Connection connection) {
-        this.connection = connection;
-        openConnection();
-        factory = new RunDatabaseDaoFactory(this.connection);
-    }
-    
     /**
      * Class constructor using default connection parameters.
      */
     public RunManager() {
         this.connection = DEFAULT_CONNECTION_PARAMETERS.createConnection();
-        openConnection();
+        this.openConnection();
         factory = new RunDatabaseDaoFactory(this.connection);
+    }
+
+    /**
+     * Class constructor.
+     *
+     * @param connection the database connection
+     */
+    public RunManager(final Connection connection) {
+        this.connection = connection;
+        this.openConnection();
+        factory = new RunDatabaseDaoFactory(this.connection);
+    }
+
+    /**
+     * Check if the run number has been set.
+     */
+    private void checkRunNumber() {
+        if (this.run == null) {
+            throw new IllegalStateException("The run number was not set.");
+        }
     }
 
     /**
@@ -117,12 +127,12 @@
             }
         } catch (final SQLException e) {
             e.printStackTrace();
-        }        
+        }
     }
 
     /**
      * Load new run information when conditions have changed.
-     * 
+     *
      * @param conditionsEvent the event with new conditions information
      */
     @Override
@@ -131,6 +141,66 @@
     }
 
     /**
+     * Delete a run from the database.
+     *
+     * @param run the run number
+     */
+    public void deleteRun() {
+        // Create object for updating run info in the database.
+        final RunSummaryDao runSummaryDao = factory.createRunSummaryDao();
+
+        // Delete run from the database.
+        runSummaryDao.deleteFullRun(run);
+    }
+
+    /**
+     * Return the database connection.
+     *
+     * @return the database connection
+     */
+    Connection getConnection() {
+        return this.connection;
+    }
+
+    /**
+     * Get the EPICS data for the current run.
+     *
+     * @param epicsType the type of EPICS data
+     * @return the EPICS data for the current run
+     */
+    public List<EpicsData> getEpicsData(final EpicsType epicsType) {
+        this.checkRunNumber();
+        if (this.dataCache.epicsData == null) {
+            LOGGER.info("loading EPICS data for run " + this.run);
+            this.dataCache.epicsData = factory.createEpicsDataDao().getEpicsData(epicsType, this.run);
+        }
+        return this.dataCache.epicsData;
+    }
+
+    /**
+     * Get the EPICS variables.
+     *
+     * @param epicsType the type of EPICS data
+     * @return the EPICS data for the current run
+     */
+    public List<EpicsVariable> getEpicsVariables(final EpicsType epicsType) {
+        return factory.createEpicsVariableDao().getEpicsVariables(epicsType);
+    }
+
+    /**
+     * Get the full run summary for the current run including scaler data, etc.
+     *
+     * @return the full run summary for the current run
+     */
+    public RunSummary getFullRunSummary() {
+        this.checkRunNumber();
+        if (this.dataCache.fullRunSummary == null) {
+            this.dataCache.fullRunSummary = factory.createRunSummaryDao().readFullRunSummary(this.run);
+        }
+        return this.dataCache.fullRunSummary;
+    }
+
+    /**
      * Get the current run number.
      *
      * @return the run number
@@ -146,6 +216,74 @@
      */
     public List<Integer> getRuns() {
         return new RunSummaryDaoImpl(this.connection).getRuns();
+    }
+
+    /**
+     * Get the full list of summaries for all runs in the database without complex data like EPICS records.
+     *
+     * @return the full list of run summaries
+     */
+    public List<RunSummary> getRunSummaries() {
+        return this.factory.createRunSummaryDao().getRunSummaries();
+    }
+
+    /**
+     * Get the run summary for the current run not including its sub-objects like scaler data.
+     *
+     * @return the run summary for the current run
+     */
+    public RunSummary getRunSummary() {
+        this.checkRunNumber();
+        if (this.dataCache.runSummary == null) {
+            this.dataCache.runSummary = factory.createRunSummaryDao().getRunSummary(this.run);
+        }
+        return this.dataCache.runSummary;
+    }
+
+    /**
+     * Get the scaler data for the current run.
+     *
+     * @return the scaler data for the current run
+     */
+    public List<ScalerData> getScalerData() {
+        this.checkRunNumber();
+        if (this.dataCache.scalerData == null) {
+            LOGGER.info("loading scaler data for run " + this.run);
+            this.dataCache.scalerData = factory.createScalerDataDao().getScalerData(run);
+        }
+        return this.dataCache.scalerData;
+    }
+
+    /**
+     * Get the trigger config for the current run.
+     *
+     * @return the trigger config for the current run
+     */
+    public TriggerConfig getTriggerConfig() {
+        this.checkRunNumber();
+        if (this.dataCache.triggerConfig == null) {
+            LOGGER.info("loading trigger config for run " + this.run);
+            this.dataCache.triggerConfig = factory.createTriggerConfigDao().getTriggerConfig(run);
+        }
+        return this.dataCache.triggerConfig;
+    }
+
+    /**
+     * Update the database with information found from crawling the files.
+     *
+     * @param runs the list of runs to update
+     * @throws SQLException if there is a database query error
+     */
+    public void insertRun(final RunSummary runSummary) throws SQLException {
+        LOGGER.info("updating run database for run " + runSummary.getRun());
+
+        // Create object for updating run info in the database.
+        final RunSummaryDao runSummaryDao = factory.createRunSummaryDao();
+
+        // Insert run summary into database.
+        runSummaryDao.insertFullRunSummary(runSummary);
+
+        LOGGER.info("done updating run database");
     }
 
     /**
@@ -167,152 +305,47 @@
     }
 
     /**
+     * Return <code>true</code> if the run exists in the database.
+     *
+     * @return <code>true</code> if the run exists in the database
+     */
+    public boolean runExists() {
+        this.checkRunNumber();
+        if (this.dataCache.runExists == null) {
+            this.dataCache.runExists = factory.createRunSummaryDao().runSummaryExists(this.run);
+        }
+        return this.dataCache.runExists;
+    }
+
+    /**
+     * Return <code>true</code> if the run exists in the database.
+     *
+     * @param run the run number
+     * @return <code>true</code> if the run exists in the database
+     */
+    boolean runExists(final int run) {
+        if (this.dataCache.runExists == null) {
+            this.dataCache.runExists = factory.createRunSummaryDao().runSummaryExists(run);
+        }
+        return this.dataCache.runExists;
+    }
+
+    /**
      * Set the run number and then load the applicable {@link RunSummary} from the database.
      *
      * @param run the run number
      */
     public void setRun(final int run) {
-        
+
         if (this.run == null || run != this.run) {
-        
+
             LOGGER.info("setting new run " + run);
-            
+
             // Set the run number.
             this.run = run;
-        
+
             // Reset the data cache.
             this.dataCache = new DataCache();
-        } 
-    }
-    
-    /**
-     * Get the run summary for the current run not including its sub-objects like scaler data.
-     * 
-     * @return the run summary for the current run
-     */
-    public RunSummary getRunSummary() {
-        checkRunNumber();
-        if (this.dataCache.runSummary == null) {
-            this.dataCache.runSummary = factory.createRunSummaryDao().getRunSummary(this.run);
-        }
-        return this.dataCache.runSummary;
-    }
-    
-    /**
-     * Get the full run summary for the current run including scaler data, etc.
-     * 
-     * @return the full run summary for the current run
-     */
-    public RunSummary getFullRunSummary() {
-        checkRunNumber();
-        if (this.dataCache.fullRunSummary == null) {
-            this.dataCache.fullRunSummary = factory.createRunSummaryDao().readFullRunSummary(this.run);
-        }
-        return this.dataCache.fullRunSummary;
-    }
-    
-    /**
-     * Get the trigger config for the current run.
-     * 
-     * @return the trigger config for the current run
-     */
-    public TriggerConfig getTriggerConfig() {
-        checkRunNumber();
-        if (this.dataCache.triggerConfig == null) {
-            LOGGER.info("loading trigger config for run " + this.run);
-            this.dataCache.triggerConfig = factory.createTriggerConfigDao().getTriggerConfig(run);
-        }
-        return this.dataCache.triggerConfig;
-    }
-    
-    /**
-     * Get the EPICS data for the current run.
-     * 
-     * @param epicsType the type of EPICS data
-     * @return the EPICS data for the current run
-     */
-    public List<EpicsData> getEpicsData(EpicsType epicsType) {
-        checkRunNumber();
-        if (this.dataCache.epicsData == null) {
-            LOGGER.info("loading EPICS data for run " + this.run);
-            this.dataCache.epicsData = factory.createEpicsDataDao().getEpicsData(epicsType, this.run);
-        }
-        return this.dataCache.epicsData;
-    }
-    
-    /**
-     * Get the scaler data for the current run.
-     * 
-     * @return the scaler data for the current run
-     */
-    public List<ScalerData> getScalerData() {
-        checkRunNumber();
-        if (this.dataCache.scalerData == null) {
-            LOGGER.info("loading scaler data for run " + this.run);
-            this.dataCache.scalerData = factory.createScalerDataDao().getScalerData(run);
-        }
-        return this.dataCache.scalerData;
-    }
-    
-    /**
-     * Update the database with information found from crawling the files.
-     *
-     * @param runs the list of runs to update
-     * @throws SQLException if there is a database query error
-     */
-    public void insertRun(final RunSummary runSummary) throws SQLException {
-        LOGGER.info("updating run database for run " + runSummary.getRun());
-
-        // Create object for updating run info in the database.
-        final RunSummaryDao runSummaryDao = factory.createRunSummaryDao();
-
-        // Insert run summary into database.
-        runSummaryDao.insertFullRunSummary(runSummary);
-
-        LOGGER.info("done updating run database");
-    }
-    
-    /**
-     * Delete a run from the database.
-     * 
-     * @param run the run number
-     */
-    public void deleteRun() {
-        // Create object for updating run info in the database.
-        final RunSummaryDao runSummaryDao = factory.createRunSummaryDao();
-
-        // Delete run from the database.
-        runSummaryDao.deleteFullRun(run);
-    }
-    
-    /**
-     * Return <code>true</code> if the run exists in the database.
-     * 
-     * @return <code>true</code> if the run exists in the database
-     */
-    public boolean runExists() {
-        checkRunNumber();
-        if (this.dataCache.runExists == null) {
-            this.dataCache.runExists = factory.createRunSummaryDao().runSummaryExists(run);
-        }
-        return this.dataCache.runExists;
-    }
-        
-    /**
-     * Check if the run number has been set.
-     */
-    private void checkRunNumber() {
-        if (this.run == null) {
-            throw new IllegalStateException("The run number was not set.");
-        }
-    }    
-    
-    /**
-     * Return the database connection.
-     * 
-     * @return the database connection
-     */
-    Connection getConnection() {
-        return this.connection;
+        }
     }
 }

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