IDEMPIERE-5889 - Cannot Open Lookup Info Window if no Window is Defined for the Table (#2070)
* IDEMPIERE-5889 - Cannot Open Lookup Info Window if no Window is Defined for the Table * IDEMPIERE-5889 - expand displayed columns' where clause according to Heng Sin * IDEMPIERE-5889 - add aliases to displayed columns' where clause
This commit is contained in:
parent
3bee3c94ac
commit
b8379d15be
|
@ -43,8 +43,10 @@ import org.compiere.model.I_C_ElementValue;
|
||||||
import org.compiere.model.MColumn;
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MLookupFactory;
|
import org.compiere.model.MLookupFactory;
|
||||||
import org.compiere.model.MReference;
|
import org.compiere.model.MReference;
|
||||||
|
import org.compiere.model.MTab;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
import org.compiere.model.PO;
|
import org.compiere.model.PO;
|
||||||
|
import org.compiere.model.Query;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
@ -394,18 +396,23 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
|
||||||
{
|
{
|
||||||
MTable table = MTable.get(Env.getCtx(), p_tableName);
|
MTable table = MTable.get(Env.getCtx(), p_tableName);
|
||||||
String uucolName = PO.getUUIDColumnName(p_tableName);
|
String uucolName = PO.getUUIDColumnName(p_tableName);
|
||||||
|
boolean hasWindowAndTab = new Query(Env.getCtx(), MTab.Table_Name, " AD_Table_ID = ? ", null)
|
||||||
|
.setParameters(table.getAD_Table_ID())
|
||||||
|
.match();
|
||||||
|
|
||||||
// Get Query Columns
|
// Get Query Columns
|
||||||
final String sqlqc = "SELECT c.ColumnName, t.AD_Table_ID, t.TableName, c.ColumnSql "
|
String sqlqc = "SELECT c.ColumnName, t.AD_Table_ID, t.TableName, c.ColumnSql "
|
||||||
+ "FROM AD_Table t"
|
+ "FROM AD_Table t"
|
||||||
+ " INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID)"
|
+ " INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID)"
|
||||||
+ "WHERE c.AD_Reference_ID IN (10,14)"
|
+ "WHERE c.AD_Reference_ID IN (10,14)"
|
||||||
+ " AND t.TableName=?" // #1
|
+ " AND t.TableName=? "; // #1
|
||||||
|
if(hasWindowAndTab) {
|
||||||
// Displayed in Window
|
// Displayed in Window
|
||||||
+ " AND EXISTS (SELECT * FROM AD_Field f "
|
sqlqc += " AND EXISTS (SELECT * FROM AD_Field f "
|
||||||
+ "WHERE f.AD_Column_ID=c.AD_Column_ID"
|
+ " WHERE f.AD_Column_ID=c.AD_Column_ID "
|
||||||
+ " AND f.IsDisplayed='Y' AND f.IsEncrypted='N' AND f.ObscureType IS NULL) "
|
+ " AND f.IsDisplayed='Y' AND f.IsEncrypted='N' AND f.ObscureType IS NULL) ";
|
||||||
+ "ORDER BY c.IsIdentifier DESC, c.IsSelectionColumn Desc, c.AD_Reference_ID, c.SeqNoSelection, c.SeqNo";
|
}
|
||||||
|
sqlqc += " ORDER BY c.IsIdentifier DESC, c.IsSelectionColumn Desc, c.AD_Reference_ID, c.SeqNoSelection, c.SeqNo";
|
||||||
|
|
||||||
int AD_Table_ID = 0;
|
int AD_Table_ID = 0;
|
||||||
String tableName = null;
|
String tableName = null;
|
||||||
|
@ -490,29 +497,49 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
|
||||||
}
|
}
|
||||||
ArrayList<ColumnInfo> list = new ArrayList<ColumnInfo>();
|
ArrayList<ColumnInfo> list = new ArrayList<ColumnInfo>();
|
||||||
StringBuilder sqlc = new StringBuilder().append(
|
StringBuilder sqlc = new StringBuilder().append(
|
||||||
"SELECT c.ColumnName, c.AD_Reference_ID, c.IsKey, f.IsDisplayed, c.AD_Reference_Value_ID, c.ColumnSql, c.AD_Column_ID "
|
"SELECT c.ColumnName, c.AD_Reference_ID, c.IsKey, "); // 1-3
|
||||||
|
if(hasWindowAndTab) { // 4
|
||||||
|
sqlc.append(" f.IsDisplayed, ");
|
||||||
|
} else {
|
||||||
|
sqlc.append(" 'Y', ");
|
||||||
|
}
|
||||||
|
sqlc.append(" c.AD_Reference_Value_ID, c.ColumnSql, c.AD_Column_ID " // 5-7
|
||||||
+ "FROM AD_Column c"
|
+ "FROM AD_Column c"
|
||||||
+ " INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID)"
|
+ " INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID)");
|
||||||
+ " INNER JOIN AD_Tab tab ON (t.AD_Table_ID=tab.AD_Table_ID)"
|
if(hasWindowAndTab) {
|
||||||
+ " INNER JOIN AD_Field f ON (tab.AD_Tab_ID=f.AD_Tab_ID AND f.AD_Column_ID=c.AD_Column_ID) "
|
sqlc.append(" INNER JOIN AD_Tab tab ON (t.AD_Table_ID=tab.AD_Table_ID)"
|
||||||
+ "WHERE t.AD_Table_ID=? "
|
+ " INNER JOIN AD_Field f ON (tab.AD_Tab_ID=f.AD_Tab_ID AND f.AD_Column_ID=c.AD_Column_ID) ");
|
||||||
+ " AND tab.IsSortTab='N'"
|
}
|
||||||
+ " AND tab.Ad_Tab_ID=(SELECT MIN(mt.AD_Tab_ID) FROM AD_tab mt WHERE mt.AD_Window_ID=? AND mt.AD_Table_ID=t.AD_Table_ID AND mt.IsActive='Y')"
|
sqlc.append( "WHERE t.AD_Table_ID=? ");
|
||||||
+ " AND (c.IsKey='Y' OR "
|
if(hasWindowAndTab) {
|
||||||
+ " (f.IsEncrypted='N' AND f.ObscureType IS NULL)) "
|
sqlc.append(" AND tab.IsSortTab='N' "
|
||||||
+ " AND c.IsActive = 'Y' "
|
+ " AND tab.Ad_Tab_ID=(SELECT MIN(mt.AD_Tab_ID) FROM AD_tab mt WHERE mt.AD_Window_ID=? AND mt.AD_Table_ID=t.AD_Table_ID AND mt.IsActive='Y')"
|
||||||
|
+ " AND (c.IsKey='Y' OR "
|
||||||
|
+ " (f.IsEncrypted='N' AND f.ObscureType IS NULL))");
|
||||||
|
} else {
|
||||||
|
sqlc.append(" AND (c.IsKey='Y' "
|
||||||
|
+ " OR c.IsIdentifier='Y' "
|
||||||
|
+ " OR c.IsParent='Y' "
|
||||||
|
+ " OR c.IsSelectionColumn='Y' "
|
||||||
|
+ " OR Upper(c.ColumnName) IN ('NAME','VALUE','DESCRIPTION','DOCUMENTNO') "
|
||||||
|
+ " OR Upper(c.ColumnName) Like '%_NAME' "
|
||||||
|
+ " OR Upper(c.ColumnName) Like '%_Value') ");
|
||||||
|
}
|
||||||
|
sqlc.append(" AND c.IsActive = 'Y' "
|
||||||
+ "ORDER BY ");
|
+ "ORDER BY ");
|
||||||
if (table.isUUIDKeyTable() || p_keyColumn.endsWith("_UU"))
|
if (table.isUUIDKeyTable() || p_keyColumn.endsWith("_UU"))
|
||||||
sqlc.append("CASE WHEN c.columnname=").append(DB.TO_STRING(uucolName)).append("THEN 0 ELSE 1 END");
|
sqlc.append("CASE WHEN c.columnname=").append(DB.TO_STRING(uucolName)).append("THEN 0 ELSE 1 END");
|
||||||
else
|
else
|
||||||
sqlc.append("c.IsKey DESC");
|
sqlc.append("c.IsKey DESC");
|
||||||
sqlc.append(", f.SeqNo");
|
if(hasWindowAndTab)
|
||||||
|
sqlc.append(", f.SeqNo");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sqlc.toString(), null);
|
pstmt = DB.prepareStatement(sqlc.toString(), null);
|
||||||
pstmt.setInt(1, AD_Table_ID);
|
pstmt.setInt(1, AD_Table_ID);
|
||||||
pstmt.setInt(2, AD_Window_ID);
|
if(hasWindowAndTab)
|
||||||
|
pstmt.setInt(2, AD_Window_ID);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
boolean keyDefined = false;
|
boolean keyDefined = false;
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
|
|
Loading…
Reference in New Issue