jetweb is hosted by Hepforge, IPPP Durham

cedar.jetweb.db
Class DBManager

java.lang.Object
  extended by cedar.jetweb.db.DBManager

public abstract class DBManager
extends java.lang.Object

DataBase operations for jetweb package objects; ResultSearchPattern, Model, RunSeries and so on.

Version:
$Date: 2006-06-21 12:36:40 +0100 (Wed, 21 Jun 2006) $ $Revision: 1197 $
Author:
S.Butterworth

Constructor Summary
DBManager()
           
 
Method Summary
static void addLumi(double lumi, int runseriesId)
          Adds the input integrated luminosity to the total for this runseries.
static void addRunSeries(RunSeries runSeries)
          Add parameters to the runseries table and associated auxilliary tables.
static boolean addToDB(Collision collision)
          Note that collisions cannot be changed, so if you try to store one with an ID which already exists, an exception will be thrown.
static boolean addToDB(Model model)
           
static boolean addToDB(RunSeriesCollection rsc)
          Store a new RunSeriesCollection
static boolean checkCollision(int collId, int procId)
          Lightweight way of checking that the input collisionId is consistent with the input processId without instantiating either the Collision or the MCProcessType.
static void deleteParms(int runseriesId)
          Clears down an existing runseries record from the DB.
static boolean exists(java.lang.String tableName, java.lang.String fieldName, int id)
          Return true if an entry with field fieldName value id exists in table tableName.
static java.util.Vector<Collision> getAllCollisions()
          Returns a Vector of all valid Collisions from the Database.
static java.util.Vector<MCProcessType> getAllMCProcessTypes(boolean selectable)
          Returns a Vector of all valid MCProcessTypes from the Database.
static java.util.Vector<MCProcessType> getAllMCProcessTypes(Collision collision)
          Returns a Vector of all valid MCProcessTypes from the Database matching the given Collision.
static java.util.Enumeration<java.lang.Integer> getAllRunSeriesIds()
          Get all the unique id numbers of all RunSeries in the DB.
static java.util.Vector<Model> getConsistentModels(ResultSearchPattern pattern)
          Returns a Vector of all existing models which are consistent with the given ResultSearchPattern.
static java.util.Vector<Model> getConsistentModels(RunSeries runseries)
          Returns a Vector of all existing models which match the given RunSeries.
static java.util.Vector<RunSeries> getConsistentRunSeries(MCProcessType proc, Model model)
          Returns a Vector of RunSeries which are consistent with the given Model and MCProcessType.
static java.util.Vector<LogFile> getLogFiles(RunSeries runseries)
          Returns Vector of LogFiles associated with this runSeries.
static int getNLogs(RunSeries runseries)
          Counts logfiles associated with this parameter set.
static int matchRunSeriesId(RunSeries runSeries)
          Is there a DB entry in runseries to match the input runSeries? if so, return its Id.
static void resetLogTime(int runseriesId)
          Sets the timestamp in the runseries table to mark new data.
static boolean selectFromDB(Collision collision)
           
static void selectFromDb(MCProcessType proc)
          Populates the input MCProcessType object from the DB
static void selectFromDb(Model model)
          Populates the input Model from the DB
static void selectFromDb(RunSeries runseries)
          Populates the input RunSeries object from the DB
static void selectFromDb(RunSeriesCollection rsc)
          Populates the input RunSeriesCollection object from the DB
static void selectId(Collision collision)
          Select & set the collision Id.
static void selectId(MCProcessType proc)
          Select & set the process Id.
static boolean updateDB(RunSeriesCollection rsc)
          Store a new RunSeriesCollection
static void updateLumi(RunSeries runseries, double newLumi)
          Compare the current luminosity to the argument and update the database if necessary.
static void zero(RunSeries lp)
          Zero all data associated with the given runseries, without removing the runseries itself.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBManager

public DBManager()
Method Detail

addToDB

public static boolean addToDB(Model model)
                       throws JetWebException
Throws:
JetWebException

selectFromDb

public static void selectFromDb(Model model)
                         throws JetWebException
Populates the input Model from the DB

Parameters:
model - the model to be populated
Throws:
JetWebException


getConsistentModels

public static java.util.Vector<Model> getConsistentModels(RunSeries runseries)
                                                   throws JetWebException
Returns a Vector of all existing models which match the given RunSeries. Also adds this runSeries to the Models, if they don't already have it in their list. Also checks the models to see if there are any consistent RunSeries they don't use. If this is the case, add the RunSeries to the model.

Parameters:
force - if true, also checks for any new & distinct models which can be built using this set of parameters and creates a new model consistent with this runseries if none already exists.
Returns:
a vector of models
Throws:
JetWebException


getConsistentModels

public static java.util.Vector<Model> getConsistentModels(ResultSearchPattern pattern)
                                                   throws JetWebException
Returns a Vector of all existing models which are consistent with the given ResultSearchPattern. Does not change the database in any way.

Parameters:
pattern - specifies parameters for a model search
Returns:
a vector of models retrieved by the database search
Throws:
JetWebException


selectFromDb

public static void selectFromDb(RunSeries runseries)
                         throws JetWebException
Populates the input RunSeries object from the DB

Parameters:
runseries - RunSeries object to be populated
Throws:
JetWebDbException
JetWebException


getLogFiles

public static java.util.Vector<LogFile> getLogFiles(RunSeries runseries)
                                             throws JetWebException
Returns Vector of LogFiles associated with this runSeries.

Parameters:
runseries - the RunSeries object for which logfile names are to be retrieved
Returns:
a vector of logfile names (strings)
Throws:
JetWebException


getNLogs

public static int getNLogs(RunSeries runseries)
                    throws JetWebException
Counts logfiles associated with this parameter set.

Parameters:
runseries - the RunSeries object for which logfile count is to be performed
Returns:
number of logfiles for this RunSeries
Throws:
JetWebException


resetLogTime

public static void resetLogTime(int runseriesId)
                         throws JetWebException
Sets the timestamp in the runseries table to mark new data. Setting timestamp to null has the effect of setting it to NOW

Parameters:
runseriesId - of record to be timestamped
Throws:
JetWebException


addLumi

public static void addLumi(double lumi,
                           int runseriesId)
                    throws JetWebException
Adds the input integrated luminosity to the total for this runseries.

Parameters:
lumi - integarated luminosity to be added.
runseriesId - of record to which it will be added.
Throws:
JetWebException


getAllRunSeriesIds

public static java.util.Enumeration<java.lang.Integer> getAllRunSeriesIds()
                                                                   throws JetWebDBException
Get all the unique id numbers of all RunSeries in the DB.

Throws:
JetWebDBException


updateLumi

public static void updateLumi(RunSeries runseries,
                              double newLumi)
                       throws JetWebDBException
Compare the current luminosity to the argument and update the database if necessary.

Throws:
JetWebDBException


zero

public static void zero(RunSeries lp)
Zero all data associated with the given runseries, without removing the runseries itself.


selectFromDb

public static void selectFromDb(MCProcessType proc)
                         throws JetWebException
Populates the input MCProcessType object from the DB

Parameters:
proc - MCProcessType object to be populated
Throws:
JetWebDbException
JetWebException


selectFromDb

public static void selectFromDb(RunSeriesCollection rsc)
                         throws JetWebException
Populates the input RunSeriesCollection object from the DB

Parameters:
rsc - RunSeriesCollection object to be populated
Throws:
JetWebDbException
JetWebException


getAllMCProcessTypes

public static java.util.Vector<MCProcessType> getAllMCProcessTypes(boolean selectable)
                                                            throws JetWebException
Returns a Vector of all valid MCProcessTypes from the Database.

Parameters:
selectable - if true, only those processes which can be generated on their own and which have relevant real data to compare to are returned.
Throws:
JetWebException


getAllMCProcessTypes

public static java.util.Vector<MCProcessType> getAllMCProcessTypes(Collision collision)
                                                            throws JetWebException
Returns a Vector of all valid MCProcessTypes from the Database matching the given Collision.

Throws:
JetWebException


exists

public static boolean exists(java.lang.String tableName,
                             java.lang.String fieldName,
                             int id)
                      throws JetWebException
Return true if an entry with field fieldName value id exists in table tableName.

Throws:
JetWebException


addToDB

public static boolean addToDB(Collision collision)
                       throws JetWebException
Note that collisions cannot be changed, so if you try to store one with an ID which already exists, an exception will be thrown.

Throws:
JetWebException


selectFromDB

public static boolean selectFromDB(Collision collision)
                            throws JetWebException
Throws:
JetWebException

getAllCollisions

public static java.util.Vector<Collision> getAllCollisions()
                                                    throws JetWebException
Returns a Vector of all valid Collisions from the Database.

Throws:
JetWebException


checkCollision

public static boolean checkCollision(int collId,
                                     int procId)
                              throws JetWebException
Lightweight way of checking that the input collisionId is consistent with the input processId without instantiating either the Collision or the MCProcessType.

Throws:
JetWebException


deleteParms

public static void deleteParms(int runseriesId)
                        throws JetWebException
Clears down an existing runseries record from the DB.

Parameters:
id - of runseries to be deleted.
Throws:
JetWebException


addRunSeries

public static void addRunSeries(RunSeries runSeries)
                         throws JetWebException
Add parameters to the runseries table and associated auxilliary tables.

Parameters:
log - to be added
Throws:
JetWebException


getConsistentRunSeries

public static java.util.Vector<RunSeries> getConsistentRunSeries(MCProcessType proc,
                                                                 Model model)
                                                          throws JetWebException
Returns a Vector of RunSeries which are consistent with the given Model and MCProcessType.

Parameters:
proc -
model -
Returns:
vector of RunSeries
Throws:
JetWebException


matchRunSeriesId

public static int matchRunSeriesId(RunSeries runSeries)
                            throws JetWebException
Is there a DB entry in runseries to match the input runSeries? if so, return its Id.

Parameters:
object - for which runseries id is to be found
Returns:
runseriesId
Throws:
JetWebException


selectId

public static void selectId(Collision collision)
                     throws JetWebException
Select & set the collision Id. Return true if one is found, otherwise false.

Throws:
JetWebException


selectId

public static void selectId(MCProcessType proc)
                     throws JetWebException
Select & set the process Id. Return true if one is found, otherwise false.

Throws:
JetWebException


addToDB

public static boolean addToDB(RunSeriesCollection rsc)
                       throws JetWebException
Store a new RunSeriesCollection

Throws:
JetWebException


updateDB

public static boolean updateDB(RunSeriesCollection rsc)
                        throws JetWebException
Store a new RunSeriesCollection

Throws:
JetWebException