diff options
author | Sudarshan Kumar <sudarshan.kumar@att.com> | 2020-09-08 14:34:24 +0530 |
---|---|---|
committer | Sunder Tattavarada <statta@research.att.com> | 2020-09-08 17:45:42 +0000 |
commit | 651ebc23c26e6bf4fb6cd8297760442683197341 (patch) | |
tree | ca2d213d1edb35a375e2a094a5147db72ebe4531 | |
parent | e533abbfe475f496857646c41e52f9aeecdac92b (diff) |
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 <sudarshan.kumar@att.com>
(cherry picked from commit 4aeca1c8e399fd8e3dc7ae39e85939fe11506849)
2 files changed, 39 insertions, 7 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 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("<!DOCTYPE html>\n"); + wholeScript.append("<html>\n"); + wholeScript.append(" <head>\n"); + wholeScript.append("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n"); + wholeScript.append("</head>\n"); + wholeScript.append("<body> \n"); + wholeScript.append("<div style=\"margin-top:135px;\"><h2>No Chart has been configured. Kindly go to Chart Wizard and configure your Chart.</h2></div>"); + wholeScript.append("</body></html> \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 = ""; |