summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-analytics/src
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntime.java792
1 files changed, 418 insertions, 374 deletions
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 361f405d..d10cd1c4 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
@@ -37,395 +37,439 @@
*/
package org.onap.portalsdk.analytics.model.runtime;
-
-
-
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
-
import org.onap.portalsdk.analytics.error.RaptorException;
import org.onap.portalsdk.analytics.model.ReportHandler;
import org.onap.portalsdk.analytics.system.AppUtils;
import org.onap.portalsdk.analytics.util.AppConstants;
import org.onap.portalsdk.analytics.view.ReportData;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.web.support.UserUtils;
public class ChartWebRuntime implements Serializable {
-
-
- // Not used - planned to use if Hibernate used as data access layer
- private String runningDataQuery = "";
- private String runningCountQuery = "";
- //CONSTANTS FOR QUERY
- public final String QRY_COUNT_REPORT = "";
- public final String QRY_DATA_REPORT = "";
-
- // Not used planning to use when filter is used
- private StringBuilder whereClause = new StringBuilder("");
- // request used to grab request parameters
- private HttpServletRequest request;
-
-
- public ReportRuntime reportRuntime;
- public ReportData reportData;
-
- //Used to pass user information
- private final Map<String, Object> params = new HashMap<>();
-
- //from chart generator retrieves list of charts to render
- public List chartList;
- public List infoList;
-
- private String totalSql;
-
-
- //
- private String drilldown_index = "0";
-
- public List getRolesCommaSeperated(HttpServletRequest request) {
- Map roles = UserUtils.getRoles(request);
- List roleList = null;
- if( roles != null ) {
- roleList = Arrays.asList(roles.keySet().toArray());
- }
-
- return roleList;
- }
-
-
- public String getUserId(HttpServletRequest request) {
- return AppUtils.getUserID(request);
- }
-
- public String generateChart(HttpServletRequest request) {
- return generateChart(request, true);
- }
-
-
- public String generateChart(HttpServletRequest request, boolean showData) {
- //wire variables
- //processRecursive(this, this);
- long currentTime = System.currentTimeMillis();
- HttpSession session = request.getSession();
- String action = nvl(request.getParameter(AppConstants.RI_ACTION), request.getParameter("action"));
- boolean genReportData = (!"chart.json".equals(action) || "chart.data.json".equals(action));
-
-
-
- final Long user_id = new Long((long) UserUtils.getUserId(request));
-
-
- boolean adminUser = false;
- try {
- adminUser = AppUtils.isAdminUser(request) || AppUtils.isSuperUser(request);
- } catch (RaptorException ex) {
- ex.printStackTrace();
- }
- 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();
- ReportRuntime rr = null;
- try {
- if(reportID !=null)
- rr = rh.loadReportRuntime(request, reportID, true, 1);
- 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, false /*download*/);
- }
- } catch (RaptorException ex) {
- ex.printStackTrace();
- }
- setReportRuntime(rr);
- setReportData( reportData);
-
- reportRuntime = getReportRuntime();
- reportData = getReportData();
-
-
- HashMap<String, String> chartOptionsMap = new HashMap<>();
-
- String rotateLabelsStr = "";
- rotateLabelsStr = AppUtils.nvl(reportRuntime.getLegendLabelAngle());
- if(rotateLabelsStr.toLowerCase().equals("standard")) {
- rotateLabelsStr = "0";
- } else if (rotateLabelsStr.toLowerCase().equals("up45")) {
- rotateLabelsStr = "45";
- } else if (rotateLabelsStr.toLowerCase().equals("down45")) {
- rotateLabelsStr = "-45";
- } else if (rotateLabelsStr.toLowerCase().equals("up90")) {
- rotateLabelsStr = "90";
- } else if (rotateLabelsStr.toLowerCase().equals("down90")) {
- rotateLabelsStr = "-90";
- } else
- rotateLabelsStr = "0";
-
- String width = (AppUtils.getRequestNvlValue(request, "width").length()>0?AppUtils.getRequestNvlValue(request, "width"):(AppUtils.nvl(reportRuntime.getChartWidth()).length()>0?reportRuntime.getChartWidth():"700"));
- String height = (AppUtils.getRequestNvlValue(request, "height").length()>0?AppUtils.getRequestNvlValue(request, "height"):(AppUtils.nvl(reportRuntime.getChartHeight()).length()>0?reportRuntime.getChartHeight():"300"));
- String animationStr = (AppUtils.getRequestNvlValue(request, "animation").length()>0?AppUtils.getRequestNvlValue(request, "animation"):new Boolean(reportRuntime.isAnimateAnimatedChart()).toString());
-
- String rotateLabels = (AppUtils.getRequestNvlValue(request, "rotateLabels").length()>0?AppUtils.getRequestNvlValue(request, "rotateLabels"):(rotateLabelsStr.length()>0?rotateLabelsStr:"0"));
- String staggerLabelsStr = (AppUtils.getRequestNvlValue(request, "staggerLabels").length()>0?AppUtils.getRequestNvlValue(request, "staggerLabels"):"false");
- String showMaxMinStr = (AppUtils.getRequestNvlValue(request, "showMaxMin").length()>0?AppUtils.getRequestNvlValue(request, "showMaxMin"):"false");
- String showControlsStr = (AppUtils.getRequestNvlValue(request, "showControls").length()>0?AppUtils.getRequestNvlValue(request, "showControls"):new Boolean(reportRuntime.displayBarControls()).toString());
- String showLegendStr = (AppUtils.getRequestNvlValue(request, "showLegend").length()>0?AppUtils.getRequestNvlValue(request, "showLegend"):new Boolean(!new Boolean(reportRuntime.hideChartLegend())).toString());
- String topMarginStr = AppUtils.getRequestNvlValue(request, "topMargin");
- String topMargin = (AppUtils.nvl(topMarginStr).length()<=0)?(reportRuntime.getTopMargin()!=null?reportRuntime.getTopMargin().toString():"30"):topMarginStr;
- String bottomMarginStr = AppUtils.getRequestNvlValue(request, "bottomMargin");
- String bottomMargin = (AppUtils.nvl(bottomMarginStr).length()<=0)?(reportRuntime.getBottomMargin()!=null?reportRuntime.getBottomMargin().toString():"50"):bottomMarginStr;
- String leftMarginStr = AppUtils.getRequestNvlValue(request, "leftMargin");
- String leftMargin = (AppUtils.nvl(leftMarginStr).length()<=0)?(reportRuntime.getLeftMargin()!=null?reportRuntime.getLeftMargin().toString():"100"):leftMarginStr;
- String rightMarginStr = AppUtils.getRequestNvlValue(request, "rightMargin");
- String rightMargin = (AppUtils.nvl(rightMarginStr).length()<=0)?(reportRuntime.getRightMargin()!=null?reportRuntime.getRightMargin().toString():"160"):rightMarginStr;
- String showTitleStr = (AppUtils.getRequestNvlValue(request, "showTitle").length()>0?AppUtils.getRequestNvlValue(request, "showTitle"):new Boolean(reportRuntime.displayChartTitle()).toString());
- String subType = AppUtils.getRequestNvlValue(request, "subType").length()>0?AppUtils.getRequestNvlValue(request, "subType"):(AppUtils.nvl(reportRuntime.getTimeSeriesRender()).equals("area")?reportRuntime.getTimeSeriesRender():"");
- String stackedStr = AppUtils.getRequestNvlValue(request, "stacked").length()>0?AppUtils.getRequestNvlValue(request, "stacked"):new Boolean(reportRuntime.isChartStacked()).toString();
- String horizontalBar = AppUtils.getRequestNvlValue(request, "horizontalBar").length()>0?AppUtils.getRequestNvlValue(request, "horizontalBar"):new Boolean(reportRuntime.isHorizontalOrientation()).toString();
- String barRealTimeAxis = AppUtils.getRequestNvlValue(request, "barRealTimeAxis");
- String barReduceXAxisLabels = AppUtils.getRequestNvlValue(request, "barReduceXAxisLabels").length()>0?AppUtils.getRequestNvlValue(request, "barReduceXAxisLabels"):new Boolean(reportRuntime.isLessXaxisTickers()).toString();;
- String timeAxis = AppUtils.getRequestNvlValue(request, "timeAxis").length()>0?AppUtils.getRequestNvlValue(request, "timeAxis"):new Boolean(reportRuntime.isTimeAxis()).toString();
- String logScale = AppUtils.getRequestNvlValue(request, "logScale").length()>0?AppUtils.getRequestNvlValue(request, "logScale"):new Boolean(reportRuntime.isLogScale()).toString();
- String precision = AppUtils.getRequestNvlValue(request, "precision").length()>0?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);
- chartOptionsMap.put("animation", animationStr);
- chartOptionsMap.put("rotateLabels", rotateLabels);
- chartOptionsMap.put("staggerLabels", staggerLabelsStr);
- chartOptionsMap.put("showMaxMin", showMaxMinStr);
- chartOptionsMap.put("showControls", showControlsStr);
- chartOptionsMap.put("showLegend", showLegendStr);
- chartOptionsMap.put("topMargin", topMargin);
- chartOptionsMap.put("bottomMargin", bottomMargin);
- chartOptionsMap.put("leftMargin", leftMargin);
- chartOptionsMap.put("rightMargin", rightMargin);
- chartOptionsMap.put("showTitle", showTitleStr);
- chartOptionsMap.put("subType", subType);
- chartOptionsMap.put("stacked", stackedStr);
- chartOptionsMap.put("horizontalBar", horizontalBar);
- chartOptionsMap.put("timeAxis", timeAxis);
- chartOptionsMap.put("barRealTimeAxis", barRealTimeAxis);
- chartOptionsMap.put("barReduceXAxisLabels", barReduceXAxisLabels);
-
- chartOptionsMap.put("logScale", logScale);
- chartOptionsMap.put("precision", precision);
-
-
-
- if(reportRuntime!=null) {
- StringBuilder title = new StringBuilder("");
- title.append(reportRuntime.getReportName());
- }
-
- if(! ("chart.json".equals(action) || "chart.data.json".equals(action))) {
-
-
- //Chart
- String chartType = reportRuntime.getChartType();
- return drawD3Charts(chartOptionsMap, request);
- //drawD3Charts();
- } else /*if (action.equals("chart.json"))*/ {
- String chartType = reportRuntime.getChartType();
- return returnChartJSON(chartOptionsMap, request, showData);
-
-
- } /*else {
-
- return ("Internal Error Occurred.");
- }*/
-
- }
-
-
- public String nvl(String s) {
- return (s == null) ? "" : s;
- }
-
- /**
- * @return the reportRuntime
- */
- public ReportRuntime getReportRuntime() {
- return reportRuntime;
- }
-
- /**
- * @param reportRuntime the reportRuntime to set
- */
- public void setReportRuntime(ReportRuntime reportRuntime) {
- this.reportRuntime = reportRuntime;
- }
-
- /**
- * @return the reportData
- */
- public ReportData getReportData() {
- return reportData;
- }
-
- /**
- * @param reportData the reportData to set
- */
- public void setReportData(ReportData reportData) {
- this.reportData = reportData;
- }
-
- public boolean isNull(String a) {
- if ((a == null) || (a.length() == 0) || a.equalsIgnoreCase("null"))
- return true;
- else
- return false;
- }
-
-
- protected String nvl(String s, String sDefault) {
- return nvl(s).equals("") ? sDefault : s;
- }
-
- protected static String nvls(String s) {
- return (s == null) ? "" : s;
- }
-
- protected static String nvls(String s, String sDefault) {
- return nvls(s).equals("") ? sDefault : s;
- }
-
- protected boolean getFlagInBoolean(String s) {
- return nvl(s).toUpperCase().startsWith("Y") || nvl(s).toLowerCase().equals("true");
- }
-
-
- /**
- * @return the chartList
- */
- public List getChartList() {
- return chartList;
- }
-
- /**
- * @param chartList the chartList to set
- */
- public void setChartList(List chartList) {
- this.chartList = chartList;
- }
-
- /**
- * @return the infoList
- */
- public List getInfoList() {
- return infoList;
- }
-
- /**
- * @param infoList the infoList to set
- */
- public void setInfoList(List infoList) {
- this.infoList = infoList;
- }
-
-
-
- private void clearReportRuntimeBackup(HttpSession session, HttpServletRequest request) {
- session.removeAttribute(AppConstants.DRILLDOWN_REPORTS_LIST);
- request.removeAttribute(AppConstants.DRILLDOWN_INDEX);
- session.removeAttribute(AppConstants.DRILLDOWN_INDEX);
- request.removeAttribute(AppConstants.FORM_DRILLDOWN_INDEX);
- session.removeAttribute(AppConstants.FORM_DRILLDOWN_INDEX);
- Enumeration<String> enum1 = session.getAttributeNames();
- String attributeName = "";
- while(enum1.hasMoreElements()) {
- attributeName = enum1.nextElement();
- if(attributeName.startsWith("parent_")) {
- session.removeAttribute(attributeName);
- }
- }
- session.removeAttribute(AppConstants.DRILLDOWN_REPORTS_LIST);
- session.removeAttribute(AppConstants.SI_BACKUP_FOR_REP_ID);
- session.removeAttribute(AppConstants.SI_COLUMN_LOOKUP);
- session.removeAttribute(AppConstants.SI_DASHBOARD_REP_ID);
- session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP);
- session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME);
- session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP);
- session.removeAttribute(AppConstants.SI_DASHBOARD_CHARTDATA_MAP);
- session.removeAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP);
- session.removeAttribute(AppConstants.SI_DATA_SIZE_FOR_TEXTFIELD_POPUP);
- session.removeAttribute(AppConstants.SI_MAP);
- session.removeAttribute(AppConstants.SI_MAP_OBJECT);
- session.removeAttribute(AppConstants.SI_REPORT_DEFINITION);
- session.removeAttribute(AppConstants.SI_REPORT_RUNTIME);
- session.removeAttribute(AppConstants.SI_REPORT_RUN_BACKUP);
- session.removeAttribute(AppConstants.SI_REPORT_SCHEDULE);
- session.removeAttribute(AppConstants.RI_REPORT_DATA);
- session.removeAttribute(AppConstants.RI_CHART_DATA);
- session.removeAttribute(AppConstants.SI_FORMFIELD_INFO);
- session.removeAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO);
- } // clearReportRuntimeBackup
-
-
- public String getTotalSql() {
- return totalSql;
- }
-
- public void setTotalSql(String totalSql) {
- this.totalSql = totalSql;
- }
-
-
-
- /* public void drawD3Charts(HashMap<String,String> chartOptionsMap) {
- drawD3Charts(chartOptionsMap);
-
- }
- */
-
- public String drawD3Charts(Map<String,String> chartOptionsMap, HttpServletRequest request) {
-
- ChartD3Helper chartHelper = new ChartD3Helper(reportRuntime);
- chartHelper.setChartType(reportRuntime.getChartType());
-
- return chartHelper.createVisualization(reportRuntime, chartOptionsMap, request);
- }
-
- public String returnChartJSON(HashMap<String,String> chartOptionsMap, HttpServletRequest request, boolean showData) {
-
- ChartJSONHelper chartJSONHelper = new ChartJSONHelper(reportRuntime);
- chartJSONHelper.setChartType(reportRuntime.getChartType());
- try {
- return chartJSONHelper.generateJSON(reportRuntime, chartOptionsMap, request, showData);
- } catch(RaptorException ex) {
- ex.printStackTrace();
- }
- return "";
-
- }
-
- }
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ChartWebRuntime.class);
+
+ // CONSTANTS FOR QUERY
+ public final String QRY_COUNT_REPORT = "";
+ public final String QRY_DATA_REPORT = "";
+
+ public ReportRuntime reportRuntime;
+ public ReportData reportData;
+
+ // Used to pass user information
+ private final transient Map<String, Object> params = new HashMap<>();
+
+ // from chart generator retrieves list of charts to render
+ public transient List chartList;
+ public transient List infoList;
+
+ private String totalSql;
+
+
+ public List getRolesCommaSeperated(HttpServletRequest request) {
+ Map roles = UserUtils.getRoles(request);
+ List roleList = null;
+ if (roles != null) {
+ roleList = Arrays.asList(roles.keySet().toArray());
+ }
+
+ return roleList;
+ }
+
+
+ public String getUserId(HttpServletRequest request) {
+ return AppUtils.getUserID(request);
+ }
+
+ public String generateChart(HttpServletRequest request) {
+ return generateChart(request, true);
+ }
+
+
+ public String generateChart(HttpServletRequest request, boolean showData) {
+ System.currentTimeMillis();
+ request.getSession();
+ String action =
+ nvl(request.getParameter(AppConstants.RI_ACTION), request.getParameter("action"));
+ boolean genReportData = (!"chart.json".equals(action) || "chart.data.json".equals(action));
+
+
+
+ final Long user_id = Long.valueOf(UserUtils.getUserId(request));
+
+
+ try {
+ if(AppUtils.isAdminUser(request) || AppUtils.isSuperUser(request)) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Request by Admin or Super User");
+ }
+ } catch (RaptorException ex) {
+ 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();
+ ReportRuntime rr = null;
+ try {
+ if (reportID != null)
+ rr = rh.loadReportRuntime(request, reportID, true, 1);
+ 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,
+ false /* download */);
+ }
+ } catch (RaptorException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "RaptorException occurred in generateChart",ex);
+ }
+ setReportRuntime(rr);
+ setReportData(reportData);
+
+ reportRuntime = getReportRuntime();
+ reportData = getReportData();
+
+
+ HashMap<String, String> chartOptionsMap = new HashMap<>();
+
+ String rotateLabelsStr = "";
+ rotateLabelsStr = AppUtils.nvl(reportRuntime.getLegendLabelAngle());
+ if (rotateLabelsStr.equalsIgnoreCase("standard")) {
+ rotateLabelsStr = "0";
+ } else if (rotateLabelsStr.equalsIgnoreCase("up45")) {
+ rotateLabelsStr = "45";
+ } else if (rotateLabelsStr.equalsIgnoreCase("down45")) {
+ rotateLabelsStr = "-45";
+ } else if (rotateLabelsStr.equalsIgnoreCase("up90")) {
+ rotateLabelsStr = "90";
+ } else if (rotateLabelsStr.equalsIgnoreCase("down90")) {
+ rotateLabelsStr = "-90";
+ } else
+ rotateLabelsStr = "0";
+
+ String width = (AppUtils.getRequestNvlValue(request, "width").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "width")
+ : (AppUtils.nvl(reportRuntime.getChartWidth()).length() > 0
+ ? reportRuntime.getChartWidth()
+ : "700"));
+ String height = (AppUtils.getRequestNvlValue(request, "height").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "height")
+ : (AppUtils.nvl(reportRuntime.getChartHeight()).length() > 0
+ ? reportRuntime.getChartHeight()
+ : "300"));
+ String animationStr = (AppUtils.getRequestNvlValue(request, "animation").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "animation")
+ : Boolean.toString(reportRuntime.isAnimateAnimatedChart()));
+
+ String rotateLabels = (AppUtils.getRequestNvlValue(request, "rotateLabels").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "rotateLabels")
+ : (rotateLabelsStr.length() > 0 ? rotateLabelsStr : "0"));
+ String staggerLabelsStr =
+ (AppUtils.getRequestNvlValue(request, "staggerLabels").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "staggerLabels")
+ : "false");
+ String showMaxMinStr = (AppUtils.getRequestNvlValue(request, "showMaxMin").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "showMaxMin")
+ : "false");
+ String showControlsStr = (AppUtils.getRequestNvlValue(request, "showControls").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "showControls")
+ : Boolean.toString(reportRuntime.displayBarControls()));
+ String showLegendStr = (AppUtils.getRequestNvlValue(request, "showLegend").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "showLegend")
+ : Boolean.toString(!Boolean.valueOf(reportRuntime.hideChartLegend())));
+ String topMarginStr = AppUtils.getRequestNvlValue(request, "topMargin");
+ String topMargin = (AppUtils.nvl(topMarginStr).length() <= 0)
+ ? (reportRuntime.getTopMargin() != null ? reportRuntime.getTopMargin().toString()
+ : "30")
+ : topMarginStr;
+ String bottomMarginStr = AppUtils.getRequestNvlValue(request, "bottomMargin");
+ String bottomMargin = (AppUtils.nvl(bottomMarginStr).length() <= 0)
+ ? (reportRuntime.getBottomMargin() != null
+ ? reportRuntime.getBottomMargin().toString()
+ : "50")
+ : bottomMarginStr;
+ String leftMarginStr = AppUtils.getRequestNvlValue(request, "leftMargin");
+ String leftMargin = (AppUtils.nvl(leftMarginStr).length() <= 0)
+ ? (reportRuntime.getLeftMargin() != null ? reportRuntime.getLeftMargin().toString()
+ : "100")
+ : leftMarginStr;
+ String rightMarginStr = AppUtils.getRequestNvlValue(request, "rightMargin");
+ String rightMargin = (AppUtils.nvl(rightMarginStr).length() <= 0)
+ ? (reportRuntime.getRightMargin() != null
+ ? reportRuntime.getRightMargin().toString()
+ : "160")
+ : rightMarginStr;
+ String showTitleStr = (AppUtils.getRequestNvlValue(request, "showTitle").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "showTitle")
+ : Boolean.toString(reportRuntime.displayChartTitle()));
+ String subType = AppUtils.getRequestNvlValue(request, "subType").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "subType")
+ : (AppUtils.nvl(reportRuntime.getTimeSeriesRender()).equals("area")
+ ? reportRuntime.getTimeSeriesRender()
+ : "");
+ String stackedStr = AppUtils.getRequestNvlValue(request, "stacked").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "stacked")
+ : Boolean.toString(reportRuntime.isChartStacked());
+ String horizontalBar = AppUtils.getRequestNvlValue(request, "horizontalBar").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "horizontalBar")
+ : Boolean.toString(reportRuntime.isHorizontalOrientation());
+ String barRealTimeAxis = AppUtils.getRequestNvlValue(request, "barRealTimeAxis");
+ String barReduceXAxisLabels =
+ AppUtils.getRequestNvlValue(request, "barReduceXAxisLabels").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "barReduceXAxisLabels")
+ : Boolean.toString(reportRuntime.isLessXaxisTickers());
+ String timeAxis = AppUtils.getRequestNvlValue(request, "timeAxis").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "timeAxis")
+ : Boolean.toString(reportRuntime.isTimeAxis());
+ String logScale = AppUtils.getRequestNvlValue(request, "logScale").length() > 0
+ ? AppUtils.getRequestNvlValue(request, "logScale")
+ : Boolean.toString(reportRuntime.isLogScale());
+ String precision = AppUtils.getRequestNvlValue(request, "precision").length() > 0
+ ? 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);
+ chartOptionsMap.put("animation", animationStr);
+ chartOptionsMap.put("rotateLabels", rotateLabels);
+ chartOptionsMap.put("staggerLabels", staggerLabelsStr);
+ chartOptionsMap.put("showMaxMin", showMaxMinStr);
+ chartOptionsMap.put("showControls", showControlsStr);
+ chartOptionsMap.put("showLegend", showLegendStr);
+ chartOptionsMap.put("topMargin", topMargin);
+ chartOptionsMap.put("bottomMargin", bottomMargin);
+ chartOptionsMap.put("leftMargin", leftMargin);
+ chartOptionsMap.put("rightMargin", rightMargin);
+ chartOptionsMap.put("showTitle", showTitleStr);
+ chartOptionsMap.put("subType", subType);
+ chartOptionsMap.put("stacked", stackedStr);
+ chartOptionsMap.put("horizontalBar", horizontalBar);
+ chartOptionsMap.put("timeAxis", timeAxis);
+ chartOptionsMap.put("barRealTimeAxis", barRealTimeAxis);
+ chartOptionsMap.put("barReduceXAxisLabels", barReduceXAxisLabels);
+
+ chartOptionsMap.put("logScale", logScale);
+ chartOptionsMap.put("precision", precision);
+
+
+
+ if (reportRuntime != null) {
+ StringBuilder title = new StringBuilder("");
+ title.append(reportRuntime.getReportName());
+ }
+
+ if (!("chart.json".equals(action) || "chart.data.json".equals(action))) {
+
+
+ reportRuntime.getChartType();
+ return drawD3Charts(chartOptionsMap, request);
+ // drawD3Charts();
+ } else /* if (action.equals("chart.json")) */ {
+ reportRuntime.getChartType();
+ return returnChartJSON(chartOptionsMap, request, showData);
+
+
+ } /*
+ * else {
+ *
+ * return ("Internal Error Occurred."); }
+ */
+
+ }
+
+
+ public String nvl(String s) {
+ return (s == null) ? "" : s;
+ }
+
+ /**
+ * @return the reportRuntime
+ */
+ public ReportRuntime getReportRuntime() {
+ return reportRuntime;
+ }
+
+ /**
+ * @param reportRuntime the reportRuntime to set
+ */
+ public void setReportRuntime(ReportRuntime reportRuntime) {
+ this.reportRuntime = reportRuntime;
+ }
+
+ /**
+ * @return the reportData
+ */
+ public ReportData getReportData() {
+ return reportData;
+ }
+
+ /**
+ * @param reportData the reportData to set
+ */
+ public void setReportData(ReportData reportData) {
+ this.reportData = reportData;
+ }
+
+ public boolean isNull(String a) {
+ if ((a == null) || (a.length() == 0) || a.equalsIgnoreCase("null"))
+ return true;
+ else
+ return false;
+ }
+
+
+ protected String nvl(String s, String sDefault) {
+ return nvl(s).equals("") ? sDefault : s;
+ }
+
+ protected static String nvls(String s) {
+ return (s == null) ? "" : s;
+ }
+
+ protected static String nvls(String s, String sDefault) {
+ return nvls(s).equals("") ? sDefault : s;
+ }
+
+ protected boolean getFlagInBoolean(String s) {
+ return nvl(s).toUpperCase().startsWith("Y") || nvl(s).equalsIgnoreCase("true");
+ }
+
+
+ /**
+ * @return the chartList
+ */
+ public List getChartList() {
+ return chartList;
+ }
+
+ /**
+ * @param chartList the chartList to set
+ */
+ public void setChartList(List chartList) {
+ this.chartList = chartList;
+ }
+
+ /**
+ * @return the infoList
+ */
+ public List getInfoList() {
+ return infoList;
+ }
+
+ /**
+ * @param infoList the infoList to set
+ */
+ public void setInfoList(List infoList) {
+ this.infoList = infoList;
+ }
+
+
+
+ private void clearReportRuntimeBackup(HttpSession session, HttpServletRequest request) {
+ session.removeAttribute(AppConstants.DRILLDOWN_REPORTS_LIST);
+ request.removeAttribute(AppConstants.DRILLDOWN_INDEX);
+ session.removeAttribute(AppConstants.DRILLDOWN_INDEX);
+ request.removeAttribute(AppConstants.FORM_DRILLDOWN_INDEX);
+ session.removeAttribute(AppConstants.FORM_DRILLDOWN_INDEX);
+ Enumeration<String> enum1 = session.getAttributeNames();
+ String attributeName = "";
+ while (enum1.hasMoreElements()) {
+ attributeName = enum1.nextElement();
+ if (attributeName.startsWith("parent_")) {
+ session.removeAttribute(attributeName);
+ }
+ }
+ session.removeAttribute(AppConstants.DRILLDOWN_REPORTS_LIST);
+ session.removeAttribute(AppConstants.SI_BACKUP_FOR_REP_ID);
+ session.removeAttribute(AppConstants.SI_COLUMN_LOOKUP);
+ session.removeAttribute(AppConstants.SI_DASHBOARD_REP_ID);
+ session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP);
+ session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME);
+ session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP);
+ session.removeAttribute(AppConstants.SI_DASHBOARD_CHARTDATA_MAP);
+ session.removeAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP);
+ session.removeAttribute(AppConstants.SI_DATA_SIZE_FOR_TEXTFIELD_POPUP);
+ session.removeAttribute(AppConstants.SI_MAP);
+ session.removeAttribute(AppConstants.SI_MAP_OBJECT);
+ session.removeAttribute(AppConstants.SI_REPORT_DEFINITION);
+ session.removeAttribute(AppConstants.SI_REPORT_RUNTIME);
+ session.removeAttribute(AppConstants.SI_REPORT_RUN_BACKUP);
+ session.removeAttribute(AppConstants.SI_REPORT_SCHEDULE);
+ session.removeAttribute(AppConstants.RI_REPORT_DATA);
+ session.removeAttribute(AppConstants.RI_CHART_DATA);
+ session.removeAttribute(AppConstants.SI_FORMFIELD_INFO);
+ session.removeAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO);
+ } // clearReportRuntimeBackup
+
+
+ public String getTotalSql() {
+ return totalSql;
+ }
+
+ public void setTotalSql(String totalSql) {
+ this.totalSql = totalSql;
+ }
+
+
+
+ /*
+ * public void drawD3Charts(HashMap<String,String> chartOptionsMap) {
+ * drawD3Charts(chartOptionsMap);
+ *
+ * }
+ */
+
+ public String drawD3Charts(Map<String, String> chartOptionsMap, HttpServletRequest request) {
+
+ ChartD3Helper chartHelper = new ChartD3Helper(reportRuntime);
+ chartHelper.setChartType(reportRuntime.getChartType());
+
+ return chartHelper.createVisualization(reportRuntime, chartOptionsMap, request);
+ }
+
+ public String returnChartJSON(Map<String, String> chartOptionsMap,
+ HttpServletRequest request, boolean showData) {
+
+ ChartJSONHelper chartJSONHelper = new ChartJSONHelper(reportRuntime);
+ chartJSONHelper.setChartType(reportRuntime.getChartType());
+ try {
+ return chartJSONHelper.generateJSON(reportRuntime, chartOptionsMap, request, showData);
+ } catch (RaptorException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "RaptorException occurred in returnChartJSON",ex);
+ }
+ return "";
+
+ }
+
+}