/** * Find report with input, throw exception if could not found. When there's more than one, use id * small one * * @param clientDomain * @param tableName * @param reportType * @return * @throws Exception */ private int getReportId(String clientDomain, String tableName, String reportType) throws Exception { reportType = reportType.toUpperCase(); Table table = nds.schema.TableManager.getInstance().findTable(tableName); if (table == null) throw new NDSException("table " + tableName + " not found."); String sql = "select r.id from ad_report r, ad_client c where c.domain='" + clientDomain + "' and r.ad_table_id=" + table.getId() + " and r.reporttype='" + reportType + "' and c.id=r.ad_client_id order by id asc"; return Tools.getInt(QueryEngine.getInstance().doQueryOne(sql), -1); }