use of org.compiere.model.MRole in project adempiere by adempiere.
the class GridSynchronizer method activateChild.
/**
* trigger when parent gc activate
*/
public void activateChild() {
window.initTab(window.getTabIndex(child.getMTab()));
child.activate();
MRole role = MRole.getDefault();
child.query(false, 0, role.getMaxQueryRecords());
}
use of org.compiere.model.MRole in project lar_361 by comitsrl.
the class Find method getNoOfRecords.
// getTotalRecords
/**
* Get the number of records of target tab
* @param query where clause for target tab
* @param alertZeroRecords show dialog if there are no records
* @return number of selected records;
* if the results are more then allowed this method will return 0
*/
private int getNoOfRecords(MQuery query, boolean alertZeroRecords) {
log.config("" + query);
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM ");
sql.append(m_tableName);
boolean hasWhere = false;
if (m_whereExtended != null && m_whereExtended.length() > 0) {
sql.append(" WHERE ").append(m_whereExtended);
hasWhere = true;
}
if (query != null && query.isActive()) {
if (hasWhere)
sql.append(" AND ");
else
sql.append(" WHERE ");
sql.append(query.getWhereClause());
}
// Add Access
String finalSQL = MRole.getDefault().addAccessSQL(sql.toString(), m_tableName, MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
finalSQL = Env.parseContext(Env.getCtx(), m_targetWindowNo, finalSQL, false);
Env.setContext(Env.getCtx(), m_targetWindowNo, TABNO, GridTab.CTX_FindSQL, finalSQL);
// Execute Qusery
m_total = 999999;
Statement stmt = null;
ResultSet rs = null;
try {
stmt = DB.createStatement();
rs = stmt.executeQuery(finalSQL);
if (rs.next())
m_total = rs.getInt(1);
} catch (SQLException e) {
log.log(Level.SEVERE, finalSQL, e);
} finally {
DB.close(rs, stmt);
rs = null;
stmt = null;
}
MRole role = MRole.getDefault();
// No Records
if (m_total == 0 && alertZeroRecords)
ADialog.info(m_targetWindowNo, this, "FindZeroRecords");
else // More then allowed
if (query != null && role.isQueryMax(m_total)) {
ADialog.error(m_targetWindowNo, this, "FindOverMax", m_total + " > " + role.getMaxQueryRecords());
// return 0 if more then allowed - teo_sarca [ 1708717 ]
m_total = 0;
} else
log.config("#" + m_total);
//
if (query != null)
statusBar.setStatusToolTip(query.getWhereClause());
return m_total;
}
Aggregations