diff options
author | Indrijeet kumar <indriku1@in.ibm.com> | 2020-05-29 11:17:43 +0530 |
---|---|---|
committer | Indrijeet kumar <indriku1@in.ibm.com> | 2020-05-29 11:17:49 +0530 |
commit | 710662cb457f754f06bd9baefdcc6bfea2f8d39f (patch) | |
tree | 1f44369d16423d145b3a71a3e0ec4ace9cd4e41b /ecomp-sdk/epsdk-analytics/src/main/java | |
parent | 273ccf87b2609ed82fe681e2211fc402f799307f (diff) |
lowered code smells in ReportSchedule
lowered code smells in ReportSchedule
Issue-ID: PORTAL-813
Change-Id: I6ec530b017fbbdcfa0211dbf5163f5c126407c21
Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main/java')
-rw-r--r-- | ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java | 61 |
1 files changed, 3 insertions, 58 deletions
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 { |