Language Maintenance does not create UUIDs

Description

Testing set up of a new system language.

After using "Add Missing Translations" or "Re-create Translation" from Language Maintenance in window Language it turned out that there were no UUID entries in the _TRL tables.

The reason is that MLanguage.addTable is missing corresponding code.

Proposed fix is to use code as in PO (mainly copy and paste from there):

diff -r 3ecdf7584bbf org.adempiere.base/src/org/compiere/model/MLanguage.java
— a/org.adempiere.base/src/org/compiere/model/MLanguage.java Thu Nov 10 15:46:40 2011 -0500
+++ b/org.adempiere.base/src/org/compiere/model/MLanguage.java Wed Nov 23 17:52:06 2011 +0100
@@ -28,6 +28,7 @@
import java.util.logging.Level;

import org.adempiere.exceptions.DBException;

+import org.adempiere.process.UUIDGenerator;

import org.compiere.Adempiere;

import org.compiere.util.DB;

import org.compiere.util.Env;

@@ -416,23 +417,44 @@
for (int i = 0; i < columns.size(); i++)

cols.append(",").append(columns.get:info);

+ //check whether db have working generate_uuid function.

+ boolean uuidFunction = DB.isGenerateUUIDSupported();

+

+ //uuid column

+ int uuidColumnId = DB.getSQLValue(get_TrxName(), "SELECT col.AD_Column_ID FROM AD_Column col INNER JOIN AD_Table tbl ON col.AD_Table_ID = tbl.AD_Table_ID WHERE tbl.TableName=? AND col.ColumnName=?",

tableName, tableName"_UU");

// Insert Statement

int AD_User_ID = Env.getAD_User_ID(getCtx());

String keyColumn = baseTable + "_ID";

- String insert = "INSERT INTO " + tableName

- + "(AD_Language,IsTranslated, AD_Client_ID,AD_Org_ID, "

- + "Createdby,UpdatedBy, "

- + keyColumn + cols + ") "

- + "SELECT '" + getAD_Language() + "','N', AD_Client_ID,AD_Org_ID, "

- + AD_User_ID + "," + AD_User_ID + ", "

- + keyColumn + cols

- + " FROM " + baseTable

- + " WHERE " + keyColumn + " NOT IN (SELECT " + keyColumn

- + " FROM " + tableName

- + " WHERE AD_Language='" + getAD_Language() + "')";

+ StringBuffer insert = new StringBuffer ("INSERT INTO ")

+ .append(tableName)

+ .append("(AD_Language,IsTranslated, AD_Client_ID,AD_Org_ID, ")

+ .append("Createdby,UpdatedBy, ")

+ .append(keyColumn)

+ .append(cols);

+ if (uuidColumnId > 0 && uuidFunction)

+ insert.append(",").append(tableName).append("_UU ) ");

+ else

+ insert.append(") ");

+

+ insert.append("SELECT '")

+ .append(getAD_Language()).append("','N', AD_Client_ID,AD_Org_ID, ")

+ .append(AD_User_ID)

+ .append(",").append(AD_User_ID).append(", ")

+ .append(keyColumn).append(cols);

+ if (uuidColumnId > 0 && uuidFunction)

+ insert.append(",Generate_UUID() ");

+ insert.append(" FROM ").append(baseTable)

+ .append(" WHERE ").append(keyColumn).append(" NOT IN (SELECT ").append(keyColumn)

+ .append(" FROM ").append(tableName)

+ .append(" WHERE AD_Language='").append(getAD_Language()).append("')");

// + " WHERE (" + keyColumn + ",'" + getAD_Language()+ "') NOT IN (SELECT "

// + keyColumn + ",AD_Language FROM " + tableName + ")";

- int no = DB.executeUpdateEx(insert, null, get_TrxName());

+ int no = DB.executeUpdateEx(insert.toString(), null, get_TrxName());

+ if (uuidColumnId > 0 && !uuidFunction) {

+ MColumn column = new MColumn(getCtx(), uuidColumnId, get_TrxName());

+ UUIDGenerator.updateUUID(column);

+ }

log.fine(tableName + " #" + no);

return no;

} // addTable

Environment

None

Activity

Show:
Fixed

Details

Assignee

Reporter

Components

Priority

Created November 23, 2011 at 10:31 PM
Updated December 19, 2021 at 3:28 PM
Resolved August 30, 2012 at 9:18 AM

Flag notifications