summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-analytics
diff options
context:
space:
mode:
authorSudarshan Kumar <sudarshan.kumar@att.com>2020-09-08 14:34:24 +0530
committerSudarshan Kumar <sudarshan.kumar@att.com>2020-09-08 14:35:45 +0530
commit4aeca1c8e399fd8e3dc7ae39e85939fe11506849 (patch)
treec9aaa1563f7fa04e9b8f9cfffdc40fdd8cdeba23 /ecomp-sdk/epsdk-analytics
parent5f2f49f765d16ac6f8db0665c3ab89f21002007a (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>
Diffstat (limited to 'ecomp-sdk/epsdk-analytics')
-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 = "";