From 710662cb457f754f06bd9baefdcc6bfea2f8d39f Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Fri, 29 May 2020 11:17:43 +0530 Subject: lowered code smells in ReportSchedule lowered code smells in ReportSchedule Issue-ID: PORTAL-813 Change-Id: I6ec530b017fbbdcfa0211dbf5163f5c126407c21 Signed-off-by: Indrijeet Kumar --- .../analytics/model/definition/ReportSchedule.java | 61 ++-------------------- 1 file changed, 3 insertions(+), 58 deletions(-) (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk') diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java index d6a4fb47..4a5aa77e 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java @@ -571,12 +571,7 @@ public class ReportSchedule extends RaptorObject implements Serializable{ while(sql.indexOf(fieldDisplay) > 0) { re1 = Pattern.compile("(^[\r\n]|[\\s])AND(.*?[^\r\n]*)"+ "\\["+fft.getFieldName()+ "\\](.*?)\\s", Pattern.DOTALL); -/* posFormField = sql.indexOf(fieldDisplay); - posAnd = sql.lastIndexOf("and", posFormField); - if(posAnd < 0) posAnd = 0; - else if (posAnd > 2) posAnd = posAnd - 2; - matcher = re1.matcher(sql); -*/ + posFormField = sql.indexOf(fieldDisplay); int posSelectField = sql.lastIndexOf("SELECT ", posFormField); int whereField = sql.indexOf(" WHERE" , posSelectField); @@ -612,12 +607,7 @@ public class ReportSchedule extends RaptorObject implements Serializable{ if(index >= 0 && matcher.find(index-30)) { sql = sql.replace(matcher.group(), " WHERE 1=1 "); } - } /*else { - replaceValue = formatListValue("", Utils - .oracleSafe(nvl(paramValues.getParamValue(fieldId))), null, false, - true, null, paramValues.getParamBaseSQL(fieldId)); - sql = Utils.replaceInString(sql, fieldDisplay, replaceValue); - }*/ + } } } @@ -1162,11 +1152,6 @@ public class ReportSchedule extends RaptorObject implements Serializable{ int len = 0; char[] buffer = new char[512]; try(Reader in = new InputStreamReader(clob.getAsciiStream())) { - // if(obj instanceof oracle.sql.CLOB) { - // in = ((oracle.sql.CLOB) obj).getCharacterStream(); - // } else if (obj instanceof weblogic.jdbc.wrapper.Clob) { - // in = ((weblogic.jdbc.base.BaseClob) obj).getCharacterStream(); - // } while ((len = in.read(buffer)) != -1) sb.append(buffer, 0, len); } catch(Exception e) { @@ -1183,20 +1168,6 @@ public class ReportSchedule extends RaptorObject implements Serializable{ else throw new RaptorException("Schedule ID " + scheduleId + " not found in the database"); } else { - /*oracle.sql.CLOB clob = null; - if (rs.next()) - clob = (oracle.sql.CLOB) rs.getObject(1); - else - throw new RuntimeException("Schedule ID " + scheduleId + " not found in the database"); - int len = 0; - char[] buffer = new char[512]; - Reader in = null; - if(clob!=null) { - in = clob.getCharacterStream(); - while ((len = in.read(buffer)) != -1) - sb.append(buffer, 0, len); - in.close(); - }*/ throw new RaptorException("only maria db support for this "); } @@ -1210,7 +1181,6 @@ public class ReportSchedule extends RaptorObject implements Serializable{ condition_sql = ds.getString(0,0); } return condition_sql; - //throw new ReportSQLException (ex.getMessage(), ex.getCause()); } catch (RaptorException e) { DbUtils.rollbackTransaction(connection); throw e; @@ -1253,42 +1223,17 @@ public class ReportSchedule extends RaptorObject implements Serializable{ stmt.setString(1,scheduleId); rs = stmt.executeQuery(); Writer out = null; - /*if(Globals.isWeblogicServer()) { - java.sql.Clob clob = null; - if (rs.next()) - clob = rs.getClob(1); - else - throw new RuntimeException("Schedule ID " + scheduleId + " not found in the database"); - - if (clob.length() > conditional_sql.length()) - clob.truncate(0); - //clob.trim(reportXML.length()); - out = ((weblogic.jdbc.vendor.oracle.OracleThinClob)clob).getCharacterOutputStream(); - } else*/ if (Globals.isPostgreSQL() || Globals.isMySQL()) { if (rs.next()) { rs.updateString(1,conditional_sql); rs.updateRow(); - //sb.append(rs.getString(1)); } else throw new RaptorException("Schedule ID " + scheduleId + " not found in the database"); - } else {/* - oracle.sql.CLOB clob = null; - if (rs.next()) - clob = (oracle.sql.CLOB) rs.getObject(1); - else - throw new RuntimeException("Schedule ID " + scheduleId + " not found in the database"); - - if (clob.length() > conditional_sql.length()) - clob.trim(conditional_sql.length()); - out = clob.getCharacterOutputStream();*/ + } else { throw new RaptorException("only maria db support for this "); } - //out.write(conditional_sql); - //out.flush(); - //out.close(); } catch (RaptorException ex) { if(ex.getMessage().indexOf("invalid identifier")!= -1) { try { -- cgit 1.2.3-korg