IDEMPIERE-4756 2pack import problem (#648)
This commit is contained in:
parent
26f88e6fd2
commit
ad558ed7ce
|
@ -31,6 +31,7 @@ import java.util.Locale;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.adempiere.exceptions.DBException;
|
import org.adempiere.exceptions.DBException;
|
||||||
import org.compiere.db.AdempiereDatabase;
|
import org.compiere.db.AdempiereDatabase;
|
||||||
import org.compiere.db.Database;
|
import org.compiere.db.Database;
|
||||||
|
@ -54,7 +55,7 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -1841918268550762201L;
|
private static final long serialVersionUID = 4379933682905553553L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get MColumn from Cache (immutable)
|
* Get MColumn from Cache (immutable)
|
||||||
|
@ -128,6 +129,20 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
|
||||||
return table.getColumn(columnName);
|
return table.getColumn(columnName);
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get MColumn given TableName and ColumnName
|
||||||
|
* @param ctx context
|
||||||
|
* @param TableName
|
||||||
|
* @param ColumnName
|
||||||
|
* @param TrxName
|
||||||
|
* @return MColumn
|
||||||
|
*/
|
||||||
|
public static MColumn get (Properties ctx, String tableName, String columnName, String trxName)
|
||||||
|
{
|
||||||
|
MTable table = MTable.get(ctx, tableName, trxName);
|
||||||
|
return table.getColumn(columnName);
|
||||||
|
} // get
|
||||||
|
|
||||||
public static String getColumnName (Properties ctx, int AD_Column_ID)
|
public static String getColumnName (Properties ctx, int AD_Column_ID)
|
||||||
{
|
{
|
||||||
return getColumnName (ctx, AD_Column_ID, null);
|
return getColumnName (ctx, AD_Column_ID, null);
|
||||||
|
@ -795,8 +810,13 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
|
||||||
int cnt = DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM AD_Ref_Table WHERE AD_Reference_ID=?", getAD_Reference_Value_ID());
|
int cnt = DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM AD_Ref_Table WHERE AD_Reference_ID=?", getAD_Reference_Value_ID());
|
||||||
if (cnt == 1) {
|
if (cnt == 1) {
|
||||||
MRefTable rt = MRefTable.get(getCtx(), getAD_Reference_Value_ID(), get_TrxName());
|
MRefTable rt = MRefTable.get(getCtx(), getAD_Reference_Value_ID(), get_TrxName());
|
||||||
if (rt != null)
|
if (rt != null) {
|
||||||
foreignTable = rt.getAD_Table().getTableName();
|
MTable table = MTable.get(getCtx(), rt.getAD_Table_ID(), get_TrxName());
|
||||||
|
if (table == null) {
|
||||||
|
throw new AdempiereException("Table " + rt.getAD_Table_ID() + " not found");
|
||||||
|
}
|
||||||
|
foreignTable = table.getTableName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (DisplayType.Button == refid) {
|
} else if (DisplayType.Button == refid) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.logging.Level;
|
||||||
|
|
||||||
import javax.xml.transform.sax.TransformerHandler;
|
import javax.xml.transform.sax.TransformerHandler;
|
||||||
|
|
||||||
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.adempiere.pipo2.AbstractElementHandler;
|
import org.adempiere.pipo2.AbstractElementHandler;
|
||||||
import org.adempiere.pipo2.Element;
|
import org.adempiere.pipo2.Element;
|
||||||
import org.adempiere.pipo2.PIPOContext;
|
import org.adempiere.pipo2.PIPOContext;
|
||||||
|
@ -182,9 +183,14 @@ public class ColumnElementHandler extends AbstractElementHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deferFK(Element element, MColumn mColumn) {
|
private void deferFK(Element element, MColumn mColumn) {
|
||||||
|
try {
|
||||||
String foreignTable = mColumn.getReferenceTableName();
|
String foreignTable = mColumn.getReferenceTableName();
|
||||||
if (foreignTable != null && ! "AD_Ref_List".equals(foreignTable))
|
if (foreignTable != null && ! "AD_Ref_List".equals(foreignTable))
|
||||||
element.deferFKColumnID = mColumn.getAD_Column_ID();
|
element.deferFKColumnID = mColumn.getAD_Column_ID();
|
||||||
|
} catch (AdempiereException e) {
|
||||||
|
// AdempiereException thrown in mColumn.getReferenceTableName() when the table is not created yet
|
||||||
|
element.deferFKColumnID = mColumn.getAD_Column_ID();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void syncColumn(PIPOContext ctx, MColumn mColumn, String action,
|
private void syncColumn(PIPOContext ctx, MColumn mColumn, String action,
|
||||||
|
|
|
@ -186,11 +186,11 @@ public class PoFiller{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (po.get_ColumnIndex(columnName) >= 0) {
|
if (po.get_ColumnIndex(columnName) >= 0) {
|
||||||
MColumn col = MColumn.get(ctx.ctx, po.get_TableName(), columnName);
|
MColumn col = MColumn.get(ctx.ctx, po.get_TableName(), columnName, po.get_TrxName());
|
||||||
MTable foreignTable = null;
|
MTable foreignTable = null;
|
||||||
String refTableName = col.getReferenceTableName();
|
String refTableName = col.getReferenceTableName();
|
||||||
if (refTableName != null) {
|
if (refTableName != null) {
|
||||||
foreignTable = MTable.get(Env.getCtx(), refTableName);
|
foreignTable = MTable.get(Env.getCtx(), refTableName, po.get_TrxName());
|
||||||
} else {
|
} else {
|
||||||
if ("Record_ID".equalsIgnoreCase(columnName)) {
|
if ("Record_ID".equalsIgnoreCase(columnName)) {
|
||||||
// special case - get the foreign table using AD_Table_ID
|
// special case - get the foreign table using AD_Table_ID
|
||||||
|
@ -207,7 +207,7 @@ public class PoFiller{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tableID > 0) {
|
if (tableID > 0) {
|
||||||
foreignTable = MTable.get(Env.getCtx(), tableID);
|
foreignTable = MTable.get(Env.getCtx(), tableID, po.get_TrxName());
|
||||||
refTableName = foreignTable.getTableName();
|
refTableName = foreignTable.getTableName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue