.config
file.
Under normal circumstances an SQLDataSource should be instantiated thru a
DataSourceInstace de.folt.datamodel.DataSourceInstance. This ensures
that only one instance per database is loaded. Esp. for importing big TMX
Files depending on the database BULK INSERT is supported (which basically
extends Hibernate). Please not hat in this case the database will be write
locked. BULK INSERT creates three csv files (for MUL, MOL and TmxProp). As
Hibernate requires unique ids no other write operations are allowed during
the TMX import process.
__USERNAME__ represents the user name - key: user name
__PASSWORD__ represents the (encrypted) password - key: password
__PORT__ represents the port of the database - key: port
__SERVER__ represents the server - key: server
A property file typically looks like that and may contain variables to be
replaced by supplied parameters:
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="connection.url">jdbc:sqlserver://__SERVER__:__PORT__;sendStringParametersAsUnicode=true</property>
<property name="connection.username">__USERNAME__</property>
<property name="connection.password">__PASSWORD__</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">de.folt.models.datamodel.sql.OpenTMSSQLServerDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">false</property>
<!-- Drop and re-create the database schema on startup -->
<!-- property name="hbm2ddl.auto">create</property -->
<property name="hibernate.format_sql">true</property>
<property name="default_batch_fetch_size">100</property>
<property name="csvsupport">true</property>
<property name="import-sqlmonolingualobject">BULK INSERT sqlmonolingualobject from '%IMPORTFILE%' WITH (TABLOCK, FIRSTROW = 2, DATAFILETYPE='widechar')</property>
<property name="import-sqlmultilingualobject">BULK INSERT sqlmultilingualobject from '%IMPORTFILE%' WITH (TABLOCK, FIRSTROW = 2, DATAFILETYPE='widechar')</property>
<property name="import-sqltmxprop">BULK INSERT sqltmxprop from '%IMPORTFILE%' WITH (TABLOCK, FIRSTROW = 2, DATAFILETYPE='widechar')</property>
<property name="csvCodePage">UCS-2</property>
<property name="indexsupport">false</property>
<property name="index-formattedsegment">ALTER TABLE sqlmonolingualobject ADD INDEX (formattedSegment(100))</property>
<property name="index-plainTextsegment">ALTER TABLE sqlmonolingualobject ADD INDEX (plainTextSegment(100))</property>
<property name="index-content">ALTER TABLE sqltmxprop ADD INDEX (content(100))</property>
<property name="convert">true</property>
<property name="convert-formattedSegment">select m from SQLMonoLingualObject m where convert(nvarchar, m.formattedSegment)= ? and m.language = ?</property>
<!-- Mapping of the mapped classes -->
<mapping class="de.folt.models.datamodel.sql.SQLMultiLingualObject"/>
<mapping class="de.folt.models.datamodel.sql.SQLMonoLingualObject"/>
<mapping class="de.folt.models.datamodel.sql.SQLTmxProp" />
</session-factory>
</hibernate-configuration>
- Author:
- klemens
|
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 |
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 |
bInitCSVImport(java.lang.String csvCodePage)
bInitCSVImport runs the necessary initialisations for BULK INSERT (csv
insert). |
boolean |
bSaveMUL(SQLMultiLingualObject sqlmulti,
int iNum)
bSaveMUL saves a SQLMUL |
boolean |
bSaveMULForCVS(SQLMultiLingualObject sqlmulti,
java.lang.String csvCodePage,
int iNum)
bSaveMULForCVS saves a SQLMUL in the corresponfing csv files. |
boolean |
bUpdateIfMULExists(SQLMultiLingualObject sqlmulti,
int iNum,
boolean bcsvsupport)
bUpdateIfMULExists this updates an existing MUL. |
java.util.Vector<MonoLingualObject> |
changedMonolingualObjects()
changedMonolingualObjects |
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. |
boolean |
createDatabase(java.util.Hashtable<java.lang.String,java.lang.Object> params)
createDatabase creates a new SQL database |
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 |
deleteDatabase(java.util.Hashtable<java.lang.String,java.lang.Object> params)
deleteDatabase creates a new SQL database |
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 |
exportTmx(java.util.Hashtable<java.lang.String,java.lang.Object> params)
exportTmx exports a database to the given tmxFile
String dbname = (String) params.get("dataSourceName");
Observer observer = (Observer) params.get("observer");
String tmxFile = (String) params.get("exportFile");
|
int |
exportTmxFile(java.lang.String tmxFile)
exportTmxFile exports the data source into an tmx file |
int |
exportTmxFile(java.lang.String tmxFile,
long update_counter)
|
int |
exportToMOL(java.util.Hashtable<java.lang.String,java.lang.Object> params)
exportToMOL exports the database in MUL/MOL format to the System.out |
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.sql.Connection |
getDirectDatabaseConnection()
|
java.util.Hashtable<java.lang.String,java.lang.Object> |
getExportParams()
|
java.util.Vector<java.lang.Integer> |
getIds()
getIds this method returns a vector of Integers which uniquely identify
each MUL of the data source |
java.util.Hashtable<java.lang.String,java.lang.Object> |
getImportParams()
|
int |
getLastErrorCode()
getLastErrorCode Method returns the last error code for an operation done
by the data source |
int |
getMaxId()
getMaxId find the maximum Id from sqlmultilingualobject -
sqlmonolingualobject - sqltmxprop |
MonoLingualObject |
getMonoLingualObjectFromId(java.lang.String id)
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 |
SQLMonoLingualPartitionedFuzzyNodeTree |
getSQLFuzzyTree()
|
java.lang.String |
getSync_user_list()
|
java.lang.String |
getSync_user()
|
java.util.Vector<java.lang.String> |
getUniqueIds()
getUniqueIds this method returns a vector of strings which uniquely
identify each MUL of the data source |
long |
getUpdate_counter_FuzzyTree()
|
boolean |
handleSession()
|
int |
hashCode()
|
boolean |
hasMoreElements()
|
int |
importTbxFile(java.util.Hashtable<java.lang.String,java.lang.Object> params)
importTbxFile |
int |
importTmxFile(java.util.Hashtable<java.lang.String,java.lang.Object> params)
importTmxFile imports a tmx file into data base database |
int |
importTmxFile(java.lang.String tmxFile)
importTmxFile import a TMX file into the data source |
int |
importXliffFile(java.util.Hashtable<java.lang.String,java.lang.Object> params)
importXliffFile imports an approved xliff file into a database |
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 |
isBLoadAllEntries()
|
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 |
isbSynchronisable()
|
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)
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 |
removeMonoLingualObject(java.lang.String stUniqudId)
Method removes a monolingual object based on its unique id |
boolean |
removeMultiLingualObject(MultiLingualObject multiLingualObject)
removeMultiLingualObject removes a MultiLingualObject from the data
source |
java.util.Vector<java.lang.Integer> |
saveCsv(java.lang.String csvCodePage,
boolean sequenceSupport)
saveCsv save the csv file to the data base using the bulk insert method
defined for the database |
boolean |
saveModifiedMonoLingualObject(MonoLingualObject monoLingualObject)
saveModifiedMonoLingualObject save a given MonoLingualObject in the data
source by replacing the old values. |
boolean |
saveModifiedMultiLingualObject(MultiLingualObject multiLingualObject)
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 |
void |
setBLoadAllEntries(boolean loadAllEntries)
If set to true will select all entries when reading entries otherwise
only the entries for a given source / target language pair are read |
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 |
setbSynchronisable(boolean bSynchronisable)
|
void |
setDataSourceType()
setDataSourceType sets the type of the data source |
void |
setDirectDatabaseConnection(java.sql.Connection directDatabaseConnection)
|
void |
setExportParams(java.util.Hashtable<java.lang.String,java.lang.Object> exportParams)
|
void |
setFuzzyTree(SQLMonoLingualPartitionedFuzzyNodeTree fuzzyTree)
|
void |
setILogLevel()
|
void |
setILogLevel(int logLevel)
|
void |
setImportParams(java.util.Hashtable<java.lang.String,java.lang.Object> importParams)
|
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. |
void |
setSync_user_list(java.lang.String sync_user_list)
|
void |
setSync_user(java.lang.String sync_user)
|
void |
setUpdate_counter_FuzzyTree(long update_counter_FuzzyTree)
|
java.lang.String |
tmxFooter()
tmxFooter a footer string |
java.lang.String |
toString()
|
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 |
int |
translate(java.util.Hashtable<java.lang.String,java.lang.Object> params)
translate translates an xliff file based on an SQL data source |
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)
|
int |
updateFuzzyTree()
|
void |
updateSQLTmxProperties(java.util.List<SQLTmxProp> sqlTmxProperties,
LinguisticProperties linguisticProperties,
java.lang.Object parent)
updateSQLTmxProperties update the List of sqlTmxProperties
with linguisticProperties
If the LinguisticProperty.PropStatus of the TmxProp is deleted the
corresponding SQLTmxProp is deleted (set to null)
If the TmxProp has the same id as the SQLTmxProp the values of SQLTmxProp
are set to the correspondig values of TmxProp If the TmxProp is not found
in List a new SQLTmxProp is added. |
| Methods inherited from class de.folt.models.datamodel.BasicDataSource |
addData, bPersist, bSupportMultiThreading, checkIfTranslationExistsInDataSource, containsKey, containsValue, copyTo, exportXliffFile, getAllAttributes, getChangedIds, getData, getDefaultDataSourceConfigurationsFileName, getFuzzyTree, getILogLevel, importTbxFile, isBChanged, removeData, runFilterMethod, searchRegExp, searchWordBased, setBChanged, setDefaultDataSourceConfigurationsFileName, setOpenTMSPropertiesFile, subSegmentResultsToGlossary, subSegmentTranslate |
| Methods inherited from class java.util.Observable |
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers |
| Methods inherited from class java.lang.Object |
equals, getClass, notify, notifyAll, wait, wait, wait |
OpenTMSSQLDataSource
public OpenTMSSQLDataSource()
- Just a dummy constructor, but useful to get some parameter settings. Here
is an example how to get the DefaultDataSourceConfigurationsFileName
OpenTMSSQLDataSource sqldatasource = new OpenTMSSQLDataSource();
String configFile = sqldatasource.getDefaultDataSourceConfigurationsFileName();
OpenTMSSQLDataSource
public OpenTMSSQLDataSource(DataSourceProperties dataModelProperties)
throws OpenTMSException
- The constructor created and associates a data sources for a given set of
parameters. The parameters are supplied in the dataModelProperties. The
following key- value pairs are supported: hibernateConfiguration -
hibernate configuration file hibernate.hbm2ddl.auto - the mode how the
database is started (create creates the baisc tables) any other hibernate
paramters can be supplied if hibernateConfiguration is not specified. In
this case the key classes
de.folt.models.datamodel.sql.SQLMultiLingualObject,
de.folt.models.datamodel.sql.SQLMonoLingualObject,
de.folt.models.datamodel.sql.SQLTmxProp are added as
addAnnotatedClass(es) annotationOnly - true ( false - if true no session
is created (mainly used for creating new databases) with createDataSource
- Parameters:
dataModelProperties - the properties of the model.
- Throws:
OpenTMSException
OpenTMSSQLDataSource
public OpenTMSSQLDataSource(java.lang.String propertiesFileName)
- Creates a OpenTMS data source based on a properties file. -- lihaitao
- Parameters:
propfileName -
main
public static void main(java.lang.String[] args)
- main
- Parameters:
args -
Example: -method createDatabase -dataSourceName test50
-dataSourceUser sa -dataSourcePassword xx -dataSourceServer
localhost -dataSourcePort 5432 -hibernateConfigFile
../hibernat/progress.cfg -method createDatabase
creates a database: params needed: -dataSourceName
-dataSourceServer -dataSourcePort -dataSourceUser
-dataSourcePassword -hibernateConfigFile
deleteDatabase deletes a database. Parameters needed:
-dataSourceName
importTmxFile imports a tmx file. Parameters needed:
-dataSourceName -sourceDocument -tempDirectory (directory with
"/" at end!) -tempFileRemove (true/false)
importXliffFile imports an xliff file. Parameters needed:
dataSourceName -sourceDocument
exportTmx exports data source into a tmx file. Parameters
needed: dataSourceName -exportFile
exportToMOL exports data source into MOL format
search search for a given segment. Parameters needed:
-dataSourceName -segment
translate translates an xliff document. Parameters needed:
-dataSourceName -sourceDocument -sourceLanguage
-targetLanguage -similarity
search searches for a MOL entry. Parameters needed:
-dataSourceName -segment -language (opt -fuzzy -similarity
-sourceLanguage -targetLamguage)
- Throws:
OpenTMSException
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 addmergeObjects - 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 addmergeObjects - 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- Overrides:
bAuthenticate in class BasicDataSource
- Parameters:
userName - the user namepassword - the password
- Returns:
- true if user / password does match and access granted, false if
user / password does not match
bInitCSVImport
public boolean bInitCSVImport(java.lang.String csvCodePage)
- bInitCSVImport runs the necessary initialisations for BULK INSERT (csv
insert). It creates three file for MUL, MOL and TmxProp csv files. It
also starts the transaction (now other write operations are allowed
druing csv import in order to ensure ID uniquness).
- Parameters:
csvCodePage - the code page to use (e.g. UCS-2 for writing the BOM order).
- Returns:
- true if successful
bSaveMUL
public boolean bSaveMUL(SQLMultiLingualObject sqlmulti,
int iNum)
- bSaveMUL saves a SQLMUL
- Parameters:
sqlmulti - the SQLMUL to saveiNum - the current SQLMUL import number (e.g. of a TMX file)
- Returns:
- true if successful
bSaveMULForCVS
public boolean bSaveMULForCVS(SQLMultiLingualObject sqlmulti,
java.lang.String csvCodePage,
int iNum)
- bSaveMULForCVS saves a SQLMUL in the corresponfing csv files.
- Parameters:
sqlmulti - the sqlmulti to savecsvCodePage - the codepage (e.g. UCS-" for the UCS-2 encoded csv files)iNum - the current import numer (e.g. from a TMX file)
- Returns:
- true if successful
bUpdateIfMULExists
public boolean bUpdateIfMULExists(SQLMultiLingualObject sqlmulti,
int iNum,
boolean bcsvsupport)
- bUpdateIfMULExists this updates an existing MUL. Method first checks if
the MUL exists.
- Parameters:
sqlmulti - the SQLMultiLingualObject which should be updatediNum - current import number (set 0 if not needed)bcsvsupport - if BULK INSERT (csv import) is used set to true
- Returns:
- true if update was done / false if MUL does not exist.
changedMonolingualObjects
public java.util.Vector<MonoLingualObject> changedMonolingualObjects()
- Description copied from interface:
DataSource
- changedMonolingualObjects
- Specified by:
changedMonolingualObjects in interface DataSource- Overrides:
changedMonolingualObjects in class BasicDataSource
- Returns:
- a Vector of changed or new MonoLingualObjects since the last read
operation
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 segmentsourceLanguage - the source languagetargetSegment - the target segmenttargetLanguage - 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
createDatabase
public boolean createDatabase(java.util.Hashtable<java.lang.String,java.lang.Object> params)
- createDatabase creates a new SQL database
- Parameters:
params - the hashtable with the necessary parameters to create the
database
String dbname = (String) params.get("dataSourceName");
String user = (String) params.get("dataSourceUser");
String password = (String) params.get("dataSourcePassword");
String server = (String) params.get("dataSourceServer");
String port = (String) params.get("dataSourcePort");
String hibernateConfigFile = (String) params.get("hibernateConfigFile");
- Returns:
- true in case of success otherwise false
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
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- Overrides:
currentTimeMillis in class BasicDataSource
- 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.)
deleteDatabase
public boolean deleteDatabase(java.util.Hashtable<java.lang.String,java.lang.Object> params)
- deleteDatabase creates a new SQL database
- Parameters:
params - hash table with one key value pair: dbaname -> data base name
- Returns:
- true in case of success, otherwise false
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
exportTmx
public int exportTmx(java.util.Hashtable<java.lang.String,java.lang.Object> params)
- exportTmx exports a database to the given tmxFile
String dbname = (String) params.get("dataSourceName");
Observer observer = (Observer) params.get("observer");
String tmxFile = (String) params.get("exportFile");
- Parameters:
params - - key value pairs: dataSourceName - exportFile / optional:
update-counter - observer
- Returns:
- number of exported entries
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- Overrides:
exportTmxFile in class BasicDataSource
- Parameters:
tmxFile - the tmx file to export to
- Returns:
- the number of entries exported
exportTmxFile
public int exportTmxFile(java.lang.String tmxFile,
long update_counter)
exportToMOL
public int exportToMOL(java.util.Hashtable<java.lang.String,java.lang.Object> params)
- exportToMOL exports the database in MUL/MOL format to the System.out
- Parameters:
params - containing the dato source to export
String dbname = (String) params.get("dataSourceName");
- Returns:
- number of exported entries
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- Overrides:
getDataSourceName in class BasicDataSource
- 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- Overrides:
getDataSourceProperties in class BasicDataSource
- 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- Overrides:
getDataSourceType in class BasicDataSource
- Returns:
- the data source type
getDirectDatabaseConnection
public java.sql.Connection getDirectDatabaseConnection()
- Returns:
- the directDatabaseConnection
getExportParams
public java.util.Hashtable<java.lang.String,java.lang.Object> getExportParams()
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- Overrides:
getIds in class BasicDataSource
- Returns:
- a vector with the unique ids
getImportParams
public java.util.Hashtable<java.lang.String,java.lang.Object> getImportParams()
getLastErrorCode
public int getLastErrorCode()
- Description copied from class:
BasicDataSource
- getLastErrorCode Method returns the last error code for an operation done
by the data source
- Specified by:
getLastErrorCode in interface DataSource- Overrides:
getLastErrorCode in class BasicDataSource
- Returns:
- an OpenTMS Error code describing the error which occurred for the
last operation
getMaxId
public int getMaxId()
- getMaxId find the maximum Id from sqlmultilingualobject -
sqlmonolingualobject - sqltmxprop
- Returns:
- the maximum Id of sqlmultilingualobject - sqlmonolingualobject -
sqltmxprop
getMonoLingualObjectFromId
public MonoLingualObject getMonoLingualObjectFromId(java.lang.String id)
- Description copied from interface:
DataSource
- getMonoLingualObjectFromId search an MOL based on its (integer) id
- Specified by:
getMonoLingualObjectFromId in interface DataSource- Overrides:
getMonoLingualObjectFromId in class BasicDataSource
- 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- Overrides:
getMonoLingualObjectFromUniqueId in class BasicDataSource
- Parameters:
uniqueID - the id to search (as String)
- Returns:
- the MOL found or null otherwise
getMultiLingualObjectCache
public ObservableHashtable<java.lang.String,MultiLingualObject> getMultiLingualObjectCache()
- Description copied from class:
BasicDataSource
- 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.
- Overrides:
getMultiLingualObjectCache in class BasicDataSource
- 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- Overrides:
getMultiLingualObjectFromId in class BasicDataSource
- 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- Overrides:
getMultiLingualObjectFromUniqueId in class BasicDataSource
- Parameters:
id - the id to search (as String)
- Returns:
- the MUL found or null otherwise
getSQLFuzzyTree
public SQLMonoLingualPartitionedFuzzyNodeTree getSQLFuzzyTree()
- Returns:
- the fuzzyTree associated with the SQL data source
getSync_user
public java.lang.String getSync_user()
getSync_user_list
public java.lang.String getSync_user_list()
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- Overrides:
getUniqueIds in class BasicDataSource
- Returns:
getUpdate_counter_FuzzyTree
public long getUpdate_counter_FuzzyTree()
handleSession
public boolean handleSession()
- Returns:
hashCode
public int hashCode()
- Overrides:
hashCode in class java.lang.Object
hasMoreElements
public boolean hasMoreElements()
- Specified by:
hasMoreElements in interface java.util.Enumeration<MultiLingualObject>- Overrides:
hasMoreElements in class BasicDataSource
importTbxFile
public int importTbxFile(java.util.Hashtable<java.lang.String,java.lang.Object> params)
- importTbxFile
- Parameters:
message -
- Returns:
importTmxFile
public int importTmxFile(java.util.Hashtable<java.lang.String,java.lang.Object> params)
- importTmxFile imports a tmx file into data base database
- Parameters:
database - the database nametmxFile - the tmx file to importobserver - an observer for the import
- Returns:
- the number of imported entries
importTmxFile
public int importTmxFile(java.lang.String tmxFile)
- importTmxFile import a TMX file into the data source
- Specified by:
importTmxFile in interface DataSource- Overrides:
importTmxFile in class BasicDataSource
- Parameters:
tmxFile - the tmx file to import
- Returns:
- number of entries read
importXliffFile
public int importXliffFile(java.util.Hashtable<java.lang.String,java.lang.Object> params)
- importXliffFile imports an approved xliff file into a database
- Parameters:
params -
String database = (String) params.get("dataSourceName");
String xliffFile = (String) params.get("sourceDocument");
tempFileRemove = (String) params.get("tempFileRemove"); (true or false string)
Observer observer = (Observer) params.get("observer");
- Returns:
- number of imported entries
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- Overrides:
importXliffFile in class BasicDataSource
- 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- Overrides:
initEnumeration in class BasicDataSource
isBLoadAllEntries
public boolean isBLoadAllEntries()
- Returns:
- the bLoadAllEntries true - read all entries from SQL data source,
otherwise only source and target language specific
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- Overrides:
isBLoadAttributesLazy in class BasicDataSource
- Returns:
- the bLoadAttributesLazy true if the should be loaded when need /
false when they should be loaded at creation time of the data
source.
isbSynchronisable
public boolean isbSynchronisable()
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- Overrides:
isSyncDataSource in class BasicDataSource
- Returns:
- true if this is a synchronizable data source
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
removeMonoLingualObject
public boolean removeMonoLingualObject(java.lang.String stUniqudId)
- Method removes a monolingual object based on its unique id
- Parameters:
stUniqudId -
- Returns:
- true if deleted
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
saveCsv
public java.util.Vector<java.lang.Integer> saveCsv(java.lang.String csvCodePage,
boolean sequenceSupport)
- saveCsv save the csv file to the data base using the bulk insert method
defined for the database
- Parameters:
csvCodePage - code page of the csv filesequenceSupport - if sequence is supported by the database the database sequence
will be set
- Returns:
- save result vector (0: 3 = success, all csv files for MUL, MOL,
TmxProp saved; otherwies error)
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- Overrides:
saveModifiedMonoLingualObject in class BasicDataSource
- Parameters:
monoLingualObject - the mono lingual object to save return true for success, false
otherwise
saveModifiedMultiLingualObject
public boolean saveModifiedMultiLingualObject(MultiLingualObject multiLingualObject)
- Description copied from interface:
DataSource
- saveModifiedMultiLingualObject saves any modification of the
MultiLingualObject, esp. doen to the LinguisticProperties
- Specified by:
saveModifiedMultiLingualObject in interface DataSource- Overrides:
saveModifiedMultiLingualObject in class BasicDataSource
- Parameters:
multiLingualObject - 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- Overrides:
search in class BasicDataSource
- Parameters:
searchMonoLingualObject - the MonoLingualObject to search forsearchParameters - 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
setBLoadAllEntries
public void setBLoadAllEntries(boolean loadAllEntries)
- If set to true will select all entries when reading entries otherwise
only the entries for a given source / target language pair are read
- Parameters:
loadAllEntries - the bLoadAllEntries to set
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- Overrides:
setBLoadAttributesLazy in class BasicDataSource
- Parameters:
loadAttributesLazy - the bLoadAttributesLazy to set; false = load at creation time;
true load at time when needed
setbSynchronisable
public void setbSynchronisable(boolean bSynchronisable)
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
setDirectDatabaseConnection
public void setDirectDatabaseConnection(java.sql.Connection directDatabaseConnection)
- Parameters:
directDatabaseConnection - the directDatabaseConnection to set
setExportParams
public void setExportParams(java.util.Hashtable<java.lang.String,java.lang.Object> exportParams)
setFuzzyTree
public void setFuzzyTree(SQLMonoLingualPartitionedFuzzyNodeTree fuzzyTree)
- Parameters:
fuzzyTree - the fuzzyTree to set
setILogLevel
public void setILogLevel()
- Overrides:
setILogLevel in class BasicDataSource
setILogLevel
public void setILogLevel(int logLevel)
- Overrides:
setILogLevel in class BasicDataSource
- Parameters:
logLevel - the iLogLevel to set
setImportParams
public void setImportParams(java.util.Hashtable<java.lang.String,java.lang.Object> importParams)
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- Overrides:
setLastErrorCode in class BasicDataSource
- Parameters:
lastErrorCode - the lastErrorCode to set
setMultiLingualObjectCache
public void setMultiLingualObjectCache(ObservableHashtable<java.lang.String,MultiLingualObject> multiLingualObjectCache)
- Description copied from class:
BasicDataSource
- 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.
- Overrides:
setMultiLingualObjectCache in class BasicDataSource
- Parameters:
multiLingualObjectCache - the multiLingualObjectCache to set
setSync_user
public void setSync_user(java.lang.String sync_user)
setSync_user_list
public void setSync_user_list(java.lang.String sync_user_list)
setUpdate_counter_FuzzyTree
public void setUpdate_counter_FuzzyTree(long update_counter_FuzzyTree)
tmxFooter
public java.lang.String tmxFooter()
- tmxFooter a footer string
- Returns:
- the footer for a tmx file </body>\n</tmx>
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
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 usefile - the file element currently to translatexliffDocument - the basic xliff documentsourceLanguage - the source language to usetargetLanguage - the target language to usematchSimilarity - the similarity (fuzzy) match quality (0 - 100) to usetranslationParameters - 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 int translate(java.util.Hashtable<java.lang.String,java.lang.Object> params)
- translate translates an xliff file based on an SQL data source
- Parameters:
database - the sql database sourcexliffFile - the xliff file to translatesourceLanguage - the source language to translatetargetLanguage - the target language to translatesimilarity - the similarity to use (integer number)translationParameters - HashtableReturns:
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- Overrides:
update in class BasicDataSource
update
public void update(java.util.Observable arg0,
java.lang.Object arg1)
- Specified by:
update in interface java.util.Observer- Overrides:
update in class BasicDataSource
updateFuzzyTree
public int updateFuzzyTree()
updateSQLTmxProperties
public void updateSQLTmxProperties(java.util.List<SQLTmxProp> sqlTmxProperties,
LinguisticProperties linguisticProperties,
java.lang.Object parent)
- updateSQLTmxProperties update the List of sqlTmxProperties
with linguisticProperties
If the LinguisticProperty.PropStatus of the TmxProp is deleted the
corresponding SQLTmxProp is deleted (set to null)
If the TmxProp has the same id as the SQLTmxProp the values of SQLTmxProp
are set to the correspondig values of TmxProp If the TmxProp is not found
in List a new SQLTmxProp is added.
- Parameters:
sqlTmxProperties - the sqlTmxProperties to updatelinguisticProperties - the linguisticProperties which are used for updating