IDEMPIERE-5149 Database lock in Translation Import/Export (#1127)

This commit is contained in:
Carlos Ruiz 2022-01-14 02:34:58 +01:00 committed by GitHub
parent e9f85bd985
commit 5cebb50f58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 4 deletions

View File

@ -122,7 +122,6 @@ public class Translation implements IApplication
/** Properties */
private Properties m_ctx = null;
/**
* Import Translation.
* Uses TranslationHandler to update translation
@ -133,6 +132,21 @@ public class Translation implements IApplication
* @return status message
*/
public String importTrl (String directory, int AD_Client_ID, String AD_Language, String Trl_Table)
{
return importTrl(directory, AD_Client_ID, AD_Language, Trl_Table, null);
}
/**
* Import Translation.
* Uses TranslationHandler to update translation
* @param directory file directory
* @param AD_Client_ID only certain client if id >= 0
* @param AD_Language language
* @param Trl_Table table
* @param trxName Transaction
* @return status message
*/
public String importTrl (String directory, int AD_Client_ID, String AD_Language, String Trl_Table, String trxName)
{
String fileName = directory + File.separator + Trl_Table + "_" + AD_Language + ".xml";
log.info(fileName);
@ -146,7 +160,7 @@ public class Translation implements IApplication
try
{
TranslationHandler handler = new TranslationHandler(AD_Client_ID);
TranslationHandler handler = new TranslationHandler(AD_Client_ID, trxName);
SAXParserFactory factory = SAXParserFactory.newInstance();
// factory.setValidating(true);
SAXParser parser = factory.newSAXParser();

View File

@ -34,17 +34,31 @@ import org.xml.sax.helpers.DefaultHandler;
*/
public class TranslationHandler extends DefaultHandler
{
/**
* Translation Handler
* @param AD_Client_ID only certain client if id >= 0
*/
public TranslationHandler (int AD_Client_ID)
{
this(AD_Client_ID, null);
} // TranslationHandler
/**
* Translation Handler
* @param AD_Client_ID only certain client if id >= 0
* @param trxName Transaction
*/
public TranslationHandler (int AD_Client_ID, String trxName)
{
m_AD_Client_ID = AD_Client_ID;
m_trxName = trxName;
} // TranslationHandler
/** Client */
private int m_AD_Client_ID = -1;
/** Transaction */
private String m_trxName = null;
/** Language */
private String m_AD_Language = null;
/** Is Base Language */
@ -174,7 +188,7 @@ public class TranslationHandler extends DefaultHandler
m_sql.insert(0, m_updateSQL);
// Execute
int no = DB.executeUpdate(m_sql.toString(), null);
int no = DB.executeUpdate(m_sql.toString(), m_trxName);
if (no == 1)
{
if (log.isLoggable(Level.FINE)) log.fine(m_sql.toString());

View File

@ -152,7 +152,7 @@ public class TranslationImpExp extends SvrProcess {
String tableName = table.getTableName();
if ("import".equals(p_ImportOrExport)) {
statusUpdate(Msg.parseTranslation(getCtx(), "@Import@ " + tableName + " ..."));
msgProc = translation.importTrl(p_Folder, p_AD_Client_ID, p_AD_Language, tableName);
msgProc = translation.importTrl(p_Folder, p_AD_Client_ID, p_AD_Language, tableName, get_TrxName());
} else {
statusUpdate(Msg.parseTranslation(getCtx(), "@Export@ " + tableName + " ..."));
msgProc = translation.exportTrl(p_Folder, p_AD_Client_ID, p_AD_Language, tableName, p_IsOnlyCentralizedData);