From 232a728a96b91419925996a726bffe13e46a8a05 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Sun, 11 Dec 2011 09:54:23 +0800 Subject: [PATCH] IDEMPIERE-106 Add getUUIDColumnName function to PO. (transplanted from b4d2e0116d801099480fb637e15655931146893e) --- .../org/adempiere/process/UUIDGenerator.java | 3 ++- .../src/org/compiere/model/PO.java | 23 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/adempiere/process/UUIDGenerator.java b/org.adempiere.base/src/org/adempiere/process/UUIDGenerator.java index 4d626398c8..f88d4dddc9 100644 --- a/org.adempiere.base/src/org/adempiere/process/UUIDGenerator.java +++ b/org.adempiere.base/src/org/adempiere/process/UUIDGenerator.java @@ -25,6 +25,7 @@ import org.adempiere.exceptions.DBException; import org.compiere.model.MColumn; import org.compiere.model.MTable; import org.compiere.model.M_Element; +import org.compiere.model.PO; import org.compiere.process.ProcessInfoParameter; import org.compiere.process.SvrProcess; import org.compiere.util.AdempiereUserError; @@ -87,7 +88,7 @@ public class UUIDGenerator extends SvrProcess { int AD_Table_ID = rs.getInt(1); String cTableName = rs.getString(2); - String columnName = cTableName + "_UU"; + String columnName = PO.getUUIDColumnName(cTableName); int AD_Column_ID = DB.getSQLValue(null, "SELECT AD_Column_ID FROM AD_Column Where AD_Table_ID = ? AND ColumnName = ?", AD_Table_ID, columnName); if (AD_Column_ID <= 0) { System.out.println("Adding UUID to " + cTableName); diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java index 29fa591284..221c768e56 100644 --- a/org.adempiere.base/src/org/compiere/model/PO.java +++ b/org.adempiere.base/src/org/compiere/model/PO.java @@ -2550,7 +2550,7 @@ public abstract class PO set_ValueNoCheck(m_KeyColumns[0], m_IDs[0]); } //uuid secondary key - int uuidIndex = p_info.getColumnIndex(get_TableName()+"_UU"); + int uuidIndex = p_info.getColumnIndex(getUUIDColumnName()); if (uuidIndex >= 0) { String value = (String)get_Value(uuidIndex); @@ -4060,6 +4060,27 @@ public abstract class PO return false; } + /** + * @return uuid column name + */ + public String getUUIDColumnName() { + return PO.getUUIDColumnName(get_TableName()); + } + + /** + * + * @param tableName + * @return uuid column name + */ + public static String getUUIDColumnName(String tableName) { + String columnName = tableName + "_UU"; + if (columnName.length() > 30) { + int i = columnName.length() - 30; + columnName = tableName.substring(0, tableName.length() - i) + "_UU"; + } + return columnName; + } + @Override protected Object clone() throws CloneNotSupportedException { PO clone = (PO) super.clone();