Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## fr.gouv.culture.sdx.utils.database
Class AbstractJDBCDatabase

    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

All Implemented Interfaces:
  org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, Database, Describable, Encodable, Identifiable, Localizable, org.apache.avalon.framework.logger.LogEnabled, Saveable, SdxObject, org.apache.avalon.framework.service.Serviceable, org.apache.excalibur.xml.sax.XMLizable

Direct Known Subclasses:
  HSQLDatabase, JDBCDatabase

public abstract class AbstractJDBCDatabase
extends DataSourceComponentBacked
implements Database

Created by IntelliJ IDEA. User: rpandey Date: Mar 3, 2003 Time: 3:58:12 PM

Nested Class Summary

Nested classes inherited from class fr.gouv.culture.sdx.utils.rdbms.JDBC
`JDBC.QueryExecutor, JDBC.Template`

Nested classes inherited from class fr.gouv.culture.sdx.utils.SdxObject
`SdxObject.ConfigurationNode`

Field Summary
`static java.lang.String[]` | `_searchModes`
`protected int` | `COLUMN_PARAM_INDEX_FIELD_ID`
`protected int` | `COLUMN_PARAM_INDEX_FIELD_PROPERTY_NAME`
`protected int` | `COLUMN_PARAM_INDEX_FIELD_PROPERTY_VALUE`
`protected java.lang.String` | `FIELD_ID`
`protected java.lang.String` | `FIELD_PROPERTY_NAME`
`protected java.lang.String` | `FIELD_PROPERTY_VALUE`

Fields inherited from class fr.gouv.culture.sdx.utils.rdbms.DataSourceComponentBacked
`ATTRIBUTE_DSI, dbSelector, dsi`

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`

Fields inherited from interface fr.gouv.culture.sdx.utils.database.Database
`CLASS_NAME_SUFFIX, DATABASE_DIR_PATH, PACKAGE_QUALNAME, SEARCH_MODE_AND, SEARCH_MODE_NOT, SEARCH_MODE_OR`

Fields inherited from interface fr.gouv.culture.sdx.utils.Encodable
`DEFAULT_ENCODING`

Fields inherited from interface fr.gouv.culture.sdx.utils.save.Saveable
`ALL_SAVE_ATTRIB, PATH_ATTRIB, SAVE_DIRECTORY_PARAM`

Constructor Summary
`AbstractJDBCDatabase()`

Method Summary
`void` | `addProperty(java.lang.String entityId, java.lang.String propertyName, java.lang.String propertyValue)` If the entity does not exist the method fails silently
`void` | `backup(SaveParameters save_config)` The backup method gives a way to an object to save its data
`void` | `configure(org.apache.avalon.framework.configuration.Configuration configuration)`
`protected void` | `createIndicies(java.sql.Connection conn)` Creates and index on the "id" field.
`void` | `delete(DatabaseEntity ent)` Deletes an entity.
`void` | `delete(DatabaseEntity[] entities)`
`void` | `empty()` Empties the database.
`boolean` | `entityExists(java.lang.String id)` Checks whether an entity with the provided id exists within this database
`protected java.lang.String` | `getAllEntitiesQuery()`
`protected java.lang.String` | `getClassNameSuffix()` Sub classes should element this method to return their class name suffix for SAX output
`DatabaseConnection` | `getConnection()`
`protected java.lang.String` | `getCreateIndiciesQuery(java.lang.String fieldName)`
`protected java.lang.String` | `getDeleteAllQuery()`
`DatabaseEntity[]` | `getEntities()` Returns the list of entities from the database.
`protected DatabaseEntity[]` | `getEntities(java.sql.ResultSet rs)` Calling methods should close ResultSet after calling this method
`DatabaseEntity` | `getEntity(java.lang.String id)` Gets an entity from the database.
`protected DatabaseEntity` | `getEntity(java.lang.String id, java.sql.ResultSet rs)` Calling methods should close ResultSet after calling this method
`protected java.lang.String` | `getEntityDeleteQuery()`
`protected java.lang.String` | `getEntityGetQuery()` Returns an SQL query that could select a entity using its id.
`protected java.lang.String[]` | `getEntityIds(java.sql.ResultSet rs)` Calling methods should close ResultSet after calling this method
`protected abstract java.lang.String` | `getEntriesWithLimitQuery(long offset, long number)` Implementation of statement with a limit parameter
`Property[]` | `getProperties(java.lang.String entityId)` Returns all properties from an entity in the database.
`protected java.lang.String` | `getPropertyAddQuery()`
`protected java.lang.String` | `getPropertyRemoveQueryWithId()`
`protected java.lang.String` | `getPropertyRemoveQueryWithoutId()`
`java.lang.String` | `getPropertyValue(java.lang.String entityId, java.lang.String name)` Returns a property value from an entity in the database.
`java.lang.String[]` | `getPropertyValues(java.lang.String entityId, java.lang.String propertyName)` Returns a repeatable property from an entity in the database.
`protected java.lang.String` | `getTableCreationQuery()` Returns an SQL query that could create the table.
`java.lang.String` | `getWildcardSearchToken()` Returns a String representing the appropriate wildcard search token for the implementation
`void` | `init()` Initializes the repository.
`void` | `releaseConnection(DatabaseConnection conn)`
`void` | `removeProperty(java.lang.String propertyName, java.lang.String propertyValue)` Removes a property with the provided name and value from the and EXISTING entity having the name/value pair It is up to the implementation to determine proper behavior if the entity with the provided id does not exist.
`void` | `removeProperty(java.lang.String entityId, java.lang.String propertyName, java.lang.String propertyValue)` If the entity does not exist the method fails silently
`void` | `restore(SaveParameters save_config)` The restore method gives a way to an object to restore its data from a backup.
`void` | `save(DatabaseEntity ent)` Saves an entity.
`java.lang.String[]` | `search(org.apache.avalon.framework.parameters.Parameters params)` Returns an array of database entity ids based upon the provided search parameters One can used Database.getEntity(id) after retrieving a list of ids with this method.
`java.lang.String[]` | `search(org.apache.avalon.framework.parameters.Parameters params, int mode)`
`java.lang.String[]` | `searchWithParams(org.apache.avalon.framework.parameters.Parameters params)` Search entities in SDX system databases with two parameters and a single table.
`long` | `size()` Returns the number of entities within this database.
`void` | `update(DatabaseEntity ent)` Updates an entity.

Methods inherited from class fr.gouv.culture.sdx.utils.rdbms.DataSourceComponentBacked
`finalize, getDataSourceComponent, releaseDataSourceComponent, service`

Methods inherited from class fr.gouv.culture.sdx.utils.rdbms.JDBC
`createTable, getTableName, handleUnsupportedTokens, initVolatileObjectsToSax`

Methods inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject
`configureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, initToSax, 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.database.Database
`getDatabaseDirectoryName, optimize`

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 fr.gouv.culture.sdx.utils.Identifiable
`getId, setId`

Methods inherited from interface fr.gouv.culture.sdx.utils.Describable
`getDescription, setDescription`

Methods inherited from interface fr.gouv.culture.sdx.utils.Encodable
`getEncoding, setEncoding`

Methods inherited from interface fr.gouv.culture.sdx.utils.Localizable
`getLocale, getXmlLang, setLocale, setXmlLang`

Methods inherited from interface org.apache.excalibur.xml.sax.XMLizable
`toSAX`

Field Detail

### FIELD_ID

    protected final java.lang.String FIELD_ID

See Also:
  Constant Field Values

### FIELD_PROPERTY_NAME

    protected final java.lang.String FIELD_PROPERTY_NAME

See Also:
  Constant Field Values

### FIELD_PROPERTY_VALUE

    protected final java.lang.String FIELD_PROPERTY_VALUE

See Also:
  Constant Field Values

### COLUMN_PARAM_INDEX_FIELD_ID

    protected final int COLUMN_PARAM_INDEX_FIELD_ID

See Also:
  Constant Field Values

### COLUMN_PARAM_INDEX_FIELD_PROPERTY_NAME

    protected final int COLUMN_PARAM_INDEX_FIELD_PROPERTY_NAME

See Also:
  Constant Field Values

### COLUMN_PARAM_INDEX_FIELD_PROPERTY_VALUE

    protected final int COLUMN_PARAM_INDEX_FIELD_PROPERTY_VALUE

See Also:
  Constant Field Values

### _searchModes

    public static final java.lang.String[] _searchModes

Constructor Detail

### AbstractJDBCDatabase

    public AbstractJDBCDatabase()

Method Detail

### 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 `DataSourceComponentBacked`
  Throws:
    `org.apache.avalon.framework.configuration.ConfigurationException`

### getEntity

    public DatabaseEntity getEntity(java.lang.String id)
                             throws SDXException

  Description copied from interface: `Database`
  Gets an entity from the database.

  Specified by:
    `getEntity` in interface `Database`
  Parameters:
    `id` - The needed entity's id.
  Throws:
    `SDXException`

### getEntities

    public DatabaseEntity[] getEntities()
                                 throws SDXException

  Description copied from interface: `Database`
  Returns the list of entities from the database.

  Specified by:
    `getEntities` in interface `Database`
  Throws:
    `SDXException`

### getPropertyValue

    public java.lang.String getPropertyValue(java.lang.String entityId,
                                             java.lang.String name)
                                      throws SDXException

  Description copied from interface: `Database`
  Returns a property value from an entity in the database.

  Specified by:
    `getPropertyValue` in interface `Database`
  Parameters:
    `entityId` - The needed entity's id.
    `name` - The needed property's name.
  Returns:
    The property is defined, otherwise `null`. If the property is defined more than once, the first value is returned.
  Throws:
    `SDXException`

### getPropertyValues

    public java.lang.String[] getPropertyValues(java.lang.String entityId,
                                                java.lang.String propertyName)
                                         throws SDXException

  Description copied from interface: `Database`
  Returns a repeatable property from an entity in the database.

  Specified by:
    `getPropertyValues` in interface `Database`
  Parameters:
    `entityId` - The needed entity's name.
    `propertyName` - The needed property's name.
  Returns:
    An enumeration of all values for this property, `null` is this property is not defined for this entity.
  Throws:
    `SDXException`

### getProperties

    public Property[] getProperties(java.lang.String entityId)
                             throws SDXException

  Description copied from interface: `Database`
  Returns all properties from an entity in the database.

  Specified by:
    `getProperties` in interface `Database`
  Throws:
    `SDXException`

### save

    public void save(DatabaseEntity ent)
              throws SDXException

  Description copied from interface: `Database`
  Saves an entity.

  Specified by:
    `save` in interface `Database`
  Throws:
    `SDXException`

### delete

    public void delete(DatabaseEntity ent)
                throws SDXException

  Description copied from interface: `Database`
  Deletes an entity.

  Specified by:
    `delete` in interface `Database`
  Throws:
    `SDXException`

### delete

    public void delete(DatabaseEntity[] entities)
                throws SDXException

  Throws:
    `SDXException`

### update

    public void update(DatabaseEntity ent)
                throws SDXException

  Description copied from interface: `Database`
  Updates an entity.

  Specified by:
    `update` in interface `Database`
  Throws:
    `SDXException`

### size

    public long size()

  Description copied from interface: `Database`
  Returns the number of entities within this database.

  Specified by:
    `size` in interface `Database`

### empty

    public void empty()
               throws SDXException

  Description copied from interface: `Database`
  Empties the database.

  Specified by:
    `empty` in interface `Database`
  Throws:
    `SDXException`

### entityExists

    public boolean entityExists(java.lang.String id)

  Description copied from interface: `Database`
  Checks whether an entity with the provided id exists within this database

  Specified by:
    `entityExists` in interface `Database`
  Parameters:
    `id` - _identifier of the entity

### search

    public java.lang.String[] search(org.apache.avalon.framework.parameters.Parameters params)
                              throws SDXException

  Description copied from interface: `Database`
  Returns an array of database entity ids based upon the provided search parameters One can used Database.getEntity(id) after retrieving a list of ids with this method.

  Specified by:
    `search` in interface `Database`
  Parameters:
    `params` - search params
  Throws:
    `SDXException`
  See Also:
    `Database.search(org.apache.avalon.framework.parameters.Parameters)`

### search

    public java.lang.String[] search(org.apache.avalon.framework.parameters.Parameters params,
                                     int mode)
                              throws SDXException

  Specified by:
    `search` in interface `Database`
  Throws:
    `SDXException`

### searchWithParams

    public java.lang.String[] searchWithParams(org.apache.avalon.framework.parameters.Parameters params)
                                        throws SDXException

  Search entities in SDX system databases with two parameters and a single table. Syntax avalaible in MySQL and HSQL. More than two parameters not implemented at this time. -mp

  Throws:
    `SDXException`

### init

    public void init()
              throws SDXException

  Initializes the repository. If there are no tables in the database, we create the necessary table

  Specified by:
    `init` in interface `Database`
  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.

  Specified by:
    `getTableCreationQuery` in class `JDBC`
  Returns:
    The query. see subclasses for implementation

### getEntityGetQuery

    protected java.lang.String getEntityGetQuery()

  Returns an SQL query that could select a entity using its id.

  This query should have one parameter for the id.

  Returns:
    The query.

### getAllEntitiesQuery

    protected java.lang.String getAllEntitiesQuery()

### getEntriesWithLimitQuery

    protected abstract java.lang.String getEntriesWithLimitQuery(long offset,
                                                                 long number)

  Implementation of statement with a limit parameter

  Parameters:
    `offset` -
    `number` -
  Returns:
    the query

### getEntityDeleteQuery

    protected java.lang.String getEntityDeleteQuery()

### getPropertyAddQuery

    protected java.lang.String getPropertyAddQuery()

### getPropertyRemoveQueryWithId

    protected java.lang.String getPropertyRemoveQueryWithId()

### getPropertyRemoveQueryWithoutId

    protected java.lang.String getPropertyRemoveQueryWithoutId()

### getDeleteAllQuery

    protected java.lang.String getDeleteAllQuery()

### getCreateIndiciesQuery

    protected java.lang.String getCreateIndiciesQuery(java.lang.String fieldName)

### getEntity

    protected DatabaseEntity getEntity(java.lang.String id,
                                       java.sql.ResultSet rs)
                                throws SDXException

  Calling methods should close ResultSet after calling this method

  Parameters:
    `id` -
    `rs` -
  Returns:
  Throws:
    `SDXException`

### getEntities

    protected DatabaseEntity[] getEntities(java.sql.ResultSet rs)
                                    throws SDXException

  Calling methods should close ResultSet after calling this method

  Parameters:
    `rs` -
  Returns:
  Throws:
    `SDXException`

### getEntityIds

    protected java.lang.String[] getEntityIds(java.sql.ResultSet rs)
                                       throws SDXException

  Calling methods should close ResultSet after calling this method

  Parameters:
    `rs` -
  Returns:
  Throws:
    `SDXException`

### createIndicies

    protected void createIndicies(java.sql.Connection conn)
                           throws SDXException

  Creates and index on the "id" field.

  Throws:
    `SDXException`

### addProperty

    public void addProperty(java.lang.String entityId,
                            java.lang.String propertyName,
                            java.lang.String propertyValue)
                     throws SDXException

  If the entity does not exist the method fails silently

  Specified by:
    `addProperty` in interface `Database`
  Parameters:
    `entityId` -
    `propertyName` -
    `propertyValue` -
  Throws:
    `SDXException`

### removeProperty

    public void removeProperty(java.lang.String entityId,
                               java.lang.String propertyName,
                               java.lang.String propertyValue)
                        throws SDXException

  If the entity does not exist the method fails silently

  Specified by:
    `removeProperty` in interface `Database`
  Parameters:
    `entityId` -
    `propertyName` -
    `propertyValue` -
  Throws:
    `SDXException`

### removeProperty

    public void removeProperty(java.lang.String propertyName,
                               java.lang.String propertyValue)
                        throws SDXException

  Description copied from interface: `Database`
  Removes a property with the provided name and value from the and EXISTING entity having the name/value pair It is up to the implementation to determine proper behavior if the entity with the provided id does not exist.

  Specified by:
    `removeProperty` in interface `Database`
  Parameters:
    `propertyName` - The property to remove
    `propertyValue` - The property value
  Throws:
    `SDXException`

### getConnection

    public DatabaseConnection getConnection()
                                     throws SDXException

  Specified by:
    `getConnection` in interface `Database`
  Throws:
    `SDXException`

### releaseConnection

    public void releaseConnection(DatabaseConnection conn)
                           throws SDXException

  Specified by:
    `releaseConnection` in interface `Database`
  Throws:
    `SDXException`

### getClassNameSuffix

    protected java.lang.String getClassNameSuffix()

  Description copied from class: `AbstractSdxObject`
  Sub classes should element this method to return their class name suffix for SAX output

  Specified by:
    `getClassNameSuffix` in class `AbstractSdxObject`

### getWildcardSearchToken

    public java.lang.String getWildcardSearchToken()

  Description copied from interface: `Database`
  Returns a String representing the appropriate wildcard search token for the implementation

  Specified by:
    `getWildcardSearchToken` in interface `Database`

### backup

    public void backup(SaveParameters save_config)
                throws SDXException

  Description copied from interface: `Saveable`
  The backup method gives a way to an object to save its data

  Specified by:
    `backup` in interface `Saveable`
  Throws:
    `SDXException`

### restore

    public void restore(SaveParameters save_config)
                 throws SDXException

  Description copied from interface: `Saveable`
  The restore method gives a way to an object to restore its data from a backup.

  Specified by:
    `restore` in interface `Saveable`
  Parameters:
    `save_config` -
  Throws:
    `SDXException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2003 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.