de.folt.models.datamodel
Class BasicDataSource

java.lang.Object
  extended by java.util.Observable
      extended by de.folt.models.datamodel.BasicDataSource
All Implemented Interfaces:
DataSource, java.util.Enumeration<MultiLingualObject>, java.util.Observer
Direct Known Subclasses:
ArayaDataSource, DB4O, ExtendedBasicDataSource, GoogleTranslate, IateTerminology, MicrosoftTranslate, MTMoses, MultiLingualObjectCollection, MultipleDataSource, OpenTMSSQLDataSource, ParallelCorpus, TbxFileDataSource, TmxFileDataSource, TradosTMDataSource, XliffFileDataSource

public class BasicDataSource
extends java.util.Observable
implements DataSource

This class implements a basic data source (implements the DataSource interface) and is intended to be sub classed for specific data sources like TMX file data source or similar. See also the subclass de.folt.models.datamodel.ExtendedBasicSource

Author:
klemens

Nested Class Summary
 class BasicDataSource.BasicDataSourceObserver
          Class implements a simple Observer for a basic data source
 
Constructor Summary
BasicDataSource()
          Standard Constructor for basic data source
BasicDataSource(DataSourceProperties dataSourceProperties)
          Creates a basic data source based on the supplied dataSourceProperties.
BasicDataSource(java.lang.String propertiesFileName)
           
 
Method Summary
 void addData(java.lang.String key, java.lang.Object object)
          addData this allows to add a whatever object to the data source based on a key
 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 bAuthenticate(java.lang.String userName, java.lang.String password)
          bAuthenticate checks if for a given data source access is granted thru user and password
 boolean bPersist()
          bPersist method persists any data in the data source
 boolean bSupportMultiThreading()
          bSupportMultiThreading defines support of multi threading (mainly for translate method)
 java.util.Vector<MonoLingualObject> changedMonolingualObjects()
          changedMonolingualObjects
 TranslationCheckResult checkIfTranslationExistsInDataSource(MonoLingualObject source, MonoLingualObject target)
          checkIfTranslationExistsInDataSource Method checks if a for a given source and target MOL matches in the data source exist.
 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.
 boolean containsKey(java.lang.String key)
          containsKey checks if a key exists
 boolean containsValue(java.lang.Object object)
          containsValue checks if a key exists
 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.
 long currentTimeMillis()
          currentTimeMillis This method returns the current time as a String.
 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.
 int exportTmxFile(java.lang.String tmxFile)
          exportTmxFile exports the data source into an tmx file
 int exportXliffFile(java.lang.String xliffFile)
          exportXliffFile export the xliff file from the data source;
 void getAllAttributes(java.lang.String outputfile)
          Write all Attributes and values to output file
 java.util.Vector<java.lang.Integer> getChangedIds()
          getChangedIds this method returns a vector of Integers of changed MULs which uniquely identify each MUL of the data source
 java.lang.Object getData(java.lang.String key)
          getData retrieves an object associated with the key
 java.lang.String getDataSourceName()
          getDataSourceName returns the name of the data source
 DataSourceProperties getDataSourceProperties()
          getDataSourceProperties returns the DataSourceProperties of the data source
 java.lang.String getDataSourceType()
          getDataSourceType get the type of the database
 java.lang.String getDefaultDataSourceConfigurationsFileName()
          getDefaultDataSourceConfigurationsFileName return the name of the default data source configurations file name
 MonoLingualPartitionedFuzzyNodeTree getFuzzyTree()
           
 java.util.Vector<java.lang.Integer> getIds()
          getIds this method returns a vector of Integers which uniquely identify each MUL of the data source
 int getILogLevel()
           
 int getLastErrorCode()
          getLastErrorCode Method returns the last error code for an operation done by the data source
 MonoLingualObject getMonoLingualObjectFromId(java.lang.String uniqueID)
          getMonoLingualObjectFromId search an MOL based on its (integer) id
 MonoLingualObject getMonoLingualObjectFromUniqueId(java.lang.String uniqueID)
          getMonoLingualObjectFromUniqueId search an MOL based on its (integer) id
 ObservableHashtable<java.lang.String,MultiLingualObject> getMultiLingualObjectCache()
          multiLingualObjectCache is a cache object which can be used by the data sources to store read MultiLingual Objects.
 MultiLingualObject getMultiLingualObjectFromId(java.lang.String id)
          getMultiLingualObjectFromId search an MUL based on its unique id
 MultiLingualObject getMultiLingualObjectFromUniqueId(java.lang.String id)
          getMultiLingualObjectFromUniqueId search an MUL based on its unique id
 java.util.Vector<java.lang.String> getUniqueIds()
          getUniqueIds this method returns a vector of strings which uniquely identify each MUL of the data source
 boolean hasMoreElements()
           
 int importTbxFile(java.lang.String tbxFile)
          importTbxFile imports a tbx file into the data source;
 int importTmxFile(java.lang.String tmxFile)
          importTmxFile import a tmx file into the datasource
 int importXliffFile(java.lang.String xliffFile)
          importXliffFile imports an xliff file into the data source; it imports the approved source / target's of the trans-units
 void initEnumeration()
          initEnumeration initialises the Enumeration of the data source
 boolean isBChanged()
           
 boolean isBLoadAttributesLazy()
          This method determines if the attributes of MultiLingualObjects or MonoLingualObjects should be loaded at the time when the data source is created (false) or when they are actually needed (true).
 boolean isSyncDataSource()
          This methods returns true if the data source (the instance of the data source) is a synchronizable data source instance.
static void main(java.lang.String[] args)
           
 MultiLingualObject nextElement()
           
 java.lang.Object removeData(java.lang.String key)
          removeData removes an object associated with the key
 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
 org.jdom.Element runFilterMethod(java.util.Hashtable<java.lang.String,java.lang.Object> translationParameters, org.jdom.Element transUnit)
          Run a filter on the transUnit results
 boolean saveModifiedMonoLingualObject(MonoLingualObject monoLingualObject)
          saveModifiedMonoLingualObject save a given MonoLingualObject in the data source by replacing the old values.
 boolean saveModifiedMultiLingualObject(MultiLingualObject mul)
          saveModifiedMultiLingualObject saves any modification of the MultiLingualObject, esp. doen to the LinguisticProperties
 java.util.Vector<MonoLingualObject> search(MonoLingualObject searchMonoLingualObject, java.util.Hashtable<java.lang.String,java.lang.Object> searchParameters)
          search search for a MonoLingualObject; if no language is given in the searchMonoLingualObject the search is done independent of the language
 java.util.Vector<MonoLingualObject> searchRegExp(MonoLingualObject searchMonoLingualObject, java.util.Hashtable<java.lang.String,java.lang.Object> searchParameters)
          search searchRegExp for a MonoLingualObject where the plain text represents a regular expression; if no language is given in the searchMonoLingualObject the search is done independent of the language
 java.util.Vector<MonoLingualObject> searchWordBased(MonoLingualObject searchMonoLingualObject, java.util.Hashtable<java.lang.String,java.lang.Object> searchParameters)
          search searchWordBased for a MonoLingualObject where the plain text segment is searched by splitting it up into words; if no language is given in the searchMonoLingualObject the search is done independent of the language
 void setBChanged(boolean changed)
           
 void setBLoadAttributesLazy(boolean loadAttributesLazy)
          This method sets loading of the the attributes of MultiLingualObjects or MonoLingualObjects; false = they should be loaded at the time when the data source is created or true = when they are actually needed.
 void setDataSourceType()
          setDataSourceType sets the type of the data source
 void setDefaultDataSourceConfigurationsFileName(java.lang.String defaultDataSourceConfigurationsFileName)
          setDefaultDataSourceConfigurationsFileName set the name of the default data source configurations file name
 void setILogLevel()
           
 void setILogLevel(int logLevel)
           
 void setLastErrorCode(int lastErrorCode)
          setLastErrorCode sets the error code of the currently running method of the data source
 void setMultiLingualObjectCache(ObservableHashtable<java.lang.String,MultiLingualObject> multiLingualObjectCache)
          multiLingualObjectCache is a cache object which can be used by the data sources to store read MultiLingual Objects.
static void setOpenTMSPropertiesFile(java.lang.String propFile)
          setOpenTMSPropertiesFile set the name of the OpenTMS properties file
 org.jdom.Element[] subSegmentResultsToGlossary(java.lang.String sourceLangauge, java.lang.String targetLanguage)
          subSegmentResultsToGlossary returns an array of glossary elements for the subSegment matching translations
 org.jdom.Element subSegmentTranslate(org.jdom.Element transUnit, XliffDocument xliffDocument, java.lang.String sourceLanguage, java.lang.String targetLanguage, java.util.Hashtable<java.lang.String,java.lang.Object> translationParameters)
          translate subSegmentTranslate a trans-unit given the source language, target Language on a sub segment level (e.g.phrase or terminology based)
 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
 void update()
          This method can be called after insert or similar actions to update internal stati, fuzzy trees etc.
 void update(java.util.Observable arg0, java.lang.Object arg1)
           
 
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

BasicDataSource

public BasicDataSource()
Standard Constructor for basic data source


BasicDataSource

public BasicDataSource(DataSourceProperties dataSourceProperties)
Creates a basic data source based on the supplied dataSourceProperties. The properties file is determined from the key value pair propertiesFile of dataSourceProperties.

Parameters:
dataSourceProperties - the dataSourceProperties to use for the construction

BasicDataSource

public BasicDataSource(java.lang.String propertiesFileName)
Parameters:
propertiesFileName -
Method Detail

main

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

setOpenTMSPropertiesFile

public static void setOpenTMSPropertiesFile(java.lang.String propFile)
setOpenTMSPropertiesFile set the name of the OpenTMS properties file

Parameters:
propFile - the name of the property file

addData

public void addData(java.lang.String key,
                    java.lang.Object object)
Description copied from interface: DataSource
addData this allows to add a whatever object to the data source based on a key

Specified by:
addData in interface DataSource
Parameters:
key - the key for the object
object - the value for the key

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
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
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

bAuthenticate

public boolean bAuthenticate(java.lang.String userName,
                             java.lang.String password)
Description copied from interface: DataSource
bAuthenticate checks if for a given data source access is granted thru user and password

Specified by:
bAuthenticate in interface DataSource
Parameters:
userName - the user name
password - the password
Returns:
true if user / password does match and access granted, false if user / password does not match

bPersist

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

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

bSupportMultiThreading

public boolean bSupportMultiThreading()
Description copied from interface: DataSource
bSupportMultiThreading defines support of multi threading (mainly for translate method)

Specified by:
bSupportMultiThreading in interface DataSource
Returns:
true if multi threading of data source access (for translate) is supported or not (=false)

changedMonolingualObjects

public java.util.Vector<MonoLingualObject> changedMonolingualObjects()
Description copied from interface: DataSource
changedMonolingualObjects

Specified by:
changedMonolingualObjects in interface DataSource
Returns:
a Vector of changed or new MonoLingualObjects since the last read operation

checkIfTranslationExistsInDataSource

public TranslationCheckResult checkIfTranslationExistsInDataSource(MonoLingualObject source,
                                                                   MonoLingualObject target)
Description copied from interface: DataSource
checkIfTranslationExistsInDataSource Method checks if a for a given source and target MOL matches in the data source exist.
This is a more complex version of checkIfTranslationExistsInDataSource(String sourceSegment, String sourceLanguage, String targetSegment, String targetLanguage) as it checks for the linguistic properties of the involved mono lingual objects too.

Specified by:
checkIfTranslationExistsInDataSource in interface DataSource
Parameters:
source - the source MOL
target - the target MOL
Returns:
a SearchStatusResult object

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
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

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
Returns:
true if success
Throws:
OpenTMSException

containsKey

public boolean containsKey(java.lang.String key)
Description copied from interface: DataSource
containsKey checks if a key exists

Specified by:
containsKey in interface DataSource
Parameters:
key - the key to search for
Returns:
true if key exists, otherwise false

containsValue

public boolean containsValue(java.lang.Object object)
Description copied from interface: DataSource
containsValue checks if a key exists

Specified by:
containsValue in interface DataSource
Parameters:
object - the object (value) to search for
Returns:
true if key exists, otherwise false

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

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

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
Parameters:
dataModelProperties - the parameters of the data source
Returns:
true if success
Throws:
OpenTMSException

currentTimeMillis

public long currentTimeMillis()
Description copied from interface: DataSource
currentTimeMillis This method returns the current time as a String. The method should return the date/time where the data source is running (e.g. the database server time). The method is mainly used to add time stamps to the MUL/MOL objetcs (creation, update, delete). It should return the server time in order to allow comparsion between different users running (client sided) OpenTMS software. The result is used to synchronise the acesses between differetn users/processes.

Specified by:
currentTimeMillis in interface DataSource
Returns:
date/time as a long - similar to currentTimeMillis() in Java (the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.)

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
Parameters:
dataModelProperties - the parameters of the data source
Returns:
true if success
Throws:
OpenTMSException

exportTmxFile

public int exportTmxFile(java.lang.String tmxFile)
Description copied from interface: DataSource
exportTmxFile exports the data source into an tmx file

Specified by:
exportTmxFile in interface DataSource
Parameters:
tmxFile - the tmx file to export to
Returns:
the number of entries exported

exportXliffFile

public int exportXliffFile(java.lang.String xliffFile)
Description copied from interface: DataSource
exportXliffFile export the xliff file from the data source;

Specified by:
exportXliffFile in interface DataSource
Parameters:
xliffFile - the xliff file to export
Returns:
the number of entries exported

getAllAttributes

public void getAllAttributes(java.lang.String outputfile)
Description copied from interface: DataSource
Write all Attributes and values to output file

Specified by:
getAllAttributes in interface DataSource
Parameters:
outputfile - target output file

getChangedIds

public java.util.Vector<java.lang.Integer> getChangedIds()
Description copied from interface: DataSource
getChangedIds this method returns a vector of Integers of changed MULs which uniquely identify each MUL of the data source

Specified by:
getChangedIds in interface DataSource
Returns:
a vector with the MUL unique ids

getData

public java.lang.Object getData(java.lang.String key)
Description copied from interface: DataSource
getData retrieves an object associated with the key

Specified by:
getData in interface DataSource
Parameters:
key - the key to search for
Returns:
the object found

getDataSourceName

public java.lang.String getDataSourceName()
Description copied from interface: DataSource
getDataSourceName returns the name of the data source

Specified by:
getDataSourceName in interface DataSource
Returns:

getDataSourceProperties

public DataSourceProperties getDataSourceProperties()
                                             throws OpenTMSException
Description copied from interface: DataSource
getDataSourceProperties returns the DataSourceProperties of the data source

Specified by:
getDataSourceProperties in interface DataSource
Returns:
the DataSourceProperties
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
Returns:
the data source type

getDefaultDataSourceConfigurationsFileName

public java.lang.String getDefaultDataSourceConfigurationsFileName()
Description copied from interface: DataSource
getDefaultDataSourceConfigurationsFileName return the name of the default data source configurations file name

Specified by:
getDefaultDataSourceConfigurationsFileName in interface DataSource
Returns:
the defaultDataSourceConfigurationsFileName; if the default file does not exist it is created

getFuzzyTree

public MonoLingualPartitionedFuzzyNodeTree getFuzzyTree()
Returns:
the fuzzyTree

getIds

public java.util.Vector<java.lang.Integer> getIds()
Description copied from interface: DataSource
getIds this method returns a vector of Integers which uniquely identify each MUL of the data source

Specified by:
getIds in interface DataSource
Returns:
a vector with the unique ids

getILogLevel

public int getILogLevel()
Returns:
the iLogLevel

getLastErrorCode

public int getLastErrorCode()
getLastErrorCode Method returns the last error code for an operation done by the data source

Specified by:
getLastErrorCode in interface DataSource
Returns:
an OpenTMS Error code describing the error which occurred for the last operation

getMonoLingualObjectFromId

public MonoLingualObject getMonoLingualObjectFromId(java.lang.String uniqueID)
Description copied from interface: DataSource
getMonoLingualObjectFromId search an MOL based on its (integer) id

Specified by:
getMonoLingualObjectFromId in interface DataSource
Returns:
the MOL found or null otherwise

getMonoLingualObjectFromUniqueId

public MonoLingualObject getMonoLingualObjectFromUniqueId(java.lang.String uniqueID)
Description copied from interface: DataSource
getMonoLingualObjectFromUniqueId search an MOL based on its (integer) id

Specified by:
getMonoLingualObjectFromUniqueId in interface DataSource
Parameters:
uniqueID - the id to search (as String)
Returns:
the MOL found or null otherwise

getMultiLingualObjectCache

public ObservableHashtable<java.lang.String,MultiLingualObject> getMultiLingualObjectCache()
multiLingualObjectCache is a cache object which can be used by the data sources to store read MultiLingual Objects. The key used is the unique id of the object.

Returns:
the multiLingualObjectCache

getMultiLingualObjectFromId

public MultiLingualObject getMultiLingualObjectFromId(java.lang.String id)
Description copied from interface: DataSource
getMultiLingualObjectFromId search an MUL based on its unique id

Specified by:
getMultiLingualObjectFromId in interface DataSource
Parameters:
id - the id to search (as String)
Returns:
the MOL found or null otherwise

getMultiLingualObjectFromUniqueId

public MultiLingualObject getMultiLingualObjectFromUniqueId(java.lang.String id)
Description copied from interface: DataSource
getMultiLingualObjectFromUniqueId search an MUL based on its unique id

Specified by:
getMultiLingualObjectFromUniqueId in interface DataSource
Parameters:
id - the id to search (as String)
Returns:
the MUL found or null otherwise

getUniqueIds

public java.util.Vector<java.lang.String> getUniqueIds()
Description copied from interface: DataSource
getUniqueIds this method returns a vector of strings which uniquely identify each MUL of the data source

Specified by:
getUniqueIds in interface DataSource
Returns:

hasMoreElements

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

importTbxFile

public int importTbxFile(java.lang.String tbxFile)
Description copied from interface: DataSource
importTbxFile imports a tbx file into the data source;

Specified by:
importTbxFile in interface DataSource
Parameters:
tbxFile - the tbx file to import
Returns:
the number of entries imported

importTmxFile

public int importTmxFile(java.lang.String tmxFile)
Description copied from interface: DataSource
importTmxFile import a tmx file into the datasource

Specified by:
importTmxFile in interface DataSource
Parameters:
tmxFile - the tmx file to import
Returns:

importXliffFile

public int importXliffFile(java.lang.String xliffFile)
Description copied from interface: DataSource
importXliffFile imports an xliff file into the data source; it imports the approved source / target's of the trans-units

Specified by:
importXliffFile in interface DataSource
Parameters:
xliffFile - the xliff file to import
Returns:
the number of entries imported

initEnumeration

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

Specified by:
initEnumeration in interface DataSource

isBChanged

public boolean isBChanged()
Returns:
the bChanged determines if the data sources has changed - added or removed entries

isBLoadAttributesLazy

public boolean isBLoadAttributesLazy()
Description copied from interface: DataSource
This method determines if the attributes of MultiLingualObjects or MonoLingualObjects should be loaded at the time when the data source is created (false) or when they are actually needed (true).

Specified by:
isBLoadAttributesLazy in interface DataSource
Returns:
the bLoadAttributesLazy true if the should be loaded when need / false when they should be loaded at creation time of the data source.

isSyncDataSource

public boolean isSyncDataSource()
Description copied from interface: DataSource
This methods returns true if the data source (the instance of the data source) is a synchronizable data source instance.

Specified by:
isSyncDataSource in interface DataSource
Returns:
true if this is a synchronizable data source

nextElement

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

removeData

public java.lang.Object removeData(java.lang.String key)
Description copied from interface: DataSource
removeData removes an object associated with the key

Specified by:
removeData in interface DataSource
Parameters:
key - the key to remove
Returns:
the object removed

removeDataSource

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

Specified by:
removeDataSource in interface DataSource

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
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
Parameters:
multiLingualObject - the MOL to remove
Returns:
true if removed; false if not

runFilterMethod

public org.jdom.Element runFilterMethod(java.util.Hashtable<java.lang.String,java.lang.Object> translationParameters,
                                        org.jdom.Element transUnit)
Run a filter on the transUnit results

Parameters:
translationParameters -
transUnit -
Returns:
the modified transUnit

saveModifiedMonoLingualObject

public boolean saveModifiedMonoLingualObject(MonoLingualObject monoLingualObject)
Description copied from interface: DataSource
saveModifiedMonoLingualObject save a given MonoLingualObject in the data source by replacing the old values. It is now allowed to change the uniquei and the id of the MOL.

Specified by:
saveModifiedMonoLingualObject in interface DataSource
Parameters:
monoLingualObject - the mono lingual object to save return true for success, false otherwise

saveModifiedMultiLingualObject

public boolean saveModifiedMultiLingualObject(MultiLingualObject mul)
Description copied from interface: DataSource
saveModifiedMultiLingualObject saves any modification of the MultiLingualObject, esp. doen to the LinguisticProperties

Specified by:
saveModifiedMultiLingualObject in interface DataSource
Parameters:
mul - the MultiLingualObject
Returns:
true if success

search

public java.util.Vector<MonoLingualObject> search(MonoLingualObject searchMonoLingualObject,
                                                  java.util.Hashtable<java.lang.String,java.lang.Object> searchParameters)
Description copied from interface: DataSource
search search for a MonoLingualObject; if no language is given in the searchMonoLingualObject the search is done independent of the language

Specified by:
search in interface DataSource
Parameters:
searchMonoLingualObject - the MonoLingualObject to search for
searchParameters - the hash table contains search parameters (e.g. language to search for etc.)
Example: matchMultiLingualLinguisticProperties for MultiLingualObjects or matchMonoLingualLinguisticProperties for MonoLingualObjects as filters
Returns:
a vector of MOL which contain the segments of the given monoLingualObject

searchRegExp

public java.util.Vector<MonoLingualObject> searchRegExp(MonoLingualObject searchMonoLingualObject,
                                                        java.util.Hashtable<java.lang.String,java.lang.Object> searchParameters)
Description copied from interface: DataSource
search searchRegExp for a MonoLingualObject where the plain text represents a regular expression; if no language is given in the searchMonoLingualObject the search is done independent of the language

Specified by:
searchRegExp in interface DataSource
Parameters:
searchMonoLingualObject - the MonoLingualObject to search for
searchParameters - the hash table contains search parameters (e.g. language to search for etc.)
Returns:
a vector of MOL which contain segment of the given monoLingualObject

searchWordBased

public java.util.Vector<MonoLingualObject> searchWordBased(MonoLingualObject searchMonoLingualObject,
                                                           java.util.Hashtable<java.lang.String,java.lang.Object> searchParameters)
Description copied from interface: DataSource
search searchWordBased for a MonoLingualObject where the plain text segment is searched by splitting it up into words; if no language is given in the searchMonoLingualObject the search is done independent of the language

Specified by:
searchWordBased in interface DataSource
Parameters:
searchMonoLingualObject - the MonoLingualObject to search for
searchParameters - the hash table contains search parameters (e.g. language to search for etc.);
Returns:
a vector of MOL which contain segment of the given monoLingualObject

setBChanged

public void setBChanged(boolean changed)
Parameters:
changed - the bChanged to set determines if the data sources has changed - added or removed entries

setBLoadAttributesLazy

public void setBLoadAttributesLazy(boolean loadAttributesLazy)
Description copied from interface: DataSource
This method sets loading of the the attributes of MultiLingualObjects or MonoLingualObjects; false = they should be loaded at the time when the data source is created or true = when they are actually needed.

Specified by:
setBLoadAttributesLazy in interface DataSource
Parameters:
loadAttributesLazy - the bLoadAttributesLazy to set; false = load at creation time; true load at time when needed

setDataSourceType

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

Specified by:
setDataSourceType in interface DataSource

setDefaultDataSourceConfigurationsFileName

public void setDefaultDataSourceConfigurationsFileName(java.lang.String defaultDataSourceConfigurationsFileName)
Description copied from interface: DataSource
setDefaultDataSourceConfigurationsFileName set the name of the default data source configurations file name

Specified by:
setDefaultDataSourceConfigurationsFileName in interface DataSource
Parameters:
defaultDataSourceConfigurationsFileName - the defaultDataSourceConfigurationsFileName to set

setILogLevel

public void setILogLevel()
Parameters:
logLevel - the iLogLevel - set to the value in OpenTMSProperties
 iLogLevel = de.folt.util.OpenTMSProperties.getInstance().getLogLevel(this.getClass().getCanonicalName());
 

setILogLevel

public void setILogLevel(int logLevel)
Parameters:
logLevel - the iLogLevel to set

setLastErrorCode

public void setLastErrorCode(int lastErrorCode)
Description copied from interface: DataSource
setLastErrorCode sets the error code of the currently running method of the data source

Specified by:
setLastErrorCode in interface DataSource
Parameters:
lastErrorCode - the lastErrorCode to set

setMultiLingualObjectCache

public void setMultiLingualObjectCache(ObservableHashtable<java.lang.String,MultiLingualObject> multiLingualObjectCache)
multiLingualObjectCache is a cache object which can be used by the data sources to store read MultiLingual Objects. The key used is the unique id of the object.

Parameters:
multiLingualObjectCache - the multiLingualObjectCache to set

subSegmentResultsToGlossary

public org.jdom.Element[] subSegmentResultsToGlossary(java.lang.String sourceLangauge,
                                                      java.lang.String targetLanguage)
Description copied from interface: DataSource
subSegmentResultsToGlossary returns an array of glossary elements for the subSegment matching translations

Specified by:
subSegmentResultsToGlossary in interface DataSource
Parameters:
sourceLangauge - the source language for the glossary
targetLanguage - the target language for the glossary
Returns:
the glossary element

subSegmentTranslate

public org.jdom.Element subSegmentTranslate(org.jdom.Element transUnit,
                                            XliffDocument xliffDocument,
                                            java.lang.String sourceLanguage,
                                            java.lang.String targetLanguage,
                                            java.util.Hashtable<java.lang.String,java.lang.Object> translationParameters)
                                     throws OpenTMSException
Description copied from interface: DataSource
translate subSegmentTranslate a trans-unit given the source language, target Language on a sub segment level (e.g.phrase or terminology based)

Specified by:
subSegmentTranslate in interface DataSource
Parameters:
transUnit - the trans unit to translate to use
xliffDocument - the basic xliff document
sourceLanguage - the source language to use
targetLanguage - the target language 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

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
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

update

public void update(java.util.Observable arg0,
                   java.lang.Object arg1)
Specified by:
update in interface java.util.Observer

update

public void update()
Description copied from interface: DataSource
This method can be called after insert or similar actions to update internal stati, fuzzy trees etc.

Specified by:
update in interface DataSource