Fix [3159033] - List fields zoom incorrectly

http://sourceforge.net/support/tracker.php?aid=3159033
Refactored DB.isSOTrx to avoid launching log errors on postgresql
This commit is contained in:
Carlos Ruiz 2011-03-26 01:01:25 -05:00
parent 4c46bf37cc
commit 06bc5898e0
3 changed files with 122 additions and 99 deletions

View File

@ -52,6 +52,7 @@ import org.compiere.model.MRole;
import org.compiere.model.MSequence; import org.compiere.model.MSequence;
import org.compiere.model.MSysConfig; import org.compiere.model.MSysConfig;
import org.compiere.model.MSystem; import org.compiere.model.MSystem;
import org.compiere.model.MTable;
import org.compiere.model.PO; import org.compiere.model.PO;
import org.compiere.model.POResultSet; import org.compiere.model.POResultSet;
import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfo;
@ -1788,6 +1789,10 @@ public final class DB
} }
// //
boolean isSOTrx = true; boolean isSOTrx = true;
boolean noIsSOTrxColumn = false;
if (MTable.get(Env.getCtx(), TableName).getColumn("IsSOTrx") == null) {
noIsSOTrxColumn = true;
} else {
String sql = "SELECT IsSOTrx FROM " + TableName String sql = "SELECT IsSOTrx FROM " + TableName
+ " WHERE " + whereClause; + " WHERE " + whereClause;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
@ -1801,11 +1806,23 @@ public final class DB
} }
catch (Exception e) catch (Exception e)
{ {
if (TableName.endsWith("Line")) noIsSOTrxColumn = true;
}
finally
{ {
close(rs, pstmt);
rs= null;
pstmt = null;
}
}
if (noIsSOTrxColumn && TableName.endsWith("Line")) {
noIsSOTrxColumn = false;
String hdr = TableName.substring(0, TableName.indexOf("Line")); String hdr = TableName.substring(0, TableName.indexOf("Line"));
if (MTable.get(Env.getCtx(), hdr).getColumn("IsSOTrx") == null) {
noIsSOTrxColumn = true;
} else {
// use IN instead of EXISTS as the subquery should be highly selective // use IN instead of EXISTS as the subquery should be highly selective
sql = "SELECT IsSOTrx FROM " + hdr String sql = "SELECT IsSOTrx FROM " + hdr
+ " h WHERE h." + hdr + "_ID IN (SELECT l." + hdr + "_ID FROM " + TableName + " h WHERE h." + hdr + "_ID IN (SELECT l." + hdr + "_ID FROM " + TableName
+ " l WHERE " + whereClause + ")"; + " l WHERE " + whereClause + ")";
PreparedStatement pstmt2 = null; PreparedStatement pstmt2 = null;
@ -1819,28 +1836,18 @@ public final class DB
} }
catch (Exception ee) catch (Exception ee)
{ {
ee = getSQLException(ee); noIsSOTrxColumn = true;
log.log(Level.FINEST, sql + " - " + e.getMessage(), ee);
} }
finally finally
{ {
close(rs2, pstmt2); close(rs2, pstmt2);
rs= null; rs2= null;
pstmt = null; pstmt2 = null;
} }
} }
else
{
log.log(Level.FINEST, TableName + " - No SOTrx", e);
}
}
finally
{
close(rs);
close(pstmt);
rs= null;
pstmt = null;
} }
if (noIsSOTrxColumn)
log.log(Level.FINEST, TableName + " - No SOTrx");
return isSOTrx; return isSOTrx;
} // isSOTrx } // isSOTrx

View File

@ -1293,6 +1293,11 @@ public class VLookup extends JComponent
if (m_lookup != null && m_lookup instanceof MLookup) if (m_lookup != null && m_lookup instanceof MLookup)
{ {
int AD_Reference_ID = ((MLookup)m_lookup).getAD_Reference_Value_ID(); int AD_Reference_ID = ((MLookup)m_lookup).getAD_Reference_Value_ID();
if (DisplayType.List == m_lookup.getDisplayType()) {
keyColumnName = "AD_Ref_List_ID";
keyTableName = "AD_Ref_List";
value = DB.getSQLValue(null, "SELECT AD_Ref_List_ID FROM AD_Ref_List WHERE AD_Reference_ID=? AND Value=?", AD_Reference_ID, value);
} else {
if (AD_Reference_ID != 0) if (AD_Reference_ID != 0)
{ {
String query = "SELECT kc.ColumnName, kt.TableName" String query = "SELECT kc.ColumnName, kt.TableName"
@ -1324,6 +1329,8 @@ public class VLookup extends JComponent
rs = null; pstmt = null; rs = null; pstmt = null;
} }
} // Table Reference } // Table Reference
}
} // MLookup } // MLookup
if(keyColumnName != null && keyColumnName.length() !=0) if(keyColumnName != null && keyColumnName.length() !=0)

View File

@ -43,11 +43,13 @@ import org.compiere.acct.Doc;
import org.compiere.model.GridWindowVO; import org.compiere.model.GridWindowVO;
import org.compiere.model.Lookup; import org.compiere.model.Lookup;
import org.compiere.model.MAcctSchema; import org.compiere.model.MAcctSchema;
import org.compiere.model.MLookup;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.util.CCache; import org.compiere.util.CCache;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.CacheMgt; import org.compiere.util.CacheMgt;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Ini; import org.compiere.util.Ini;
import org.compiere.util.Language; import org.compiere.util.Language;
@ -415,6 +417,13 @@ public final class AEnv
{ {
zoomQuery = new MQuery(); // ColumnName might be changed in MTab.validateQuery zoomQuery = new MQuery(); // ColumnName might be changed in MTab.validateQuery
String column = lookup.getColumnName(); String column = lookup.getColumnName();
// Check if it is a Table Reference
if (lookup instanceof MLookup && DisplayType.List == lookup.getDisplayType())
{
int AD_Reference_ID = ((MLookup)lookup).getAD_Reference_Value_ID();
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 //strip off table name, fully qualify name doesn't work when zoom into detail tab
if (column.indexOf(".") > 0) if (column.indexOf(".") > 0)
{ {