diff options
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime')
8 files changed, 295 insertions, 911 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java index ff8094fd..dd063554 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java @@ -278,13 +278,11 @@ public class ChartD3Helper { } } - //Object uniqueElements [] = ts.toArray(); - //SortedSet s = Collections.synchronizedSortedSet(ts); uniqueElements = ts.toArray(); } else { DataColumnType dct = null; List yTextSeries = reportRuntime.getChartDisplayNamesList(AppConstants.CHART_ALL_COLUMNS, formValues); - //if(columnValuesList.size() == 1) { + for (Iterator iter = l.iterator(); iter.hasNext();) { dct = (DataColumnType) iter.next(); @@ -307,19 +305,10 @@ public class ChartD3Helper { chartLeftAxisLabel = (chartLeftAxisLabel.indexOf("|")!=-1)?chartLeftAxisLabel.substring(0,chartLeftAxisLabel.indexOf("|")):""; } columnMap.put(dct.getDisplayName(), dct.getColId()); - /* - ts.add(dct.getDisplayName()); - if(nvl(chartLeftAxisLabel).length()<=0) { - chartLeftAxisLabel = nvl(dct.getYAxis()); - chartLeftAxisLabel = (chartLeftAxisLabel.indexOf("|")!=-1)?chartLeftAxisLabel.substring(0,chartLeftAxisLabel.indexOf("|")):""; - } - columnMap.put(dct.getDisplayName(), dct.getColId()); - */ } } } - //SortedSet s = Collections.synchronizedSortedSet(ts); uniqueElements = ts.toArray(); } @@ -373,13 +362,10 @@ public class ChartD3Helper { wholeScript.append("<script src=\""+ chartScriptsPath +"d3/js/tooltip.js\"></script> \n"); wholeScript.append("<script src=\""+ chartScriptsPath +"d3/js/utils.js\"></script> \n"); wholeScript.append("<script src=\""+ chartScriptsPath +"d3/js/models/axis.min.js\"></script> \n"); - //wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/discreteBar.js\"></script> \n"); - //wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/discreteBarChart.js\"></script> \n"); wholeScript.append("<script src=\""+ chartScriptsPath +"d3/js/models/multiChart.js\"></script> \n"); //json wholeScript.append("<script> \n"); wholeScript.append("historicalBarChart = [ \n"); - //wholeScript.append("{ \n"); // data ArrayList dataSeries = new ArrayList(); @@ -453,7 +439,6 @@ public class ChartD3Helper { //continue; flagNoDate = 1; int pos = 0; - //if(!((String)uniqueElementsList.get(i)).equals(dateStr)) { for (int f=0 ; f< uniqueXAxisElements.length; f++) { if(uniqueXAxisElements[f].equals(dateStr)){ pos = f ; @@ -462,10 +447,9 @@ public class ChartD3Helper { } dateStrList.add("'"+dateStr+"'"); - //uniqueElement = (String)uniqueElements[j]; try { YAXISNUM = Integer.parseInt(ds.getString(i, columnMap.get((hasCustomizedChartColor?(uniqueElement.indexOf("|")!=-1?uniqueElement.substring(0, uniqueElement.indexOf("|")):uniqueElement):uniqueElement)))); - //if(MAXNUM < YAXISNUM) MAXNUM = YAXISNUM; + if(MAXDOUBLENUM < YAXISNUM) MAXDOUBLENUM = YAXISNUM; } catch (NumberFormatException ex) { @@ -571,7 +555,6 @@ public class ChartD3Helper { //continue; flagNoDate = 1; int pos = 0; - //if(!((String)uniqueElementsList.get(i)).equals(dateStr)) { for (int f=0 ; f< uniqueXAxisElements.length; f++) { if(uniqueXAxisElements[f].equals(dateStr)){ pos = f ; @@ -622,7 +605,6 @@ public class ChartD3Helper { } dataSeriesOverAllMap.put(uniqueElements[j], dataSeriesStrMap); } else { - //date = MMDDYYYYFormat.parse(ds.getString(i, 1), new ParsePosition(0)); if(!barRealTimeAxis) { // true - non-time if(!dateStrList.contains(new Long(date.getTime()).toString())) { dateStrList.add(new Long(date.getTime()).toString()); @@ -652,8 +634,6 @@ public class ChartD3Helper { //flagNull = 1; } - //if(ds.getString(i, 2).equals(uniqueElements[j])) { - // dateStrList.add("'"+dateStr+"'"); HashMap<String, String> dataMap = dataSeriesMap.get((String) uniqueElements[j]); if(logScale) { dataMap.put(date.getTime()+"", (flagNull == 0 ? (YAXISDOUBLENUM>0?new Double(Math.log10(YAXISDOUBLENUM)).toString():new Double(Math.log10(new Double(YAXISNUM>0?YAXISNUM:1).doubleValue())).toString()): "null")); @@ -662,9 +642,7 @@ public class ChartD3Helper { dataMap.remove(date.getTime()); } dataMap.put(date.getTime()+"", (flagNull == 0 ? (YAXISDOUBLENUM>0?new Double(YAXISDOUBLENUM).toString():new Integer(YAXISNUM).toString()): "null")); - //System.out - // .println(dataMap + " " + dataSeriesMap); - //} + } } else if (AppUtils.nvl(ds.getString(i, 2)).length()<=0) { @@ -681,7 +659,6 @@ public class ChartD3Helper { } } } - // dataSeriesOverAllMap.put(uniqueElements[j], dataSeriesMap); } } @@ -719,19 +696,13 @@ public class ChartD3Helper { Long endDate = Long.parseLong((String) dateElements[dateElements.length-1]); java.util.Date date1 = null; //first value - date1 = new java.util.Date(initialDate.longValue()); - /* DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss Z"); - System.out.println(formatter.format(new java.util.Date(initialDate.longValue()))); - */ //initialDate = initialDate + HOUR; - + date1 = new java.util.Date(initialDate.longValue()); dateStrBuf.append(initialDate+","); sortSet.add(""+initialDate); // DateUtils. while ( initialDate <= endDate) { - //System.out.println("********** " + df.format(initialDate)); - //date1 = new java.util.Date(initialDate.longValue() * 1000); date1 = new java.util.Date(initialDate.longValue()); if(formatFlag==HOURFLAG) date1 = DateUtils.addHours(date1, 1); @@ -749,13 +720,7 @@ public class ChartD3Helper { dateStrBuf.append(initialDate+","); sortSet.add(""+initialDate); } - //DateUtils.addHours(date1, 1); - } - //DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); - //df.setTimeZone(TimeZone.getTimeZone("UTC")); - //java.util.Date date1 = new java.util.Date(initialDate.longValue() * 1000); - //java.util.Date d = df. - //for () + } } } dateStrBuf.deleteCharAt(dateStrBuf.length()-1); @@ -1230,16 +1195,7 @@ public class ChartD3Helper { } } - /*StringBuffer dataSeries1 = new StringBuffer(""); - dataSeries1.append(" { key: \"Series1\",values: ["); - StringBuffer dataSeries2 = new StringBuffer(""); - dataSeries2.append(" { key: \"Series2\", values: ["); - StringBuffer dataSeries3 = new StringBuffer(""); - dataSeries3.append(" { key: \"Series3\", values: ["); - */ - - //long minTime = 1000000000000000L; int MAXNUM = 0; double MAXDOUBLENUM = 0.0; int YAXISNUM = 0; @@ -1449,17 +1405,9 @@ public class ChartD3Helper { } } - // ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + minTime + " , \"y\":" + 0 +"}, "); } -/* if(ds.getString(i, 2).equals("Series1")) { - dataSeries1.append("[ " + date.getTime() + " , " + ds.getString(i, 3) +"], "); - } else if (ds.getString(i, 2).equals("Series2")) { - dataSeries2.append("[ " + date.getTime() + " , " + ds.getString(i, 3) +"], "); - } else if (ds.getString(i, 2).equals("Series3")) { - dataSeries3.append("[ " + date.getTime() + " , " + ds.getString(i, 3) +"], "); - } -*/ } + } for (int i = 0; i < uniqueRevElements.length; i++) { StringBuffer strBuf = ((StringBuffer) dataSeries.get(i)); @@ -1475,10 +1423,8 @@ public class ChartD3Helper { for (int i = 0; i < uniqueRevElements.length; i++) { wholeScript.append((StringBuffer)dataSeries.get(i)); } -/* wholeScript.append(dataSeries1); - wholeScript.append(dataSeries2); - wholeScript.append(dataSeries3); -*/ wholeScript.append("];\n"); + + wholeScript.append("];\n"); /* Sorting is commented out.*/ StringBuffer dateStrBuf = new StringBuffer(""); @@ -1911,12 +1857,7 @@ public class ChartD3Helper { columnValues.add(AppUtils.nvls(ds.getString(i, columnIndex), "null")); } } -/* actual = ds.getString(i, "actual"); - //forecast = ds.getString(i, "forecast"); - upperBound = ds.getString(i, "upperBound"); - lowerBound = ds.getString(i, "lowerBound"); - -*/ if(!timeCharts) + if(!timeCharts) anomalyText = ds.getString(i, "anomaly_text"); //dataStrBuf.append(" [new Date(moment(\""+dateStr+"\")),"+ actual /*+","+ forecast*/+","+ lowerBound +","+ upperBound +"],\n"); dataStrBuf.append(" [new Date(moment(\""+dateStr+"\"))"); @@ -1952,9 +1893,7 @@ public class ChartD3Helper { } } - - //if(!timeCharts) - //anomalyRec = anomalyRec - 1; + minDate = maxDate - (new Long(reportRuntime.getZoomIn()).longValue()*60*60*1000); System.out.println(new java.util.Date(maxDate) + " " + new java.util.Date(minDate) + " " + reportRuntime.getZoomIn()); @@ -1965,7 +1904,6 @@ public class ChartD3Helper { wholeScript.append("<!DOCTYPE html>\n"); wholeScript.append("<html>\n"); wholeScript.append(" <head>\n"); - //wholeScript.append("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7; IE=EmulateIE9\">\n"); wholeScript.append("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n"); wholeScript.append("<script type=\"text/javascript\" src=\""+ chartScriptsPath +"dy3/js/dygraph-combined.js\"></script>\n"); wholeScript.append("<script type=\"text/javascript\" src=\""+ chartScriptsPath +"dy3/js/moment.min.js\"></script>\n"); @@ -2185,8 +2123,6 @@ public class ChartD3Helper { if(!timeCharts) { wholeScript.append(" function nameAnnotation(ann) { \n"); wholeScript.append(" return ann.shortText; \n"); - //wholeScript.append(" var m = moment(ann.x);\n"); - //wholeScript.append(" return \"(\" + ann.series + \", \" + m.format(\"YYYY-MM-DD HH\"); + \")\"; \n"); wholeScript.append(" }\n"); wholeScript.append(" anns = [];\n"); } @@ -2195,9 +2131,6 @@ public class ChartD3Helper { wholeScript.append(" g = new Dygraph(\n"); wholeScript.append(" document.getElementById(\"div_g"+reportRuntime.getReportID()+"\"),\n"); //data here - /*wholeScript.append(" [\n"); - wholeScript.append(dataStrBuf.toString()); - wholeScript.append(" ],\n");*/ wholeScript.append(" data , \n"); wholeScript.append(" {\n"); @@ -2242,16 +2175,8 @@ public class ChartD3Helper { wholeScript.append(" var minutes = d.getMinutes();\n"); wholeScript.append(" var seconds = d.getSeconds();\n"); wholeScript.append(" var wholeString = Dygraph.zeropad(month)+'/'+Dygraph.zeropad(day);\n"); - // wholeScript.append(" if(hour >= 0 && minutes > 0 && seconds > 0) {\n"); - //wholeScript.append(" wholeString += ' ' + Dygraph.zeropad(hour) + ':'+Dygraph.zeropad(minutes)+':'+Dygraph.zeropad(seconds);\n"); - //wholeScript.append(" } else if (hour >= 0 && minutes > 0 && seconds == 0) {\n"); if(AppUtils.nvl(reportRuntime.getTimeAxisType()).length()==0 || AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("hourly")) wholeScript.append(" wholeString += ' ' + Dygraph.zeropad(hour) + ':'+Dygraph.zeropad(minutes);\n"); - //wholeScript.append(" } else if (hour >= 0 && (minutes >= 0 && seconds > 0)) {\n"); - //wholeScript.append(" wholeString += ' ' + Dygraph.zeropad(hour) + ':'+Dygraph.zeropad(minutes)+':'+Dygraph.zeropad(seconds);\n"); - //wholeScript.append(" } else if (hour >= 0) { \n"); - //wholeScript.append(" wholeString += ' ' + Dygraph.zeropad(hour); \n"); - //wholeScript.append(" } \n"); wholeScript.append(" return wholeString; \n"); wholeScript.append(" },\n"); wholeScript.append(" ticker: function (a, b, pixels, opts, dygraph, vals) { \n "); @@ -2280,15 +2205,6 @@ public class ChartD3Helper { wholeScript.append(" touchstart : newDygraphTouchstart,\n"); wholeScript.append(" touchend : Dygraph.defaultInteractionModel.touchend,\n"); wholeScript.append(" touchmove : Dygraph.defaultInteractionModel.touchmove\n"); - //wholeScript.append(" 'dblclick' : dblClickV3,\n"); - //wholeScript.append(" 'mousewheel' : scrollV3\n"); - - /*wholeScript.append(" 'mousedown' : downV3,\n"); - wholeScript.append(" 'mousemove' : moveV3,\n"); - wholeScript.append(" 'mouseup' : upV3,\n"); - wholeScript.append(" 'click' : clickV3,\n"); - wholeScript.append(" 'dblclick' : dblClickV3,\n"); - wholeScript.append(" 'mousewheel' : scrollV3\n");*/ wholeScript.append("},\n"); /*wholeScript.append(" zoomCallback: function(minDate, maxDate, yRanges) { \n"); if(AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("daily")) { 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<String, String> 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<DataColumnType> 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()) { diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntime.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntime.java index d10cd1c4..63aef767 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntime.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntime.java @@ -115,12 +115,8 @@ public class ChartWebRuntime implements Serializable { logger.error(EELFLoggerDelegate.errorLogger, "RaptorException occurred in generateChart",ex); } List roleList = getRolesCommaSeperated(request); - // final Map<String, Object> params = new HashMap<String, Object>(); params.put("user_id", user_id); params.put("role_list", roleList); - // params.put("public_yn", "Y"); - - // String action = request.getParameter(AppConstants.RI_ACTION); String reportID = AppUtils.getRequestValue(request, AppConstants.RI_REPORT_ID); ReportHandler rh = new ReportHandler(); @@ -131,9 +127,6 @@ public class ChartWebRuntime implements Serializable { if (rr.getReportType().equals(AppConstants.RT_HIVE)) { String sql = rr.getReportSQL(); rr.setWholeSQL(sql); - // if(genReportData) - // reportData = rr.loadHiveLinearReportData(rr.getWholeSQL(),user_id.toString(), - // 10000,request); } else { if (genReportData) reportData = rr.loadReportData(0, user_id.toString(), 10000, request, @@ -247,16 +240,6 @@ public class ChartWebRuntime implements Serializable { ? AppUtils.getRequestNvlValue(request, "precision") : "2"; - /* - * boolean animation = AppUtils.getRequestFlag(request, "animation"); boolean staggerLabels - * = AppUtils.getRequestFlag(request, "staggerLabels"); boolean showMaxMin = - * (showMaxMinStr.length()<=0)?false:Boolean.parseBoolean(showMaxMinStr); boolean - * showControls = (showControlsStr.length()<=0)?true:Boolean.parseBoolean(showControlsStr); - * boolean showLegend = - * (showLegendStr.length()<=0)?true:Boolean.parseBoolean(showLegendStr); boolean showTitle = - * (showTitleStr.length()<=0)?true:Boolean.parseBoolean(showTitleStr); boolean stacked = - * (stackedStr.length()<=0)?true:Boolean.parseBoolean(stackedStr); - */ // Add all options to Map chartOptionsMap.put("width", width); chartOptionsMap.put("height", height); @@ -293,17 +276,12 @@ public class ChartWebRuntime implements Serializable { reportRuntime.getChartType(); return drawD3Charts(chartOptionsMap, request); - // drawD3Charts(); - } else /* if (action.equals("chart.json")) */ { + } else{ reportRuntime.getChartType(); return returnChartJSON(chartOptionsMap, request, showData); - } /* - * else { - * - * return ("Internal Error Occurred."); } - */ + } } @@ -441,14 +419,6 @@ public class ChartWebRuntime implements Serializable { } - - /* - * public void drawD3Charts(HashMap<String,String> chartOptionsMap) { - * drawD3Charts(chartOptionsMap); - * - * } - */ - public String drawD3Charts(Map<String, String> chartOptionsMap, HttpServletRequest request) { ChartD3Helper chartHelper = new ChartD3Helper(reportRuntime); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java index f3633a67..49ed35b3 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java @@ -142,9 +142,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme public static final String FFT_TEXTAREA = "TEXT"; -// Changed to "TEXT" -// public static final String FFT_TEXTAREA = "TEXTAREA"; - public static final String FFT_COMBO_BOX = "COMBO_BOX"; public static final String FFT_LIST_BOX = "LIST_BOX"; @@ -186,7 +183,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme boolean required, String defaultValue, String helpText, boolean visible, String dependsOn, Calendar rangeStartDate, Calendar rangeEndDate, String rangeStartDateSQL, String rangeEndDateSQL, String multiSelectListSize) { - // super(); this(fieldName, fieldDisplayName, fieldType, validationType, required, defaultValue, helpText, dependsOn, rangeStartDate, rangeEndDate, rangeStartDateSQL, rangeEndDateSQL, multiSelectListSize); setVisible(visible); @@ -251,7 +247,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme String rangeStartDateSQL, String rangeEndDateSQL, String multiSelectListSize) { this(fieldName, fieldDisplayName, fieldType, validationType, required, defaultValue, helpText, dependsOn, rangeStartDate, rangeEndDate, rangeStartDateSQL, rangeEndDateSQL, multiSelectListSize); - // if(dependsOn !=null){ this.dependsOn = dependsOn; }else { this.dependsOn = "" if (defaultValue != null && defaultValue.length() > 10 && defaultValue.substring(0, 10).trim().toLowerCase().startsWith("select")) { setFieldDefaultSQL(defaultValue); @@ -388,14 +383,7 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } public String getHelpLink(String fieldName) { - // return "<a href=\"#\" onclick=\"javascript:ShowContent('" + fieldName + - // "_div')\"><img src=\""+AppUtils.getBaseFolderURL()+"images/quickhelp_dk.gif\" - // width=\"12\" height=\"12\" alt=\"\" border=\"0\" class=\"qh-element\" - // /></a>"; return ((getHelpText() != null && getHelpText().length() > 0) ? "tooltipText=\"" + getHelpText() + "\">" : ">"); - // return ((getHelpText()!=null && getHelpText().length()>0)? "<img - // src=\"static/fusion/raptor/images/quickhelp_lt.gif\" tooltipText=\""+ - // getHelpText() + "\"/>": ""); } public String getCallableAfterChainingJavascript(String fieldName, ReportRuntime rr) { @@ -459,7 +447,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } if (fieldType.equals(FFT_COMBO_BOX)) { StringBuffer sb = new StringBuffer(); - // System.out.println("COMBO BOX " + fieldName); String oldSQL = ""; if (!required) sb.append("obj.options[obj.options.length] = new Option('-->select value<--','');"); @@ -467,18 +454,10 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme IdNameList lookup = getLookupList(); try { if (!hasPredefinedList) { - // if(dependsOn != null && dependsOn != "") { - // if(dependsOn != null && dependsOn != "" ) { IdNameSql lu = (IdNameSql) lookup; String SQL = ""; SQL = lu.getSql(); - /* - * if(nvl(fieldValue,"").length()<=0) SQL = lu.getSql(); else SQL = - * lu.getBaseSQLForPDFExcel(false); - */ - // System.out.println("FORMFIELD 6666667 First" + ((IdNameSql)lookup).getSql()); oldSQL = lu.getSql(); - // SQL = Utils.replaceInString(SQL, "[VALUE]", fieldValue); if (formValues != null) { Set set = formValues.entrySet(); String value = ""; @@ -502,10 +481,7 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } lookup = new IdNameSql(-1, SQL, lu.getDefaultSQL()); } - // } lookupList = lookup; - - // } try { lookup.loadUserData(0, "", getDbInfo(), getUserId()); } catch (Exception e) { @@ -519,12 +495,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme for (lookup.resetNext(); lookup.hasNext();) { IdNameValue value = lookup.getNext(); if (value != null && value.getId() != null && value.getName() != null) { - /* - * if (count == 0 && required) { selectedValue = value.getId(); count++; } else - * if (nvl(fieldValue).length()>0){ if (fieldValue != null && - * fieldValue.equals(value.getId())){ selectedValue = value.getId(); } count++; - * } else { count++; } - */ if (count == 0) { if (required) { selectedValue = value.getId(); @@ -550,14 +520,12 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } formValues.put(fieldDisplayName, selectedValue); } catch (Exception e) { - // throw new RaptorRuntimeException(e); } if (!hasPredefinedList) { if (oldSQL != null && !oldSQL.equals("")) { ((IdNameSql) lookup).setSQL(oldSQL); } } - // System.out.println("FORMFIELD 6666667 " + ((IdNameSql)lookup).getSql()); if (isVisible()) return sb.toString(); else @@ -570,16 +538,9 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme IdNameList lookup = getLookupList(); try { if (!hasPredefinedList) { - // if(dependsOn != null && dependsOn != "") { - // if(dependsOn != null && dependsOn != "" ) { IdNameSql lu = (IdNameSql) lookup; String SQL = ""; SQL = lu.getSql(); - /* - * if(nvl(fieldValue,"").length()<=0) SQL = lu.getSql(); else SQL = - * lu.getBaseSQLForPDFExcel(false); SQL = Utils.replaceInString(SQL, "[VALUE]", - * fieldValue); - */ oldSQL = lu.getSql(); if (formValues != null) { Set set = formValues.entrySet(); @@ -633,7 +594,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme else return ""; } else if (fieldType.equals(FFT_TEXT_W_POPUP)) { - // System.out.println("TEXT POPUP " + fieldName); String oldSQL = ""; IdNameValue idNamevalue = null; String fieldDefValue = ""; @@ -661,7 +621,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } } SQL = Utils.replaceInString(SQL, "[" + entry.getKey() + "]", value); - // if(SQL.indexOf("'"+"["+entry.getKey()+"]"+"'")!=-1) { if (SQL.indexOf("'" + "[" + entry.getKey() + "]" + "'") != -1 || SQL.indexOf("'" + "[" + entry.getKey()) != -1 || SQL.indexOf(entry.getKey() + "]" + "'") != -1 @@ -698,7 +657,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme lookup = new IdNameSql(-1, SQL, null); } } - // lookupList = lookup; if (getFieldDefaultSQL() != null && (fieldValue == null || fieldValue.trim().equalsIgnoreCase("null") || fieldValue.trim().length() <= 0)) { @@ -739,7 +697,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } } catch (Exception e) { - // throw new RaptorRuntimeException(e); } // ----- END ---// @@ -757,16 +714,9 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } } - } catch (Exception e) { // throw new RaptorRuntimeException(e); + } catch (Exception e) { } if (isVisible()) { - /* - * return "<input type=text class=\"text\" size=30 maxlength=50 id=\"" + - * fieldName +"\" name=\"" + fieldName + "\" value=\"" + nvl(fieldDefValue) + - * "\">\n" + "<a href=\"javascript:showArgPopupNew('" + fieldName + - * "', 'document.formd." + fieldName + "')\"><img border=0 src=\"" + - * AppUtils.getImgFolderURL() + "shareicon.gif\" " + getHelpLink(fieldName); - */ return "obj.value=\"" + Utils.singleQuoteEncode(nvl(fieldDefValue)) + "\";"; } else @@ -776,11 +726,8 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme String oldSQL = ""; try { IdNameList lookup = getLookupList(); - // if(dependsOn != null && dependsOn != "") { - // if(dependsOn != null && dependsOn != "" ) { IdNameSql lu = (IdNameSql) lookup; String SQL = lu.getSql(); - // System.out.println("SQL HIDDEN 1 " + SQL); oldSQL = lu.getSql(); if (formValues != null) { Set set = formValues.entrySet(); @@ -798,14 +745,11 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } } - // System.out.println("HIDDEN " + "["+entry.getKey()+"]" + "-" + value); SQL = Utils.replaceInString(SQL, "[" + entry.getKey() + "]", value); } lookup = new IdNameSql(-1, SQL, lu.getDefaultSQL()); } - // System.out.println("SQL HIDDEN 2 " + SQL); - // } lookupList = lookup; // } if (nvl(fieldValue).length() > 0 && (dependsOn == null || dependsOn.length() <= 0)) { @@ -815,7 +759,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme int iCnt = 0; for (lookup.resetNext(); lookup.hasNext(); iCnt++) { IdNameValue value = lookup.getNext(); - // System.out.println("HIDDEN " + value.getId() + " " + value.getName()); sb.append((value != null) ? "obj.value=\"" + nvl(value.getId()) + "\";" : ""); if (value.isReadOnly()) sb.append("obj.disabled=true;"); @@ -834,15 +777,12 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme if (oldSQL != null && !oldSQL.equals("")) { ((IdNameSql) lookup).setSQL(oldSQL); } - // lookup.clearData(); } catch (Exception e) { - // throw new RaptorRuntimeException(e); } // if(isVisible()) return sb.toString(); } else if (fieldType.equals(FFT_LIST_BOX)) { StringBuffer sb = new StringBuffer(); - // System.out.println("COMBO BOX " + fieldName); String oldSQL = ""; if (!required) sb.append("obj.options[obj.options.length] = new Option('-->select value<--','');"); @@ -850,18 +790,10 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme IdNameList lookup = getLookupList(); try { if (!hasPredefinedList) { - // if(dependsOn != null && dependsOn != "") { - // if(dependsOn != null && dependsOn != "" ) { IdNameSql lu = (IdNameSql) lookup; String SQL = ""; SQL = lu.getSql(); - /* - * if(nvl(fieldValue,"").length()<=0) SQL = lu.getSql(); else SQL = - * lu.getBaseSQLForPDFExcel(false); - */ - // System.out.println("FORMFIELD 6666667 First" + ((IdNameSql)lookup).getSql()); oldSQL = lu.getSql(); - // SQL = Utils.replaceInString(SQL, "[VALUE]", fieldValue); if (formValues != null) { Set set = formValues.entrySet(); String value = ""; @@ -903,12 +835,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme for (lookup.resetNext(); lookup.hasNext();) { IdNameValue value = lookup.getNext(); if (value != null && value.getId() != null && value.getName() != null) { - /* - * if (count == 0 && required) { selectedValue = value.getId(); count++; } else - * if (nvl(fieldValue).length()>0){ if (fieldValue != null && - * fieldValue.equals(value.getId())){ selectedValue = value.getId(); } count++; - * } else { count++; } - */ if (count == 0) { if (required) { selectedValue = value.getId(); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessor.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessor.java index 0805b22c..62bf4335 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessor.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessor.java @@ -134,9 +134,6 @@ public class FormatProcessor extends RaptorObject { + origValue.substring(3, 5); try { - // DataSet ds = DbUtils.executeQuery("SELECT TO_CHAR(TO_DATE('" + origValue + "', '" - // + dateFormat + "'), 'YYYY-MM-DD') val FROM DUAL"); - String sql = Globals.getGenerateSqlVisualDual(); DataSet ds = DbUtils.executeQuery("SELECT TO_CHAR(TO_DATE('" + origValue + "', '" + dateFormat + "'), 'YYYY-MM-DD') val"+sql); @@ -166,8 +163,6 @@ public class FormatProcessor extends RaptorObject { beforeDecimalPoint = false; else if (c == '-' && integerValue.length() == 0) isNegative = true; - // else - // if(c=='0'||c=='1'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7'||c=='8'||c=='9') else if (Character.isDigit(c)) if (beforeDecimalPoint) integerValue.append(c); @@ -276,8 +271,6 @@ public class FormatProcessor extends RaptorObject { if( anyFormatter == null ) anyFormatter = formatter; - // String sValue = convertValue(dv.getDisplayValue()); - //if (sValue.length() > 0) { for (Iterator iter = semaphore.getFormatList().getFormat().iterator(); iter .hasNext();) { FormatType fmt = (FormatType) iter.next(); @@ -311,42 +304,16 @@ public class FormatProcessor extends RaptorObject { valueMatched = isEqual(sValue, formatterValue) || isLessThan(sValue, formatterValue); } - //s_logger.debug("SYSOUT " + " " +sValue +" " +fmt.getBgColor() + " " + fmt.getLessThanValue()+ " " +valueMatched); if (fmt.getLessThanValue().length() > 0 && valueMatched) { formatter = (HtmlFormatter) formatters.get(fmt.getFormatId()); formatter.setFormatId(fmt.getFormatId()); formatModified = true; - //dv.setFormatId(fmt.getFormatId()); - //dr.setFormatId(fmt.getFormatId()); - //break; - } else { // if + } else { if(!formatModified) formatter = anyFormatter; - //if(!((formatter!=null && formatter!=anyFormatter) || (defaultFormatter!=null && formatter!=defaultFormatter))) - // formatter = anyFormatter; - //formatter.setFormatId(anyFormatter.getFormatId()); } - /*else if ((fmt.getLessThanValue().length() <= 0) - && (fmt.getFormatId().length() > 0)) { - formatter = (HtmlFormatter) formatters.get(fmt.getFormatId()); - System.out.println("---------------lesser "+ fmt.getFormatId()+ " " + fmt.getBgColor()); - dv.setFormatId(fmt.getFormatId()); - dr.setFormatId(fmt.getFormatId()); - // break; - } // else if*/ - } // for - /*} else { - for (Iterator iter = semaphore.getFormatList().getFormat().iterator(); iter - .hasNext();) { - FormatType fmt = (FormatType) iter.next(); - if(fmt.getLessThanValue().length()<=0 && fmt.getExpression().length()<=0 && !fmt.isBold() && !fmt.isItalic() && !fmt.isUnderline() && fmt.getFontSize().equals("11")) { - formatter = defaultFormatter; - } else - formatter = anyFormatter; } - - //formatter.setFormatId(anyFormatter.getFormatId()); - } */ + if(formatter != null) { if (semaphore.getSemaphoreType().equals(AppConstants.ST_ROW)) { @@ -356,17 +323,14 @@ public class FormatProcessor extends RaptorObject { dr.setRowFormatter(formatter); dr.setFormatId(formatter.getFormatId()); // This is added for excel download - //if (!formatter.equals(defaultFormatter)) { dr.setRowFormat(true); - //} } } else { if(nvl(targetColId).length()>0) { if(targetDataValue!=null) { targetDataValue.setCellFormatter(formatter); - targetDataValue.setFormatId(formatter.getFormatId()); - //if (!formatter.equals(defaultFormatter)) { + targetDataValue.setFormatId(formatter.getFormatId()); targetDataValue.setCellFormat(true); int count = 0; for (dr.resetNext(); dr.hasNext();) { @@ -383,12 +347,10 @@ public class FormatProcessor extends RaptorObject { } else { dv.setCellFormatter(formatter); - dv.setFormatId(formatter.getFormatId()); - //if (!formatter.equals(defaultFormatter)) { + dv.setFormatId(formatter.getFormatId()); dv.setCellFormat(true); - //} } - }// else + } } } // setHtmlFormatters diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportFormFields.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportFormFields.java index 7bacd229..e50d465e 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportFormFields.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportFormFields.java @@ -86,15 +86,12 @@ public class ReportFormFields extends Vector { String visible = nvl(fft.getVisible(),"Y"); String dependsOn = nvl(fft.getDependsOn(), ""); Calendar rangeStartDate = (fft.getRangeStartDate()==null)?null:fft.getRangeStartDate().toGregorianCalendar(); - Calendar rangeEndDate = (fft.getRangeEndDate()==null)?null:fft.getRangeEndDate().toGregorianCalendar(); - //Calendar rangeEndDate = fft.getRangeEndDate().toGregorianCalendar(); + Calendar rangeEndDate = (fft.getRangeEndDate()==null)?null:fft.getRangeEndDate().toGregorianCalendar(); String rangeStartDateSQL = fft.getRangeStartDateSQL(); String rangeEndDateSQL = fft.getRangeEndDateSQL(); String userId = AppUtils.getUserID(request); String multiSelectListSize = fft.getMultiSelectListSize(); - - //s_logger.debug("ranges are : " + fft.getRangeStartDate() + fft.getRangeEndDate()); - //s_logger.debug("fieldSQL B4" + fieldSQL); + if(fieldSQL!=null) { for (int i = 0; i < reqParameters.length; i++) { if(!reqParameters[i].startsWith("ff") && (request.getParameter(reqParameters[i].toUpperCase())!=null && request.getParameter(reqParameters[i].toUpperCase()).length() > 0)) @@ -104,7 +101,6 @@ public class ReportFormFields extends Vector { } for (int i = 0; i < scheduleSessionParameters.length; i++) { - //s_logger.debug(" Session " + " scheduleSessionParameters[i] " + scheduleSessionParameters[i].toUpperCase() + " " + request.getParameter(scheduleSessionParameters[i])); if(request.getParameter(scheduleSessionParameters[i])!=null && request.getParameter(scheduleSessionParameters[i]).trim().length()>0 ) fieldSQL = Utils.replaceInString(fieldSQL, "[" + scheduleSessionParameters[i].toUpperCase()+"]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), request.getParameter(scheduleSessionParameters[i]) )); if(request.getAttribute(scheduleSessionParameters[i])!=null && ((String)request.getAttribute(scheduleSessionParameters[i])).trim().length()>0 ) @@ -113,14 +109,9 @@ public class ReportFormFields extends Vector { } for (int i = 0; i < sessionParameters.length; i++) { - //if(!sessionParameters[i].startsWith("ff")) - //fieldSQL = Utils.replaceInString(fieldSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i].toUpperCase()) ); - //else { if (session.getAttribute(sessionParameters[i])!=null && ((String)session.getAttribute(sessionParameters[i])).length() > 0) { - //s_logger.debug(" Session " + " sessionParameters[i] " + sessionParameters[i] + " " + (String)session.getAttribute(sessionParameters[i])); fieldSQL = Utils.replaceInString(fieldSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) ); } - // } } fieldSQL = Utils.replaceInString(fieldSQL, "[USERID]", userId); fieldSQL = Utils.replaceInString(fieldSQL, "[USER_ID]", userId); @@ -136,7 +127,6 @@ public class ReportFormFields extends Vector { fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[" + reqParameters[i].toUpperCase()+"]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), request.getParameter(reqParameters[i]) )); } for (int i = 0; i < scheduleSessionParameters.length; i++) { - //s_logger.debug(" Session " + " scheduleSessionParameters[i] " + scheduleSessionParameters[i].toUpperCase() + " " + request.getParameter(scheduleSessionParameters[i])); if(request.getParameter(scheduleSessionParameters[i])!=null && request.getParameter(scheduleSessionParameters[i]).trim().length()>0 ) fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[" + scheduleSessionParameters[i].toUpperCase()+"]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), request.getParameter(scheduleSessionParameters[i]) )); if(request.getAttribute(scheduleSessionParameters[i])!=null && ((String)request.getAttribute(scheduleSessionParameters[i])).trim().length()>0 ) @@ -145,9 +135,6 @@ public class ReportFormFields extends Vector { } for (int i = 0; i < sessionParameters.length; i++) { - //if(!sessionParameters[i].startsWith("ff")) - //fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i].toUpperCase()) ); - //else if (session.getAttribute(sessionParameters[i])!=null && ((String)session.getAttribute(sessionParameters[i])).length() > 0) fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) ); } @@ -156,7 +143,6 @@ public class ReportFormFields extends Vector { fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[USER_ID]", userId); fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[LOGGED_USERID]", userId); } - //s_logger.debug("fieldSQL After" + fieldSQL); if(rangeStartDateSQL!=null) { for (int i = 0; i < reqParameters.length; i++) { if(!reqParameters[i].startsWith("ff") && (request.getParameter(reqParameters[i].toUpperCase())!=null && request.getParameter(reqParameters[i].toUpperCase()).length() > 0)) @@ -217,9 +203,8 @@ public class ReportFormFields extends Vector { String lColFormat = null; if (rw.getReportDefType().equals(AppConstants.RD_SQL_BASED)) { String colId = nvl(fft.getColId()); - lTableName = ReportWrapper.getSQLBasedFFTColTableName(colId); // colId.substring(0, - // colId.indexOf('.')); - lColumnName = ReportWrapper.getSQLBasedFFTColColumnName(colId); // colId.substring(colId.lastIndexOf('.')+1); + lTableName = ReportWrapper.getSQLBasedFFTColTableName(colId); + lColumnName = ReportWrapper.getSQLBasedFFTColColumnName(colId); lColumnType = AppConstants.CT_CHAR; try { lColumnType = nvl(DataCache.getReportTableDbColumnType(lTableName, @@ -249,8 +234,6 @@ public class ReportFormFields extends Vector { if (lColumnType.equals(AppConstants.CT_DATE)) selectVal = "TO_CHAR(" + selectVal + ", '" + AppConstants.DEFAULT_DATE_FORMAT + "')"; - // DataSet ds = DbUtils.executeQuery("SELECT - // "+selectVal+" FROM "+lTableName); DataSet ds = ConnectionUtils.getDataSet("SELECT " + selectVal + " FROM " + lTableName, rw.getDBInfo()); if (ds.getRowCount() > 0) diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportJSONRuntime.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportJSONRuntime.java index d3d44ac3..de5c892b 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportJSONRuntime.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportJSONRuntime.java @@ -406,48 +406,12 @@ import org.onap.portalsdk.analytics.view.ColumnHeader; }*/ -/*class Row { - private String displayValue; - private String dataType; - private String colId; - private boolean visible; - - - public boolean isVisible() { - return visible; - } - public void setVisible(boolean visible) { - this.visible = visible; - } - public String getDisplayValue() { - return displayValue; - } - public void setDisplayValue(String displayValue) { - this.displayValue = displayValue; - } - public String getDataType() { - return dataType; - } - public void setDataType(String dataType) { - this.dataType = dataType; - } - public String getColId() { - return colId; - } - public void setColId(String colId) { - this.colId = colId; - } - - -}*/ class FormFieldJSON { private String fieldId; private String fieldDisplayName; private String fieldType; private String validationType; private boolean required; - //private String defaultValue; - private Calendar rangeStartDate; private Calendar rangeEndDate; private String multiSelectListSize; diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java index b6f944a7..d10826af 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java @@ -55,7 +55,8 @@ import java.util.regex.Pattern; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; - +import org.apache.commons.lang.StringUtils; +import org.apache.jcs.engine.CacheUtils; import org.onap.portalsdk.analytics.error.RaptorException; import org.onap.portalsdk.analytics.model.DataCache; import org.onap.portalsdk.analytics.model.ReportHandler; @@ -70,7 +71,9 @@ import org.onap.portalsdk.analytics.system.ConnectionUtils; import org.onap.portalsdk.analytics.system.DbUtils; import org.onap.portalsdk.analytics.system.Globals; import org.onap.portalsdk.analytics.util.AppConstants; +import org.onap.portalsdk.analytics.util.CachingUtils; import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.RemDbInfo; import org.onap.portalsdk.analytics.util.Utils; import org.onap.portalsdk.analytics.view.ColumnHeader; import org.onap.portalsdk.analytics.view.ColumnHeaderRow; @@ -85,9 +88,11 @@ import org.onap.portalsdk.analytics.xmlobj.DataColumnType; import org.onap.portalsdk.analytics.xmlobj.FormFieldType; import org.onap.portalsdk.analytics.xmlobj.ObjectFactory; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.portalsdk.core.objectcache.jcs.JCSCacheManager; import org.onap.portalsdk.core.util.SecurityCodecUtil; import org.owasp.esapi.ESAPI; - +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.ObjectMapper; @@ -108,11 +113,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; * */ +@Component public class ReportRuntime extends ReportWrapper implements Cloneable, Serializable { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportRuntime.class); - //TODO DELETE IF PARSE SQL is not working private int curSQLParsePos = 0; private String xmlFileURL = null; @@ -131,10 +136,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa private boolean displayContent = true; - private boolean reportRunLogged = false; // Used to avoid multiple - // entries in the report log - // when executing with different - // params or going to next page + private boolean reportRunLogged = false; private DataSet chartDataCache = null; @@ -142,11 +144,13 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa private int cachedPageNo = -1; - private String cachedSQL = null; // For display purposes only + private String cachedSQL = null; - private String wholeSQL = null; // For display purposes only + private String wholeSQL = null; - private String totalSql = null; // For display purposes only + private String totalSql = null; + + private boolean isSinglePageDownload = false; private ReportParamValues reportParamValues = null; @@ -184,53 +188,51 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa private int DATE_OPTION = -1; + public boolean isSinglePageDownload() { + return isSinglePageDownload; + } + + public void setSinglePageDownload(boolean isSinglePageDownload) { + this.isSinglePageDownload = isSinglePageDownload; + } + public void setReportFormFields(ReportFormFields reportFormFields) { this.reportFormFields = reportFormFields; } + public ReportRuntime() { + super(); + } - /* - * private ReportRuntime(CustomReport cr, String reportID, - * HttpServletRequest request) { super(cr, reportID); - * - * reportParamValues = new ReportParamValues(this); reportFormFields = new - * ReportFormFields(this); - * - * if(request!=null) setParamValues(request); } // ReportRuntime - */ private ReportRuntime(CustomReportType crType, String reportID, HttpServletRequest request, String ownerID, String createID, String createDate, String updateID, String updateDate, String menuID, boolean menuApproved) throws RaptorException { super(crType, reportID, ownerID, createID, createDate, updateID, updateDate, menuID, menuApproved); initializeReportRuntime(request); - } // ReportRuntime + } public ReportRuntime(ReportWrapper rw) throws RaptorException { this(rw, null); - } // ReportRuntime + } public ReportRuntime(ReportWrapper rw, HttpServletRequest request)throws RaptorException { super(rw); initializeReportRuntime(request); - } // ReportRuntime + } private void initializeReportRuntime(HttpServletRequest request) throws RaptorException { reportFormFields = new ReportFormFields(this, request); setParamValues(request, true, true); visualManager = new VisualManager(); - } // initializeReportRuntime + } -// public void setReportFormFields(HttpServletRequest request) { -// reportFormFields = new ReportFormFields(this, request); -// setParamValues(request, true, true); -// } public static ReportRuntime unmarshal(String reportXML, String reportID) throws RaptorException { return unmarshal(reportXML, reportID, null); - } // unmarshal + } public static ReportRuntime unmarshal(String reportXML, String reportID, HttpServletRequest request) throws RaptorException { @@ -242,7 +244,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa return new ReportRuntime(crType, reportID, request, null, null, null, null, null, null, false); - } // unmarshal + } public String getXmlFileURL() { return xmlFileURL; @@ -339,8 +341,8 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa setDisplayForm(false); else setDisplayForm(true); - } // else - } // setDisplayFlags + } + } public void logReportRun(String userID, String executionTime, String formFields) throws RaptorException { if (reportRunLogged) @@ -348,7 +350,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa ReportLoader.createReportLogEntry(null, reportID, userID, AppConstants.RLA_RUN,executionTime,formFields ); reportRunLogged = true; - } // logReportRun + } public void logReportExecutionTime(String userId, String executionTime, String action, String formFields) throws RaptorException { ReportLoader.createReportLogEntryForExecutionTime(null, reportID, userId,executionTime , action, formFields); @@ -367,7 +369,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (pageDataCache != null) pageDataCache.resetVisualSettings(); - } // resetVisualSettings + } /** ************** ReportParamValues processing *************** */ @@ -385,7 +387,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } else if (request != null) { paramsUpdated = reportParamValues.setParamValues(request,refresh); } - // This is called even in the wizard page. Hence this condition. + if((ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)!=null) { if(reportParamValuesFPE!=null) reportParamValuesFPE.setParamValues(request,refresh); else { @@ -394,15 +396,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } } else { reportFormFields = new ReportFormFields(this, request); - //added below two lines for dashboard default value reportParamValues = new ReportParamValues(reportFormFields, getReportDefType()); reportParamValues.setParamValues(request,refresh); - //End reportParamValuesFPE = new ReportParamValuesForPDFExcel(reportFormFields, getReportDefType()); reportParamValuesFPE.setParamValues(request,refresh); } -// } if (paramsUpdated) { setReportDataSize(-1); chartDataCache = null; @@ -417,35 +416,32 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa grandTotalCrosstab = null; if(!refresh) resetVisualSettings(); - } // if + } displayChart = (request.getParameter(AppConstants.RI_DISPLAY_CHART) == null) ? !isDisplayOptionHideChart() : request.getParameter("display_chart") .equals("Y"); return paramsUpdated; - } // setParamValues + } public String getParamValue(String key) { - //reportParamValues.printValues(); return reportParamValues.getParamValue(key); - } // getParamValue + } - public String getParamDisplayValue(String key) { - //reportParamValues.printValues(); + public String getParamDisplayValue(String key) {; return reportParamValues.getParamDisplayValue(key); - } // getParamValue - + } public Enumeration getParamKeys() { return reportParamValues.keys(); - } // getParamKeys + } public Enumeration getParamKeysForPDFExcel() { return reportParamValuesFPE.keys(); - } // getParamKeys + } public String getParamValueForPDFExcel(String key) { return reportParamValuesFPE.getParamValue(key); - } // getParamValue + } public ArrayList getParamNameValuePairs() { ArrayList paramList = new ArrayList(getReportFormFields().size()); @@ -453,9 +449,9 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa FormField ff = (FormField) iter.next(); paramList.add(new IdNameValue(ff.getFieldDisplayName(), reportParamValues .getParamDisplayValue(ff.getFieldName()))); - } // for + } return paramList; - } // getParamNameValuePairs + } public ArrayList getParamNameValuePairsforPDFExcel(HttpServletRequest request, int type /*excel =1; pdf=2*/) { javax.servlet.http.HttpSession session = request.getSession(); @@ -465,7 +461,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if(paramList!=null && paramList.size()>0) return paramList; } - //System.out.println(" getParamNamePairs type " + type + " " + Globals.customizeFormFieldInfo()); if ( reportParamValuesFPE == null) { reportParamValuesFPE = new ReportParamValuesForPDFExcel(reportFormFields, getReportDefType()); reportParamValuesFPE.setParamValues(request,true); @@ -474,7 +469,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa String valueString = ""; for (Iterator iter = getReportFormFields().iterator(); iter.hasNext();) { FormField ff = (FormField) iter.next(); - if(ff.isVisible() && /*!ff.getFieldType().equals(FormField.FFT_HIDDEN) &&*/ type == 1){ + if(ff.isVisible() && type == 1){ valueString = reportParamValuesFPE.getParamDisplayValue(ff.getFieldName()); } else if(ff.isVisible() && type != 1) { valueString = reportParamValuesFPE.getParamDisplayValue(ff.getFieldName()); @@ -482,8 +477,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if(valueString.equalsIgnoreCase("NULL")) valueString=""; paramList.add(new IdNameValue(ff.getFieldDisplayName(), valueString)); -// } - } // for + } String pdfAttachmentKey = AppUtils.getRequestValue(request, "pdfAttachmentKey"); boolean isSchedule = false; @@ -501,10 +495,8 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } if(isSchedule) { - //debugLogger.debug("Globals " + Globals.getSessionParamsForScheduling()); String[] scheduleSessionParam = Globals.getSessionParamsForScheduling().split(","); for (int i = 0; i < scheduleSessionParam.length; i++) { - //debugLogger.debug(" scheduleSessionParam[i] " + scheduleSessionParam[i] + " " + request.getParameter(scheduleSessionParam[i]) ); if(request.getParameter(scheduleSessionParam[i])!=null) paramList.add(new IdNameValue(ESAPI.encoder().canonicalize(scheduleSessionParam[i].toUpperCase()), ESAPI.encoder().canonicalize(request.getParameter(scheduleSessionParam[i])))); } @@ -518,7 +510,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } catch(Exception ex) {} } else { - //System.out.println(" In Else getParamNamePairs type " + type); String[] sessionDisplayParameters = Globals.getDisplaySessionParamInPDFEXCEL().split(","); if(session != null && !isSchedule ) { session.setAttribute("login_id", AppUtils.getUserBackdoorLoginId(request)); @@ -526,7 +517,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa String sessionDispParam = sessionDisplayParameters[i]; if(nvl(sessionDispParam).length()>0) { String sessionDispParamArr[] = sessionDispParam.split(";"); - //System.out.println("Session " + sessionDispParamArr[1] + " " + (String)session.getAttribute(sessionDispParamArr[0])); paramList.add(new IdNameValue(sessionDispParamArr[1], nvl((String)session.getAttribute(sessionDispParamArr[0]),""))); } } @@ -555,9 +545,8 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa String name = value.getName().replaceAll(",","~"); value.setName(name); } - //request.getSession().setAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO, paramList); return paramList; - } // getParamNameValuePairs + } /** ************** ReportFormFields processing *************** */ @@ -570,7 +559,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if(comment.length()>0) { al = getParamNameValuePairsforPDFExcel(request, 2); if(al!=null) { - //st = new StringBuffer(comment); for (int i=0; i < al.size(); i++) { IdNameValue idNameValue = (IdNameValue)al.get(i); if(nvl(idNameValue.getId()).equals("DATE")) @@ -591,15 +579,15 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa public boolean needFormInput() { return reportFormFields.getFieldCount() > 0; - } // needFormInput + } public FormField getFormField(String fieldName) { return reportFormFields.getFormField(fieldName); - } // getFormField + } public ReportFormFields getReportFormFields() { return reportFormFields; - } // getReportFormFields + } public void setChartDataCache(DataSet chartDataCache) { this.chartDataCache = chartDataCache; @@ -621,10 +609,10 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa ds = ConnectionUtils.getDataSet(sql, dbInfo); if (Globals.getCacheChartData()) chartDataCache = ds; - } // if + } return ds; - } // loadChartData + } public String getReportDataSQL(String userId, int downloadLimit, HttpServletRequest request) throws RaptorException { String reportSQL = ""; @@ -643,11 +631,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa rd = pageDataCache; if(isGoBackAction && rd!=null) return rd; - if (rd == null) { // Commented So that Data is refreshed from DB again - if (getReportDataSize() < 0) - if (pageNo > 0) - pageNo = 0; - + if (rd == null) { if (getReportType().equals(AppConstants.RT_CROSSTAB)) rd = loadCrossTabReportData(pageNo, userId, downloadLimit, request, download); else if (getReportType().equals(AppConstants.RT_LINEAR)) @@ -661,10 +645,10 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa pageDataCache = rd; cachedPageNo = pageNo; } - } // if // Commented So that Data is refreshed from DB again + } return rd; - } // loadReportData + } private ReportData loadCrossTabReportData(int pageNo, String userId, int downloadLimit, HttpServletRequest request, boolean download) throws RaptorException { String reportSQL = generateSQL(reportParamValues, userId, request); @@ -672,13 +656,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa cachedSQL = reportSQL; wholeSQL = reportSQL; List reportCols = getAllColumns(); - // replace the request parameter specified in the drill down DataColumnType dataColumnRequest = getCrossTabValueColumn(); reportSQL = parseReportSQLForDrillDownParams(reportSQL, dataColumnRequest, request); DataSet ds = null; - // try { String dbInfo = getDBInfo(); StringBuffer colNames = new StringBuffer(); StringBuffer colExtraIdNames = new StringBuffer(); @@ -687,24 +669,18 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa for (Iterator iter = reportCols.iterator(); iter.hasNext();) { DataColumnType dc = (DataColumnType) iter.next(); - //TODO: commented if (dc.isVisible()) { if (colNames.length() > 0) colNames.append(", "); colNames.append(dc.getColId()); - //TODO uncomment if it's not working} // if - - // Checking for extra fields necessary for drill-down if (nvl(dc.getDrillDownURL()).length() > 0) { System.out.println("Drilldown URL " + dc.getDrillDownURL()); } - } // for + } if (reportSQL.toUpperCase().indexOf("GROUP BY ") < 0) colNames.append(colExtraIdNames.toString()); colNames.append(colExtraDateNames.toString()); - //reportSQL = " SELECT ROWNUM rnum, " - // + colNames.toString() + " FROM (" + reportSQL + ") "; String rSQL = Globals.getLoadCrosstabReportData(); rSQL = rSQL.replace("[colNames.toString()]", colNames.toString()); @@ -769,8 +745,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_ROW)) { RowHeaderCol rhc = new RowHeaderCol(); rhc.setColumnTitle(dct.getDisplayName()); - // rhc.setColumnWidth("10%"); - //rhc.setColumnWidth(dct.getDisplayWidth() + "%"); if(nvl(dct.getDisplayWidthInPxls()).length()<=0) { dct.setDisplayWidthInPxls("100px"); } @@ -805,29 +779,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa rd.reportRowHeaderCols.addRowHeaderCol(rhc); } } - } // for - - //int dataColumnIdx = getCrossTabValueColumnIndex(); + } FormatProcessor formatProcessor = new FormatProcessor(getSemaphoreById(dataColumn .getSemaphoreId()), getReportDefType().equals(AppConstants.RD_SQL_BASED) ? AppConstants.CT_NUMBER : dataColumn.getColType(), dataColumn.getColFormat(), false); List dataList = new ArrayList(); - /* //fillup all rows based on rowheaders - Vector rowHeaders = crossTabOrderManager.getRowHeaderValues(); - CrossTabColumnValues crossTabRowValues; - int size = 0; - for (int i = 0; i < rowHeaders.size(); i++) { - if((i+1)==rowHeaders.size()) { - crossTabRowValues = (CrossTabColumnValues) rowHeaders.get(i); - size = crossTabRowValues.getValuesCount(); - } - } - - for (int i = 0; i < size; i++) { - dataList.add(new DataRow()); - }*/ - for (int i = 0; i < ds.getRowCount(); i++) { Vector rValues = new Vector(); Vector cValues = new Vector(); @@ -865,41 +822,19 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dv.setDisplayName(dataColumn.getDisplayName()); dv.setColId(dataColumn.getColId()); dv.setNowrap(nvl(dataColumn.getNowrap(),"null").equals("false")?"null":nvl(dataColumn.getNowrap(),"null")); - /*StringBuffer indentation = new StringBuffer(""); - if(dataColumn.getIndentation()!=null && dataColumn.getIndentation().intValue()>0) { - for (int indent=0; indent < dataColumn.getIndentation(); indent++) { - indentation.append("\t"); - } - dv.setNowrap("true"); - } - dv.setIndentation(indentation.toString());*/ - if (nvl(dataColumn.getDrillDownURL()).length() > 0) { if(dv.getDisplayValue().length() > 0) { dv.setDrillDownURL(parseDrillDownURL(i, /* dataColumnIdx, */ds, dataColumn,request, childReportFormFields)); dv.setDrillDowninPoPUp(dataColumn.isDrillinPoPUp()!=null?dataColumn.isDrillinPoPUp():false); } if (dv.getDisplayValue().length() == 0) { - //dv.setDisplayValue("[NULL]"); dv.setDisplayValue(""); } - } // if + } rd.setDataValue(rValues, cValues, cValuesSort.size()==0?null:cValuesSort, dv, formatProcessor, crossTabOrderManager, dataList); - } // for + } rd.setReportDataList(dataList); - /*if (getReportDataSize() < 0) - setReportDataSize(rd.getDataRowCount());*/ - - /*if (pageNo >= 0) - rd.truncateData(pageNo * getPageSize(), (pageNo + 1) * getPageSize() - 1); - else { - if( downloadLimit != -1) - rd.truncateData(0, downloadLimit - 1); - else - rd.truncateData(0, -1); - }*/ - if (colDataTotalsCrosstab == null) colDataTotalsCrosstab = generateDataTotalsCrossTab(AppConstants.CV_COLUMN, userId,request); if (displayColTotals && colDataTotalsCrosstab != null) @@ -926,13 +861,9 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa rd.setGrandTotalCrossTab(Utils.truncateTotalDecimals(grandTotalCrosstab), dataColumn.getDisplayAlignment(), getCrossTabDisplayTotal(AppConstants.CV_COLUMN), dataList); - } // if + } rd.consolidateColumnHeaders(visualManager); - //if (Globals.getMergeCrosstabRowHeadings()) - // rd.consolidateRowHeaders(); - //rd.addRowNumbers(pageNo, dataList); - if (displayColTotals && colDataTotalsCrosstab != null) { String totalLabel = "Total"; String colDisplayTotal = getCrossTabDisplayTotal(AppConstants.CV_COLUMN); @@ -942,11 +873,8 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (getReportDataSize() > getPageSize()) totalLabel += "_nl_(for all pages)"; - //rd.setCrossTabColumnTotalLabel(totalLabel); - } // if - //rd.applyVisibility(); - //Collections.sort((List)dataList, new DataRowComparable()); + } DataRow drInFor1 = null; Vector<DataValue> v1= null, v2 = null; ArrayList<String> temp = new ArrayList<>(); @@ -957,9 +885,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa v1 = drInFor1.getRowValues(); if(i<dataList.size()-1) { v2 = ((DataRow)dataList.get(i+1)).getRowValues(); - } /*else { - v2 = ((DataRow)dataList.get(i-1)).getRowValues(); - }*/ + } for (int j = 0; j < v1.size(); j++) { if(j==0) { if(v1.get(j).getDisplayValue().length()>0) { // another ArrayList @@ -975,13 +901,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } rd.setReportDataList(dataList); if (getReportDataSize() < 0) { - //setReportDataSize(rd.getDataRowCount()); setReportDataSize(rd.getReportDataList().size()); } return rd; - } // loadCrossTabReportData - + } public DataValue addDataValue(DataColumnType dataColumn, String columnValue) { DataValue dv = new DataValue(); @@ -998,7 +922,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } - /*private*/ public boolean doesReportContainsGroupFormField() { + public boolean doesReportContainsGroupFormField() { int flag = 0; if(getFormFieldList()!=null) { for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) { @@ -1013,10 +937,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } private ReportData loadLinearReportData(int pageNo, String userId, int downloadLimit, HttpServletRequest request, boolean download) throws RaptorException { + long startTime = System.currentTimeMillis(); + logger.info("Session ID: " + request.getSession().getId()); + boolean isSameSession = false; + String action = nvl(request.getParameter(AppConstants.RI_ACTION), request.getParameter("action"));; - String reportSQL = ""; - if(action.endsWith("session")) { reportSQL = getWholeSQL(); wholeSQL = reportSQL; @@ -1028,11 +954,24 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } DataSet ds = null; String dbInfo = getDBInfo(); - ds = ConnectionUtils.getDataSet(wholeSQL, dbInfo); - setReportDataSize(ds.getRowCount()); - //wholeSQL = reportSQL; + long runWHoleSqlStart = System.currentTimeMillis(); + String SQLForCount = "SELECT count(*) FROM (" + reportSQL + ")"+ (Globals.isPostgreSQL() || Globals.isMySQL()?" AS ":"") +" x "; + boolean isPageDowload = Boolean.valueOf(request.getParameter(AppConstants.PAGE_DOWNLOAD)); + if(download) { + if(isPageDowload) { + ds = ConnectionUtils.getDataSet(cachedSQL, dbInfo); + } + else { + String downloadAll = generateSubsetSQL(0, downloadLimit, userId, request, true, null); + ds = ConnectionUtils.getDataSet(downloadAll, dbInfo); + } + } + long runWHoleSqlEnd = System.currentTimeMillis(); + logger.info("Run whole sql to set reportDataSize took:"+ (runWHoleSqlEnd - runWHoleSqlStart)/1000F + "Seconds"); + long hibernateSessionTimeStart = System.currentTimeMillis(); HttpSession session = request.getSession(); - //debugLogger.debug(" ******** Download Limit ********* " + downloadLimit + " %%%%%%%%%%PAGE " + pageNo ); + long hibernateSessionTimeEnd = System.currentTimeMillis(); + logger.info("Hibernate session time : " + (hibernateSessionTimeEnd - hibernateSessionTimeStart)/1000F + " Seconds"); List reportCols = null; StringBuffer colNames = new StringBuffer(); @@ -1049,12 +988,18 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } else { - String pagedSQL = null; // reportSQL; + String pagedSQL = null; + long genaratePageSqlStart = System.currentTimeMillis(); + boolean getColumnNamesFromReportSQL = false; + if(Globals.getDBType().equals(AppConstants.ORACLE)) { + getColumnNamesFromReportSQL = true; + } if (pageNo >= 0) - pagedSQL = generatePagedSQL(pageNo, userId, request, false, null); + pagedSQL = generatePagedSQL(pageNo, userId, request, getColumnNamesFromReportSQL, null); else - pagedSQL = generateSubsetSQL(0, downloadLimit, userId, request, false, null); - // replace the request parameter specified in the drill down + pagedSQL = generateSubsetSQL(0, downloadLimit, userId, request, getColumnNamesFromReportSQL, null); + long genaratePageSqlend = System.currentTimeMillis(); + logger.info("generate paged sql took : " + (genaratePageSqlend - genaratePageSqlStart)/1000F + " Seconds"); reportCols = getAllColumns(); colNames = new StringBuffer(); for (Iterator iter = reportCols.iterator(); iter.hasNext();) { @@ -1072,18 +1017,30 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa cachedSQL = pagedSQL; - // try { + if(doesReportContainsGroupFormField()) { if (pageNo >= 0) - pagedSQL = generatePagedSQL(pageNo, userId, request, true, reportParamValues); + pagedSQL = generatePagedSQL(pageNo, userId, request, getColumnNamesFromReportSQL, reportParamValues); else - pagedSQL = generateSubsetSQL(0, downloadLimit, userId, request, true, reportParamValues); + pagedSQL = generateSubsetSQL(0, downloadLimit, userId, request, getColumnNamesFromReportSQL, reportParamValues); } - //check for Group formfield - //if groupformfield get columns from sql - + long start = System.currentTimeMillis(); ds = ConnectionUtils.getDataSet(pagedSQL, dbInfo); - + long end = System.currentTimeMillis(); + float sec = (end - start) / 1000F; + logger.info("Get page data : "+sec + " seconds"); + if (ds.getRowCount() < getPageSize() && pageNo == 0) { + setReportDataSize(ds.getRowCount()); + } else { + if (CachingUtils.isTotalCountAvailable(request.getSession().getId() + wholeSQL) && !download) { + setReportDataSize(CachingUtils.getTotalRowsCount(request.getSession().getId() + wholeSQL)); + } else { + DataSet countData = null; + countData = ConnectionUtils.getDataSet(SQLForCount, dbInfo); + setReportDataSize(countData.getInt(0, 0)); + CachingUtils.cacheTotalRowCount(request.getSession().getId() + wholeSQL, countData.getInt(0, 0)); + } + } if(doesReportContainsGroupFormField()) { List reportCols1 = getAllColumns(); reportCols = new Vector(); @@ -1120,20 +1077,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } } - - // if ( (remDbInfo!=null) && (!remDbInfo.equals(AppConstants.DB_LOCAL))) - // { - // Globals.getRDbUtils().setDBPrefix(remDbInfo); - // ds = RemDbUtils.executeQuery(pagedSQL); - // } - // else - // ds = DbUtils.executeQuery(pagedSQL); - /* - * } catch(SQLException e) { throw new - * ReportSQLException("[ReportRuntime.loadLinearReportData] - * "+e.getMessage(), pagedSQL); } - */ - if (getReportDataSize() < 0) if (pageNo < 0) setReportDataSize(ds.getRowCount()); @@ -1141,30 +1084,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa setReportDataSize(ds.getRowCount()); else { - /*Pattern re1 = Pattern.compile("[Oo][Rr][Dd][Ee][Rr](.*?[^\r\n]*)[Bb][Yy]", Pattern.DOTALL); - Pattern re2 = Pattern.compile("[Oo][Rr][Dd][Ee][Rr](.*?[^\r\n]*)[Bb][Yy]((.*?[^\r\n]*)|[\\s]|[^0-9a-zA-Z])\\)", Pattern.DOTALL); - Matcher matcher = re1.matcher(reportSQL); - Matcher matcher2 = null; - int startPoint = reportSQL.length()-30; - String startReportSQL = ""; - String endReportSQL = ""; - while(reportSQL.indexOf("xid", startPoint)!=-1)startPoint++; - if (matcher.find(startPoint)) { - startReportSQL = reportSQL.substring(0, reportSQL.indexOf(matcher.group())); - endReportSQL = reportSQL.substring(reportSQL.indexOf(matcher.group())); - matcher2 = re2.matcher(endReportSQL); - if(matcher2.find()) - endReportSQL = endReportSQL.substring(matcher.group().length()-1); - else - endReportSQL = ""; - reportSQL = startReportSQL + endReportSQL; - }*/ String countSQL = "SELECT count(*) FROM (" + reportSQL + ")"+ (Globals.isPostgreSQL() || Globals.isMySQL()?" AS ":"") +" x "; String dbType = ""; if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) { try { - org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo(); dbType = remDbInfo.getDBType(dbInfo); if (dbType.equals("DAYTONA") && reportSQL.trim().toUpperCase().startsWith("SELECT")) { Pattern re1 = Pattern.compile("order(.*?[^\r\n]*)by", Pattern.DOTALL); @@ -1185,9 +1109,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } DataSet ds2 = null; - // try { if(reportSQL.trim().toUpperCase().startsWith("SELECT")) { + long start1 = System.currentTimeMillis(); ds2 = ConnectionUtils.getDataSet(countSQL, dbInfo); + long end1 = System.currentTimeMillis(); + float sec1 = (end1 - start1) / 1000F; System.out.println("Get count data : "+sec1 + " seconds"); if (ds2.getRowCount() > 0) setReportDataSize(ds2.getInt(0, 0)); else @@ -1195,26 +1121,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa "[ReportRuntime.loadLinearReportData] Unable to load report data size"); } else setReportDataSize(50); - // if ( (remDbInfo!=null) && - // (!remDbInfo.equals(AppConstants.DB_LOCAL))){ - // Globals.getRDbUtils().setDBPrefix(remDbInfo); - // ds2 = RemDbUtils.executeQuery(countSQL); - // } - // else - // ds2 = DbUtils.executeQuery(countSQL); - /* - * } catch(SQLException e) { throw new - * ReportSQLException("[ReportRuntime.loadLinearReportData size] - * "+e.getMessage(), countSQL); } - */ - - - } // else + + + } } ReportData rd = new ReportData(pageNo, true); - - // Already defined changed for modifying request parameters - //List reportCols = getAllColumns(); Vector visibleCols = new Vector(reportCols.size()); Vector formatProcessors = new Vector(reportCols.size()); @@ -1222,8 +1133,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa // rd.reportColumnHeaderRows.addColumnHeaderRow(chr); // chr.setRowHeight("30"); int count =0 ; - - /* ADDED */ ReportFormFields rff = getReportFormFields(); ReportFormFields childReportFormFields = null; String fieldDisplayName = ""; @@ -1236,7 +1145,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa for(int i = 0 ; i < rff.size(); i++) { fieldDisplayName = "["+((FormField)rff.getFormField(i)).getFieldDisplayName()+"]"; fieldValue = ""; - //if(dct.getOriginalDisplayName()==null) dct.setOriginalDisplayName(dct.getDisplayName()); if (dct.getDependsOnFormField().equals(fieldDisplayName)) { fieldValue = nvl(request.getParameter(((FormField)rff.getFormField(i)).getFieldName())); @@ -1253,8 +1161,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } } } - - /* ADDED */ String displayName = ""; for (Iterator iter = reportCols.iterator(); iter.hasNext();) { @@ -1266,11 +1172,14 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa AppConstants.RD_SQL_BASED))); if (nvl(dc.getDrillDownURL()).length() > 0) { + if(!dc.getDrillDownURL().contains("c_master")) { childReportFormFields = getChildReportFormFields(request,AppUtils.getDrillActionURL()+""+dc.getDrillDownURL()); + }else { + childReportFormFields = getChildReportFormFields(request,dc.getDrillDownURL()); + } } if (dc.isVisible()) { visibleCols.add(count,dc); - //if(dc.getColId().startsWith("group")) { for (int d = 0; d < reportCols.size(); d++) { if(reportCols.get(d)!=null) { DataColumnType dct1 = (DataColumnType) reportCols.get(d); @@ -1295,43 +1204,19 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa visualManager.isColumnVisible(dc.getColId()), visualManager .getSortByColId().equals(dc.getColId()) ? visualManager .getSortByAscDesc() : null, isRuntimeColSortDisabled(), dc.getLevel()!=null?dc.getLevel():0, dc.getStart()!=null?dc.getStart():0, dc.getColspan()!=null?dc.getColspan():0, dc.isIsSortable()!=null?dc.isIsSortable():false); - // chr.addColumnHeader(new ColumnHeader(dc.getDisplayName(), - // (dc.getDisplayWidth()>100)?"10%":(""+dc.getDisplayWidth()+"%"))); - } // if + } else { visibleCols.add(count,null); rd.createColumn(dc.getColId(), AppConstants.HIDDEN, dc.getDisplayWidthInPxls(), dc.getDisplayHeaderAlignment(), true, null,false, dc.getLevel()!=null?dc.getLevel():0, dc.getStart()!=null?dc.getStart():0, dc.getColspan()!=null?dc.getColspan():0, dc.isIsSortable()!=null?dc.isIsSortable():false); -// formatProcessors.add(count,null); } count++; - } // for + } if(getReportDefType().equals(AppConstants.RD_SQL_BASED_DATAMIN) && pageNo ==0) { - /*Vector v = null; - try { - v = addForecastData(reportSQL); - } catch (Exception ex) { - ex.printStackTrace(); - throw new RaptorException (ex); - } - session.setAttribute("FORECASTED_DATA", v); - DataSet dsWhole = ConnectionUtils.getDataSet(wholeSQL, dbInfo); - dsWhole.addAll(v); - session.setAttribute(AppConstants.RI_CHART_FORECAST_DATA, dsWhole); - } - if(getReportDefType().equals(AppConstants.RD_SQL_BASED_DATAMIN) && session.getAttribute("FORECASTED_DATA")!=null) { - Vector vForecastedData = (Vector)session.getAttribute("FORECASTED_DATA"); - if(vForecastedData.size() > 0) - ds.addAll(vForecastedData);*/ } - - // Utils._assert(chr.size()==ds.getColumnCount(), - // "[ReportRuntime.loadLinearReportData] The number of visible columns - // does not match the number of data columns"); - //TODO: This should be optimized to accept -1 for flat file download for (int r = 0; r < Math.min(ds.getRowCount(), ((pageNo < 0) ? (downloadLimit == -1?Globals.getFlatFileUpperLimit():Globals.getDownloadLimit() ) : getPageSize())); r++) { DataRow dr = new DataRow(); rd.reportDataRows.addDataRow(dr); @@ -1341,6 +1226,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa DataColumnType dct = (DataColumnType) reportCols.get(c); DataValue dv = new DataValue(); dr.addDataValue(dv); + String reverseDispalyValue = reverseDisplayValue(ds.getString(r, ds.getColumnIndex(dct.getColId()))); + reverseDispalyValue = StringUtils.substringBefore(reverseDispalyValue, ","); + if(download) + dv.setDisplayValue(reverseDispalyValue); + else dv.setDisplayValue(ds.getString(r, ds.getColumnIndex(dct.getColId()))); dv.setColName(dct.getColName()); dv.setColId(dct.getColId()); @@ -1368,7 +1258,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } if (dv.getDisplayValue().length() == 0) { - //dv.setDisplayValue("[NULL]"); dv.setDisplayValue(""); } } // if @@ -1377,20 +1266,14 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dv.setVisible(false); dv.setHidden(true); } - //System.out.println("in Linear report b4" + dr.getFormatId() + dr.getBgColorHtml() + dv.getDisplayValue()); - if(dr.getFormatId()!=null) ((FormatProcessor) formatProcessors.get(c)).setHtmlFormatters(dv, dr, true); else ((FormatProcessor) formatProcessors.get(c)).setHtmlFormatters(dv, dr, false); + } + } + } - //System.out.println("in Linear report After" + dr.getFormatId() + dr.getBgColorHtml() + dv.getDisplayValue()); - } // if reportCols - } // for - } // for - - //Only if rownumber options is needed - //rd.addRowNumbers(pageNo, getPageSize()); if (colDataTotalsLinear == null) { if(!download && !action.endsWith("session")) @@ -1406,12 +1289,13 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa totalLabel += "<br><font size=1>(for all pages)</font>"; rd.setColumnDataTotalsLinear(colDataTotalsLinear, totalLabel); - } // if - // Please note the below function doesn't set the visibility for dv since this is set in this function. - Sundar + } rd.applyVisibility(); - + long endTime = System.currentTimeMillis(); + float totalTime = (endTime - startTime)/1000F; + logger.info("Linearreportdata took: " + totalTime +"Seconds"); return rd; - } // loadLinearReportData + } @@ -1427,16 +1311,13 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (nvl(dct.getDisplayTotal()).length() > 0) { displayColTotals = true; break; - } // if - } // if checking dct - } // for + } + } + } DataSet ds = null; if (displayColTotals) { dr = new DataRow(); - // ds = - // DbUtils.executeQuery(generateTotalSQLLinear(reportParamValues, - // userId)); ds = ConnectionUtils.getDataSet(reportSQL, dbInfo); @@ -1473,12 +1354,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dv.setVisible(dct.isVisible()); if(dv.isVisible()) dr.addDataValue(dv); - } // dct check - } // for + } + } } return dr; - } // generateColumnDataTotalsLinear + } public ReportData loadHiveLinearReportData(String reportSQL, String userId, int downloadLimit, HttpServletRequest request) throws RaptorException { @@ -1492,7 +1373,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa HttpSession session = request.getSession(); DataSet ds = null; - // try { String dbInfo = getDBInfo(); List reportCols = getAllColumns(); @@ -1508,18 +1388,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa ds = ConnectionUtils.getDataSet(wholeSQL, dbInfo); ReportData rd = new ReportData(0, true); - - // Already defined changed for modifying request parameters - //List reportCols = getAllColumns(); Vector visibleCols = new Vector(reportCols.size()); Vector formatProcessors = new Vector(reportCols.size()); - - // ColumnHeaderRow chr = new ColumnHeaderRow(); - // rd.reportColumnHeaderRows.addColumnHeaderRow(chr); - // chr.setRowHeight("30"); int count =0 ; + - /* ADDED */ ReportFormFields rff = getReportFormFields(); ReportFormFields childReportFormFields = null; String fieldDisplayName = ""; @@ -1532,7 +1405,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa for(int i = 0 ; i < rff.size(); i++) { fieldDisplayName = "["+((FormField)rff.getFormField(i)).getFieldDisplayName()+"]"; fieldValue = ""; - //if(dct.getOriginalDisplayName()==null) dct.setOriginalDisplayName(dct.getDisplayName()); if (dct.getDependsOnFormField().equals(fieldDisplayName)) { fieldValue = nvl(request.getParameter(((FormField)rff.getFormField(i)).getFieldName())); @@ -1550,7 +1422,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } } - /* ADDED */ String displayName = ""; for (Iterator iter = reportCols.iterator(); iter.hasNext();) { @@ -1566,7 +1437,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } if (dc.isVisible()) { visibleCols.add(count,dc); - //if(dc.getColId().startsWith("group")) { for (int d = 0; d < reportCols.size(); d++) { if(reportCols.get(d)!=null) { DataColumnType dct1 = (DataColumnType) reportCols.get(d); @@ -1591,17 +1461,15 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa visualManager.isColumnVisible(dc.getColId()), visualManager .getSortByColId().equals(dc.getColId()) ? visualManager .getSortByAscDesc() : null, isRuntimeColSortDisabled(), dc.getLevel()!=null?dc.getLevel():0, dc.getStart()!=null?dc.getStart():0, dc.getColspan()!=null?dc.getColspan():0, dc.isIsSortable()!=null?dc.isIsSortable():false); - // chr.addColumnHeader(new ColumnHeader(dc.getDisplayName(), - // (dc.getDisplayWidth()>100)?"10%":(""+dc.getDisplayWidth()+"%"))); - } // if + + } else { visibleCols.add(count,null); rd.createColumn(dc.getColId(), "", dc.getDisplayWidthInPxls(), dc.getDisplayHeaderAlignment(), true, null,false, dc.getLevel()!=null?dc.getLevel():0, dc.getStart()!=null?dc.getStart():0, dc.getColspan()!=null?dc.getColspan():0, dc.isIsSortable()!=null?dc.isIsSortable():false); -// formatProcessors.add(count,null); } count++; - } // for + } ArrayList reportDataList = new ArrayList(); for (int r = 0; r < ds.getRowCount(); r++) { @@ -1640,30 +1508,24 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } if (dv.getDisplayValue().length() == 0) { - //dv.setDisplayValue("[NULL]"); dv.setDisplayValue(""); } - } // if + } } else { dv.setVisible(false); dv.setHidden(true); } - //System.out.println("in Linear report b4" + dr.getFormatId() + dr.getBgColorHtml() + dv.getDisplayValue()); if(dr.getFormatId()!=null) ((FormatProcessor) formatProcessors.get(c)).setHtmlFormatters(dv, dr, true); else ((FormatProcessor) formatProcessors.get(c)).setHtmlFormatters(dv, dr, false); - - //System.out.println("in Linear report After" + dr.getFormatId() + dr.getBgColorHtml() + dv.getDisplayValue()); - } // if reportCols - } // for + } + } reportDataList.add(dr); - } // for + } rd.setReportDataList(reportDataList); - //Only if rownumber options is needed - //rd.addRowNumbers(pageNo, getPageSize()); if (colDataTotalsLinear == null) colDataTotalsLinear = generateColumnDataTotalsLinear(new ArrayList(reportCols), userId, @@ -1674,21 +1536,19 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa totalLabel += "<br><font size=1>(for all pages)</font>"; rd.setColumnDataTotalsLinear(colDataTotalsLinear, totalLabel); - } // if - // Please note the below function doesn't set the visibility for dv since this is set in this function. - Sundar + } + rd.applyVisibility(); return rd; - } // loadHiveLinearReportData + } + - //For Hive reports public int getHiveReportCount(String sql) throws RaptorException { - //select t from (select count(*) t from (select * from program)x)x1; int count = 0; String countSql = "select t from (select count(*) t from ("+ sql + ")" + (Globals.isPostgreSQL() || Globals.isMySQL() ?" AS ":"") + " x) AS x1"; DataSet ds = null; - // try { String dbInfo = getDBInfo(); System.out.println("SQL getReportCount()- " + countSql); try { @@ -1697,7 +1557,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa String dbType = ""; if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) { try { - org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo(); dbType = remDbInfo.getDBType(dbInfo); } catch (Exception ex) { throw new RaptorException(ex); @@ -1709,10 +1568,10 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } catch (NumberFormatException ex) {} return count; - } // getReportCount + } - /*private*/ public ReportFormFields getChildReportFormFields( HttpServletRequest request, String URL ) throws RaptorException { + public ReportFormFields getChildReportFormFields( HttpServletRequest request, String URL ) throws RaptorException { String childReportID = getReportID(URL); ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, childReportID, @@ -1733,20 +1592,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa return reportID; } - /*private*/ public String parseDrillDownURL(int rowIdx, /* int colIdx, */DataSet ds, DataColumnType dct, HttpServletRequest request, ReportFormFields ddReportFormFields) +public String parseDrillDownURL(int rowIdx, /* int colIdx, */DataSet ds, DataColumnType dct, HttpServletRequest request, ReportFormFields ddReportFormFields) throws RaptorException { Vector viewActions = DataCache.getDataViewActions(); javax.servlet.http.HttpSession session = request.getSession(); StringBuffer dUrl = new StringBuffer(); - - //String childReportID = getReportID(dct.getDrillDownURL()); - - //ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, childReportID, - // false, 1); - - //ReportFormFields ddReportFormFields = ddRr.getReportFormFields(); - boolean isViewAction = false; int flag = 0; String requestParam =""; @@ -1755,18 +1606,14 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa AppUtils.getBaseActionURL() + ((String) viewActions.get(k)))) isViewAction = true; if (isViewAction) { - // Drill-down to record details - String param = nvl(dct.getDrillDownParams()); // i.e. - // "c_master=[bo1.RECID$]" + String param = nvl(dct.getDrillDownParams()); param = param.substring(AppUtils.getBaseActionParam().length() + 1, - param.length() - 1); // i.e. "bo1.RECID$" - param = param.replace('.', '_'); // i.e. "bo1.RECID$" + param.length() - 1); + param = param.replace('.', '_'); dUrl.append(AppUtils.getBaseActionParam()); dUrl.append(java.net.URLEncoder.encode(ds.getString(rowIdx, param.toLowerCase()))); } else { - // Drill-down to another report - // Replacing col ids with values String param = nvl(dct.getDrillDownParams()); while (param.indexOf('[') >= 0) { int startIdx = param.indexOf('['); @@ -1782,13 +1629,10 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa sb.append(param.substring(0, startIdx)); if (param.charAt(startIdx + 1) == '!') { - // Parameter is a form field value String fieldId = param.substring(startIdx + 2, endIdx); String fieldValue = (String) reportParamValues.get(fieldId); sb.append(java.net.URLEncoder.encode(nvl(fieldValue))); - //TODO Add a else if condition to check whether the param is from request Param - //TODO make a unique symbol like # }else if (param.charAt(startIdx + 1) == '#') { flag = 1; String fieldId = param.substring(startIdx + 2, endIdx); @@ -1796,14 +1640,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa sb.append(java.net.URLEncoder.encode(nvl(fieldValue))); }else { - // Parameter is a column value String fieldValue = ""; String colValue = null; String colId = null; if (param.indexOf('!') < 0 || param.indexOf('!') > endIdx) colId = param.substring(startIdx + 1, endIdx); else { - // Need to use NVL(column, form field) colId = param.substring(startIdx + 1, param.indexOf('!')); String fieldId = param.substring(param.indexOf('!') + 1, endIdx); @@ -1812,7 +1654,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa fieldValue = reportParamValues.getParamValueforTextAreaDrilldown(fieldId); } else fieldValue = (String) reportParamValues.get(fieldId); - } // else + } DataColumnType column = getColumnById(colId); String columnName = ""; @@ -1835,39 +1677,29 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if(nvl(dependsOn).length()>0) System.out.println("DependsOn " + dependsOn); if (column != null) { - // if (column.getColType().equals(AppConstants.CT_DATE)) - //if (!nvl(column.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT) - // .equals(AppConstants.DEFAULT_DATE_FORMAT)) - // Use extra column instead - //commented out below line usually for Visual - //colId += AppConstants.DD_COL_EXTENSION; colValue = ds.getString(rowIdx, colId.toLowerCase()); - // if SQL-Based and drill-down param is a date, decode - // it to the expected Oracle format **/ if (getReportDefType().equals(AppConstants.RD_SQL_BASED)) if (!getColumnNoParseDateFlag(column)) if (ReportParamDateValueParser.isDateParam(colValue)) colValue = ReportParamDateValueParser .formatDateParamValue(colValue); - } // if + } String suppressValues = "|" + nvl(dct.getDrillDownType()) + "|"; if (suppressValues.length() > 2 && suppressValues.indexOf("|" + colValue + "|") >= 0) - // Parameter value is suppressed and not passed to the - // drill-down report colValue = null; sb.append(java.net.URLEncoder.encode(nvl(colValue, fieldValue))); } else { sb.delete(sb.lastIndexOf("&")+1, sb.length()); } - } // else + } if (endIdx < param.length() - 1) sb.append(param.substring(endIdx + 1)); param = sb.toString(); - } // while + } if(Globals.getPassRequestParamInDrilldown()) { if(param.indexOf('#') < 0) { String[] reqParameters = Globals.getRequestParams().split(","); @@ -1920,28 +1752,16 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } dUrl.append(AppConstants.DRILLDOWN_INDEX); int index = Integer.parseInt(nvl(AppUtils.getRequestValue(request, AppConstants.DRILLDOWN_INDEX), "0")); - /* - int form_index = Integer.parseInt(nvl(AppUtils.getRequestValue(request, AppConstants.FORM_DRILLDOWN_INDEX), "0")); - index = index>0 ? --index : 0; - form_index = form_index>0 ? --form_index : 0;*/ request.setAttribute(AppConstants.DRILLDOWN_INDEX, Integer.toString(index)); - /*session.setAttribute(AppConstants.DRILLDOWN_INDEX, Integer.toString(index)); - request.setAttribute(AppConstants.FORM_DRILLDOWN_INDEX, Integer.toString(form_index)); - session.setAttribute(AppConstants.FORM_DRILLDOWN_INDEX, Integer.toString(form_index));*/ - dUrl.append("=" + AppUtils.getRequestNvlValue(request, AppConstants.DRILLDOWN_INDEX)); - - //TODO Add a if condition to check whether the param is request Param - } // if + } if (dUrl.length() > 0) dUrl.insert(0, ((dct.getDrillDownURL()).indexOf('&') > 0) ? '&' : '&'); dUrl.insert(0, AppUtils.getDrillActionURL()+dct.getDrillDownURL()); - //debugLogger.debug(" [[[[[[[[[[[[[[[[ " + dUrl); - return dUrl.toString(); - } // parseDrillDownURL + } /** *********************************************************************************** */ @@ -1957,16 +1777,13 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (nvl(dct.getDisplayTotal()).length() > 0) { displayColTotals = true; break; - } // if - } // if checking dct - } // for + } + } + } DataSet ds = null; if (displayColTotals) { dr = new DataRow(); - // ds = - // DbUtils.executeQuery(generateTotalSQLLinear(reportParamValues, - // userId)); ds = ConnectionUtils.getDataSet(generateTotalSQLLinear(reportParamValues, userId,request), dbInfo); @@ -1985,6 +1802,9 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa totalValue = nvl(AppConstants.TOTAL_FUNCTIONS.getNameById(dct .getDisplayTotal())) + ": " + totalValue; + if( nvl(dct.getDisplayTotal()).length() > 0 && dct.getDisplayTotal().equals(AppConstants.TOTAL_SUM_ID)){ + totalValue = "Total: "+ totalValue; + } dv.setDisplayValue(Utils.truncateTotalDecimals(totalValue)); dv.setAlignment(dct.getDisplayAlignment()); @@ -2002,12 +1822,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dv.setIndentation(indentation.toString()); dv.setDisplayTotal(dct.getDisplayTotal()); dv.setBold(true); - } // dct check - } // for + } + } } return dr; - } // generateColumnDataTotalsLinear + } private Vector generateDataTotalsCrossTab(String rowColPos, String userId, HttpServletRequest request) throws RaptorException { @@ -2022,9 +1842,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa displayRowTotals = displayTotals; if (displayTotals) { - // DataSet ds = - // DbUtils.executeQuery(generateTotalSQLCrossTab(reportParamValues, - // rowColPos, userId)); String executeSql = generateTotalSQLCrossTab( sql, rowColPos, userId, request, reportParamValues); DataSet ds = ConnectionUtils.getDataSet(executeSql, getDbInfo()); @@ -2044,34 +1861,31 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dataValue.setAlignment("center"); dataValue.setDisplayValue(ds.getString(i, cPos++)); headerValues.add(dataValue); - - //headerValues.add(ds.getString(i, cPos++)); } else if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_VALUE)) totalValue = ds.getString(i, cPos++); - } // for + } dataTotals.add(new CrossTabTotalValue(headerValues, Utils .truncateTotalDecimals(totalValue))); - } // for - } // if + } + } return dataTotals; - } // generateDataTotalsCrossTab - + } /** *********************************************************************************** */ public void hideColVisual(String colId) { visualManager.hideColumn(colId); if (pageDataCache != null) pageDataCache.columnVisualShowHide(colId, false); - } // hideColVisual + } public void showColVisual(String colId) { visualManager.showColumn(colId); if (pageDataCache != null) pageDataCache.columnVisualShowHide(colId, true); - } // showColVisual + } public void sortColVisual(String colId) { visualManager.setSortByColumn(colId); @@ -2079,13 +1893,13 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa pageDataCache = null; cachedPageNo = -1; - } // sortColVisual + } /** *********************************************************************************** */ public String generateDistinctValuesSQL(DataColumnType dct, String userId, HttpServletRequest request) throws RaptorException { return super.generateDistinctValuesSQL(reportParamValues, dct, userId, request); - } // generateDistinctValuesSQL + } public String getDbInfo() { return this.cr.getDbInfo(); @@ -2102,18 +1916,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa logger.debug(EELFLoggerDelegate.debugLogger, ("Flat File parseReportSQL ******* SQL " + sql)); sql = sql.replaceAll("([\\s]*\\() (?!FROM)", "("); sql = sql.replaceAll("[\\s]*\\)", ")"); - //sql = sql.replaceAll("[dD][eE][cC][oO][dD][eE] ", "decode"); - //sql = sql.replaceAll("[\\s]*\\(", "("); - //sql = replaceNewLine(sql, "decode ", "decode"); - //sql = replaceNewLine(sql, "DECODE ", "decode"); - //sql = replaceNewLine(sql, "Decode ", "decode"); String nextToken = getNextSQLParseToken(sql, true); String dbInfo = getDbInfo(); boolean isCYMBALScript = false; if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) { try { - org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo(); String dbType = remDbInfo.getDBType(dbInfo); if (dbType.equals("DAYTONA") && !(nextToken.toUpperCase().equals("SELECT"))) { isCYMBALScript = true; @@ -2124,9 +1932,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } if ( isCYMBALScript == false ) { while (nextToken.length() > 0) { - //System.out.println("LastToken " + lastToken + " NextToken " + nextToken); - - if (parsedSQL.length() == 0) { if (nextToken.toUpperCase().equals("SELECT")) parsedSQL.append("SELECT "); @@ -2155,9 +1960,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa parsedSQL.append(sql.substring(lastParsePos)); break; } else { - //System.out.println("Next Token " + nextToken); if (nextToken.charAt(nextToken.length() - 1) == ',') { - // The token ends with , nextToken = nextToken.substring(0, nextToken.length() - 1); if (nextToken.length() == 0) { @@ -2165,9 +1968,8 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa updatedReportCols.add(getParseSQLDataColumn(lastToken, null, parsedSQL, updatedReportCols, false)); lastToken = null; - } // else just comma => ignore it + } } else { - //System.out.println("Next Token " + nextToken + " is Here" + " Last Token " + lastToken); if (lastToken != null) { updatedReportCols.add(getParseSQLDataColumn(lastToken, nextToken, parsedSQL, updatedReportCols, false)); @@ -2177,28 +1979,25 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa parsedSQL, updatedReportCols, false)); } } else { - // The token doesn't end with , if (lastToken == null) lastToken = nextToken; else { String token = getNextSQLParseToken(sql, false); - //System.out.println(" ********** " + token + " " + lastToken); if (!token.toUpperCase().equals("FROM")) throw new org.onap.portalsdk.analytics.error.ValidationException( "|FROM keyword or a comma expected after [" + nextToken + "]."); - //System.out.println("Next Token " + nextToken); updatedReportCols.add(getParseSQLDataColumn(lastToken, nextToken, parsedSQL, updatedReportCols, false)); lastToken = null; - } // else - } // else - } // else + } + } + } lastParsePos = curSQLParsePos; nextToken = getNextSQLParseToken(sql, true); - } // while - } else { // if CYMBAL Script + } + } else { nextToken = getNextCYMBALSQLParseToken(sql, true); Pattern re = null; Matcher matcher = null; @@ -2207,7 +2006,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (lastToken == null) lastToken = nextToken; if( lastToken.toUpperCase().equals("DO DISPLAY")) { - re = Pattern.compile("each(.*)\\[.(.*?)\\]"); //\\[(.*?)\\] + re = Pattern.compile("each(.*)\\[.(.*?)\\]"); matcher = re.matcher(nextToken); if (matcher.find()) { extracted = matcher.group(); @@ -2238,7 +2037,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa return parsedSQL.toString(); - } // parseReportSQL + } private String getNextCYMBALSQLParseToken(String sql, boolean updateParsePos) { int braketCount = 0; @@ -2250,11 +2049,10 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (ch!='\n') nextToken.append(ch); else break; - } // for + } return nextToken.toString(); - } // getNextSQLParseToken - + } private String getNextSQLParseToken(String sql, boolean updateParsePos) { int braketCount = 0; boolean isInsideQuote = false; @@ -2283,12 +2081,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa braketCount--; else if (ch == '\''/* ||ch=='\"' */) isInsideQuote = (!isInsideQuote); - } // else - } // for + } + } return nextToken.toString(); - } // getNextSQLParseToken - + } private DataColumnType getParseSQLDataColumn(String sqlExpression, String colId, StringBuffer parsedSQL, Vector updatedReportCols, boolean isCYMBALScript) throws RaptorException { DataColumnType dct = null; @@ -2302,7 +2099,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dct = getColumnById(colId); } else { - // Getting unique column id + colId = ""; int colIdN = 0; for (int i = 0; (i < sqlExpression.length()) && (colIdN < 2); i++) @@ -2328,10 +2125,10 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa idAlreadyUsed = true; break; } - } // for + } colId += (colIdN - 1); - } // else + } if (dct == null) { dct = (new ObjectFactory()).createDataColumnType(); @@ -2339,7 +2136,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dct.setDisplayWidth(10); dct.setDisplayAlignment("Left"); dct.setVisible(true); - dct.setGroupBreak(false); // ??? + dct.setGroupBreak(false); boolean isValidIdentifier = Character.isLetterOrDigit(sqlExpression.charAt(0)); for (int i = 0; i < sqlExpression.length(); i++) @@ -2353,8 +2150,8 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dct.setDisplayName(sqlExpression); } else { dct.setDisplayName(colId); - } // else - } // if + } + } if(!isCYMBALScript) sqlExpression = sqlExpression.replaceAll(", '", ",'"); dct.setDbColName(sqlExpression); @@ -2362,7 +2159,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dct.setCalculated(true); dct.setColType(AppConstants.CT_CHAR); dct.setDbColType(AppConstants.CT_CHAR); - adjustColumnType(dct); // ??? + adjustColumnType(dct); if(!isCYMBALScript) { if (parsedSQL.toString().equals("SELECT ") @@ -2376,8 +2173,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } return dct; - } // getParseSQLDataColumn - + } private boolean isParseSQLColID(String token) { if (nvl(token).length() == 0) return false; @@ -2390,12 +2186,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (!(Character.isLetterOrDigit(ch) || ch == '_')) return false; - } // for + } return true; - } // isParseSQLColID + } - /*private*/ public String parseReportSQLForDrillDownParams(String reportSQL, DataColumnType dataColumnRequest, HttpServletRequest request){ + public String parseReportSQLForDrillDownParams(String reportSQL, DataColumnType dataColumnRequest, HttpServletRequest request){ String param = nvl(dataColumnRequest.getDrillDownParams()); String sql = reportSQL; int pos = 0; @@ -2409,7 +2205,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa else break; if (param.charAt(startIdx + 1) == '#') { - // Parameter is a form field value String fieldId = param.substring(startIdx + 2, endIdx); String fieldValue = ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), request.getParameter(fieldId)); sql = Utils.replaceInString(sql, "[" + fieldId.toUpperCase()+"]", fieldValue ); @@ -2479,7 +2274,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep try { return super.clone(); } catch (CloneNotSupportedException e) { - // this shouldn't happen, since we are Cloneable throw new InternalError("Cloning throws error."); } } @@ -2491,7 +2285,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep public String getReportSQLWithRowNum(String _orderBy, boolean asc) { String sql = getWholeSQL(); int closeBracketPos = 0; - // Added reportSQLOnlyFirstPart which has Column information with Rownum return nvl(getReportSQLOnlyFirstPart()) + " " + sql + ") x "; } @@ -2540,11 +2333,11 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep visibleColExist = true; break; } - } // for - } // if + } + } return visibleColExist; - } // canPersistLinearReport + } public void persistLinearReport(HttpServletRequest request) throws RaptorException { @@ -2557,8 +2350,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep String reportXML = marshal(); logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] Report " + reportID + " XML marshalled succesfully")); - - // Update report verifySQLBasedReportAccess(request); reportSecurity.reportUpdate(request); connection = DbUtils.startTransaction(); @@ -2575,7 +2366,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep } finally { DbUtils.clearConnection(connection); } - } // persistLinearReport + } public void persistDashboardReport(HttpServletRequest request) throws RaptorException { @@ -2586,8 +2377,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep String reportXML = marshal(); logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] Report " + reportID + " XML marshalled succesfully")); - - // Update report verifySQLBasedReportAccess(request); reportSecurity.reportUpdate(request); connection = DbUtils.startTransaction(); @@ -2604,7 +2393,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep } finally { DbUtils.clearConnection(connection); } - } // persistDashboardReport + } public String getTotalSql() { return totalSql; } @@ -2663,7 +2452,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep ObjectMapper mapper = new ObjectMapper(); ReportJSONRuntime reportJSONRuntime = new ReportJSONRuntime(); reportJSONRuntime.setReportTitle(getReportTitle()); - //reportJSONRuntime.setReportSubTitle(getReportSubTitle()); reportJSONRuntime.setReportID(getReportID()); reportJSONRuntime.setReportDescr(getReportDescr()); reportJSONRuntime.setReportName(getReportName()); @@ -2672,7 +2460,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep reportJSONRuntime.setAllowEdit(isAllowEdit(request)); reportJSONRuntime.setColIdxTobeFreezed(getFrozenColumnId()); reportJSONRuntime.setNumFormCols(getNumFormColsAsInt()); - //back button url reportJSONRuntime.setBackBtnURL(""); String chartType = getChartType(); boolean displayChart = (nvl(chartType).length()>0)&&getDisplayChart(); @@ -2699,7 +2486,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep ffJSON.setHelpText(ff.getHelpText()); ffJSON.setValidationType(ff.getValidationType()); ffJSON.setVisible(ff.isVisible()); - //ffJSON.setTriggerOtherFormFields(ff.getDependsOn()); IdNameList lookup = null; lookup = ff.getLookupList(); String selectedValue = ""; @@ -2723,7 +2509,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep lookupList = lookup; try { lookup.loadUserData(0, "", ff.getDbInfo(), ff.getUserId()); - } catch (Exception e ){ e.printStackTrace(); //throw new RaptorRuntimeException(e); + } catch (Exception e ){ e.printStackTrace(); } } lookup.trimToSize(); @@ -2735,7 +2521,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep IdNameValue value = lookup.getNext(); readOnly = value.isReadOnly(); if(requestValue != null && Arrays.asList(requestValue).contains(value.getId())) { - //if(value.getId().equals(requestValue)) value.setDefaultValue(true); } else if (AppUtils.nvl(ff.getDefaultValue()).length()>0) { if(ff.getDefaultValue().equals(value.getId())) { @@ -2749,7 +2534,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep || ff.getFieldType().equals(FormField.FFT_LIST_MULTI)) { formFieldValues.add(value); } - //break; + } } else { if(requestValue!=null && requestValue.length>0) { @@ -2783,7 +2568,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep } // for } reportJSONRuntime.setFormFieldList(formFieldJSONList); - //reportJSONRuntime.setReportDataColumns(get); int count = 0; Map<String,Object> dvJSON = null; if(rd!=null) { @@ -2791,6 +2575,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep reportJSONRuntime.setTotalRows(getReportDataSize()); ArrayList<ColumnHeader> colList = new ArrayList<>(); ArrayList<Map<String,Object>> reportDataRows = new ArrayList<>(); + ArrayList<Map<String,Object>> reportTotalDataRows = new ArrayList<Map<String,Object>>(); for(rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext(); ) { count++; ColumnHeaderRow chr = rd.reportColumnHeaderRows.getNext(); @@ -2815,10 +2600,26 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep reportDataRows.add(dvJSON); } } + if(rd.reportDataTotalRow != null) { + for(rd.reportDataTotalRow.resetNext(); rd.reportDataTotalRow.hasNext(); count++) { + dvJSON = new HashMap<String,Object>(); + DataRow dr = rd.reportDataTotalRow.getNext(); + for(dr.resetNext(); dr.hasNext(); ) { + DataValue dv = dr.getNext(); + try { + dvJSON.put(dv.getColId(), dv); + } catch (Exception ex) { + ex.printStackTrace(); + + } + } + reportTotalDataRows.add(dvJSON); + } + } reportJSONRuntime.setReportDataColumns(colList); reportJSONRuntime.setReportDataRows(reportDataRows); - //reportJSONRuntime.setSqlWhole(getWholeSQL()); reportJSONRuntime.setPageSize(getPageSize()); + reportJSONRuntime.setReportTotalDataRows(reportTotalDataRows); } @@ -2880,16 +2681,14 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep setTriggerThisFormFieldCheck(getReportFormFields(), ff); SQL = parseAndFillReq_Session_UserValues(request, SQL, userId); SQL = parseAndFillOtherFormfieldValues(request, SQL, userId, formFieldJSONList); - //SQL = parseAndFillWithCurrentValues(formGrid,SQL, ff); String defaultSQL = lu.getDefaultSQL(); defaultSQL = parseAndFillReq_Session_UserValues(request, defaultSQL, userId); - //defaultSQL = parseAndFillWithCurrentValues(formGrid,defaultSQL, ff); lookup = new IdNameSql(-1,SQL,defaultSQL); lookupList = lookup; try { lookup.loadUserData(0, "", ff.getDbInfo(), ff.getUserId()); - } catch (Exception e ){ e.printStackTrace(); //throw new RaptorRuntimeException(e); + }catch (Exception e) { } } lookup.trimToSize(); @@ -2898,10 +2697,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep ArrayList<String> requestValueList = new ArrayList<>(); requestValueList.add(requestValue); - /*if(ff.isTriggerThisFormfield()) { - refreshFormFieldsWithLatestValue(request, userId, ff, formFieldJSONList); - }*/ - for (lookup.resetNext(); lookup.hasNext();) { IdNameValue value = lookup.getNext(); @@ -2911,7 +2706,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep value.setDefaultValue(true); } formFieldValues.add(value); - //break; + } } else { @@ -2931,21 +2726,17 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep ((IdNameSql)lookup).setSQL(oldSQL); } } - - - //if(!ff.isTriggerThisFormfield()) { ffJSON.setFormFieldValues(formFieldValues); - //} + break; - } //if - } //for - }//for - }//if + } + } + } + } reportJSONRuntime.setFormFieldList(formFieldJSONList); - //reportJSONRuntime.setReportDataColumns(get); return reportJSONRuntime; @@ -2993,16 +2784,12 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep boolean multiple = false; if(type.equals("LIST_MULTI_SELECT")) multiple = true; - //multiple = (selectedItems.size()>1); for(Iterator iter = selectedItems.iterator(); iter.hasNext(); ) { count++; String entry = (String) iter.next(); if(count == 1 && multiple) value.append("("); - //if(type.equals(FormField.FFT_CHECK_BOX)) - /*if(type.equals(FormField.FFT_CHECK_BOX)) - value.append("'"+Utils.oracleSafe(entry)+"'"); - else*/ if (type.equals(FormField.FFT_LIST_MULTI)) + else if (type.equals(FormField.FFT_LIST_MULTI)) value.append("'"+Utils.oracleSafe(entry)+"'"); else if(type.equals(FormField.FFT_LIST_BOX)) value.append(Utils.oracleSafe(entry)); @@ -3029,14 +2816,10 @@ public String parseAndFillWithCurrentValues(HttpServletRequest request, String s String fieldDisplay = getFormFieldDisplayName(fft); String formfield_value = ""; List<String> selectedItems = new ArrayList<>(); - //Added so that Combo Box in old RAPTOR definition is translated to List box if(fft.getFieldType().equals(FormField.FFT_COMBO_BOX)) { fft.setFieldType(FormField.FFT_LIST_BOX); } if(!fft.getFieldType().equals(FormField.FFT_BLANK)) { - //if(source_Formfield==null || (source_Formfield!=null && !fft.getFieldId().equals(source_Formfield.getFieldName()))) { - // Add oracle safe - // Add param base sql if(fft.getFieldType().equals(FormField.FFT_LIST_MULTI) || fft.getFieldType().equals(FormField.FFT_CHECK_BOX)) { if(request.getParameterValues(fieldId)!=null && request.getParameterValues(fieldId).length > 0) { @@ -3067,73 +2850,10 @@ public String parseAndFillWithCurrentValues(HttpServletRequest request, String s } } else if (fft.getValidationType().equals(FormField.VT_DATE) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)|| fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) { - /*if(formGrid.hasFellow(fieldId, true)) { - Datebox tb = (Datebox) formGrid.getFellowIfAny(fieldId, true); - try { - formfield_value = tb.getText(); - } catch (WrongValueException ex) { - formfield_value = ""; - } - if(AppUtils.nvl(formfield_value).length() > 0) { - if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)) { - if(formGrid.hasFellow(fieldId+"_Hr", true)) { - Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true); - formfield_value = formfield_value + " " + hiddenLbHr.getValue(); - } - } else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)) { - if(formGrid.hasFellow(fieldId+"_Min", true)) { - Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true); - //formfield_value = formfield_value + " " + hiddenLbHr.getValue(); - Label hiddenLbMin = (Label) formGrid.getFellowIfAny(fieldId+"_Min", true); - formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue(); - - } - } else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) { - if(formGrid.hasFellow(fieldId+"_Sec", true)) { - Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true); - //formfield_value = formfield_value + " " + hiddenLbHr.getValue(); - Label hiddenLbMin = (Label) formGrid.getFellowIfAny(fieldId+"_Min", true); - //formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue(); - Label hiddenLbSec = (Label) formGrid.getFellowIfAny(fieldId+"_Sec", true); - formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue()+ ":" +hiddenLbSec.getValue(); - - } - } - } - } else { - formfield_value = ""; - }*/ } else if ((fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)|| fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC))) { - /*if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)|| - fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) { - if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)) { - if(formGrid.hasFellow(fieldId+"_Hr", true)) { - Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true); - formfield_value = formfield_value + " " + hiddenLbHr.getValue(); - } - } else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)) { - if(formGrid.hasFellow(fieldId+"_Min", true)) { - Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true); - //formfield_value = formfield_value + " " + hiddenLbHr.getValue(); - Label hiddenLbMin = (Label) formGrid.getFellowIfAny(fieldId+"_Min", true); - formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue(); - - } - } else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) { - if(formGrid.hasFellow(fieldId+"_Sec", true)) { - Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true); - //formfield_value = formfield_value + " " + hiddenLbHr.getValue(); - Label hiddenLbMin = (Label) formGrid.getFellowIfAny(fieldId+"_Min", true); - //formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue(); - Label hiddenLbSec = (Label) formGrid.getFellowIfAny(fieldId+"_Sec", true); - formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue()+ ":" +hiddenLbSec.getValue(); - } - } - - } */ } else if (fft.getFieldType().equals(FormField.FFT_TEXT_W_POPUP)) { if(request.getParameter(fieldId)!=null) { formfield_value = request.getParameter(fieldId); @@ -3146,16 +2866,15 @@ public String parseAndFillWithCurrentValues(HttpServletRequest request, String s } else { formfield_value = ""; } - //} + } if(nvl(formfield_value).length()>0) { sql = Utils.replaceInString(sql, fieldDisplay, formfield_value); } else { sql = Utils.replaceInString(sql, "'"+fieldDisplay+"'", "null"); sql = Utils.replaceInString(sql, fieldDisplay, "null"); - //sql = Utils.replaceInString(sql, fieldDisplay, "''"); } - } // for + } } } return sql; @@ -3177,7 +2896,6 @@ public String parseAndFillWithCurrentValues(HttpServletRequest request, String s } for (int i = 0; i < scheduleSessionParameters.length; i++) { - //debugLogger.debug(" Session " + " scheduleSessionParameters[i] " + scheduleSessionParameters[i].toUpperCase() + " " + request.getParameter(scheduleSessionParameters[i])); if(request.getParameter(scheduleSessionParameters[i])!=null && request.getParameter(scheduleSessionParameters[i]).trim().length()>0 ) sql = Utils.replaceInString(sql, "[" + scheduleSessionParameters[i].toUpperCase()+"]", request.getParameter(scheduleSessionParameters[i]) ); if(request.getAttribute(scheduleSessionParameters[i])!=null && ((String)request.getAttribute(scheduleSessionParameters[i])).trim().length()>0 ) @@ -3186,14 +2904,10 @@ public String parseAndFillWithCurrentValues(HttpServletRequest request, String s } for (int i = 0; i < sessionParameters.length; i++) { - //if(!sessionParameters[i].startsWith("ff")) - //fieldSQL = Utils.replaceInString(fieldSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i].toUpperCase()) ); - //else { if (session.getAttribute(sessionParameters[i])!=null && ((String)session.getAttribute(sessionParameters[i])).length() > 0) { - //debugLogger.debug(" Session " + " sessionParameters[i] " + sessionParameters[i] + " " + (String)session.getAttribute(sessionParameters[i])); sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) ); } - // } + } sql = Utils.replaceInString(sql, "[USERID]", user_id); sql = Utils.replaceInString(sql, "[USER_ID]", user_id); @@ -3203,4 +2917,24 @@ public String parseAndFillWithCurrentValues(HttpServletRequest request, String s return sql; } -} // ReportRuntime + private static String reverseDisplayValue(String value) { + int i = value.length() - 1; + int start, end = i + 1; + String result = ""; + while (i >= 0) { + if (value.charAt(i) == ',') { + start = i + 1; + while (start != end) + result += value.charAt(start++); + result += ','; + end = i; + } + i--; + } + start = 0; + while (start != end) + result += value.charAt(start++); + return result; + } + +} |