IDEMPIERE-56 / IDEMPIERE-4723 Clean up iDempiere's code (#1402)

Cleanup useless code - as the value is assigned the condition below is always true
This commit is contained in:
Carlos Ruiz 2022-07-21 12:37:27 +02:00 committed by GitHub
parent b0e7389f0a
commit 9a977d6e16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 35 additions and 41 deletions

View File

@ -382,50 +382,44 @@ public final class AEnv
{ {
if (lookup == null) if (lookup == null)
return; return;
//
MQuery zoomQuery = lookup.getZoomQuery();
// still null means the field is empty or not selected item // still null means the field is empty or not selected item
if (value == null) if (value == null)
value = -1; value = -1;
//
// If not already exist or exact value MQuery zoomQuery = new MQuery(); // ColumnName might be changed in MTab.validateQuery
if (zoomQuery == null || value != null) String column = lookup.getColumnName();
{ // Check if it is a List Reference
zoomQuery = new MQuery(); // ColumnName might be changed in MTab.validateQuery if (lookup instanceof MLookup)
String column = lookup.getColumnName(); {
// Check if it is a List Reference int AD_Reference_ID = ((MLookup)lookup).getAD_Reference_Value_ID();
if (lookup instanceof MLookup) if (AD_Reference_ID > 0)
{ {
int AD_Reference_ID = ((MLookup)lookup).getAD_Reference_Value_ID(); MReference reference = MReference.get(AD_Reference_ID);
if (AD_Reference_ID > 0) if (reference.getValidationType().equals(MReference.VALIDATIONTYPE_ListValidation))
{ {
MReference reference = MReference.get(AD_Reference_ID); column = "AD_Ref_List_ID";
if (reference.getValidationType().equals(MReference.VALIDATIONTYPE_ListValidation)) value = DB.getSQLValue(null, "SELECT AD_Ref_List_ID FROM AD_Ref_List WHERE AD_Reference_ID=? AND Value=?", AD_Reference_ID, value);
{ }
column = "AD_Ref_List_ID"; }
value = DB.getSQLValue(null, "SELECT AD_Ref_List_ID FROM AD_Ref_List WHERE AD_Reference_ID=? AND Value=?", AD_Reference_ID, value); }
} //strip off table name, fully qualify name doesn't work when zoom into detail tab
} if (column.indexOf(".") > 0)
} {
//strip off table name, fully qualify name doesn't work when zoom into detail tab int p = column.indexOf(".");
if (column.indexOf(".") > 0) String tableName = column.substring(0, p);
{ column = column.substring(column.indexOf(".")+1);
int p = column.indexOf("."); zoomQuery.setZoomTableName(tableName);
String tableName = column.substring(0, p); zoomQuery.setZoomColumnName(column);
column = column.substring(column.indexOf(".")+1); }
zoomQuery.setZoomTableName(tableName); else
zoomQuery.setZoomColumnName(column); {
} zoomQuery.setZoomColumnName(column);
else //remove _ID to get table name
{ zoomQuery.setZoomTableName(column.substring(0, column.length() - 3));
zoomQuery.setZoomColumnName(column); }
//remove _ID to get table name zoomQuery.setZoomValue(value);
zoomQuery.setZoomTableName(column.substring(0, column.length() - 3)); zoomQuery.addRestriction(column, MQuery.EQUAL, value);
} zoomQuery.setRecordCount(1); // guess
zoomQuery.setZoomValue(value);
zoomQuery.addRestriction(column, MQuery.EQUAL, value);
zoomQuery.setRecordCount(1); // guess
}
if (value instanceof Integer && ((Integer) value).intValue() >= 0 && zoomQuery != null && zoomQuery.getZoomTableName() != null) { if (value instanceof Integer && ((Integer) value).intValue() >= 0 && zoomQuery != null && zoomQuery.getZoomTableName() != null) {
int tableId = MTable.getTable_ID(zoomQuery.getZoomTableName()); int tableId = MTable.getTable_ID(zoomQuery.getZoomTableName());
zoom(tableId, ((Integer) value).intValue(), zoomQuery, lookup.getWindowNo()); zoom(tableId, ((Integer) value).intValue(), zoomQuery, lookup.getWindowNo());