Package adams.db.upgrade
Class AbstractTableUpgrade
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.db.upgrade.AbstractTableUpgrade
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,DatabaseConnectionHandler,DatabaseConnectionProvider,DatabaseConnectionUser,Serializable
- Direct Known Subclasses:
FixInvalidMySQLTimestampDefault,PassThrough
public abstract class AbstractTableUpgrade extends AbstractOptionHandler implements DatabaseConnectionHandler
Abstract superclass for all helper classes that upgrade tables in one way or another.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractDatabaseConnectionm_Connectiondatabase connection.protected booleanm_Upgradedindicates whether the upgrade has happened.protected StringBuilderm_UpgradeInfothe information generated during upgrading.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractTableUpgrade()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddInfo(String s)Appends the string to the upgrade info plus a new line.protected abstract voiddoUpgrade()Performs the actual upgrade.static AbstractTableUpgradeforCommandLine(String cmdline)Instantiates the table upgrade scheme from the given commandline (i.e., classname and optional options).static AbstractTableUpgradeforName(String classname, String[] options)Instantiates the table upgrade scheme with the given options.AbstractDatabaseConnectiongetDatabaseConnection()Returns the current database connection.static String[]getUpgraders()Returns a list with classnames of upgrade schemes.abstract StringglobalInfo()Returns a string describing the object.protected voidinitialize()Initializes the members.protected voidpostUpgrade()A post-upgrade hook.protected voidpreUpgrade()A pre-upgrade hook.voidreset()Resets the reader (but does not clear the input data!).voidsetDatabaseConnection(AbstractDatabaseConnection value)Sets the database connection to use.StringBuilderupgrade()Performs the upgrade if not yet performed and returns the information that was generated during the upgrade (can be empty).-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_UpgradeInfo
protected StringBuilder m_UpgradeInfo
the information generated during upgrading.
-
m_Upgraded
protected boolean m_Upgraded
indicates whether the upgrade has happened.
-
m_Connection
protected transient AbstractDatabaseConnection m_Connection
database connection.
-
-
Method Detail
-
globalInfo
public abstract String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractOptionHandler
-
reset
public void reset()
Resets the reader (but does not clear the input data!). Derived classes must call this method in set-methods of parameters to assure the invalidation of previously generated data.- Overrides:
resetin classAbstractOptionHandler
-
setDatabaseConnection
public void setDatabaseConnection(AbstractDatabaseConnection value)
Sets the database connection to use.- Specified by:
setDatabaseConnectionin interfaceDatabaseConnectionHandler- Parameters:
value- the database connection
-
getDatabaseConnection
public AbstractDatabaseConnection getDatabaseConnection()
Returns the current database connection.- Specified by:
getDatabaseConnectionin interfaceDatabaseConnectionProvider- Returns:
- the database connection
-
addInfo
protected void addInfo(String s)
Appends the string to the upgrade info plus a new line.- Parameters:
s- the string to add
-
preUpgrade
protected void preUpgrade()
A pre-upgrade hook.
-
doUpgrade
protected abstract void doUpgrade()
Performs the actual upgrade.
-
postUpgrade
protected void postUpgrade()
A post-upgrade hook.
-
upgrade
public StringBuilder upgrade()
Performs the upgrade if not yet performed and returns the information that was generated during the upgrade (can be empty).- Returns:
- (potential) information generated during the upgrade
-
getUpgraders
public static String[] getUpgraders()
Returns a list with classnames of upgrade schemes.- Returns:
- the upgrade schemes
-
forName
public static AbstractTableUpgrade forName(String classname, String[] options)
Instantiates the table upgrade scheme with the given options.- Parameters:
classname- the classname of the table upgrade scheme to instantiateoptions- the options for the table upgrade scheme- Returns:
- the instantiated table upgrade scheme or null if an error occurred
-
forCommandLine
public static AbstractTableUpgrade forCommandLine(String cmdline)
Instantiates the table upgrade scheme from the given commandline (i.e., classname and optional options).- Parameters:
cmdline- the classname (and optional options) of the table upgrade scheme to instantiate- Returns:
- the instantiated table upgrade scheme or null if an error occurred
-
-