IDEMPIERE-5008 Performance improvement of "NF3.0 Tree On Any Table". (#938)

Co-authored-by: jpiere <h.hagiwara@compiere-distribution-lab.net>
This commit is contained in:
HideakiHagiwara 2021-10-21 16:48:09 +09:00 committed by GitHub
parent 1970ee6539
commit 9f835c3e15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -286,7 +286,7 @@ public class MTree extends MTree_Base
try try
{ {
// load Node details - addToTree -> getNodeDetail // load Node details - addToTree -> getNodeDetail
getNodeDetails(); getNodeDetails(linkColName, linkID);
// //
pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt.setInt(1, getAD_Tree_ID()); pstmt.setInt(1, getAD_Tree_ID());
@ -445,7 +445,7 @@ public class MTree extends MTree_Base
* - Node_ID * - Node_ID
* The SQL contains security/access control * The SQL contains security/access control
*/ */
private void getNodeDetails () private void getNodeDetails (String linkColName, int linkID)
{ {
// SQL for Node Info // SQL for Node Info
StringBuilder sqlNode = new StringBuilder(); StringBuilder sqlNode = new StringBuilder();
@ -506,7 +506,19 @@ public class MTree extends MTree_Base
sqlNode.append("t.Description,t.IsSummary,").append(color) sqlNode.append("t.Description,t.IsSummary,").append(color)
.append(" FROM ").append(tableName).append(" t "); .append(" FROM ").append(tableName).append(" t ");
if (!m_editable) 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()) { } else if (isValueDisplayed()) {
sqlNode.append("SELECT t.").append(columnNameX) sqlNode.append("SELECT t.").append(columnNameX)
.append("_ID, t.Value || ' - ' || t.Name, t.Description, t.IsSummary,").append(color) .append("_ID, t.Value || ' - ' || t.Name, t.Description, t.IsSummary,").append(color)