summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunder Tattavarada <statta@research.att.com>2020-09-08 14:27:03 +0000
committerGerrit Code Review <gerrit@onap.org>2020-09-08 14:27:03 +0000
commitcd2441d21cad8776e0c9230d66cd2d04920c4a13 (patch)
tree86db45beaed32c581693852bbf1c25cb45fd2a9a
parentaa3b3145613813d69b62a3f6a8606a099a04bf7c (diff)
parent4aeca1c8e399fd8e3dc7ae39e85939fe11506849 (diff)
Merge "Fixed chart Issue- Throwing error on the screen"
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java34
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartJSONHelper.java12
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 = "";