Search in sources :

Example 41 with MRole

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());
}
Also used : MRole(org.compiere.model.MRole)

Example 42 with MRole

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;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) MRole(org.compiere.model.MRole) ResultSet(java.sql.ResultSet)

Aggregations

MRole (org.compiere.model.MRole)42 PreparedStatement (java.sql.PreparedStatement)14 ResultSet (java.sql.ResultSet)14 SQLException (java.sql.SQLException)11 ArrayList (java.util.ArrayList)7 Point (java.awt.Point)4 Properties (java.util.Properties)4 BigDecimal (java.math.BigDecimal)3 Statement (java.sql.Statement)3 GridField (org.compiere.model.GridField)3 GridTab (org.compiere.model.GridTab)3 QName (javax.xml.namespace.QName)2 MBrowse (org.adempiere.model.MBrowse)2 XFireFault (org.codehaus.xfire.fault.XFireFault)2 ICreateFrom (org.compiere.grid.ICreateFrom)2 MOrgInfo (org.compiere.model.MOrgInfo)2 MProcess (org.compiere.model.MProcess)2 MTable (org.compiere.model.MTable)2 MWFActivity (org.compiere.wf.MWFActivity)2 ADLoginRequest (pl.x3E.adInterface.ADLoginRequest)2