IDEMPIERE-106 Add getUUIDColumnName function to PO.
(transplanted from b4d2e0116d801099480fb637e15655931146893e)
This commit is contained in:
parent
5c3266eef6
commit
232a728a96
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue