|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfr.gouv.culture.sdx.utils.AbstractSdxObject
fr.gouv.culture.sdx.utils.lucene.LuceneDataStore
fr.gouv.culture.sdx.utils.database.LuceneDatabase
An implementation of database operations using Lucene.
For a detailed description of the database abstraction in SDX, please see the Database interface.
When creating a LuceneDatabase object, these steps should be followed :
| Nested Class Summary |
| Nested classes inherited from class fr.gouv.culture.sdx.utils.SdxObject |
SdxObject.ConfigurationNode |
| Field Summary | |
protected java.lang.String |
DATABASE_DIR_NAME
|
protected java.lang.String |
id
|
| Fields inherited from class fr.gouv.culture.sdx.utils.lucene.LuceneDataStore |
ALL_FIELD, ALL_VALUE, analyzer, fsd, fsdFile, ID_FIELD, LUCENE_CHECK_FILE, searcher, useCompoundFiles, XML_LANG_FIELD |
| 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 | |
LuceneDatabase()
|
|
LuceneDatabase(java.io.File dir)
Gets or creates a _database stored at a given dir. |
|
| 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)
|
void |
delete(DatabaseEntity ent)
Deletes an entity from the database. |
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 |
getClassNameSuffix()
Sub classes should element this method to return their class name suffix for SAX output |
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 within the database. |
protected DatabaseEntity |
getEntity(org.apache.lucene.document.Document ldoc)
Builds an entity from a Lucene document. |
DatabaseEntity |
getEntity(java.lang.String id)
Returns an entity for a given id. |
java.lang.String |
getIndexPath()
Return's the absolute path for the directory in which the database resides |
Property[] |
getProperties(java.lang.String entityId)
Returns all properties from an entity in the database. |
java.lang.String |
getProperty(java.lang.String documentId,
java.lang.String property)
Searches database for a given document id, and then returns the content of the specified field. |
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 Lucene database. |
protected boolean |
initToSax()
Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML |
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)
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 entity)
Saves an entity within the database. |
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. |
protected void |
write(org.apache.lucene.document.Document lDoc)
Writes a document to the index |
| Methods inherited from class fr.gouv.culture.sdx.utils.lucene.LuceneDataStore |
delete, delete, delete, delete, finalize, freeResources, getFSDirectory, getFSDirectory, getReader, getSearcher, getWriter, getWriter, init, initVolatileObjectsToSax, isUsingCompoundFiles, recycleSearcher, search, search, verifyIndex, writeLuceneData |
| Methods inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject |
configureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, service, 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 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 |
protected java.lang.String DATABASE_DIR_NAME
protected java.lang.String id
| Constructor Detail |
public LuceneDatabase()
public LuceneDatabase(java.io.File dir)
throws SDXException
One should call the enableLogging() method before using this database, otherwise errors won't be logged.
Most of all, you should call the init() method to make sure that the database can be used.
dir - The directory where the Lucene database is stored.| Method Detail |
public void init()
throws SDXException
It the database exists, nothing is done here. If it is doesn't exist, it will be created.
init in interface DatabaseSDXException
public java.lang.String getProperty(java.lang.String documentId,
java.lang.String property)
throws SDXException
documentId - The id of the document to search for.property - The field name, or the property to search for.
SDXException
public DatabaseEntity getEntity(java.lang.String id)
throws SDXException
getEntity in interface Databaseid - The entity's id.
null if no entity has this id.
SDXException
public DatabaseEntity[] getEntities()
throws SDXException
getEntities in interface DatabaseSDXException
protected DatabaseEntity getEntity(org.apache.lucene.document.Document ldoc)
throws SDXException
ldoc - The Lucene document.
SDXException
public void save(DatabaseEntity entity)
throws SDXException
save in interface Databaseentity - The entity to save.
SDXException
protected void write(org.apache.lucene.document.Document lDoc)
throws SDXException
LuceneDataStore
write in class LuceneDataStorelDoc - The lucene document to add
SDXException
public java.lang.String getPropertyValue(java.lang.String entityId,
java.lang.String name)
throws SDXException
getPropertyValue in interface DatabaseentityId - The needed entity's id.name - The property's name for the desired value.
null. If the property is
defined more than once, the first value is returned.
SDXException
public java.lang.String[] getPropertyValues(java.lang.String entityId,
java.lang.String propertyName)
throws SDXException
Please note that this method currently doesn't work for Lucene, which still stores (?) and retrieves only the last added repeatable property.TODO:remove this note after we commit our lucene changes
getPropertyValues in interface DatabaseentityId - The needed entity's name.propertyName - The needed property's name.
null if this
property is not defined for this entity.
SDXException
public Property[] getProperties(java.lang.String entityId)
throws SDXException
getProperties in interface DatabaseentityId - The entity's id.
SDXException
public void delete(DatabaseEntity ent)
throws SDXException
delete in interface Databaseent - The entity to delete (must have an id).
A new DatabaseEntity can be created with the id set to the
id of the entity desired for deletion and then this new entity
can be passed to this method and the appropriate entity corresponding
to that id will be deleted.
SDXException
public void delete(DatabaseEntity[] entities)
throws SDXException
SDXException
public void update(DatabaseEntity ent)
throws SDXException
update in interface Databaseent - The entity to update.
SDXExceptiondelete(fr.gouv.culture.sdx.utils.database.DatabaseEntity),
save(fr.gouv.culture.sdx.utils.database.DatabaseEntity)public long size()
size in interface Databasesize in class LuceneDataStore
public void empty()
throws SDXException
empty in interface DatabaseSDXExceptionpublic java.lang.String getIndexPath()
LuceneDataStore
getIndexPath in class LuceneDataStore
public void optimize()
throws SDXException
Database
optimize in interface Databaseoptimize in class LuceneDataStoreSDXExceptionpublic boolean entityExists(java.lang.String id)
Database
entityExists in interface Databaseid - _identifier of the entity
public java.lang.String[] search(org.apache.avalon.framework.parameters.Parameters params)
throws SDXException
Database
search in interface Databaseparams - search params
SDXException
public java.lang.String[] search(org.apache.avalon.framework.parameters.Parameters params,
int mode)
throws SDXException
search in interface DatabaseSDXException
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 AbstractSdxObjectorg.apache.avalon.framework.configuration.ConfigurationExceptionpublic java.lang.String getDatabaseDirectoryName()
Database
getDatabaseDirectoryName in interface Database
public DatabaseConnection getConnection()
throws SDXException
getConnection in interface DatabaseSDXException
public void releaseConnection(DatabaseConnection conn)
throws SDXException
releaseConnection in interface DatabaseSDXException
public void addProperty(java.lang.String entityId,
java.lang.String propertyName,
java.lang.String propertyValue)
throws SDXException
addProperty in interface DatabaseentityId - propertyName - propertyValue -
SDXException
public void removeProperty(java.lang.String entityId,
java.lang.String propertyName,
java.lang.String propertyValue)
throws SDXException
removeProperty in interface DatabaseentityId - propertyName - propertyValue -
SDXException
public void removeProperty(java.lang.String propertyName,
java.lang.String propertyValue)
throws SDXException
Database
removeProperty in interface DatabasepropertyName - The property to removepropertyValue - The property value
SDXExceptionprotected java.lang.String getClassNameSuffix()
AbstractSdxObject
getClassNameSuffix in class AbstractSdxObjectpublic java.lang.String getWildcardSearchToken()
Database
getWildcardSearchToken in interface Databaseprotected boolean initToSax()
AbstractSdxObject
initToSax in class LuceneDataStore
public void backup(SaveParameters save_config)
throws SDXException
Saveable
backup in interface Saveablebackup in class LuceneDataStoreSDXExceptionSaveable.backup(fr.gouv.culture.sdx.utils.save.SaveParameters)
public void restore(SaveParameters save_config)
throws SDXException
Saveable
restore in interface Saveablerestore in class LuceneDataStoreSDXExceptionSaveable.restore(fr.gouv.culture.sdx.utils.save.SaveParameters)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||