From ff522b3e5bdfbf63e87f1cd95dbb77295782461c Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Tue, 19 May 2020 10:41:07 +0530 Subject: removed unwanted codes in ChartJSONHelper comp removed unwanted codes in ChartJSONHelper component Issue-ID: PORTAL-813 Change-Id: I66c5c2c4b3a32c4040d1faba75043811345ccd56 Signed-off-by: Indrijeet Kumar --- .../analytics/model/runtime/ChartJSONHelper.java | 79 ++-------------------- 1 file changed, 4 insertions(+), 75 deletions(-) (limited to 'ecomp-sdk') diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartJSONHelper.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartJSONHelper.java index 0caca218..268b20cc 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartJSONHelper.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartJSONHelper.java @@ -302,7 +302,6 @@ public class ChartJSONHelper { public String generateJSON(ReportRuntime reportRuntime,Map chartOptionsMap, HttpServletRequest request, boolean showData) throws RaptorException { - //String width, String height, boolean animation, String rotateLabels, boolean staggerLabels, boolean showMaxMin, boolean showLegend, boolean showControls, String topMargin, String bottomMargin, boolean showTitle, String subType String userId = AppUtils.getUserID(request); String width = chartOptionsMap.get("width"); String height = chartOptionsMap.get("height"); @@ -343,7 +342,6 @@ public class ChartJSONHelper { List l = reportRuntime.getAllColumns(); List lGroups = reportRuntime.getAllChartGroups(); HashMap mapYAxis = reportRuntime.getAllChartYAxis(reportRuntime.getReportParamValues()); - //ReportParamValues reportParamValues = reportRuntime.getReportParamValues(); String chartLeftAxisLabel = reportRuntime.getFormFieldFilled(nvl(reportRuntime.getChartLeftAxisLabel())); String chartRightAxisLabel = reportRuntime.getFormFieldFilled(nvl(reportRuntime.getChartRightAxisLabel())); @@ -391,7 +389,6 @@ public class ChartJSONHelper { ds = ConnectionUtils.getDataSet(reportSQL, dbInfo); } } catch (RaptorException ex) { - //throw new RaptorException("Error while loading chart data", ex); logger.error(EELFLoggerDelegate.debugLogger, ("********************************************************************************")); logger.error(EELFLoggerDelegate.debugLogger, (chartType.toUpperCase()+" - " + "Report ID : " + reportRuntime.getReportID() + " ERROR THROWN FOR GIVEN QUERY ")); logger.error(EELFLoggerDelegate.debugLogger, ("QUERY - " + reportRuntime.getWholeSQL())); @@ -400,7 +397,6 @@ public class ChartJSONHelper { } if(ds==null) { - //displayChart = false; if(chartType.equals(AppConstants.GT_ANNOTATION_CHART)) ds = new DataSet(); else @@ -468,19 +464,11 @@ public class ChartJSONHelper { categoryAxisJSON.setValue(dct.getColId()); chartJSON.setCategoryAxisJSON(categoryAxisJSON); } - //allColumns - //.add(new Item(dct.getColId(), dct.getDisplayName())); } - //chartJSON.setCategoryAxis(categoryAxis); - //chartJSON.set List chartValueCols = reportRuntime.getChartValueColumnsList(AppConstants.CHART_ALL_COLUMNS, null); DataColumnType dct_RangeAxis = null; - //int noChart = 0; - //if(chartValueCols.size()<=0) { - //chartValueCols.addAll(reportCols); - //noChart = 1; - //} + if(chartValueCols.size() <= 0) { chartValueCols = reportCols; } @@ -617,8 +605,6 @@ public class ChartJSONHelper { chartTypeJSON.setValue(chartType); chartJSON.setChartTypeJSON(chartTypeJSON); } - //mapper.setVisibility(JsonMethod.FIELD, Visibility.ANY); - //mapper.setVisibilityChecker(mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE)); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); String jsonInString = ""; @@ -681,14 +667,10 @@ public class ChartJSONHelper { //Add order by clause Pattern re1 = Pattern.compile("(^[\r\n]*|([\\s]))[Oo][Rr][Dd][Ee][Rr](.*?[^\r\n]*)[Bb][Yy]",Pattern.DOTALL); - //Pattern re1 = Pattern.compile("order(.*?[^\r\n]*)by", Pattern.DOTALL); Matcher matcher = re1.matcher(reportSQL); - //Pattern re1 = Pattern.compile("(^[\r\n]*|([\\s]))[Oo][Rr][Dd][Ee][Rr][Tt](.*?[^\r\n]*)[Bb][Yy]",Pattern.DOTALL); - //int startPoint = sql.length()-30; reportSQL = reportSQL + " "; reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Ss][Ee][Ll][Ee][Cc][Tt]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" SELECT "); - //reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Ff][Rr][Oo][Mm]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" FROM "); reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Rr][Ee]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" WHERE "); reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Nn]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" WHEN "); reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Aa][Nn][Dd]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" AND "); @@ -724,13 +706,9 @@ public class ChartJSONHelper { formfield_value = AppUtils.getRequestNvlValue(request, fieldId); String paramValue = nvl(formfield_value); if(paramValue.length()>0) { - /*sql = Utils.replaceInString(sql, "'" + fieldDisplay + "'", nvl( - paramValue, "NULL"));*/ reportSQL = Utils.replaceInString(reportSQL, fieldDisplay, nvl( paramValue, "NULL")); } - /*sql = Utils.replaceInString(sql, "'" + fieldDisplay + "'", nvl( - paramValue, "NULL"));*/ reportSQL = Utils.replaceInString(reportSQL, "'" + fieldDisplay + "'", nvl( paramValue, "NULL")); reportSQL = Utils.replaceInString(reportSQL, fieldDisplay , nvl( @@ -739,7 +717,6 @@ public class ChartJSONHelper { } logger.debug(EELFLoggerDelegate.debugLogger, ("SQL " + reportSQL)); String legendCol = "1 a"; - // String valueCol = "1"; StringBuffer groupCol = new StringBuffer(); StringBuffer seriesCol = new StringBuffer(); StringBuffer valueCols = new StringBuffer(); @@ -749,8 +726,6 @@ public class ChartJSONHelper { String colName = getColumnSelectStr(dc, request); if (nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND)) legendCol = getSelectExpr(dc, colName)+" " + dc.getColId(); - // if(dc.getChartSeq()>0) - // valueCol = "NVL("+colName+", 0) "+dc.getColId(); if ((!nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND)) && (dc.getChartSeq()!=null && dc.getChartSeq().intValue() <= 0) && dc.isGroupBreak()) { groupCol.append(", "); @@ -760,18 +735,9 @@ public class ChartJSONHelper { for (Iterator iter = reportCols.iterator(); iter.hasNext();) { DataColumnType dc = (DataColumnType) iter.next(); if(dc.isChartSeries()!=null && dc.isChartSeries().booleanValue()) { - //System.out.println("*****************, "+ " " +getColumnSelectStr(dc, paramValues)+ " "+ getSelectExpr(dc,getColumnSelectStr(dc, paramValues))); seriesCol.append(", "+ getSelectExpr(dc,getColumnSelectStr(dc, request))+ " " + dc.getColId()); } } - - /*for (Iterator iter = reportCols.iterator(); iter.hasNext();) { - DataColumnType dc = (DataColumnType) iter.next(); - if(!dc.isChartSeries() && !(nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND))) { - //System.out.println("*****************, "+ " " +getColumnSelectStr(dc, paramValues)+ " "+ getSelectExpr(dc,getColumnSelectStr(dc, paramValues))); - seriesCol.append(", "+ formatChartColumn(getSelectExpr(dc,getColumnSelectStr(dc, paramValues)))+ " " + dc.getColId()); - } - }*/ for (Iterator iter = chartValueCols.iterator(); iter.hasNext();) { DataColumnType dc = (DataColumnType) iter.next(); @@ -794,7 +760,6 @@ public class ChartJSONHelper { seriesCol.append("," + (AppUtils.nvl(paramValue).length()>0? paramValue:"null") + " " + dc.getColId()); } else { - //valueCols.append(", NVL(" + formatChartColumn(colName) + ",0) " + dc.getColId()); seriesCol.append("," + (AppUtils.nvl(paramValue).length()>0? paramValue:formatChartColumn(colName)) + " " + dc.getColId()); } } // for @@ -803,7 +768,6 @@ public class ChartJSONHelper { DataColumnType dc = (DataColumnType) iter.next(); String colName = dc.getDisplayName(); String colValue = getColumnSelectStr(dc, request); - //String colName = getColumnSelectStr(dc, formGrid); if(colName.equals(AppConstants.RI_CHART_TOTAL_COL)) seriesCol.append(", " + AppConstants.RI_CHART_TOTAL_COL + " " + AppConstants.RI_CHART_TOTAL_COL ); if (colName.equals(AppConstants.RI_CHART_COLOR)) @@ -816,45 +780,14 @@ public class ChartJSONHelper { seriesCol.append(", " + AppConstants.RI_CHART_MARKER_TEXT_LEFT + " " + AppConstants.RI_CHART_MARKER_TEXT_LEFT ); if(colName.equals(AppConstants.RI_CHART_MARKER_TEXT_RIGHT)) seriesCol.append(", " + AppConstants.RI_CHART_MARKER_TEXT_RIGHT + " " + AppConstants.RI_CHART_MARKER_TEXT_RIGHT ); - //if(colName.equals(AppConstants.RI_ANOMALY_TEXT)) - //seriesCol.append(", " + AppConstants.RI_ANOMALY_TEXT + " " + AppConstants.RI_ANOMALY_TEXT ); } - - //debugLogger.debug("ReportSQL Chart " + reportSQL ); - /*for (Iterator iter = chartValueCols.iterator(); iter.hasNext();) { - DataColumnType dc = (DataColumnType) iter.next(); - String colName = getColumnSelectStr(dc, paramValues); - //valueCols.append(", NVL(" + formatChartColumn(colName) + ",0) " + dc.getColId()); - valueCols.append("," + formatChartColumn(colName) + " " + dc.getColId()); - } // for - for (Iterator iter = reportCols.iterator(); iter.hasNext();) { - DataColumnType dc = (DataColumnType) iter.next(); - String colName = getColumnSelectStr(dc, paramValues); - //if(colName.equals(AppConstants.RI_CHART_TOTAL_COL) || colName.equals(AppConstants.RI_CHART_COLOR)) { - if(colName.equals(AppConstants.RI_CHART_TOTAL_COL)) - valueCols.append(", " + AppConstants.RI_CHART_TOTAL_COL + " " + AppConstants.RI_CHART_TOTAL_COL ); - if (colName.equals(AppConstants.RI_CHART_COLOR)) - valueCols.append(", " + AppConstants.RI_CHART_COLOR + " " + AppConstants.RI_CHART_COLOR ); - if (colName.equals(AppConstants.RI_CHART_INCLUDE)) - valueCols.append(", " + AppConstants.RI_CHART_INCLUDE + " " + AppConstants.RI_CHART_INCLUDE ); - //} - }*/ + String final_sql = ""; reportSQL = Utils.replaceInString(reportSQL, " from ", " FROM "); reportSQL = Utils.replaceInString(reportSQL, " From ", " FROM "); reportSQL = Utils.replaceInString(reportSQL, " select ", " SELECT "); reportSQL = Utils.replaceInString(reportSQL, " union ", " UNION "); - //reportSQL = reportSQL.replaceAll("[\\s]*\\(", "("); -// if(reportSQL.indexOf("UNION") != -1) { -// if(reportSQL.indexOf("FROM(")!=-1) -// final_sql += " "+reportSQL.substring(reportSQL.indexOf("FROM(") ); -// else if (reportSQL.indexOf("FROM (")!=-1) -// final_sql += " "+reportSQL.substring(reportSQL.indexOf("FROM (") ); -// //TODO ELSE THROW ERROR -// } -// else { -// final_sql += " "+reportSQL.substring(reportSQL.toUpperCase().indexOf(" FROM ")); -// } + int pos = 0; int pos_first_select = 0; int pos_dup_select = 0; @@ -863,11 +796,10 @@ public class ChartJSONHelper { if (reportSQL.indexOf("FROM", pos)!=-1) { pos = reportSQL.indexOf("FROM", pos); pos_dup_select = reportSQL.lastIndexOf("SELECT",pos); - pos_first_select = reportSQL.indexOf("SELECT");//,pos); + pos_first_select = reportSQL.indexOf("SELECT"); logger.debug(EELFLoggerDelegate.debugLogger, ("pos_select " + pos_first_select + " " + pos_dup_select)); if(pos_dup_select > pos_first_select) { logger.debug(EELFLoggerDelegate.debugLogger, ("********pos_dup_select ********" + pos_dup_select)); - //pos_dup_select1 = pos_dup_select; pos_prev_select = pos_first_select; pos_last_select = pos_dup_select; while (pos_last_select > pos_prev_select) { @@ -891,9 +823,6 @@ public class ChartJSONHelper { } // generateChartSQL private String getColumnSelectStr(DataColumnType dc, HttpServletRequest request) { - //String colName = dc.isCalculated() ? dc.getColName() - // : ((nvl(dc.getTableId()).length() > 0) ? (dc.getTableId() + "." + dc - // .getColName()) : dc.getColName()); String colName = dc.getColName(); String paramValue = null; //if (dc.isCalculated()) { -- cgit 1.2.3-korg