Search in sources :

Example 1 with ASearch

use of org.compiere.apps.ASearch in project adempiere by adempiere.

the class Viewer method cmd_find.

//	cmd_report
/**
	 * 	Query Report
	 */
private void cmd_find() {
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();
    String title = null;
    String tableName = null;
    //	Get Find Tab Info
    String sql = "SELECT t.AD_Tab_ID " + //	,w.Name, t.Name, w.IsDefault, t.SeqNo, ABS (tt.AD_Window_ID-t.AD_Window_ID)
    "FROM AD_Tab t" + " INNER JOIN AD_Window w ON (t.AD_Window_ID=w.AD_Window_ID)" + " INNER JOIN AD_Table tt ON (t.AD_Table_ID=tt.AD_Table_ID) " + "WHERE tt.AD_Table_ID=? " + "ORDER BY w.IsDefault DESC, t.SeqNo, ABS (tt.AD_Window_ID-t.AD_Window_ID)";
    int AD_Tab_ID = DB.getSQLValue(null, sql, AD_Table_ID);
    // ASP
    MClient client = MClient.get(Env.getCtx());
    String ASPFilter = "";
    if (client.isUseASP())
        ASPFilter = "     AND (   AD_Tab_ID IN ( " + // Just ASP subscribed tabs for client "
        "              SELECT t.AD_Tab_ID " + "                FROM ASP_Tab t, ASP_Window w, ASP_Level l, ASP_ClientLevel cl " + "               WHERE w.ASP_Level_ID = l.ASP_Level_ID " + "                 AND cl.AD_Client_ID = " + client.getAD_Client_ID() + "                 AND cl.ASP_Level_ID = l.ASP_Level_ID " + "                 AND t.ASP_Window_ID = w.ASP_Window_ID " + "                 AND t.IsActive = 'Y' " + "                 AND w.IsActive = 'Y' " + "                 AND l.IsActive = 'Y' " + "                 AND cl.IsActive = 'Y' " + // Show
        "                 AND t.ASP_Status = 'S') " + "        OR AD_Tab_ID IN ( " + // + show ASP exceptions for client
        "              SELECT AD_Tab_ID " + "                FROM ASP_ClientException ce " + "               WHERE ce.AD_Client_ID = " + client.getAD_Client_ID() + "                 AND ce.IsActive = 'Y' " + "                 AND ce.AD_Tab_ID IS NOT NULL " + "                 AND ce.AD_Field_ID IS NULL " + // Show
        "                 AND ce.ASP_Status = 'S') " + "       ) " + "   AND AD_Tab_ID NOT IN ( " + // minus hide ASP exceptions for client
        "          SELECT AD_Tab_ID " + "            FROM ASP_ClientException ce " + "           WHERE ce.AD_Client_ID = " + client.getAD_Client_ID() + "             AND ce.IsActive = 'Y' " + "             AND ce.AD_Tab_ID IS NOT NULL " + "             AND ce.AD_Field_ID IS NULL " + // Hide
        "             AND ce.ASP_Status = 'H')";
    //
    sql = "SELECT Name, TableName FROM AD_Tab_v WHERE AD_Tab_ID=? " + ASPFilter;
    if (!Env.isBaseLanguage(Env.getCtx(), "AD_Tab"))
        sql = "SELECT Name, TableName FROM AD_Tab_vt WHERE AD_Tab_ID=?" + " AND AD_Language='" + Env.getAD_Language(Env.getCtx()) + "' " + ASPFilter;
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, AD_Tab_ID);
        ResultSet rs = pstmt.executeQuery();
        //
        if (rs.next()) {
            title = rs.getString(1);
            tableName = rs.getString(2);
        }
        //
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
    }
    GridField[] findFields = null;
    if (tableName != null)
        findFields = GridField.createFields(m_ctx, m_WindowNo, 0, AD_Tab_ID);
    //	FR [ 295 ]
    if (findFields == null) {
        //	No Tab for Table exists
        if (launchProcessPara()) {
            revalidate();
        } else {
            return;
        }
    } else {
        ASearch search = new ASearch(bFind, this, title, AD_Tab_ID, AD_Table_ID, tableName, m_reportEngine, findFields, 1);
        search = null;
        revalidate();
    }
    //	setCursor
    cmd_drill();
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) GridField(org.compiere.model.GridField) ASearch(org.compiere.apps.ASearch) Point(java.awt.Point) MClient(org.compiere.model.MClient)

Aggregations

Point (java.awt.Point)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ASearch (org.compiere.apps.ASearch)1 GridField (org.compiere.model.GridField)1 MClient (org.compiere.model.MClient)1