hepdata is hosted by Hepforge, IPPP Durham

cedar.hepdata.db
Class DBUtil

java.lang.Object
  extended by cedar.hepdata.db.DBUtil

public abstract class DBUtil
extends java.lang.Object

General Database utilities.

Version:
$Date: 2006-01-20 11:25:51 +0000 (Fri, 20 Jan 2006) $ $Revision: 465 $
Author:
S Butterworth

Field Summary
protected static java.text.DateFormat format
           
protected static java.text.DecimalFormat intForm
           
protected static java.text.DateFormat longformat
           
protected static int MAX_OBS_DESC_LENGTH
           
protected static int MAX_RE_DESC_LENGTH
           
protected static int MAXERRORS
           
protected static java.lang.String PCTFORM
           
protected static java.text.DecimalFormat sciForm
           
 
Constructor Summary
DBUtil()
           
 
Method Summary
protected static java.lang.String getEqualsString(java.util.Date dt)
          Utility method to format a Date to be included in an SQL query
protected static java.lang.String getEqualsString(java.lang.String s)
          Utility method to format a string to be included in an SQL query
protected static java.lang.String getExp(java.lang.Double dbl)
          Writes out Double as string in exponential form and returns the exponential.part
protected static java.lang.String getMantissa(java.lang.Double dbl)
          Writes out Double as string in exponential form and returns the part BEFORE the exponential.
protected static java.lang.Double getNumeric(java.lang.String sval)
          converts an input string into a double (if this is easy to do!)
protected static java.lang.String getString(java.util.Date dt)
          Utility method to format a Date to be included in an SQL insert or update
protected static java.lang.String getString(java.lang.Double dbl)
          Utility method to format a double to be included in an SQL insert or update
protected static java.lang.String getString(java.lang.String s)
          Utility method to format a string to be included in an SQL insert or update
protected static boolean isPresent(Axis ax)
          queries axis table to find if record with given id exists
protected static boolean isPresent(Dataset ds)
          queries dataset table to find if record with given id exists
protected static boolean isPresent(Paper p)
          queries paper table to find if record with given id exists
protected static void lookupDS(Axis ax)
          Replace legacy values of paperId and datasetId with new values from the DB.
protected static void lookupDS(Dataset ds)
          Replace legacy values of paperId and datasetId with new values from the DB.
protected static void lookupDS(Observable obs)
          Replace legacy values of paperId and datasetId with new values from the DB.
protected static void lookupDS(Reaction r)
          Replace legacy values of paperId and datasetId with new values from the DB.
protected static boolean nullDescRecord(Dataset ds)
          Finds whether this Dataset record has a description
protected static void selectDatasetHeader(Dataset ds)
          Lookup a Header for a Dataset
protected static boolean selectId(Detector d)
          Populates the input Detector's ID from the DB
protected static boolean selectId(Experiment ex)
          Populates the input Experiment's ID from the DB
protected static boolean selectId(Observable obs)
          Populates the input Observable's ID from the DB
protected static Property selectId(Property p)
          Populates the input Property's ID from the DB
protected static boolean selectId(Reaction reaction)
          Populates the input REaCTION's ID from the DB
protected static boolean selectId(Reference r)
          Populates the input Reference's ID from the DB
protected static int selectIdFromLegacy(int leg)
          Lookup a PaperID from a Legacy PaperID
protected static void selectMaxId(Dataset ds)
          Find Maximum dataset number on the database for a given paper Set the provided dataset's ID to one greater than this maximum
protected static java.lang.String stripBrackets(java.lang.String in)
          Strips brackets,asterisks and quotation marks from a string.
protected static java.lang.String stripSpeech(java.lang.String in)
          Strips quotation marks from a string.
protected static boolean systematicsPresent(Dataset ds)
          Checks whether there are entries in Systematics table for given Dataset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

format

protected static java.text.DateFormat format

longformat

protected static java.text.DateFormat longformat

sciForm

protected static java.text.DecimalFormat sciForm

intForm

protected static java.text.DecimalFormat intForm

PCTFORM

protected static java.lang.String PCTFORM

MAXERRORS

protected static int MAXERRORS

MAX_OBS_DESC_LENGTH

protected static int MAX_OBS_DESC_LENGTH

MAX_RE_DESC_LENGTH

protected static int MAX_RE_DESC_LENGTH
Constructor Detail

DBUtil

public DBUtil()
Method Detail

selectIdFromLegacy

protected static int selectIdFromLegacy(int leg)
                                 throws HDException
Lookup a PaperID from a Legacy PaperID

Parameters:
leg - Id
Returns:
paperId
Throws:
HDException


selectDatasetHeader

protected static void selectDatasetHeader(Dataset ds)
                                   throws HDException
Lookup a Header for a Dataset

Parameters:
ds - dataset
Throws:
HDException


isPresent

protected static boolean isPresent(Paper p)
                            throws HDException
queries paper table to find if record with given id exists

Parameters:
p - Paper
Throws:
HDException


selectMaxId

protected static void selectMaxId(Dataset ds)
                           throws HDException
Find Maximum dataset number on the database for a given paper Set the provided dataset's ID to one greater than this maximum

Parameters:
ds - dataset
Throws:
HDException


isPresent

protected static boolean isPresent(Dataset ds)
                            throws HDException
queries dataset table to find if record with given id exists

Parameters:
ds - dataset
Throws:
HDException


nullDescRecord

protected static boolean nullDescRecord(Dataset ds)
                                 throws HDException
Finds whether this Dataset record has a description

Parameters:
ds - dataset
Returns:
boolean : true if the dataset has no description
Throws:
HDException


selectId

protected static boolean selectId(Reaction reaction)
                           throws HDException
Populates the input REaCTION's ID from the DB

Parameters:
reaction - to be populated
Returns:
boolean : true if reaction exists
Throws:
HDException


selectId

protected static boolean selectId(Observable obs)
                           throws HDException
Populates the input Observable's ID from the DB

Parameters:
obs - observable to be populated
Returns:
boolean : true if Observable exists
Throws:
HDException


selectId

protected static boolean selectId(Detector d)
                           throws HDException
Populates the input Detector's ID from the DB

Parameters:
d - detector to be populated
Returns:
boolean : true if detector exists
Throws:
HDException


selectId

protected static boolean selectId(Experiment ex)
                           throws HDException
Populates the input Experiment's ID from the DB

Parameters:
ex - experiment to be populated
Returns:
boolean : true if experiment exists
Throws:
HDException


selectId

protected static boolean selectId(Reference r)
                           throws HDException
Populates the input Reference's ID from the DB

Parameters:
r - reference to be populated
Returns:
boolean : true if reference exists
Throws:
HDException


selectId

protected static Property selectId(Property p)
                            throws HDException
Populates the input Property's ID from the DB

Parameters:
p - property to be populated
Returns:
Property that has been populated.=
Throws:
HDException


lookupDS

protected static void lookupDS(Reaction r)
                        throws HDException
Replace legacy values of paperId and datasetId with new values from the DB.

Parameters:
r - Reaction for which paperId and datasetId will be replaced.
Throws:
HDException


lookupDS

protected static void lookupDS(Observable obs)
                        throws HDException
Replace legacy values of paperId and datasetId with new values from the DB.

Parameters:
obs - Observable for which paperId and datasetId will be replaced.
Throws:
HDException


lookupDS

protected static void lookupDS(Dataset ds)
                        throws HDException
Replace legacy values of paperId and datasetId with new values from the DB.

Parameters:
ds - Dataset for which paperId and datasetId will be replaced.
Throws:
HDException


lookupDS

protected static void lookupDS(Axis ax)
                        throws HDException
Replace legacy values of paperId and datasetId with new values from the DB.

Parameters:
ax - Axis for which paperId and datasetId will be replaced.
Throws:
HDException


isPresent

protected static boolean isPresent(Axis ax)
                            throws HDException
queries axis table to find if record with given id exists

Parameters:
ax - Axis
Throws:
HDException


systematicsPresent

protected static boolean systematicsPresent(Dataset ds)
Checks whether there are entries in Systematics table for given Dataset.

Parameters:
ds - dataset
Returns:
boolean : true if there are systematics


getString

protected static java.lang.String getString(java.lang.Double dbl)
Utility method to format a double to be included in an SQL insert or update

Parameters:
dbl - Double
Returns:
String from Double


getMantissa

protected static java.lang.String getMantissa(java.lang.Double dbl)
Writes out Double as string in exponential form and returns the part BEFORE the exponential.

Parameters:
dbl - Double
Returns:
String : first part of exponential


getExp

protected static java.lang.String getExp(java.lang.Double dbl)
Writes out Double as string in exponential form and returns the exponential.part

Parameters:
dbl - Double
Returns:
String : the exponential


getString

protected static java.lang.String getString(java.lang.String s)
Utility method to format a string to be included in an SQL insert or update

Parameters:
s - String input
Returns:
formatted String


getEqualsString

protected static java.lang.String getEqualsString(java.lang.String s)
Utility method to format a string to be included in an SQL query

Parameters:
s - String input
Returns:
formatted String


getEqualsString

protected static java.lang.String getEqualsString(java.util.Date dt)
Utility method to format a Date to be included in an SQL query

Parameters:
dt - Date input
Returns:
formatted String


getString

protected static java.lang.String getString(java.util.Date dt)
Utility method to format a Date to be included in an SQL insert or update

Parameters:
dt - Date input
Returns:
formatted String


stripBrackets

protected static java.lang.String stripBrackets(java.lang.String in)
Strips brackets,asterisks and quotation marks from a string. java.lang.String.replace() won't replace a char with null which is why I have done it this way..

Parameters:
in - String input
Returns:
formatted string


stripSpeech

protected static java.lang.String stripSpeech(java.lang.String in)
Strips quotation marks from a string. java.lang.String.replace() won't replace a char with null which is why I have done it this way..

Parameters:
in - String input
Returns:
formatted string


getNumeric

protected static java.lang.Double getNumeric(java.lang.String sval)
converts an input string into a double (if this is easy to do!)

Parameters:
sval - string value
Returns:
Double (null if string cannot be converted) Note: this method is not infalible and may convert only part of the string!


Generated 20060512 1623

HEPData