de.folt.models.datamodel.db4o
Class DB4O

java.lang.Object
  extended by java.util.Observable
      extended by de.folt.models.datamodel.BasicDataSource
          extended by de.folt.models.datamodel.db4o.DB4O
All Implemented Interfaces:
DataSource, java.util.Enumeration<MultiLingualObject>, java.util.Observer

public class DB4O
extends BasicDataSource

Author:
klemens

Nested Class Summary
 
Nested classes/interfaces inherited from class de.folt.models.datamodel.BasicDataSource
BasicDataSource.BasicDataSourceObserver
 
Constructor Summary
DB4O(DataSourceProperties dataModelProperties)
           
 
Method Summary
 boolean addMonoLingualObject(MonoLingualObject monoLingualObject, boolean mergeObjects)
          addMultiLingualObject adds a MonoLingualObject to the given MultiLingualObject to the data source
 boolean addMultiLingualObject(MultiLingualObject multiLingualObject, boolean mergeObjects)
          addMultiLingualObject adds a MultiLingualObject to the data source
 boolean bPersist()
          bPersist method persists any data in the data source
 TranslationCheckResult checkIfTranslationExistsInDataSource(java.lang.String sourceSegment, java.lang.String sourceLanguage, java.lang.String targetSegment, java.lang.String targetLanguage)
          checkIfTranslationExistsInDataSource function checks if for a given combination of source segment/source language - target segment (translation)/target language a translation exists
 void cleanDataSource()
          cleanDataSource method is used to allow some clean operations e.g. after an instance has been loaded.
 boolean clearDataSource()
          clearDataSource removes the content in a data source.
 int copyFrom(DataSource dataSource)
          copyFrom copies the content of the data source dataSource to the this data source; this requires that the data source implements the methods nextElement; iniEnumeration and hasMoreElements.
 int copyTo(DataSource dataSource)
          copyTo copies the content of this data source to the specified data source; this requires that the data source implements the methods nextElement; iniEnumeration and hasMoreElements.
 boolean createDataSource(DataSourceProperties dataModelProperties)
          createDataSource creates a new Data source; this is esp. intended for creating a new database, e.g. in MySQL or Ms SQL Server.
 boolean deleteDataSource(DataSourceProperties dataModelProperties)
          deleteDataSource deletes an existing Data source; this is esp. intended for deleting a database, e.g. in MySQL or Ms SQL Server.
 java.lang.String getDataSourceType()
          getDataSourceType get the type of the database
 boolean hasMoreElements()
           
 void initEnumeration()
          initEnumeration initialises the Enumeration of the data source
static void main(java.lang.String[] args)
          main
 MultiLingualObject nextElement()
           
 void removeDataSource()
          removeDataSource method called when the DataSource should be removed
 boolean removeMonoLingualObject(MonoLingualObject monoLingualObject)
          removeMonoLingualObject removes a MonoLingualObject from the data source; not all data source may support this method and may return false in any case (e.g.
 boolean removeMultiLingualObject(MultiLingualObject multiLingualObject)
          removeMultiLingualObject removes a MultiLingualObject from the data source
 void setDataSourceType()
          setDataSourceType sets the type of the data source
 org.jdom.Element translate(org.jdom.Element transUnit, org.jdom.Element file, XliffDocument xliffDocument, java.lang.String sourceLanguage, java.lang.String targetLanguage, int matchSimilarity, java.util.Hashtable<java.lang.String,java.lang.Object> translationParameters)
          translate translates a trans-unit given the source language, target Language and match similarity
 
Methods inherited from class de.folt.models.datamodel.BasicDataSource
addData, bAuthenticate, bSupportMultiThreading, changedMonolingualObjects, checkIfTranslationExistsInDataSource, containsKey, containsValue, currentTimeMillis, exportTmxFile, exportXliffFile, getAllAttributes, getChangedIds, getData, getDataSourceName, getDataSourceProperties, getDefaultDataSourceConfigurationsFileName, getFuzzyTree, getIds, getILogLevel, getLastErrorCode, getMonoLingualObjectFromId, getMonoLingualObjectFromUniqueId, getMultiLingualObjectCache, getMultiLingualObjectFromId, getMultiLingualObjectFromUniqueId, getUniqueIds, importTbxFile, importTmxFile, importXliffFile, isBChanged, isBLoadAttributesLazy, isSyncDataSource, removeData, runFilterMethod, saveModifiedMonoLingualObject, saveModifiedMultiLingualObject, search, searchRegExp, searchWordBased, setBChanged, setBLoadAttributesLazy, setDefaultDataSourceConfigurationsFileName, setILogLevel, setILogLevel, setLastErrorCode, setMultiLingualObjectCache, setOpenTMSPropertiesFile, subSegmentResultsToGlossary, subSegmentTranslate, update, update
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DB4O

public DB4O(DataSourceProperties dataModelProperties)
Parameters:
dataModelProperties - the data model parameters
Main Key: dataModelProperties.getDataSourceProperty("database"); - the name of the database
Method Detail

main

public static void main(java.lang.String[] args)
main

Parameters:
args -

addMonoLingualObject

public boolean addMonoLingualObject(MonoLingualObject monoLingualObject,
                                    boolean mergeObjects)
Description copied from interface: DataSource
addMultiLingualObject adds a MonoLingualObject to the given MultiLingualObject to the data source

Specified by:
addMonoLingualObject in interface DataSource
Overrides:
addMonoLingualObject in class BasicDataSource
Parameters:
monoLingualObject - the MOL object to add
mergeObjects - if true first a search is done if the containing MonoLingualObjects exist in the data source (based on the segment text); if they exist they are merged; if false the MUL is added as new entry
Returns:
true if added; false if the MultiLingualObject does not exist

addMultiLingualObject

public boolean addMultiLingualObject(MultiLingualObject multiLingualObject,
                                     boolean mergeObjects)
Description copied from interface: DataSource
addMultiLingualObject adds a MultiLingualObject to the data source

Specified by:
addMultiLingualObject in interface DataSource
Overrides:
addMultiLingualObject in class BasicDataSource
Parameters:
multiLingualObject - the object to add
mergeObjects - if true first a search is done if the containing MonoLingualObjects exist in the data source (based on the segment text); if they exist they are merged; if false the MUL is added as new entry
Returns:
true if added; false if not

bPersist

public boolean bPersist()
Description copied from interface: DataSource
bPersist method persists any data in the data source

Specified by:
bPersist in interface DataSource
Overrides:
bPersist in class BasicDataSource
Returns:
true in case of success or false otherwise

checkIfTranslationExistsInDataSource

public TranslationCheckResult checkIfTranslationExistsInDataSource(java.lang.String sourceSegment,
                                                                   java.lang.String sourceLanguage,
                                                                   java.lang.String targetSegment,
                                                                   java.lang.String targetLanguage)
Description copied from interface: DataSource
checkIfTranslationExistsInDataSource function checks if for a given combination of source segment/source language - target segment (translation)/target language a translation exists

Specified by:
checkIfTranslationExistsInDataSource in interface DataSource
Overrides:
checkIfTranslationExistsInDataSource in class BasicDataSource
Parameters:
sourceSegment - the source segment
sourceLanguage - the source language
targetSegment - the target segment
targetLanguage - the target language
Returns:
a TranslationCheckResult (for more details see TranslationCheckResult)

cleanDataSource

public void cleanDataSource()
Description copied from interface: DataSource
cleanDataSource method is used to allow some clean operations e.g. after an instance has been loaded.
An example is disposing a tmx document after having read all the entries.

Specified by:
cleanDataSource in interface DataSource
Overrides:
cleanDataSource in class BasicDataSource

clearDataSource

public boolean clearDataSource()
                        throws OpenTMSException
Description copied from interface: DataSource
clearDataSource removes the content in a data source. In addition it can be used to delete a TMX data source.

Specified by:
clearDataSource in interface DataSource
Overrides:
clearDataSource in class BasicDataSource
Returns:
true if success
Throws:
OpenTMSException

copyFrom

public int copyFrom(DataSource dataSource)
Description copied from interface: DataSource
copyFrom copies the content of the data source dataSource to the this data source; this requires that the data source implements the methods nextElement; iniEnumeration and hasMoreElements. Those methods are used to get the MultiLingualObject and store them.

Specified by:
copyFrom in interface DataSource
Overrides:
copyFrom in class BasicDataSource

copyTo

public int copyTo(DataSource dataSource)
Description copied from interface: DataSource
copyTo copies the content of this data source to the specified data source; this requires that the data source implements the methods nextElement; iniEnumeration and hasMoreElements. Those methods are used to get the MultiLingualObject and store them.

Specified by:
copyTo in interface DataSource
Overrides:
copyTo in class BasicDataSource

createDataSource

public boolean createDataSource(DataSourceProperties dataModelProperties)
                         throws OpenTMSException
Description copied from interface: DataSource
createDataSource creates a new Data source; this is esp. intended for creating a new database, e.g. in MySQL or Ms SQL Server. In addition it can be used to create a new empty TMX data source.

Specified by:
createDataSource in interface DataSource
Overrides:
createDataSource in class BasicDataSource
Parameters:
dataModelProperties - the parameters of the data source
Returns:
true if success
Throws:
OpenTMSException

deleteDataSource

public boolean deleteDataSource(DataSourceProperties dataModelProperties)
                         throws OpenTMSException
Description copied from interface: DataSource
deleteDataSource deletes an existing Data source; this is esp. intended for deleting a database, e.g. in MySQL or Ms SQL Server. In addition it can be used to delete a TMX data source.
Currently supported key values are:
tmxfile, tmxFile, dataSourceName, dataSource, xlifffile, xliffFile - specifies names of the data sources
sourceLanguage if an xliff File datasource is created default = de
targetLanguage if an xliff File datasource is created default = en

Specified by:
deleteDataSource in interface DataSource
Overrides:
deleteDataSource in class BasicDataSource
Parameters:
dataModelProperties - the parameters of the data source
Returns:
true if success
Throws:
OpenTMSException

getDataSourceType

public java.lang.String getDataSourceType()
Description copied from interface: DataSource
getDataSourceType get the type of the database

Specified by:
getDataSourceType in interface DataSource
Overrides:
getDataSourceType in class BasicDataSource
Returns:
the data source type

hasMoreElements

public boolean hasMoreElements()
Specified by:
hasMoreElements in interface java.util.Enumeration<MultiLingualObject>
Overrides:
hasMoreElements in class BasicDataSource

initEnumeration

public void initEnumeration()
Description copied from interface: DataSource
initEnumeration initialises the Enumeration of the data source

Specified by:
initEnumeration in interface DataSource
Overrides:
initEnumeration in class BasicDataSource

nextElement

public MultiLingualObject nextElement()
Specified by:
nextElement in interface java.util.Enumeration<MultiLingualObject>
Overrides:
nextElement in class BasicDataSource

removeDataSource

public void removeDataSource()
Description copied from interface: DataSource
removeDataSource method called when the DataSource should be removed

Specified by:
removeDataSource in interface DataSource
Overrides:
removeDataSource in class BasicDataSource

removeMonoLingualObject

public boolean removeMonoLingualObject(MonoLingualObject monoLingualObject)
Description copied from interface: DataSource
removeMonoLingualObject removes a MonoLingualObject from the data source; not all data source may support this method and may return false in any case (e.g. XliffDataSource)

Specified by:
removeMonoLingualObject in interface DataSource
Overrides:
removeMonoLingualObject in class BasicDataSource
Parameters:
monoLingualObject - the MUL to remove
Returns:
true if removed; false if not

removeMultiLingualObject

public boolean removeMultiLingualObject(MultiLingualObject multiLingualObject)
Description copied from interface: DataSource
removeMultiLingualObject removes a MultiLingualObject from the data source

Specified by:
removeMultiLingualObject in interface DataSource
Overrides:
removeMultiLingualObject in class BasicDataSource
Parameters:
multiLingualObject - the MOL to remove
Returns:
true if removed; false if not

setDataSourceType

public void setDataSourceType()
Description copied from interface: DataSource
setDataSourceType sets the type of the data source

Specified by:
setDataSourceType in interface DataSource
Overrides:
setDataSourceType in class BasicDataSource

translate

public org.jdom.Element translate(org.jdom.Element transUnit,
                                  org.jdom.Element file,
                                  XliffDocument xliffDocument,
                                  java.lang.String sourceLanguage,
                                  java.lang.String targetLanguage,
                                  int matchSimilarity,
                                  java.util.Hashtable<java.lang.String,java.lang.Object> translationParameters)
                           throws OpenTMSException
Description copied from interface: DataSource
translate translates a trans-unit given the source language, target Language and match similarity

Specified by:
translate in interface DataSource
Overrides:
translate in class BasicDataSource
Parameters:
transUnit - the trans unit to translate to use
file - the file element currently to translate
xliffDocument - the basic xliff document
sourceLanguage - the source language to use
targetLanguage - the target language to use
matchSimilarity - the similarity (fuzzy) match quality (0 - 100) to use
translationParameters - the hash table contains parameters which control some parameters, e.g. should header/source/target properties be written to alt-trans
Returns:
the modified trans-unit with new translation
Throws:
OpenTMSException