public abstract class AbstractJDBCDatabase extends DataSourceComponentBacked implements Database
JDBC.QueryExecutor, JDBC.TemplateSdxObject.ConfigurationNode| Modifier and Type | Field and Description |
|---|---|
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 |
ATTRIBUTE_DSI, dbSelector, dsi_configuration, _context, _description, _encoding, _id, _locale, _logger, _manager, _xmlizable_objects, _xmlLang, isToSaxInitializedCLASS_NAME_SUFFIX, DATABASE_DIR_PATH, PACKAGE_QUALNAME, SEARCH_MODE_AND, SEARCH_MODE_NOT, SEARCH_MODE_ORDEFAULT_ENCODINGALL_SAVE_ATTRIB, PATH_ATTRIB, SAVE_DIRECTORY_PARAM| Constructor and Description |
|---|
AbstractJDBCDatabase() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
finalize, getDataSourceComponent, releaseDataSourceComponent, servicecreateTable, getTableName, handleUnsupportedTokens, initVolatileObjectsToSaxconfigureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, initToSax, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, toSAX, verifyConfigurationResourcesclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDatabaseDirectoryName, optimizegetId, setIdgetDescription, setDescriptiongetEncoding, setEncodinggetLocale, getXmlLang, setLocale, setXmlLangprotected final java.lang.String FIELD_ID
protected final java.lang.String FIELD_PROPERTY_NAME
protected final java.lang.String FIELD_PROPERTY_VALUE
protected final int COLUMN_PARAM_INDEX_FIELD_ID
protected final int COLUMN_PARAM_INDEX_FIELD_PROPERTY_NAME
protected final int COLUMN_PARAM_INDEX_FIELD_PROPERTY_VALUE
public static final java.lang.String[] _searchModes
public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
throws org.apache.avalon.framework.configuration.ConfigurationException
configure in interface org.apache.avalon.framework.configuration.Configurableconfigure in class DataSourceComponentBackedorg.apache.avalon.framework.configuration.ConfigurationExceptionpublic DatabaseEntity getEntity(java.lang.String id) throws SDXException
DatabasegetEntity in interface Databaseid - The needed entity's id.SDXExceptionpublic DatabaseEntity[] getEntities() throws SDXException
DatabasegetEntities in interface DatabaseSDXExceptionpublic java.lang.String getPropertyValue(java.lang.String entityId,
java.lang.String name)
throws SDXException
DatabasegetPropertyValue in interface DatabaseentityId - The needed entity's id.name - The needed property's name.null. If the property is
defined more than once, the first value is returned.SDXExceptionpublic java.lang.String[] getPropertyValues(java.lang.String entityId,
java.lang.String propertyName)
throws SDXException
DatabasegetPropertyValues in interface DatabaseentityId - The needed entity's name.propertyName - The needed property's name.null is this
property is not defined for this entity.SDXExceptionpublic Property[] getProperties(java.lang.String entityId) throws SDXException
DatabasegetProperties in interface DatabaseSDXExceptionpublic void save(DatabaseEntity ent) throws SDXException
Databasesave in interface DatabaseSDXExceptionpublic void delete(DatabaseEntity ent) throws SDXException
Databasedelete in interface DatabaseSDXExceptionpublic void delete(DatabaseEntity[] entities) throws SDXException
SDXExceptionpublic void update(DatabaseEntity ent) throws SDXException
Databaseupdate in interface DatabaseSDXExceptionpublic long size()
Databasepublic void empty()
throws SDXException
Databaseempty in interface DatabaseSDXExceptionpublic boolean entityExists(java.lang.String id)
DatabaseentityExists in interface Databaseid - _identifier of the entitypublic java.lang.String[] search(org.apache.avalon.framework.parameters.Parameters params)
throws SDXException
Databasesearch in interface Databaseparams - search paramsSDXExceptionDatabase.search(org.apache.avalon.framework.parameters.Parameters)public java.lang.String[] search(org.apache.avalon.framework.parameters.Parameters params,
int mode)
throws SDXException
search in interface DatabaseSDXExceptionpublic java.lang.String[] searchWithParams(org.apache.avalon.framework.parameters.Parameters params)
throws SDXException
SDXExceptionpublic void init()
throws SDXException
init in interface DatabaseSDXExceptionprotected java.lang.String getTableCreationQuery()
JDBCThis query should not have any parameter.
getTableCreationQuery in class JDBCprotected java.lang.String getEntityGetQuery()
This query should have one parameter for the id.
protected java.lang.String getAllEntitiesQuery()
protected abstract java.lang.String getEntriesWithLimitQuery(long offset,
long number)
offset - number - protected java.lang.String getEntityDeleteQuery()
protected java.lang.String getPropertyAddQuery()
protected java.lang.String getPropertyRemoveQueryWithId()
protected java.lang.String getPropertyRemoveQueryWithoutId()
protected java.lang.String getDeleteAllQuery()
protected java.lang.String getCreateIndiciesQuery(java.lang.String fieldName)
protected DatabaseEntity getEntity(java.lang.String id, java.sql.ResultSet rs) throws SDXException
id - rs - SDXExceptionprotected DatabaseEntity[] getEntities(java.sql.ResultSet rs) throws SDXException
rs - SDXExceptionprotected java.lang.String[] getEntityIds(java.sql.ResultSet rs)
throws SDXException
rs - SDXExceptionprotected void createIndicies(java.sql.Connection conn)
throws SDXException
SDXExceptionpublic void addProperty(java.lang.String entityId,
java.lang.String propertyName,
java.lang.String propertyValue)
throws SDXException
addProperty in interface DatabaseentityId - propertyName - propertyValue - SDXExceptionpublic void removeProperty(java.lang.String entityId,
java.lang.String propertyName,
java.lang.String propertyValue)
throws SDXException
removeProperty in interface DatabaseentityId - propertyName - propertyValue - SDXExceptionpublic void removeProperty(java.lang.String propertyName,
java.lang.String propertyValue)
throws SDXException
DatabaseremoveProperty in interface DatabasepropertyName - The property to removepropertyValue - The property valueSDXExceptionpublic DatabaseConnection getConnection() throws SDXException
getConnection in interface DatabaseSDXExceptionpublic void releaseConnection(DatabaseConnection conn) throws SDXException
releaseConnection in interface DatabaseSDXExceptionprotected java.lang.String getClassNameSuffix()
AbstractSdxObjectgetClassNameSuffix in class AbstractSdxObjectpublic java.lang.String getWildcardSearchToken()
DatabasegetWildcardSearchToken in interface Databasepublic void backup(SaveParameters save_config) throws SDXException
Saveablebackup in interface SaveableSDXExceptionpublic void restore(SaveParameters save_config) throws SDXException
Saveablerestore in interface SaveableSDXExceptionCopyright © 2000-2010 Ministere de la culture et de la communication / AJLSM. All Rights Reserved.