Fixed 24533. Improve performance of import translation process
authorStefan Hühner <stefan.huehner@openbravo.com>
Fri, 16 Aug 2013 14:12:21 +0200
changeset 20990 94fb69776ef0
parent 20989 5d62f819746e
child 20991 94a0603a19cc
Fixed 24533. Improve performance of import translation process
- Add ad_process_id index to ad_column
- Rewrite ad_process_trl_trg using exists instead of in clause
and pull up one restriction from subselect to main clause
- Shorting logging output per xml file imported by not repeating
path of every file imported but just printing it once per module.
- Make order in which files are imported stable by adding a order
by tablename clause to sql retrieving list of _trl tables.
src-db/database/model/tables/AD_COLUMN.xml
src-db/database/model/triggers/AD_PROCESS_TRL_TRG.xml
src/org/openbravo/erpCommon/ad_forms/TranslationManager.java
src/org/openbravo/erpCommon/ad_forms/Translation_data.xsql
src/org/openbravo/erpCommon/modules/ApplyModule.java
--- a/src-db/database/model/tables/AD_COLUMN.xml	Fri Aug 16 20:31:10 2013 +0200
+++ b/src-db/database/model/tables/AD_COLUMN.xml	Fri Aug 16 14:12:21 2013 +0200
@@ -241,6 +241,9 @@
       <index name="AD_COLUMN_TABLE" unique="false">
         <index-column name="AD_TABLE_ID"/>
       </index>
+      <index name="AD_COLUMN_PROCESS" unique="false">
+        <index-column name="AD_PROCESS_ID"/>
+      </index>
       <unique name="AD_COLUMN_NAME">
         <unique-column name="AD_TABLE_ID"/>
         <unique-column name="COLUMNNAME"/>
--- a/src-db/database/model/triggers/AD_PROCESS_TRL_TRG.xml	Fri Aug 16 20:31:10 2013 +0200
+++ b/src-db/database/model/triggers/AD_PROCESS_TRL_TRG.xml	Fri Aug 16 14:12:21 2013 +0200
@@ -55,12 +55,12 @@
              Description = :NEW.Description,
              HELP = :NEW.HELP,             
              Updated = now()
-       WHERE AD_Field_ID IN (
-               SELECT F.AD_Field_ID
+       WHERE F.IsCentrallyMaintained = 'Y'
+         AND EXISTS (
+               SELECT 1
                  FROM AD_Column C, ad_module m
                 WHERE F.AD_Column_ID = C.AD_Column_ID
                   AND C.AD_Process_ID = :NEW.AD_Process_ID
-                  AND F.IsCentrallyMaintained = 'Y'
                   and m.ad_module_id = f.ad_module_id
                   and m.ad_language = :new.ad_language);
                   
--- a/src/org/openbravo/erpCommon/ad_forms/TranslationManager.java	Fri Aug 16 20:31:10 2013 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/TranslationManager.java	Fri Aug 16 14:12:21 2013 +0200
@@ -634,7 +634,8 @@
       // factory.setValidating(true);
       final SAXParser parser = factory.newSAXParser();
       parser.parse(in, handler);
-      log4j.info("importTrl - Updated=" + handler.getUpdateCount() + " - from file " + fileName);
+      log4j
+          .info("importTrl - Updated=" + handler.getUpdateCount() + " - from file " + in.getName());
       // return Msg.getMsg(Env.getCtx(), "Updated") + "=" +
       // handler.getUpdateCount();
       return "";
--- a/src/org/openbravo/erpCommon/ad_forms/Translation_data.xsql	Fri Aug 16 20:31:10 2013 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/Translation_data.xsql	Fri Aug 16 14:12:21 2013 +0200
@@ -89,6 +89,7 @@
          select upper(tablename) AS c
            from ad_table 
           where upper(tablename) like '%TRL'
+          order by tablename
       </Sql>
   </SqlMethod> 
 
--- a/src/org/openbravo/erpCommon/modules/ApplyModule.java	Fri Aug 16 20:31:10 2013 +0200
+++ b/src/org/openbravo/erpCommon/modules/ApplyModule.java	Fri Aug 16 14:12:21 2013 +0200
@@ -129,9 +129,10 @@
 
         // Import language modules
         for (int i = 0; i < data.length; i++) {
-          log4j.info("Importing language " + data[i].adLanguage + " from module " + data[i].name);
-          TranslationManager.importTrlDirectory(pool, obDir + "/modules/" + data[i].javapackage
-              + "/referencedata/translation", data[i].adLanguage, "0", null);
+          String folder = obDir + "/modules/" + data[i].javapackage + "/referencedata/translation";
+          log4j.info("Importing language " + data[i].adLanguage + " from module " + data[i].name
+              + " from folder: " + folder);
+          TranslationManager.importTrlDirectory(pool, folder, data[i].adLanguage, "0", null);
         }
       }
       // ************ Reference data for system client modules ************