used cached resultset for reporting in places (wip)
This commit is contained in:
+13
-20
@@ -197,13 +197,8 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
|
|
||||||
private String getSQLtoRun(final String name, final String type,
|
private String getSQLtoRun(final String name, final String type,
|
||||||
final Map<String, String> queryParams) {
|
final Map<String, String> queryParams) {
|
||||||
String sql = null;
|
|
||||||
|
String sql = getSql(name, type);
|
||||||
if (type.equals("report")) {
|
|
||||||
sql = getReportSql(name);
|
|
||||||
} else {
|
|
||||||
sql = getParameterSql(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<String> keys = queryParams.keySet();
|
Set<String> keys = queryParams.keySet();
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
@@ -222,30 +217,28 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
|||||||
sql = genericDataService.replace(sql, "${currentUserId}", currentUser
|
sql = genericDataService.replace(sql, "${currentUserId}", currentUser
|
||||||
.getId().toString());
|
.getId().toString());
|
||||||
|
|
||||||
// wrap sql to prevent JDBC sql errors and also prevent malicious sql
|
sql = wrapSQL(sql);
|
||||||
sql = "select x.* from (" + sql + ") x";
|
|
||||||
|
|
||||||
return sql;
|
return sql;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getReportSql(String reportName) {
|
private String wrapSQL(String sql) {
|
||||||
|
// wrap sql to prevent JDBC sql errors, prevent malicious sql and a
|
||||||
|
// CachedRowSetImpl bug
|
||||||
|
|
||||||
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7046875 - prevent
|
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7046875 - prevent
|
||||||
// Invalid Column Name bug in sun's CachedRowSetImpl where it doesn't
|
// Invalid Column Name bug in sun's CachedRowSetImpl where it doesn't
|
||||||
// pick up on label names, only column names
|
// pick up on label names, only column names
|
||||||
String sql = "select * from (select report_sql as the_sql from stretchy_report where report_name = '"
|
return "select x.* from (" + sql + ") x";
|
||||||
+ reportName + "') x";
|
|
||||||
return getSql(sql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getParameterSql(String parameterName) {
|
private String getSql(String name, String type) {
|
||||||
String sql = "select * from (select parameter_sql as the_sql from stretchy_parameter where parameter_name = '"
|
|
||||||
+ parameterName + "') x";
|
|
||||||
return getSql(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getSql(String inputSql) {
|
|
||||||
|
|
||||||
|
String inputSql = "select " + type + "_sql as the_sql from stretchy_"
|
||||||
|
+ type + " where " + type + "_name = '" + name + "'";
|
||||||
|
inputSql = wrapSQL(inputSql);
|
||||||
|
|
||||||
String sqlErrorMsg = "Sql: " + inputSql;
|
String sqlErrorMsg = "Sql: " + inputSql;
|
||||||
CachedRowSet rs = genericDataService.getCachedResultSet(inputSql,
|
CachedRowSet rs = genericDataService.getCachedResultSet(inputSql,
|
||||||
sqlErrorMsg);
|
sqlErrorMsg);
|
||||||
|
|||||||
Reference in New Issue
Block a user