diff --git a/org.adempiere.base.process/src/org/compiere/process/CreateWindowFromTable.java b/org.adempiere.base.process/src/org/compiere/process/CreateWindowFromTable.java index 70db47e2da..ca603d8c1d 100644 --- a/org.adempiere.base.process/src/org/compiere/process/CreateWindowFromTable.java +++ b/org.adempiere.base.process/src/org/compiere/process/CreateWindowFromTable.java @@ -122,8 +122,7 @@ public class CreateWindowFromTable extends SvrProcess MWindow window; int tabSeqNo = 0; if (p_isNewWindow) { - if (MWindow.WINDOWTYPE_Transaction.equals(p_WindowType) && - table.getColumnIndex("Processed") <= 0) + if (MWindow.WINDOWTYPE_Transaction.equals(p_WindowType) && ! table.columnExistsInDB("Processed")) throw new AdempiereException(Msg.getMsg(getCtx(), "TrxWindowMandatoryProcessed")); int i = DB.getSQLValue(get_TrxName(), "SELECT 1 FROM AD_Window WHERE AD_Window.name = ?", table.getName()); @@ -183,9 +182,9 @@ public class CreateWindowFromTable extends SvrProcess tab.setIsSingleRow(true); //Default //Set order by - if (table.getColumnIndex("Value") > 0 && !table.getColumn("Value").isVirtualColumn()) + if (table.columnExistsInDB("Value")) tab.setOrderByClause(table.getTableName() + ".Value"); - else if (table.getColumnIndex("Name") > 0 && !table.getColumn("Name").isVirtualColumn()) + else if (table.columnExistsInDB("Name")) tab.setOrderByClause(table.getTableName() + ".Name"); else tab.setOrderByClause(table.getTableName() + ".Created DESC"); diff --git a/org.adempiere.base/src/org/adempiere/model/GenericZoomProvider.java b/org.adempiere.base/src/org/adempiere/model/GenericZoomProvider.java index a9d811ce11..16a5cdfeea 100644 --- a/org.adempiere.base/src/org/adempiere/model/GenericZoomProvider.java +++ b/org.adempiere.base/src/org/adempiere/model/GenericZoomProvider.java @@ -165,7 +165,7 @@ public class GenericZoomProvider implements IZoomProvider { final MQuery query = new MQuery(); MTable table = MTable.get(ctx, targetTableName); - if (table.getColumnIndex("AD_Client_ID") < 0) // table doesn't have AD_Client_ID + if (! table.columnExistsInDB("AD_Client_ID")) // table doesn't have AD_Client_ID return null; int tabIDLoop = AD_Tab_ID; diff --git a/org.adempiere.base/src/org/compiere/model/MTable.java b/org.adempiere.base/src/org/compiere/model/MTable.java index cd1dae7e68..eea1456af1 100644 --- a/org.adempiere.base/src/org/compiere/model/MTable.java +++ b/org.adempiere.base/src/org/compiere/model/MTable.java @@ -67,7 +67,7 @@ public class MTable extends X_AD_Table implements ImmutablePOSupport /** * */ - private static final long serialVersionUID = 2951110137945905890L; + private static final long serialVersionUID = -7981455044208282721L; public final static int MAX_OFFICIAL_ID = 999999; @@ -384,14 +384,10 @@ public class MTable extends X_AD_Table implements ImmutablePOSupport { if (columnName == null || columnName.length() == 0) return null; - getColumns(false); - // - for (int i = 0; i < m_columns.length; i++) - { - if (columnName.equalsIgnoreCase(m_columns[i].getColumnName())) - return m_columns[i]; - } - return null; + int idx = getColumnIndex(columnName); + if (idx < 0) + return null; + return m_columns[idx]; } // getColumn /** @@ -410,6 +406,27 @@ public class MTable extends X_AD_Table implements ImmutablePOSupport return -1; } // getColumnIndex + /** + * Column exists and is not virtual? + * @param ColumnName column name + * @return boolean - true indicating that the column exists in the table and is not virtual + */ + public synchronized boolean columnExistsInDB (String ColumnName) + { + MColumn column = getColumn(ColumnName); + return column != null && ! column.isVirtualColumn(); + } // columnExistsInDB + + /** + * Column exists? + * @param ColumnName column name + * @return boolean - true indicating that the column exists in dictionary + */ + public synchronized boolean columnExistsInDictionary (String ColumnName) + { + return getColumnIndex(ColumnName) >= 0; + } // columnExistsInDictionary + /** * Get Column Index * @param AD_Column_ID column @@ -425,7 +442,7 @@ public class MTable extends X_AD_Table implements ImmutablePOSupport return -1; } // getColumnIndex - + /** * Table has a single Key * @return true if table has single key column diff --git a/org.adempiere.base/src/org/compiere/model/MTree_Base.java b/org.adempiere.base/src/org/compiere/model/MTree_Base.java index 30d817a2f0..efc21424e4 100644 --- a/org.adempiere.base/src/org/compiere/model/MTree_Base.java +++ b/org.adempiere.base/src/org/compiere/model/MTree_Base.java @@ -406,12 +406,12 @@ public class MTree_Base extends X_AD_Tree implements ImmutablePOSupport String tableName = getSourceTableName(true); MTable table = MTable.get(getCtx(), tableName); - if (table.getColumnIndex("IsSummary") < 0) { + if (! table.columnExistsInDB("IsSummary")) { // IsSummary is mandatory column to have a tree log.saveError("Error", "IsSummary column required for tree tables"); return false; } - if (table.getColumnIndex("Value") < 0) { + if (! table.columnExistsInDB("Value")) { if (isTreeDrivenByValue()) { // Value is mandatory column to have a tree driven by Value setIsTreeDrivenByValue(false); diff --git a/org.adempiere.base/src/org/idempiere/process/MoveClient.java b/org.adempiere.base/src/org/idempiere/process/MoveClient.java index 07d6316515..54d762320e 100644 --- a/org.adempiere.base/src/org/idempiere/process/MoveClient.java +++ b/org.adempiere.base/src/org/idempiere/process/MoveClient.java @@ -831,7 +831,7 @@ public class MoveClient extends SvrProcess { || "AD_Language".equalsIgnoreCase(columnName) || "EntityType".equalsIgnoreCase(columnName))) { convertTable = ""; - } else if ("Record_ID".equalsIgnoreCase(columnName) && table.getColumnIndex("AD_Table_ID") > 0) { + } else if ("Record_ID".equalsIgnoreCase(columnName) && table.columnExistsInDB("AD_Table_ID")) { // Special case for Record_ID int tableId = rsGD.getInt("AD_Table_ID"); if (tableId > 0) { @@ -920,7 +920,7 @@ public class MoveClient extends SvrProcess { // not found in the table - try to get it again - could be missed in first pass convertedId = getLocalIDFor(convertTable, id, tableName); if (convertedId < 0) { - if (("Record_ID".equalsIgnoreCase(columnName) && table.getColumnIndex("AD_Table_ID") > 0) + if (("Record_ID".equalsIgnoreCase(columnName) && table.columnExistsInDB("AD_Table_ID")) || (("Node_ID".equalsIgnoreCase(columnName) || "Parent_ID".equalsIgnoreCase(columnName)) && ( "AD_TreeNode".equalsIgnoreCase(tableName) || "AD_TreeNodeMM".equalsIgnoreCase(tableName) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java index 86d17b769c..3f55128c4e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java @@ -241,7 +241,7 @@ ContextMenuListener, IZoomableEditor if (lookup != null && (lookup.getDisplayType() == DisplayType.TableDir || lookup.getDisplayType() == DisplayType.Table)) // only for Table & TableDir { MTable table = MTable.get(Env.getCtx(), tableName); - isShortListAvailable = (table.getColumnIndex("IsShortList") >= 0); + isShortListAvailable = table.columnExistsInDB("IsShortList"); if (isShortListAvailable) { onlyShortListItems=true;