fr.gouv.culture.sdx.utils.database
Class HSQLDatabase
java.lang.Object
fr.gouv.culture.sdx.utils.AbstractSdxObject
fr.gouv.culture.sdx.utils.rdbms.JDBC
fr.gouv.culture.sdx.utils.rdbms.DataSourceComponentBacked
fr.gouv.culture.sdx.utils.database.AbstractJDBCDatabase
fr.gouv.culture.sdx.utils.database.HSQLDatabase
- All Implemented Interfaces:
- Database, Describable, Encodable, Identifiable, Localizable, Saveable, SdxObject, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, org.apache.excalibur.xml.sax.XMLizable
public class HSQLDatabase
- extends AbstractJDBCDatabase
Fields inherited from class fr.gouv.culture.sdx.utils.rdbms.JDBC |
tableName |
Fields inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject |
_configuration, _context, _description, _encoding, _id, _locale, _logger, _manager, _xmlizable_objects, _xmlLang, isToSaxInitialized |
Method Summary |
void |
backup(SaveParameters save_config)
Save the database |
void |
configure(org.apache.avalon.framework.configuration.Configuration configuration)
|
protected void |
finalize()
|
protected java.lang.String |
getAlterTableNameQuery(java.lang.String oldName)
|
DatabaseConnection |
getConnection()
|
java.lang.String |
getDatabaseDirectoryName()
If the database is a directory based file system implemenation like lucene
this method should return a valid name for a directory which may be created to house
the database, or in the case of hsql it will return a valid table name |
protected java.lang.String |
getEntriesWithLimitQuery(long offset,
long number)
Implementation of statement with a limit parameter |
protected java.lang.String |
getOptimizeQuery()
|
protected java.lang.String |
getTableCreationQuery()
Returns an SQL query that could create the table. |
protected java.lang.String |
getTableName()
Returns a table name used to store the repository's data. |
void |
init()
Initializes the database. |
protected boolean |
initToSax()
Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML |
protected void |
initVolatileObjectsToSax()
Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML
Some objects need to be refresh each time a toSAX is called |
void |
optimize()
Utility method for database maintenance,
normally used to optimize indices of Lucene based repositories
It is the responsibility of the Repository to ensure that
unnecessary optimizations are not performed when this method
is called. |
void |
releaseConnection(DatabaseConnection conn)
|
void |
restore(SaveParameters save_config)
Restore the database |
java.lang.String[] |
search(org.apache.avalon.framework.parameters.Parameters params,
int mode)
|
Methods inherited from class fr.gouv.culture.sdx.utils.database.AbstractJDBCDatabase |
addProperty, createIndicies, delete, delete, empty, entityExists, getAllEntitiesQuery, getClassNameSuffix, getCreateIndiciesQuery, getDeleteAllQuery, getEntities, getEntities, getEntity, getEntity, getEntityDeleteQuery, getEntityGetQuery, getEntityIds, getProperties, getPropertyAddQuery, getPropertyRemoveQueryWithId, getPropertyRemoveQueryWithoutId, getPropertyValue, getPropertyValues, getWildcardSearchToken, removeProperty, removeProperty, save, search, searchWithParams, size, update |
Methods inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject |
configureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, toSAX, verifyConfigurationResources |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface fr.gouv.culture.sdx.utils.SdxObject |
getLog |
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled |
enableLogging |
Methods inherited from interface org.apache.avalon.framework.context.Contextualizable |
contextualize |
Methods inherited from interface org.apache.avalon.framework.service.Serviceable |
service |
Methods inherited from interface org.apache.excalibur.xml.sax.XMLizable |
toSAX |
dbDirPath
protected java.lang.String dbDirPath
hsqldb
protected HSQLDB hsqldb
DATABASE_DIR_NAME
protected java.lang.String DATABASE_DIR_NAME
HSQLDatabase
public HSQLDatabase()
getDatabaseDirectoryName
public java.lang.String getDatabaseDirectoryName()
- Description copied from interface:
Database
- If the database is a directory based file system implemenation like lucene
this method should return a valid name for a directory which may be created to house
the database, or in the case of hsql it will return a valid table name
- Returns:
- A directory name (not a full path)
configure
public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
throws org.apache.avalon.framework.configuration.ConfigurationException
- Specified by:
configure
in interface org.apache.avalon.framework.configuration.Configurable
- Overrides:
configure
in class AbstractJDBCDatabase
- Throws:
org.apache.avalon.framework.configuration.ConfigurationException
getConnection
public DatabaseConnection getConnection()
throws SDXException
- Specified by:
getConnection
in interface Database
- Overrides:
getConnection
in class AbstractJDBCDatabase
- Throws:
SDXException
releaseConnection
public void releaseConnection(DatabaseConnection conn)
throws SDXException
- Specified by:
releaseConnection
in interface Database
- Overrides:
releaseConnection
in class AbstractJDBCDatabase
- Throws:
SDXException
getOptimizeQuery
protected java.lang.String getOptimizeQuery()
optimize
public void optimize()
throws SDXException
- Description copied from interface:
Database
- Utility method for database maintenance,
normally used to optimize indices of Lucene based repositories
It is the responsibility of the Repository to ensure that
unnecessary optimizations are not performed when this method
is called.
- Throws:
SDXException
init
public void init()
throws SDXException
- Initializes the database.
If there are no tables in the database,
we create the necessary table
- Specified by:
init
in interface Database
- Overrides:
init
in class AbstractJDBCDatabase
- Throws:
SDXException
getTableCreationQuery
protected java.lang.String getTableCreationQuery()
- Description copied from class:
JDBC
- Returns an SQL query that could create the table.
This query should not have any parameter.
- Overrides:
getTableCreationQuery
in class AbstractJDBCDatabase
- Returns:
- The query.
see subclasses for implementation
getTableName
protected java.lang.String getTableName()
- Description copied from class:
JDBC
- Returns a table name used to store the repository's data.
- Overrides:
getTableName
in class JDBC
- Returns:
- The table name should be appropriately escaped for table building.
getAlterTableNameQuery
protected java.lang.String getAlterTableNameQuery(java.lang.String oldName)
finalize
protected void finalize()
throws java.lang.Throwable
- Overrides:
finalize
in class DataSourceComponentBacked
- Throws:
java.lang.Throwable
search
public java.lang.String[] search(org.apache.avalon.framework.parameters.Parameters params,
int mode)
throws SDXException
- Specified by:
search
in interface Database
- Overrides:
search
in class AbstractJDBCDatabase
- Throws:
SDXException
initToSax
protected boolean initToSax()
- Description copied from class:
AbstractSdxObject
- Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML
- Specified by:
initToSax
in class AbstractSdxObject
initVolatileObjectsToSax
protected void initVolatileObjectsToSax()
- Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML
Some objects need to be refresh each time a toSAX is called
- Overrides:
initVolatileObjectsToSax
in class JDBC
backup
public void backup(SaveParameters save_config)
throws SDXException
- Save the database
- Specified by:
backup
in interface Saveable
- Overrides:
backup
in class AbstractJDBCDatabase
- Throws:
SDXException
- See Also:
Saveable.backup(fr.gouv.culture.sdx.utils.save.SaveParameters)
getEntriesWithLimitQuery
protected java.lang.String getEntriesWithLimitQuery(long offset,
long number)
- Description copied from class:
AbstractJDBCDatabase
- Implementation of statement with a limit parameter
- Specified by:
getEntriesWithLimitQuery
in class AbstractJDBCDatabase
- Returns:
- the query
- See Also:
HSQL implementation
SELECT LIMIT >offset< >number<
DISTINCT * FROM >table_name<);
restore
public void restore(SaveParameters save_config)
throws SDXException
- Restore the database
- Specified by:
restore
in interface Saveable
- Overrides:
restore
in class AbstractJDBCDatabase
- Throws:
SDXException
- See Also:
Saveable.restore(fr.gouv.culture.sdx.utils.save.SaveParameters)
Copyright © 2000-2010 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.