From 4aeca1c8e399fd8e3dc7ae39e85939fe11506849 Mon Sep 17 00:00:00 2001 From: Sudarshan Kumar Date: Tue, 8 Sep 2020 14:34:24 +0530 Subject: Fixed chart Issue- Throwing error on the screen Fixed chart Issue- Throwing error on the screen while running older report Issue-ID: PORTAL-1000 Change-Id: I569cd01cea830d16b32c34b516e399d9207b21cc Signed-off-by: Sudarshan Kumar --- .../analytics/model/runtime/ChartD3Helper.java | 34 ++++++++++++++++++---- .../analytics/model/runtime/ChartJSONHelper.java | 12 +++++++- 2 files changed, 39 insertions(+), 7 deletions(-) (limited to 'ecomp-sdk/epsdk-analytics') 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 a63ce959..6367c3e6 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 @@ -155,12 +155,12 @@ public class ChartD3Helper { try { precision = Integer.parseInt(chartOptionsMap.get("precision")); } catch (NumberFormatException ex) { - logger.debug(EELFLoggerDelegate.debugLogger, ex.getMessage()); + logger.debug(EELFLoggerDelegate.debugLogger, ex.getMessage()); } - final Long user_id = new Long((long) UserUtils.getUserId(request)); + final Long user_id = new Long((long) UserUtils.getUserId(request)); - String chartType = reportRuntime.getChartType(); + String chartType = reportRuntime.getChartType(); List l = reportRuntime.getAllColumns(); String chartLeftAxisLabel = reportRuntime.getFormFieldFilled(nvl(reportRuntime.getChartLeftAxisLabel())); @@ -175,12 +175,21 @@ public class ChartD3Helper { String legendColumnName = (reportRuntime.getChartLegendColumn()!=null)?reportRuntime.getChartLegendColumn().getDisplayName():"Legend Column"; boolean displayChart = (nvl(chartType).length()>0)&&reportRuntime.getDisplayChart(); - StringBuilder wholeScript = new StringBuilder(""); + StringBuilder wholeScript = new StringBuilder(""); String title = reportRuntime.getReportTitle(); - title = parseTitle(title, formValues); + //Assigning reportName as title in case of title is blank or null + if(title == null || "".equalsIgnoreCase(title)) { + title = reportRuntime.getReportName(); + } + if(title != null) { + title = parseTitle(title, formValues); + }else { + logger.debug(EELFLoggerDelegate.debugLogger, "Report Title is NULL."); + } + String chartScriptsPath = (isEmbedded?AppUtils.getChartScriptsPath(""):AppUtils.getChartScriptsPath()); if(displayChart) { @@ -2822,7 +2831,20 @@ public class ChartD3Helper { } } try(BufferedWriter out = new BufferedWriter(new FileWriter("test.txt"))) { - out.write(wholeScript.toString()); + if(wholeScript !=null && wholeScript.length() > 0) { + out.write(wholeScript.toString()); + }else { + wholeScript = new StringBuilder(""); + wholeScript.append("\n"); + wholeScript.append("\n"); + wholeScript.append(" \n"); + wholeScript.append("\n"); + wholeScript.append("\n"); + wholeScript.append(" \n"); + wholeScript.append("

No Chart has been configured. Kindly go to Chart Wizard and configure your Chart.

"); + wholeScript.append(" \n"); + out.write(wholeScript.toString()); + } } catch (IOException e) { e.printStackTrace(); System.out.println("Exception "); 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 088409e1..934db0ab 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 @@ -359,7 +359,17 @@ public class ChartJSONHelper { String title = reportRuntime.getReportTitle(); - title = parseTitle(title, formValues); + //Assigning reportName as title in case of title is blank or null + if(title == null || "".equalsIgnoreCase(title)) { + title = reportRuntime.getReportName(); + } + + if(title != null) { + title = parseTitle(title, formValues); + }else { + logger.debug(EELFLoggerDelegate.debugLogger, "Report Title is NULL."); + } + ObjectMapper mapper = new ObjectMapper(); ChartJSON chartJSON = new ChartJSON(); String sql = ""; -- cgit 1.2.3-korg