IDEMPIERE-106 Add getUUIDColumnName function to PO.
(transplanted from cb4db1801b53b0208f47bddc93529c68f30eb915)
This commit is contained in:
parent
232a728a96
commit
6ff4f0aea3
|
@ -278,7 +278,7 @@ public class MColumn extends X_AD_Column
|
||||||
if (isAllowCopy()) {
|
if (isAllowCopy()) {
|
||||||
if ( isKey()
|
if ( isKey()
|
||||||
|| getColumnSQL() != null
|
|| getColumnSQL() != null
|
||||||
|| colname.equals(getAD_Table().getTableName()+"_UU")
|
|| colname.equals(PO.getUUIDColumnName(getAD_Table().getTableName()))
|
||||||
|| isStandardColumn()
|
|| isStandardColumn()
|
||||||
)
|
)
|
||||||
setIsAllowCopy(false);
|
setIsAllowCopy(false);
|
||||||
|
|
|
@ -3164,7 +3164,7 @@ public abstract class PO
|
||||||
|
|
||||||
//uuid column
|
//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=?",
|
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+"_Trl", tableName+"_Trl_UU");
|
tableName+"_Trl", PO.getUUIDColumnName(tableName+"_Trl"));
|
||||||
|
|
||||||
StringBuffer sql = new StringBuffer ("INSERT INTO ")
|
StringBuffer sql = new StringBuffer ("INSERT INTO ")
|
||||||
.append(tableName).append("_Trl (AD_Language,")
|
.append(tableName).append("_Trl (AD_Language,")
|
||||||
|
@ -3172,7 +3172,7 @@ public abstract class PO
|
||||||
.append(iColumns)
|
.append(iColumns)
|
||||||
.append(" IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy");
|
.append(" IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy");
|
||||||
if (uuidColumnId > 0 && uuidFunction)
|
if (uuidColumnId > 0 && uuidFunction)
|
||||||
sql.append(",").append(tableName).append("_Trl_UU ) ");
|
sql.append(",").append(PO.getUUIDColumnName(tableName+"_Trl")).append(" ) ");
|
||||||
else
|
else
|
||||||
sql.append(" ) ");
|
sql.append(" ) ");
|
||||||
sql.append("SELECT l.AD_Language,t.")
|
sql.append("SELECT l.AD_Language,t.")
|
||||||
|
@ -3344,9 +3344,9 @@ public abstract class PO
|
||||||
|
|
||||||
//uuid column
|
//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=?",
|
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=?",
|
||||||
acctTable, acctTable+"_UU");
|
acctTable, PO.getUUIDColumnName(acctTable));
|
||||||
if (uuidColumnId > 0 && uuidFunction)
|
if (uuidColumnId > 0 && uuidFunction)
|
||||||
sb.append(",").append(acctTable).append("_UU");
|
sb.append(",").append(PO.getUUIDColumnName(acctTable));
|
||||||
// .. SELECT
|
// .. SELECT
|
||||||
sb.append(") SELECT ").append(get_ID())
|
sb.append(") SELECT ").append(get_ID())
|
||||||
.append(", p.C_AcctSchema_ID, p.AD_Client_ID,0,'Y', SysDate,")
|
.append(", p.C_AcctSchema_ID, p.AD_Client_ID,0,'Y', SysDate,")
|
||||||
|
@ -3417,14 +3417,14 @@ public abstract class PO
|
||||||
|
|
||||||
//uuid column
|
//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=?",
|
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");
|
tableName, PO.getUUIDColumnName(tableName));
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer ("INSERT INTO ")
|
StringBuffer sb = new StringBuffer ("INSERT INTO ")
|
||||||
.append(tableName)
|
.append(tableName)
|
||||||
.append(" (AD_Client_ID,AD_Org_ID, IsActive,Created,CreatedBy,Updated,UpdatedBy, "
|
.append(" (AD_Client_ID,AD_Org_ID, IsActive,Created,CreatedBy,Updated,UpdatedBy, "
|
||||||
+ "AD_Tree_ID, Node_ID, Parent_ID, SeqNo");
|
+ "AD_Tree_ID, Node_ID, Parent_ID, SeqNo");
|
||||||
if (uuidColumnId > 0 && uuidFunction)
|
if (uuidColumnId > 0 && uuidFunction)
|
||||||
sb.append(", ").append(tableName).append("_UU) ");
|
sb.append(", ").append(PO.getUUIDColumnName(tableName)).append(") ");
|
||||||
else
|
else
|
||||||
sb.append(") ");
|
sb.append(") ");
|
||||||
sb.append("SELECT t.AD_Client_ID, 0, 'Y', SysDate, "+getUpdatedBy()+", SysDate, "+getUpdatedBy()+","
|
sb.append("SELECT t.AD_Client_ID, 0, 'Y', SysDate, "+getUpdatedBy()+", SysDate, "+getUpdatedBy()+","
|
||||||
|
|
|
@ -585,7 +585,7 @@ public abstract class AbstractElementHandler implements ElementHandler {
|
||||||
protected <T extends PO> T findPO(Properties ctx, Element element) {
|
protected <T extends PO> T findPO(Properties ctx, Element element) {
|
||||||
T po = null;
|
T po = null;
|
||||||
String tableName = element.getElementValue();
|
String tableName = element.getElementValue();
|
||||||
String uuidColumn = tableName + "_UU";
|
String uuidColumn = PO.getUUIDColumnName(tableName);
|
||||||
String idColumn = tableName + "_ID";
|
String idColumn = tableName + "_ID";
|
||||||
if (element.properties.containsKey(uuidColumn)) {
|
if (element.properties.containsKey(uuidColumn)) {
|
||||||
String uuid = element.properties.get(uuidColumn).contents.toString();
|
String uuid = element.properties.get(uuidColumn).contents.toString();
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.adempiere.pipo2;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
|
import org.compiere.model.PO;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
@ -39,7 +40,7 @@ public class ReferenceUtils {
|
||||||
}
|
}
|
||||||
else if (isUUIDLookup(e))
|
else if (isUUIDLookup(e))
|
||||||
{
|
{
|
||||||
return IDFinder.findIdByColumn(referenceKey, referenceKey + "_UU", value.trim(), Env.getAD_Client_ID(ctx), trxName);
|
return IDFinder.findIdByColumn(referenceKey, PO.getUUIDColumnName(referenceKey), value.trim(), Env.getAD_Client_ID(ctx), trxName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -94,9 +95,9 @@ public class ReferenceUtils {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MTable table = MTable.get(Env.getCtx(), tableName);
|
MTable table = MTable.get(Env.getCtx(), tableName);
|
||||||
if (table.getColumn(tableName + "_UU") != null)
|
if (table.getColumn(PO.getUUIDColumnName(tableName)) != null)
|
||||||
{
|
{
|
||||||
sql = "SELECT " + tableName + "_UU" + " FROM "
|
sql = "SELECT " + PO.getUUIDColumnName(tableName) + " FROM "
|
||||||
+ tableName + " WHERE " + keyColumn + " = ?";
|
+ tableName + " WHERE " + keyColumn + " = ?";
|
||||||
String value = DB.getSQLValueString(null, sql, id);
|
String value = DB.getSQLValueString(null, sql, id);
|
||||||
if (value != null && value.trim().length() > 0)
|
if (value != null && value.trim().length() > 0)
|
||||||
|
|
Loading…
Reference in New Issue