fr.gouv.culture.sdx.utils.database
Interface Database

All Superinterfaces:
org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, Describable, Encodable, Identifiable, Localizable, org.apache.avalon.framework.logger.LogEnabled, Saveable, SdxObject, org.apache.avalon.framework.service.Serviceable, org.apache.excalibur.xml.sax.XMLizable
All Known Implementing Classes:
AbstractDatabase, AbstractJDBCDatabase, HSQLDatabase, JDBCDatabase, LuceneDatabase, MSSQLDatabase, MYSQLDatabase, ORACLEDatabase, POSTGRESQLDatabase, UserDatabase

public interface Database
extends SdxObject, Saveable

A simple database abstraction for managing document-like simple data.

Various SDX objects must manage simple data structures : the framework keeps track of applications, an application keeps track of document bases, user and groups, a document base keeps track of repositories, etc. These management tasks share some common properties : (1) they can involve quite complex and variable data structures ; (2) the management tasks need only a few properties from these complex structures ; (3) the underlying entities are all managed by their ids.

The Database interface models a Database managing simple entities by their ids and some properties, some may be repeatable. The complex structures behind the entities are stored in XML outside of the database.

SDX implements for now only one Database class : a LuceneDatabase, which uses Lucene, SDX's underlying search engine, to manage and retrieve these entities.


Nested Class Summary
 
Nested classes/interfaces inherited from interface fr.gouv.culture.sdx.utils.SdxObject
SdxObject.ConfigurationNode
 
Field Summary
static java.lang.String CLASS_NAME_SUFFIX
           
static java.lang.String DATABASE_DIR_PATH
          Key name for the directory path in which to store database contents
static java.lang.String PACKAGE_QUALNAME
           
static int SEARCH_MODE_AND
           
static int SEARCH_MODE_NOT
           
static int 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
 
Method Summary
 void addProperty(java.lang.String entityId, java.lang.String propertyName, java.lang.String propertyValue)
          Adds a property with the provided name and value to the EXISTING entity with the provided id It is up to the implementation to determine proper behavior if the entity with the provided id does not exist.
 void delete(DatabaseEntity ent)
          Deletes an entity.
 void empty()
          Empties the database.
 boolean entityExists(java.lang.String id)
          Checks whether an entity with the provided id exists within this database
 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
 DatabaseEntity[] getEntities()
          Returns the list of entities from the database.
 DatabaseEntity getEntity(java.lang.String id)
          Gets an entity from the database.
 Property[] getProperties(java.lang.String entityId)
          Returns all properties from an entity in the database.
 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.
 java.lang.String getWildcardSearchToken()
          Returns a String representing the appropriate wildcard search token for the implementation
 void init()
          Initializes the database.
 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 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)
          Removes a property with the provided name and value to the EXISTING entity with the provided id It is up to the implementation to determine proper behavior if the entity with the provided id does not exist.
 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)
           
 long size()
          Returns the number of entities within this database.
 void update(DatabaseEntity ent)
          Updates an entity.
 
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.avalon.framework.configuration.Configurable
configure
 
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
 
Methods inherited from interface fr.gouv.culture.sdx.utils.save.Saveable
backup, restore
 

Field Detail

SEARCH_MODE_OR

static final int SEARCH_MODE_OR
See Also:
Constant Field Values

SEARCH_MODE_AND

static final int SEARCH_MODE_AND
See Also:
Constant Field Values

SEARCH_MODE_NOT

static final int SEARCH_MODE_NOT
See Also:
Constant Field Values

DATABASE_DIR_PATH

static final java.lang.String DATABASE_DIR_PATH
Key name for the directory path in which to store database contents

See Also:
Constant Field Values

PACKAGE_QUALNAME

static final java.lang.String PACKAGE_QUALNAME
See Also:
Constant Field Values

CLASS_NAME_SUFFIX

static final java.lang.String CLASS_NAME_SUFFIX
See Also:
Constant Field Values
Method Detail

getEntity

DatabaseEntity getEntity(java.lang.String id)
                         throws SDXException
Gets an entity from the database.

Parameters:
id - The needed entity's id.
Throws:
SDXException

getEntities

DatabaseEntity[] getEntities()
                             throws SDXException
Returns the list of entities from the database.

Throws:
SDXException

getPropertyValue

java.lang.String getPropertyValue(java.lang.String entityId,
                                  java.lang.String name)
                                  throws SDXException
Returns a property value from an entity in the 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

java.lang.String[] getPropertyValues(java.lang.String entityId,
                                     java.lang.String propertyName)
                                     throws SDXException
Returns a repeatable property from an entity in the 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

Property[] getProperties(java.lang.String entityId)
                         throws SDXException
Returns all properties from an entity in the database.

Throws:
SDXException

save

void save(DatabaseEntity ent)
          throws SDXException
Saves an entity.

Throws:
SDXException

delete

void delete(DatabaseEntity ent)
            throws SDXException
Deletes an entity.

Throws:
SDXException

update

void update(DatabaseEntity ent)
            throws SDXException
Updates an entity.

Throws:
SDXException

size

long size()
Returns the number of entities within this database.


empty

void empty()
           throws SDXException
Empties the database.

Throws:
SDXException

init

void init()
          throws SDXException
Initializes the database.

Throws:
SDXException

entityExists

boolean entityExists(java.lang.String id)
Checks whether an entity with the provided id exists within this database

Parameters:
id - _identifier of the entity

getWildcardSearchToken

java.lang.String getWildcardSearchToken()
Returns a String representing the appropriate wildcard search token for the implementation


search

java.lang.String[] search(org.apache.avalon.framework.parameters.Parameters params)
                          throws SDXException
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.

Parameters:
params - search params
Throws:
SDXException

optimize

void optimize()
              throws SDXException
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

getDatabaseDirectoryName

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

Returns:
A directory name (not a full path)

getConnection

DatabaseConnection getConnection()
                                 throws SDXException
Throws:
SDXException

releaseConnection

void releaseConnection(DatabaseConnection conn)
                       throws SDXException
Throws:
SDXException

addProperty

void addProperty(java.lang.String entityId,
                 java.lang.String propertyName,
                 java.lang.String propertyValue)
                 throws SDXException
Adds a property with the provided name and value to the EXISTING entity with the provided id It is up to the implementation to determine proper behavior if the entity with the provided id does not exist.

Parameters:
entityId - The entity to update
propertyName - The property to add
propertyValue - The property value
Throws:
SDXException

removeProperty

void removeProperty(java.lang.String entityId,
                    java.lang.String propertyName,
                    java.lang.String propertyValue)
                    throws SDXException
Removes a property with the provided name and value to the EXISTING entity with the provided id It is up to the implementation to determine proper behavior if the entity with the provided id does not exist.

Parameters:
entityId - The entity to update
propertyName - The property to remove
propertyValue - The property value
Throws:
SDXException

removeProperty

void removeProperty(java.lang.String propertyName,
                    java.lang.String propertyValue)
                    throws SDXException
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.

Parameters:
propertyName - The property to remove
propertyValue - The property value
Throws:
SDXException

search

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


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