Skip to content

Commit

Permalink
- create SysConfig
Browse files Browse the repository at this point in the history
- add Dialog when reaching max query records
  • Loading branch information
CarlosRuiz-globalqss committed Apr 26, 2024
1 parent 7f2ca16 commit cda0e11
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
6 changes: 4 additions & 2 deletions org.adempiere.base/src/org/compiere/model/GridTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ public GridTab(GridTabVO vo, GridWindow w, boolean virtual)
public static final String CTX_IsLookupOnlySelection = "_TabInfo_IsLookupOnlySelection";
public static final String CTX_IsAllowAdvancedLookup = "_TabInfo_IsAllowAdvancedLookup";

public static final int DEFAULT_MAX_QUERY_RECORDS = 100000;
public static final int DEFAULT_GLOBAL_MAX_QUERY_RECORDS = 100000;

/**
* Tab loader for Tabs > 0
*/
Expand Down Expand Up @@ -3571,7 +3572,8 @@ public int getMaxQueryRecords() {
if (roleMaxQueryRecords > 0 && (roleMaxQueryRecords < tabMaxQueryRecords || tabMaxQueryRecords == 0))
tabMaxQueryRecords = roleMaxQueryRecords;
if (tabMaxQueryRecords == 0)
tabMaxQueryRecords = DEFAULT_MAX_QUERY_RECORDS;
tabMaxQueryRecords = MSysConfig.getIntValue(MSysConfig.GLOBAL_MAX_QUERY_RECORDS,
DEFAULT_GLOBAL_MAX_QUERY_RECORDS, Env.getAD_Client_ID(Env.getCtx()));
return tabMaxQueryRecords;
}

Expand Down
16 changes: 8 additions & 8 deletions org.adempiere.base/src/org/compiere/model/GridTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,15 @@ public class GridTable extends AbstractTableModel
implements Serializable
{
/**
* generated serial id
*
*/
private static final long serialVersionUID = -5564364545827057092L;
private static final long serialVersionUID = -2602189278069194311L;

protected static final String SORTED_DSE_EVENT = "Sorted";

public static final int DEFAULT_GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS = 10;

public static final int DEFAULT_COUNT_TIMEOUT_IN_SECONDS = 1;

public static final int DEFAULT_GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS = 30;
public static final int DEFAULT_GRIDTABLE_COUNT_TIMEOUT_IN_SECONDS = 1;

public static final String LOAD_TIMEOUT_ERROR_MESSAGE = "GridTabLoadTimeoutError";

public static final String DATA_REFRESH_MESSAGE = "Refreshed";
Expand Down Expand Up @@ -3019,7 +3018,8 @@ protected int open (int maxRows)
{
pstmt = DB.prepareStatement(m_SQL_Count, get_TrxName());
setParameter (pstmt, true);
int timeout = DEFAULT_COUNT_TIMEOUT_IN_SECONDS;
int timeout = MSysConfig.getIntValue(MSysConfig.GRIDTABLE_INITIAL_COUNT_TIMEOUT_IN_SECONDS,
DEFAULT_GRIDTABLE_COUNT_TIMEOUT_IN_SECONDS, Env.getAD_Client_ID(Env.getCtx()));
if (timeout > 0)
pstmt.setQueryTimeout(timeout);
rs = pstmt.executeQuery();
Expand Down Expand Up @@ -3074,7 +3074,7 @@ private void openResultSet() {
{
m_pstmt.setMaxRows(this.maxRows);
}
//ensure not all row is fectch into memory for virtual table
//ensure not all rows are fetch into memory for virtual table
if (m_virtual)
m_pstmt.setFetchSize(100);
setParameter (m_pstmt, false);
Expand Down
4 changes: 3 additions & 1 deletion org.adempiere.base/src/org/compiere/model/MSysConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class MSysConfig extends X_AD_SysConfig
/**
*
*/
private static final long serialVersionUID = -4149262106340017798L;
private static final long serialVersionUID = 8121897973805635995L;

/** Constant for Predefine System Configuration Names (in alphabetical order) */

Expand Down Expand Up @@ -119,7 +119,9 @@ public class MSysConfig extends X_AD_SysConfig
public static final String FORM_SQL_QUERY_LOG_ISSUE = "FORM_SQL_QUERY_LOG_ISSUE";
public static final String FORM_SQL_QUERY_MAX_RECORDS = "FORM_SQL_QUERY_MAX_RECORDS";
public static final String FORM_SQL_QUERY_TIMEOUT_IN_SECONDS = "FORM_SQL_QUERY_TIMEOUT_IN_SECONDS";
public static final String GLOBAL_MAX_QUERY_RECORDS = "GLOBAL_MAX_QUERY_RECORDS";
public static final String GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS = "GRIDTABLE_LOAD_TIMEOUT_IN_SECONDS";
public static final String GRIDTABLE_INITIAL_COUNT_TIMEOUT_IN_SECONDS = "GRIDTABLE_INITIAL_COUNT_TIMEOUT_IN_SECONDS";
public static final String HTML_REPORT_MINIFY = "HTML_REPORT_MINIFY";
public static final String HTML_REPORT_THEME = "HTML_REPORT_THEME";
public static final String IBAN_VALIDATION = "IBAN_VALIDATION";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,8 @@ private int getRecordCount(GridTab mTab, StringBuffer where) {
String finalSQL = MRole.getDefault().addAccessSQL(sql.toString(),
mTab.getTableName(), MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
int no = -1;
int timeout = GridTable.DEFAULT_COUNT_TIMEOUT_IN_SECONDS;
int timeout = MSysConfig.getIntValue(MSysConfig.GRIDTABLE_INITIAL_COUNT_TIMEOUT_IN_SECONDS,
GridTable.DEFAULT_GRIDTABLE_COUNT_TIMEOUT_IN_SECONDS, Env.getAD_Client_ID(Env.getCtx()));
try (PreparedStatement stmt = DB.prepareStatement(finalSQL, null)) {
if (timeout > 0)
stmt.setQueryTimeout(timeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3150,7 +3150,8 @@ private int getNoOfRecords (MQuery query, boolean alertRecords)
Env.setContext(Env.getCtx(), m_targetWindowNo, TABNO, GridTab.CTX_FindSQL, finalSQL);

// Execute Query
int timeout = GridTable.DEFAULT_COUNT_TIMEOUT_IN_SECONDS;
int timeout = MSysConfig.getIntValue(MSysConfig.GRIDTABLE_INITIAL_COUNT_TIMEOUT_IN_SECONDS,
GridTable.DEFAULT_GRIDTABLE_COUNT_TIMEOUT_IN_SECONDS, Env.getAD_Client_ID(Env.getCtx()));
m_total = 999999;
Statement stmt = null;
ResultSet rs = null;
Expand Down Expand Up @@ -3189,6 +3190,8 @@ private int getNoOfRecords (MQuery query, boolean alertRecords)
// Load not more than max allow
if (m_gridTab != null && alertRecords && m_total != COUNTING_RECORDS_TIMED_OUT && m_gridTab.isQueryMax(m_total))
{
Dialog.info(m_targetWindowNo, "FindOverMax",
m_total + " > " + m_gridTab.getMaxQueryRecords());
m_total = m_gridTab.getMaxQueryRecords();
}
else
Expand Down

0 comments on commit cda0e11

Please sign in to comment.