summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-analytics/src
diff options
context:
space:
mode:
authorIndrijeet kumar <indriku1@in.ibm.com>2020-05-14 08:36:33 +0530
committerIndrijeet kumar <indriku1@in.ibm.com>2020-05-14 08:36:49 +0530
commitce65b93181c3929c7ee00a57b3a8a6f23a37b60b (patch)
tree1d2bc57574013b957118e31cf8d2776a8968c697 /ecomp-sdk/epsdk-analytics/src
parente1dce346175ec18962e8687479da76b59ca75ab2 (diff)
lowered code smells in SearchHandler comp
lowered code smells in SearchHandler comp Issue-ID: PORTAL-813 Change-Id: I0da657f3fbe141f4d986d46090cb9cb4c5b08a7e Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/SearchHandler.java98
1 files changed, 1 insertions, 97 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/SearchHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/SearchHandler.java
index 22108350..5d122cd3 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/SearchHandler.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/SearchHandler.java
@@ -176,48 +176,11 @@ public class SearchHandler extends org.onap.portalsdk.analytics.RaptorObject {
for (Iterator iter = AppUtils.getUserRoles(request).iterator(); iter.hasNext();)
roleList.append("," + ((String) iter.next()));
//<a href="#" alt="Run report" onClick="document.forma.r_action.value='report.run'; document.forma.c_master.value='1073';">
- /*String sql = "SELECT cr.rep_id, "
- + "cr.rep_id report_id, "
- + rep_title_sql+
- "||DECODE(cr.public_yn, 'Y', '', '"
- + PRIVATE_ICON
- + "')||cr.title||'</a>' title, "
- + "cr.descr, "
- + "au.first_name||' '||au.last_name owner_name, "
- + "TO_CHAR(cr.create_date, 'MM/DD/YYYY') create_date, "
- + "DECODE(NVL(cr.owner_id, cr.create_id), "
- + userID
- + ", 'N', NVL(ra.read_only_yn, 'Y')) read_only_yn, "
- + "DECODE(NVL(cr.owner_id, cr.create_id), "
- + userID
- + ", 'Y', 'N') user_is_owner_yn, "
- + "case when report_xml like '%<allowSchedule>N</allowSchedule>%' "
- + "then 'N' "
- + "when report_xml like '%<allowSchedule>Y</allowSchedule>%' "
- + "or 1 = (select distinct 1 from cr_report_schedule where rep_id = cr.rep_id) "
- + "then 'Y' "
- + "else 'N' end "
- + "FROM cr_report cr, "
- + "app_user au, "
- + "(SELECT rep_id, "
- + "MIN(read_only_yn) read_only_yn "
- + "FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = "
- + userID
- + ") "
- + "UNION ALL "
- + "(SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN ("
- + roleList.toString() + "))" + ") report_access " + "GROUP BY rep_id) ra "
- + "WHERE TO_CHAR(cr.rep_id) = nvl('" + fReportID
- + "', TO_CHAR(cr.rep_id)) AND " + "UPPER(cr.title) LIKE UPPER('%"
- + fReportName + "%') AND " + "nvl(cr.owner_id, cr.create_id) = au.user_id "
- + "AND cr.rep_id = ra.rep_id (+) ";*/
-
String sql = Globals.getLoadReportSearchResult();
String rep_id = "";
String rep_id_sql_value = "";
String rep_id_options = "";
String rep_id_sql = Globals.getLoadReportSearchRepIdSql();
- //rep_id_sql = " AND ROUND(cr.rep_id, 0) like coalesce('%%', ROUND(cr.rep_id, 0)) ";
if(request.getParameter("rep_id")!=null) {
rep_id = request.getParameter("rep_id");
}
@@ -308,23 +271,14 @@ public class SearchHandler extends org.onap.portalsdk.analytics.RaptorObject {
sql = sql.replace("[fReportName]",rep_name_sql);
if (menuId.length() > 0){
- /*sql += "AND INSTR('|'||cr.menu_id||'|', '|'||'" + menuId + "'||'|') > 0 "
- * +"AND
- * cr.menu_approved_yn =
- * 'Y' "
- ;*/
String sql_add = Globals.getLoadReportSearchInstr();
sql+= sql_add;
}
- //String user_sql = " AND nvl(cr.owner_id, cr.create_id) = " + userID;
String user_sql = Globals.getLoadReportSearchResultUser();
- //String public_sql = " AND (nvl(cr.owner_id, cr.create_id) = " + userID
- // + " OR cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL)";
String public_sql = Globals.getLoadReportSearchResultPublic();
- //String fav_sql = " AND cr.rep_id in (select rep_id from cr_favorite_reports where user_id = " + userID +" ) ";
String fav_sql = Globals.getLoadReportSearchResultFav();
if (userOnly)
@@ -346,15 +300,12 @@ public class SearchHandler extends org.onap.portalsdk.analytics.RaptorObject {
// else - not super user - doesn't get access to private reports of
// other users (= Public reports); Admin users get edit right
// override later
- //sql += public_sql;
sql += " " + public_sql;
}
if (sortOrder.equals(AppConstants.RI_F_OWNER_ID)){
- //sql += " ORDER BY DECODE(nvl(cr.owner_id, cr.create_id), " + userID
- //+ ", ' ', upper(au.first_name||' '||au.last_name)), upper(cr.title)";
String sql_sort = Globals.getLoadReportSearchResultSort();
sql+=" " + sql_sort;
}
@@ -366,7 +317,6 @@ public class SearchHandler extends org.onap.portalsdk.analytics.RaptorObject {
sql += " ORDER BY cr.public_yn desc";
else
- // if(sortOrder.equals(AppConstants.RI_F_REPORT_NAME))
sql += " ORDER BY upper(cr.title)";
sql = sql.replace("[rep_title_sql]", "cr.title");
@@ -374,14 +324,10 @@ public class SearchHandler extends org.onap.portalsdk.analytics.RaptorObject {
sql = sql.replace("[userID]", userID);
sql = sql.replace("[roleList.toString()]", roleList.toString());
- //System.out.println("query is for search list is : " + sql);
DataSet ds = DbUtils.executeQuery(sql, rep_name_sql_value, rep_id_sql_value);
ReportSearchResultJSON rsr = new ReportSearchResultJSON(0, 6, 7);
rsr.parseData(ds, request, 0, 20, 6, 7);
- //saveCSVPageFile(request, rsr);
- //rsr.truncateToPage(pageNo);
- //saveCSVPageFile(request, rsr);
return rsr;
} // loadReportSearchResult
@@ -413,35 +359,6 @@ public class SearchHandler extends org.onap.portalsdk.analytics.RaptorObject {
for (Iterator iter = AppUtils.getUserRoles(request).iterator(); iter.hasNext();)
roleList.append("," + ((String) iter.next()));
//<a href="#" alt="Run report" onClick="document.forma.r_action.value='report.run'; document.forma.c_master.value='1073';">
- /*String sql = "SELECT cr.rep_id, "
- + "cr.rep_id report_id, "
- + rep_title_sql+
- "||DECODE(cr.public_yn, 'Y', '', '"
- + PRIVATE_ICON
- + "')||cr.title||'</a>' title, "
- + "cr.descr, "
- + "au.first_name||' '||au.last_name owner_name, "
- + "TO_CHAR(cr.create_date, 'MM/DD/YYYY') create_date, "
- + "DECODE(NVL(cr.owner_id, cr.create_id), "
- + userID
- + ", 'N', NVL(ra.read_only_yn, 'Y')) read_only_yn, "
- + "DECODE(NVL(cr.owner_id, cr.create_id), "
- + userID
- + ", 'Y', 'N') user_is_owner_yn "
- + "FROM cr_report cr, "
- + "app_user au, "
- + "(SELECT rep_id, "
- + "MIN(read_only_yn) read_only_yn "
- + "FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = "
- + userID
- + ") "
- + "UNION ALL "
- + "(SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN ("
- + roleList.toString() + "))" + ") report_access " + "GROUP BY rep_id) ra "
- + "WHERE TO_CHAR(cr.rep_id) = nvl('" + fReportID
- + "', TO_CHAR(cr.rep_id)) AND " + "UPPER(cr.title) LIKE UPPER('%"
- + fReportName + "%') AND " + "nvl(cr.owner_id, cr.create_id) = au.user_id "
- + "AND cr.rep_id = ra.rep_id (+) ";*/
String sql = Globals.getLoadFolderReportResult();
sql = sql.replace("[rep_title_sql]", rep_title_sql);
@@ -452,20 +369,13 @@ public class SearchHandler extends org.onap.portalsdk.analytics.RaptorObject {
sql = sql.replace("[fReportName]", fReportName);
if (menuId.length() > 0){
- /*sql += "AND INSTR('|'||cr.menu_id||'|', '|'||'" + menuId + "'||'|') > 0 "
- * +"AND
- * cr.menu_approved_yn =
- * 'Y' "
- ;*/
+
String sql_add = Globals.getLoadReportSearchInstr();
sql+= sql_add;
}
- //String user_sql = " AND nvl(cr.owner_id, cr.create_id) = " + userID;
String user_sql = Globals.getLoadReportSearchResultUser();
- //String public_sql = " AND (nvl(cr.owner_id, cr.create_id) = " + userID
- // + " OR cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL)";
String public_sql = Globals.getLoadReportSearchResultPublic();
if (userOnly)
@@ -489,10 +399,6 @@ public class SearchHandler extends org.onap.portalsdk.analytics.RaptorObject {
if (sortOrder.equals(AppConstants.RI_F_OWNER_ID)){
-
- //sql += " ORDER BY DECODE(nvl(cr.owner_id, cr.create_id), " + userID
- // + ", ' ', au.first_name||' '||au.last_name), cr.title";
-
String sql_sort = Globals.getLoadFolderReportResultSort();
sql+=sql_sort;
}
@@ -503,10 +409,8 @@ public class SearchHandler extends org.onap.portalsdk.analytics.RaptorObject {
else if(sortOrder.equals(AppConstants.RI_F_PUBLIC))
sql += " ORDER BY cr.public_yn desc";
else
- // if(sortOrder.equals(AppConstants.RI_F_REPORT_NAME))
sql += " ORDER BY cr.title";
- //System.out.println("query is for search list is : " + sql);
DataSet ds = DbUtils.executeQuery(sql);
ReportSearchResult rsr = new ReportSearchResult(-1, 6, 7);