From 9f835c3e15bde562ae5946da3793f3c0e1f4f493 Mon Sep 17 00:00:00 2001 From: HideakiHagiwara <58879487+HideakiHagiwara@users.noreply.github.com> Date: Thu, 21 Oct 2021 16:48:09 +0900 Subject: [PATCH] IDEMPIERE-5008 Performance improvement of "NF3.0 Tree On Any Table". (#938) Co-authored-by: jpiere --- .../src/org/compiere/model/MTree.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MTree.java b/org.adempiere.base/src/org/compiere/model/MTree.java index 6de50d774a..3ee329e1f9 100644 --- a/org.adempiere.base/src/org/compiere/model/MTree.java +++ b/org.adempiere.base/src/org/compiere/model/MTree.java @@ -286,7 +286,7 @@ public class MTree extends MTree_Base try { // load Node details - addToTree -> getNodeDetail - getNodeDetails(); + getNodeDetails(linkColName, linkID); // pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt.setInt(1, getAD_Tree_ID()); @@ -445,7 +445,7 @@ public class MTree extends MTree_Base * - Node_ID * The SQL contains security/access control */ - private void getNodeDetails () + private void getNodeDetails (String linkColName, int linkID) { // SQL for Node Info StringBuilder sqlNode = new StringBuilder(); @@ -506,7 +506,19 @@ public class MTree extends MTree_Base sqlNode.append("t.Description,t.IsSummary,").append(color) .append(" FROM ").append(tableName).append(" t "); if (!m_editable) - sqlNode.append(" WHERE t.IsActive='Y'"); + { + if (Util.isEmpty(linkColName) || linkID==0 ) + sqlNode.append(" WHERE t.IsActive='Y'"); + else + sqlNode.append(" WHERE t.IsActive='Y' AND t.").append(linkColName).append("=").append(linkID); + + }else { + + if (!Util.isEmpty(linkColName) && linkID > 0) + sqlNode.append(" WHERE t.").append(linkColName).append("=").append(linkID); + + } + } else if (isValueDisplayed()) { sqlNode.append("SELECT t.").append(columnNameX) .append("_ID, t.Value || ' - ' || t.Name, t.Description, t.IsSummary,").append(color)