From 68ae89d149aaefa3f3e80f65204d0433d3c9402e Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 10 Dec 2009 01:07:52 +0000 Subject: [PATCH] Peer review for: [2904737] - fix BOM back compatibility [2910358] - Error in context when Key field is found in different tabs. [2910368] - Error in context when IsActive field is found in different [2871039] - Tax Rate Parent window not working Guarantee backward compatibility with previous approach Added method to get tab context variables without defaulting to window or login variable (required safety measure) Some refactorings to improve reading and performance Reactivate hidden tabs - and move back BOM & Formula window to manufacturing menu --- base/src/org/compiere/model/GridField.java | 13 +------- base/src/org/compiere/model/GridTab.java | 31 ++++++++--------- base/src/org/compiere/model/GridTable.java | 29 ++++++++-------- base/src/org/compiere/util/Env.java | 25 ++++++++++++++ migration/354a-trunk/oracle/629_BF2904737.sql | 33 +++++++++++++++++++ .../354a-trunk/postgresql/629_BF2904737.sql | 33 +++++++++++++++++++ 6 files changed, 121 insertions(+), 43 deletions(-) create mode 100644 migration/354a-trunk/oracle/629_BF2904737.sql create mode 100644 migration/354a-trunk/postgresql/629_BF2904737.sql diff --git a/base/src/org/compiere/model/GridField.java b/base/src/org/compiere/model/GridField.java index 548cba42c4..ac6474393a 100644 --- a/base/src/org/compiere/model/GridField.java +++ b/base/src/org/compiere/model/GridField.java @@ -69,8 +69,6 @@ import org.compiere.util.Evaluator; public class GridField implements Serializable, Evaluatee { - - /** * */ @@ -1295,11 +1293,6 @@ public class GridField ((Boolean)newValue).booleanValue()); Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName, m_value==null ? null : (((Boolean)m_value) ? "Y" : "N")); - //BF [ 2910368 ] - if(m_vo.ColumnName.equals("IsActive")) - { - Env.setContext(m_vo.ctx, m_vo.WindowNo,m_vo.TabNo, m_vo.ColumnName, ((Boolean)newValue).booleanValue() ? "Y" : "N"); - } } else if (newValue instanceof Timestamp) { @@ -1313,12 +1306,8 @@ public class GridField backupValue(); // teo_sarca [ 1699826 ] Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, m_value==null ? null : m_value.toString()); - //BF [ 2910358 ] - if(isKey()) - { - Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName, + Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName, m_value==null ? null : m_value.toString()); - } } // Does not fire, if same value diff --git a/base/src/org/compiere/model/GridTab.java b/base/src/org/compiere/model/GridTab.java index c95cb63bb2..80fc0ea523 100644 --- a/base/src/org/compiere/model/GridTab.java +++ b/base/src/org/compiere/model/GridTab.java @@ -99,7 +99,6 @@ import org.compiere.util.ValueNamePair; */ public class GridTab implements DataStatusListener, Evaluatee, Serializable { - /** * */ @@ -625,16 +624,18 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable } else { - //BF [ 2910358 ] - //String value = Env.getContext(m_vo.ctx, m_vo.WindowNo, lc, true); - String value = Env.getContext(m_vo.ctx, m_vo.WindowNo, this.getParentTabNo(),lc); - //BF [ 2910358 ] - // explicit parent link defined + String value = null; if ( m_parentColumnName.length() > 0 ) { - // value = Env.getContext(m_vo.ctx, m_vo.WindowNo, m_parentColumnName, true); - value = Env.getContext(m_vo.ctx, m_vo.WindowNo, this.getParentTabNo(),m_parentColumnName); - } + // explicit parent link defined + value = Env.getContext(m_vo.ctx, m_vo.WindowNo, getParentTabNo(), m_parentColumnName, true); + if (value == null || value.length() == 0) + value = Env.getContext(m_vo.ctx, m_vo.WindowNo, m_parentColumnName, true); // back compatibility + } else { + value = Env.getContext(m_vo.ctx, m_vo.WindowNo, getParentTabNo(), lc, true); + if (value == null || value.length() == 0) + value = Env.getContext(m_vo.ctx, m_vo.WindowNo, lc, true); // back compatibility + } // Same link value? if (refresh) @@ -3048,15 +3049,15 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable private int getParentTabNo() { int tabNo = m_vo.TabNo; - int currentLevel = Env.getContextAsInt(m_vo.ctx, m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel); + int currentLevel = m_vo.TabLevel; int parentLevel = currentLevel-1; if (parentLevel < 0) return tabNo; - while (parentLevel != currentLevel) - { - tabNo--; - currentLevel = Env.getContextAsInt(m_vo.ctx, m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel); - } + while (parentLevel != currentLevel) + { + tabNo--; + currentLevel = Env.getContextAsInt(m_vo.ctx, m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel); + } return tabNo; } } // GridTab diff --git a/base/src/org/compiere/model/GridTable.java b/base/src/org/compiere/model/GridTable.java index 88b63a7b44..5dca2d8f5d 100644 --- a/base/src/org/compiere/model/GridTable.java +++ b/base/src/org/compiere/model/GridTable.java @@ -82,8 +82,6 @@ import org.compiere.util.ValueNamePair; public class GridTable extends AbstractTableModel implements Serializable { - - /** * */ @@ -122,8 +120,6 @@ public class GridTable extends AbstractTableModel private boolean m_withAccessControl; private boolean m_readOnly = true; private boolean m_deleteable = true; - - public static final String CTX_KeyColumnName = "KeyColumnName"; // /** Rowcount */ @@ -300,15 +296,16 @@ public class GridTable extends AbstractTableModel select.append(" FROM ").append(m_tableName); m_SQL_Select = select.toString(); m_SQL_Count = "SELECT COUNT(*) FROM " + m_tableName; - //BF [ 2910358 ] + //BF [ 2910358 ] //Restore the Original Value for Key Column Name based in Tab Context Value - String parentKey = Env.getContext(m_ctx, m_WindowNo, getParentTabNo(), CTX_KeyColumnName); - String valueKey = Env.getContext(m_ctx, m_WindowNo, getParentTabNo(), parentKey); - - if(valueKey != null && valueKey.length() > 0) + int parentTabNo = getParentTabNo(); + String parentKey = Env.getContext(m_ctx, m_WindowNo, parentTabNo, GridTab.CTX_KeyColumnName, true); + String valueKey = Env.getContext(m_ctx, m_WindowNo, parentTabNo, parentKey, true); + String currKey = Env.getContext(m_ctx, m_WindowNo, parentKey); + if (valueKey != null && valueKey.length() > 0 && parentKey != null && parentKey.length() > 0 && ! currKey.equals(valueKey)) { - Env.setContext(m_ctx, m_WindowNo, parentKey, valueKey); - } + Env.setContext(m_ctx, m_WindowNo, parentKey, valueKey); + } StringBuffer where = new StringBuffer(""); // WHERE @@ -3256,11 +3253,11 @@ public class GridTable extends AbstractTableModel int parentLevel = currentLevel-1; if (parentLevel < 0) return tabNo; - while (parentLevel != currentLevel) - { - tabNo--; - currentLevel = Env.getContextAsInt(m_ctx, m_WindowNo, tabNo, GridTab.CTX_TabLevel); - } + while (parentLevel != currentLevel) + { + tabNo--; + currentLevel = Env.getContextAsInt(m_ctx, m_WindowNo, tabNo, GridTab.CTX_TabLevel); + } return tabNo; } } diff --git a/base/src/org/compiere/util/Env.java b/base/src/org/compiere/util/Env.java index 2772532b6e..5650f94eb7 100644 --- a/base/src/org/compiere/util/Env.java +++ b/base/src/org/compiere/util/Env.java @@ -531,6 +531,31 @@ public final class Env return s; } // getContext + /** + * Get Value of Context for Window & Tab, + * if not found global context if available. + * If TabNo is TAB_INFO only tab's context will be checked. + * @param ctx context + * @param WindowNo window no + * @param TabNo tab no + * @param context context key + * @param onlyTab if true, no window value is searched + * @return value or "" + */ + public static String getContext (Properties ctx, int WindowNo, int TabNo, String context, boolean onlyTab) + { + if (ctx == null || context == null) + throw new IllegalArgumentException ("Require Context"); + String s = ctx.getProperty(WindowNo+"|"+TabNo+"|"+context); + // If TAB_INFO, don't check Window and Global context - teo_sarca BF [ 2017987 ] + if (TAB_INFO == TabNo) + return s != null ? s : ""; + // + if (s == null && ! onlyTab) + return getContext(ctx, WindowNo, context, false); + return s; + } // getContext + /** * Get Context and convert it to an integer (0 if error) * @param ctx context diff --git a/migration/354a-trunk/oracle/629_BF2904737.sql b/migration/354a-trunk/oracle/629_BF2904737.sql new file mode 100644 index 0000000000..39fe1dad99 --- /dev/null +++ b/migration/354a-trunk/oracle/629_BF2904737.sql @@ -0,0 +1,33 @@ +-- Dec 9, 2009 7:28:02 PM COT +-- BF [2904737] - fix BOM back compatibility +UPDATE AD_Tab SET IsActive='Y',Updated=TO_DATE('2009-12-09 19:28:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=53286 +; + +-- Dec 9, 2009 7:28:06 PM COT +UPDATE AD_Tab SET IsActive='Y',Updated=TO_DATE('2009-12-09 19:28:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=53287 +; + +-- Dec 9, 2009 7:28:42 PM COT +UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=0, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53023 +; + +-- Dec 9, 2009 7:28:42 PM COT +UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=1, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53024 +; + +-- Dec 9, 2009 7:28:43 PM COT +UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=2, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53025 +; + +-- Dec 9, 2009 7:28:43 PM COT +UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=3, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53026 +; + +-- Dec 9, 2009 7:28:43 PM COT +UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=4, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53027 +; + +-- Dec 9, 2009 7:28:43 PM COT +UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=5, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53028 +; + diff --git a/migration/354a-trunk/postgresql/629_BF2904737.sql b/migration/354a-trunk/postgresql/629_BF2904737.sql new file mode 100644 index 0000000000..08501b6156 --- /dev/null +++ b/migration/354a-trunk/postgresql/629_BF2904737.sql @@ -0,0 +1,33 @@ +-- Dec 9, 2009 7:28:02 PM COT +-- BF [2904737] - fix BOM back compatibility +UPDATE AD_Tab SET IsActive='Y',Updated=TO_TIMESTAMP('2009-12-09 19:28:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=53286 +; + +-- Dec 9, 2009 7:28:06 PM COT +UPDATE AD_Tab SET IsActive='Y',Updated=TO_TIMESTAMP('2009-12-09 19:28:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=53287 +; + +-- Dec 9, 2009 7:28:42 PM COT +UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=0, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=10 AND Node_ID=53023 +; + +-- Dec 9, 2009 7:28:42 PM COT +UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=1, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=10 AND Node_ID=53024 +; + +-- Dec 9, 2009 7:28:43 PM COT +UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=2, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=10 AND Node_ID=53025 +; + +-- Dec 9, 2009 7:28:43 PM COT +UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=3, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=10 AND Node_ID=53026 +; + +-- Dec 9, 2009 7:28:43 PM COT +UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=4, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=10 AND Node_ID=53027 +; + +-- Dec 9, 2009 7:28:43 PM COT +UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=5, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=10 AND Node_ID=53028 +; +