jetweb is hosted by Hepforge, IPPP Durham

cedar.jetweb.db
Class DBPlotManager

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

public abstract class DBPlotManager
extends java.lang.Object

DataBase operations for paper and plot packages; PaperBank, Paper,DataPlot, PlotSelection.

Version:
$Date: 2006-06-08 19:44:00 +0100 (Thu, 08 Jun 2006) $ $Revision: 1180 $
Author:
S.Butterworth

Field Summary
static java.lang.String FITTED
          specifies Fitted data
static java.lang.String PREDICTED
          specifies Predicted data
static java.lang.String REAL
          specifies Real data
 
Constructor Summary
DBPlotManager()
           
 
Method Summary
static void add(PlotSwitch ps)
           
static boolean addPaper(Paper paper)
          Updates the database, adding a new paper record or amending an existing one if a record already exists for the supplied paper.
static void delete(Paper paper)
          Delete this paper from the data base.
static void delete(PlotSwitch ps)
          Clears down an existing PlotSwitch from the DB.
static void delete(RealPlot plot)
          Delete this plot from the data base and remove all record of it from the paper.
static void fillPaper(Paper paper)
          Retrieve the data for a Paper from the DataBase.
static void fillPlots(Paper paper)
          Finds all the plots for the specified paper.
static void fromDB(RealPlot plot)
           
static void fromDB(java.lang.String ConName, RealPlot plot)
          Fills a RealPlot from the database.
static double[] getChi2(int plotId, int fitId)
           
static java.util.List<java.lang.Integer> getCsnIds(int cssId, boolean sorted)
          Retrieves database IDs of all CrossSections belonging to a given CrossSectionSet.
static java.util.List<java.lang.Integer> getCSSIds(int csnId, boolean sorted)
          Retrieves database IDs of all CrossSectionSets containing a given CrossSection.
static java.util.Vector<DataPoint> getDataPoints(DataPlot plot)
          Retrieves the collection of points for a dataplot from the database.
static java.util.Vector<PlotSwitch> getMatchedSwitches(int plotId, Generator gen)
          Return the PlotSwitches (in a Vector) for this plotId which most specifically match the input RunSeries.
static int getMaxCssId()
          Returns highest value CrossSectionSetId.
static int getPaperId(java.lang.String dirName)
          Retrieves ID of a paper, given its directory
static java.util.Enumeration<Paper> getPapers()
          Initialises the PaperBank database.
static int getPlotId(int paperId, int plotNumber)
           
static int getPlotId(java.lang.String ConName, int paperId, int plotNumber)
          Retrieves DB Id of a plot, given the paper and plot number
static int getProcId(int runSeriesId)
          Return the MCProcessId for the given RunSeriesId.
static java.util.HashSet<PlotSwitch> getSwitches(int plotId)
          Return Enumeration of the switches associated with this plot.
static void insertCrossSection(RealPlot plot, int paperId)
           
static void insertCrossSection(java.lang.String ConName, RealPlot plot, int paperId)
          Insert new DB record for this RealData plot.
static void insertCrossSectionSet(java.util.Iterator<java.lang.Integer> plotIds, int cssId)
          Inserts a new cross_section_set record into the database.
static void insertData(DataPlot plot)
          Insert data points for this real/predicted/fitted data plot to the DB
static void insertFittedPrediction(FittedPlot plot)
          Adds a fitted prediction to the database
static boolean plotExists(DataPlot plot, RunSeries runSeries)
          Checks existance of a predicted plot matching a given runSeries and a given RealPlot.
static void populateSelection(PlotSelection selection)
           
static void selectPlotSwitch(PlotSwitch plotSwitch)
          Fill the fields of this plotSwitch from the DB.
static void update(PlotSwitch ps)
          Store this PlotSwitch to the database.
static void updateCrossSectionLabels(RealPlot plot)
          Update DB record for this RealData plot labels & switches
static void updateCrossSectionPoints(DataPlot plot)
          Update real/predicted/fitted data points in the database for an existing plot - delete existing data points and repopulate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REAL

public static final java.lang.String REAL
specifies Real data

See Also:
Constant Field Values


PREDICTED

public static final java.lang.String PREDICTED
specifies Predicted data

See Also:
Constant Field Values


FITTED

public static final java.lang.String FITTED
specifies Fitted data

See Also:
Constant Field Values

Constructor Detail

DBPlotManager

public DBPlotManager()
Method Detail

getPapers

public static java.util.Enumeration<Paper> getPapers()
                                              throws JetWebException
Initialises the PaperBank database.

Returns:
enumeration of all papers in the database
Throws:
JetWebException


fillPaper

public static void fillPaper(Paper paper)
                      throws JetWebException
Retrieve the data for a Paper from the DataBase.

Throws:
JetWebException


getPaperId

public static int getPaperId(java.lang.String dirName)
                      throws JetWebException
Retrieves ID of a paper, given its directory

Parameters:
dirname - name of the directory containing files relevant to a paper
Returns:
paper id from database
Throws:
JetWebException


fillPlots

public static void fillPlots(Paper paper)
                      throws JetWebException
Finds all the plots for the specified paper. Adds them to the collection on the paper.

Parameters:
paper - for which plots are to be retrieved
Throws:
JetWebException


fromDB

public static void fromDB(java.lang.String ConName,
                          RealPlot plot)
                   throws JetWebException
Fills a RealPlot from the database.

Throws:
JetWebException


fromDB

public static void fromDB(RealPlot plot)
                   throws JetWebException
Throws:
JetWebException

addPaper

public static boolean addPaper(Paper paper)
                        throws JetWebException
Updates the database, adding a new paper record or amending an existing one if a record already exists for the supplied paper. The plots associated with a paper (if any) are not affected.

Parameters:
paper - the paper to add / amend in the database
Returns:
true for update, false for add
Throws:
JetWebException


getDataPoints

public static java.util.Vector<DataPoint> getDataPoints(DataPlot plot)
                                                 throws JetWebException
Retrieves the collection of points for a dataplot from the database. Queries data_point / predicted_point / fitted_point for real / predicted / fitted data.

Parameters:
plot - for which points are to be retrieved
Returns:
vector of data point objects
Throws:
JetWebException


updateCrossSectionPoints

public static void updateCrossSectionPoints(DataPlot plot)
                                     throws JetWebException
Update real/predicted/fitted data points in the database for an existing plot - delete existing data points and repopulate

Parameters:
plot - object representing the plot to be updated
Throws:
JetWebException


insertData

public static void insertData(DataPlot plot)
                       throws JetWebException
Insert data points for this real/predicted/fitted data plot to the DB

Parameters:
plot - object containing pointed to be inserted
Throws:
JetWebException


insertCrossSection

public static void insertCrossSection(java.lang.String ConName,
                                      RealPlot plot,
                                      int paperId)
                               throws JetWebException
Insert new DB record for this RealData plot.

Parameters:
plot - - plot to be added to database
paperId - - DB id for paper to which this plot belongs
Throws:
JetWebException


insertCrossSection

public static void insertCrossSection(RealPlot plot,
                                      int paperId)
                               throws JetWebException
Throws:
JetWebException

updateCrossSectionLabels

public static void updateCrossSectionLabels(RealPlot plot)
                                     throws JetWebException
Update DB record for this RealData plot labels & switches

Parameters:
plot - - plot to be added to database
Throws:
JetWebException


insertFittedPrediction

public static void insertFittedPrediction(FittedPlot plot)
                                   throws JetWebException
Adds a fitted prediction to the database

Parameters:
plot - for which fitted prediction is to be inserted
Throws:
JetWebException


getPlotId

public static int getPlotId(java.lang.String ConName,
                            int paperId,
                            int plotNumber)
                     throws JetWebException
Retrieves DB Id of a plot, given the paper and plot number

Parameters:
ConName - name of data base to query for paper
paperId - of paper to which plot belongs
plotNumber - number of the plot in the paper
Returns:
plotId, -1 if not found
Throws:
JetWebException


getPlotId

public static int getPlotId(int paperId,
                            int plotNumber)
                     throws JetWebException
Throws:
JetWebException

getCSSIds

public static java.util.List<java.lang.Integer> getCSSIds(int csnId,
                                                          boolean sorted)
                                                   throws JetWebException
Retrieves database IDs of all CrossSectionSets containing a given CrossSection. Optionally, the list of IDs can be sorted.

Parameters:
csnId - identifies the crosssection that must be in the sets
sorted - - if true, the list retrieved will be sorted
Returns:
a List of crossSectionSet Ids (Integer values), optionally sorted
Throws:
JetWebException


getCsnIds

public static java.util.List<java.lang.Integer> getCsnIds(int cssId,
                                                          boolean sorted)
                                                   throws JetWebException
Retrieves database IDs of all CrossSections belonging to a given CrossSectionSet. Optionally, the list of IDs can be sorted.

Parameters:
cssId - identifies the crosssectionset
sorted - - if true, the list retrieved will be sorted
Returns:
a List of crossSection Ids (Integer values), optionally sorted
Throws:
JetWebException


getMaxCssId

public static int getMaxCssId()
                       throws JetWebException
Returns highest value CrossSectionSetId. This method is necessary for the generation of new CrossSectionSet IDs because there are no database sequences in mySQL.

Returns:
largest value of crosssection set id in the database
Throws:
JetWebException


insertCrossSectionSet

public static void insertCrossSectionSet(java.util.Iterator<java.lang.Integer> plotIds,
                                         int cssId)
                                  throws JetWebException
Inserts a new cross_section_set record into the database.

Parameters:
plotIds - list(Integers) of all the plots belonging to the new set
cssId - for the new cross_sectionset record
Throws:
JetWebException


plotExists

public static boolean plotExists(DataPlot plot,
                                 RunSeries runSeries)
                          throws JetWebException
Checks existance of a predicted plot matching a given runSeries and a given RealPlot.

Parameters:
RealPlot -
RunSeries -
Returns:
true if the plot exists, otherwise false
Throws:
JEtWebDBException
JetWebException


populateSelection

public static void populateSelection(PlotSelection selection)
                              throws JetWebException
Throws:
JetWebException

getChi2

public static double[] getChi2(int plotId,
                               int fitId)

selectPlotSwitch

public static void selectPlotSwitch(PlotSwitch plotSwitch)
                             throws JetWebException
Fill the fields of this plotSwitch from the DB. The ID must be set in advance.

Throws:
JetWebException


getSwitches

public static java.util.HashSet<PlotSwitch> getSwitches(int plotId)
                                                 throws JetWebException
Return Enumeration of the switches associated with this plot.

Throws:
JetWebException


getProcId

public static int getProcId(int runSeriesId)
                     throws JetWebException
Return the MCProcessId for the given RunSeriesId.

Throws:
JetWebException


update

public static void update(PlotSwitch ps)
                   throws JetWebException
Store this PlotSwitch to the database.

Throws:
JetWebException


add

public static void add(PlotSwitch ps)
                throws JetWebException
Throws:
JetWebException

delete

public static void delete(PlotSwitch ps)
                   throws JetWebException
Clears down an existing PlotSwitch from the DB.

Parameters:
ps - PlotSwitch to be deleted
Throws:
JetWebException


delete

public static void delete(RealPlot plot)
                   throws JetWebException
Delete this plot from the data base and remove all record of it from the paper. Also delete all predictions and fits for this plot.

Throws:
JetWebException


delete

public static void delete(Paper paper)
                   throws JetWebException
Delete this paper from the data base.

Throws:
JetWebException


getMatchedSwitches

public static java.util.Vector<PlotSwitch> getMatchedSwitches(int plotId,
                                                              Generator gen)
                                                       throws JetWebException
Return the PlotSwitches (in a Vector) for this plotId which most specifically match the input RunSeries. That is, those which match both generator and version if specified; if not, those that match the generator and do not specify a version; if not, then those which specify neither generator nor version.

Throws:
JetWebException