summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime')
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/BarChartOptions.java75
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/CategoryAxisJSON.java24
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartD3Helper.java4064
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartGen.java73
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSON.java448
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSONHelper.java1550
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartWebRuntime.java420
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/CommonChartOptions.java81
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ErrorJSONRuntime.java43
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FlexTimeSeriesChartOptions.java38
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FormField.java2111
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FormatProcessor.java375
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/Item.java54
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/LookupDBInfo.java89
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/RangeAxisJSON.java93
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportFormFields.java366
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportJSONRuntime.java694
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamDateValueParser.java194
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamValues.java370
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcel.java419
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportRuntime.java3618
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/TimeSeriesChartOptions.java62
-rw-r--r--ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/VisualManager.java68
23 files changed, 0 insertions, 15329 deletions
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/BarChartOptions.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/BarChartOptions.java
deleted file mode 100644
index 7e99dc6e..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/BarChartOptions.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-public class BarChartOptions {
- private boolean verticalOrientation;
- private boolean stackedChart;
- private boolean displayBarControls;
- private boolean xAxisDateType;
- private boolean minimizeXAxisTickers;
- private boolean timeAxis;
- private boolean yAxisLogScale;
-
- public boolean isVerticalOrientation() {
- return verticalOrientation;
- }
- public void setVerticalOrientation(boolean verticalOrientation) {
- this.verticalOrientation = verticalOrientation;
- }
- public boolean isStackedChart() {
- return stackedChart;
- }
- public void setStackedChart(boolean stackedChart) {
- this.stackedChart = stackedChart;
- }
- public boolean isDisplayBarControls() {
- return displayBarControls;
- }
- public void setDisplayBarControls(boolean displayBarControls) {
- this.displayBarControls = displayBarControls;
- }
- public boolean isxAxisDateType() {
- return xAxisDateType;
- }
- public void setxAxisDateType(boolean xAxisDateType) {
- this.xAxisDateType = xAxisDateType;
- }
- public boolean isMinimizeXAxisTickers() {
- return minimizeXAxisTickers;
- }
- public void setMinimizeXAxisTickers(boolean minimizeXAxisTickers) {
- this.minimizeXAxisTickers = minimizeXAxisTickers;
- }
- public boolean isTimeAxis() {
- return timeAxis;
- }
- public void setTimeAxis(boolean timeAxis) {
- this.timeAxis = timeAxis;
- }
- public boolean isyAxisLogScale() {
- return yAxisLogScale;
- }
- public void setyAxisLogScale(boolean yAxisLogScale) {
- this.yAxisLogScale = yAxisLogScale;
- }
-
-
-}
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/CategoryAxisJSON.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/CategoryAxisJSON.java
deleted file mode 100644
index 93fab6e9..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/CategoryAxisJSON.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-public class CategoryAxisJSON extends IndexValueJSON {
-
-}
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartD3Helper.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartD3Helper.java
deleted file mode 100644
index c46f48ac..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartD3Helper.java
+++ /dev/null
@@ -1,4064 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.apache.commons.lang.time.DateUtils;
-import org.openecomp.portalsdk.analytics.error.RaptorException;
-import org.openecomp.portalsdk.analytics.model.ReportHandler;
-import org.openecomp.portalsdk.analytics.model.base.ChartSeqComparator;
-import org.openecomp.portalsdk.analytics.system.AppUtils;
-import org.openecomp.portalsdk.analytics.system.ConnectionUtils;
-import org.openecomp.portalsdk.analytics.util.AppConstants;
-import org.openecomp.portalsdk.analytics.util.DataSet;
-import org.openecomp.portalsdk.analytics.util.HtmlStripper;
-import org.openecomp.portalsdk.analytics.util.Utils;
-import org.openecomp.portalsdk.analytics.view.ReportData;
-import org.openecomp.portalsdk.analytics.xmlobj.DataColumnType;
-import org.openecomp.portalsdk.analytics.xmlobj.FormFieldType;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.web.support.UserUtils;
-
-public class ChartD3Helper {
-
- EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ChartD3Helper.class);
-
-
- private ReportRuntime reportRuntime;
- private String chartType;
-
- public static final long HOUR = 3600*1000;
- public static final long DAY = 3600*1000*24;
- public static final long MONTH = 3600*1000*24*31;
- public static final long YEAR = 3600*1000*24*365;
-
-
- public ChartD3Helper() {
-
- }
-
- /**
- * @return the chartType
- */
- public String getChartType() {
- return chartType;
- }
-
- /**
- * @param chartType the chartType to set
- */
- public void setChartType(String chartType) {
- this.chartType = chartType;
- }
-
- public ChartD3Helper(ReportRuntime rr) {
- this.reportRuntime = rr;
- }
-
- public String createVisualization(String reportID, HttpServletRequest request) throws RaptorException {
- //From annotations chart
- clearReportRuntimeBackup(request);
-
- //HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest();
- final Long user_id = new Long((long) UserUtils.getUserId(request));
- //String action = request.getParameter(AppConstants.RI_ACTION);
- //String reportID = AppUtils.getRequestValue(request, AppConstants.RI_REPORT_ID);
-
- ReportHandler rh = new ReportHandler();
- ReportData reportData = null;
- HashMap<String, String> chartOptionsMap = new HashMap<String, String>();
- try {
- if(reportID !=null) {
- reportRuntime = rh.loadReportRuntime(request, reportID, true, 1);
- setChartType(reportRuntime.getChartType());
- reportData = reportRuntime.loadReportData(0, user_id.toString(), 10000,request, false);
- }
-
-
-
- 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";
-
-
- 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);
-
-
- } catch (RaptorException ex) {
- ex.printStackTrace();
- }
- return createVisualization(reportRuntime, chartOptionsMap, request);
- }
-
- public String createVisualization(ReportRuntime reportRuntime, HttpServletRequest request) throws RaptorException {
-
- 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";
-
- HashMap<String,String> chartOptionsMap = new HashMap<String, String>();
- chartOptionsMap.put("width", reportRuntime.getChartWidth());
- chartOptionsMap.put("height", reportRuntime.getChartHeight());
- chartOptionsMap.put("animation", new Boolean(reportRuntime.isAnimateAnimatedChart()).toString());
- chartOptionsMap.put("rotateLabels", rotateLabelsStr);
- chartOptionsMap.put("staggerLabels", "false");
- chartOptionsMap.put("showMaxMin", "false");
- chartOptionsMap.put("showControls", new Boolean(reportRuntime.displayBarControls()).toString());
- chartOptionsMap.put("showLegend", new Boolean(!reportRuntime.hideChartLegend()).toString());
- chartOptionsMap.put("topMargin", reportRuntime.getTopMargin()!=null?reportRuntime.getTopMargin().toString():"30");
- chartOptionsMap.put("bottomMargin", reportRuntime.getBottomMargin()!=null?reportRuntime.getBottomMargin().toString():"50");
- chartOptionsMap.put("leftMargin", reportRuntime.getLeftMargin()!=null?reportRuntime.getLeftMargin().toString():"100");
- chartOptionsMap.put("rightMargin", reportRuntime.getRightMargin()!=null?reportRuntime.getRightMargin().toString():"160");
- chartOptionsMap.put("showTitle", new Boolean(reportRuntime.displayChartTitle()).toString());
- chartOptionsMap.put("subType", (AppUtils.nvl(reportRuntime.getTimeSeriesRender()).equals("area")?reportRuntime.getTimeSeriesRender():""));
- chartOptionsMap.put("stacked", new Boolean(reportRuntime.isChartStacked()).toString());
- chartOptionsMap.put("horizontalBar", new Boolean(reportRuntime.isHorizontalOrientation()).toString());
- chartOptionsMap.put("timeAxis", new Boolean(reportRuntime.isTimeAxis()).toString());
- chartOptionsMap.put("barReduceXAxisLabels", new Boolean(reportRuntime.isLessXaxisTickers()).toString());
-
- chartOptionsMap.put("logScale", new Boolean(reportRuntime.isLogScale()).toString());
- chartOptionsMap.put("precision", "2");
-
-
-
- return createVisualization(reportRuntime, chartOptionsMap, request);
- }
-
- public String createVisualization(ReportRuntime reportRuntime, HashMap<String,String> chartOptionsMap, HttpServletRequest request) throws RaptorException {
-
- //String width, String height, boolean animation, String rotateLabels, boolean staggerLabels, boolean showMaxMin, boolean showLegend, boolean showControls, String topMargin, String bottomMargin, boolean showTitle, String subType
-
- String width = chartOptionsMap.get("width");
- String height = chartOptionsMap.get("height");
- boolean animation = getBooleanValue(chartOptionsMap.get("animation"), true);
- String rotateLabels = chartOptionsMap.get("rotateLabels");
- boolean staggerLabels = getBooleanValue(chartOptionsMap.get("staggerLabels"));
- boolean showMaxMin = getBooleanValue(chartOptionsMap.get("showMaxMin"), false);
- boolean showLegend = getBooleanValue(chartOptionsMap.get("showLegend"), true);
- boolean showControls = getBooleanValue(chartOptionsMap.get("showControls"), true);
- String topMargin = chartOptionsMap.get("topMargin");
- String bottomMargin = chartOptionsMap.get("bottomMargin");
- String leftMargin = chartOptionsMap.get("leftMargin");
- String rightMargin = chartOptionsMap.get("rightMargin");
- boolean showTitle = getBooleanValue(chartOptionsMap.get("showTitle"), true);
- String subType = chartOptionsMap.get("subType");
- boolean stacked = getBooleanValue(chartOptionsMap.get("stacked"), false);
- boolean horizontalBar = getBooleanValue(chartOptionsMap.get("horizontalBar"), false);
- boolean barRealTimeAxis = getBooleanValue(chartOptionsMap.get("barRealTimeAxis"), true);
- boolean barReduceXAxisLabels= getBooleanValue(chartOptionsMap.get("barReduceXAxisLabels"), false);
- boolean timeAxis = getBooleanValue(chartOptionsMap.get("timeAxis"), true);
-
-
- boolean logScale = getBooleanValue(chartOptionsMap.get("logScale"), false);
-
- int precision = 2;
-
- try {
- precision = Integer.parseInt(chartOptionsMap.get("precision"));
- } catch (NumberFormatException ex) {
-
- }
-
- final Long user_id = new Long((long) UserUtils.getUserId(request));
-
- HttpSession session = null;
- session = request.getSession();
-
- String chartType = reportRuntime.getChartType();
- List l = reportRuntime.getAllColumns();
- List lGroups = reportRuntime.getAllChartGroups();
- HashMap mapYAxis = reportRuntime.getAllChartYAxis(reportRuntime.getReportParamValues());
- //ReportParamValues reportParamValues = reportRuntime.getReportParamValues();
- String chartLeftAxisLabel = reportRuntime.getFormFieldFilled(nvl(reportRuntime.getChartLeftAxisLabel()));
- String chartRightAxisLabel = reportRuntime.getFormFieldFilled(nvl(reportRuntime.getChartRightAxisLabel()));
-
- boolean multipleSeries = reportRuntime.isMultiSeries();
-
- java.util.HashMap formValues = null;
- formValues = getRequestParametersMap(reportRuntime, request);
-
-
- String legendColumnName = (reportRuntime.getChartLegendColumn()!=null)?reportRuntime.getChartLegendColumn().getDisplayName():"Legend Column";
- boolean displayChart = (nvl(chartType).length()>0)&&reportRuntime.getDisplayChart();
- HashMap additionalChartOptionsMap = new HashMap();
-
- StringBuffer wholeScript = new StringBuffer("");
-
- String title = reportRuntime.getReportTitle();
-
- title = parseTitle(title, formValues);
-
- if(displayChart) {
- DataSet ds = null;
- try {
- if (!(chartType.equals(AppConstants.GT_HIERARCHICAL) || chartType.equals(AppConstants.GT_HIERARCHICAL_SUNBURST) || chartType.equals(AppConstants.GT_ANNOTATION_CHART))) {
- ds = (DataSet) loadChartData(new Long(user_id).toString(), request);
- } else if(chartType.equals(AppConstants.GT_ANNOTATION_CHART)) {
- String reportSQL = reportRuntime.getWholeSQL();
- String dbInfo = reportRuntime.getDBInfo();
- ds = ConnectionUtils.getDataSet(reportSQL, dbInfo);
- if(ds.getRowCount()<=0) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("********************************************************************************"));
- logger.debug(EELFLoggerDelegate.debugLogger, (chartType.toUpperCase()+" - " + "Report ID : " + reportRuntime.getReportID() + " DATA IS EMPTY"));
- logger.debug(EELFLoggerDelegate.debugLogger, ("QUERY - " + reportSQL));
- logger.debug(EELFLoggerDelegate.debugLogger, ("********************************************************************************"));
- }
- } else if(chartType.equals(AppConstants.GT_HIERARCHICAL)||chartType.equals(AppConstants.GT_HIERARCHICAL_SUNBURST)) {
- String reportSQL = reportRuntime.getWholeSQL();
- String dbInfo = reportRuntime.getDBInfo();
- ds = ConnectionUtils.getDataSet(reportSQL, dbInfo);
- }
- } catch (RaptorException ex) {
- //throw new RaptorException("Error while loading chart data", ex);
- logger.error(EELFLoggerDelegate.debugLogger, ("********************************************************************************"));
- logger.error(EELFLoggerDelegate.debugLogger, (chartType.toUpperCase()+" - " + "Report ID : " + reportRuntime.getReportID() + " ERROR THROWN FOR GIVEN QUERY "));
- logger.error(EELFLoggerDelegate.debugLogger, ("QUERY - " + reportRuntime.getWholeSQL()));
- logger.error(EELFLoggerDelegate.debugLogger, ("ERROR STACK TRACE" + ex.getMessage()));
- logger.error(EELFLoggerDelegate.debugLogger, ("********************************************************************************"));
-
- }
- if(ds==null) {
- //displayChart = false;
- if(chartType.equals(AppConstants.GT_ANNOTATION_CHART))
- ds = new DataSet();
- else
- displayChart = false;
- }
- if(displayChart) {
-
- if (chartType.equals(AppConstants.GT_BAR_3D)) {
-
- // get category if not give the column name for the data column use this to develop series.
- boolean hasCategoryAxis = reportRuntime.hasSeriesColumn();
-
- boolean hasCustomizedChartColor = false;
- int flag = 0;
- flag = hasCategoryAxis?1:0;
- Object uniqueElements [] = null;
- ArrayList uniqueElementsList = new ArrayList();
- Object uniqueXAxisElements[] = null;
- ArrayList ts = new ArrayList();
- //Set<String> ts1 = new HashSet();
- ArrayList<String> ts1 = new ArrayList();
- HashMap<String, String> columnMap = new HashMap();
- String uniqueXAxisStr = "";
- if(!timeAxis){
- for (int i = 0; i < ds.getRowCount(); i++) {
- uniqueXAxisStr = ds.getString(i, 0);
- ts1.add(uniqueXAxisStr);
- }
- }
- uniqueElementsList.addAll(ts1);
- uniqueXAxisElements = ts1.toArray();
-
- if(flag == 1) {
- StringBuffer catStr = new StringBuffer("");
- String color="";
- for (int i = 0; i < ds.getRowCount(); i++) {
- catStr = new StringBuffer("");
- catStr.append(ds.getString(i, 2));
- try {
- if(ds.getString(i, "chart_color")!=null) {
- color = ds.getString(i, "chart_color");
- hasCustomizedChartColor = true;
- catStr.append("|"+color);
- }
- } catch (ArrayIndexOutOfBoundsException ex) {
- //System.out.println("No Chart Color");
- }
-
- if(catStr.length()>0) {
- //duplicates are avoided
- if(!ts.contains(catStr.toString()))
- ts.add(catStr.toString());
-
- }
- /* Get Chart LeftAxis Label even from Range Axis definition. */
- DataColumnType dct = null;
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- dct = (DataColumnType) iter.next();
- if(!(nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND))) {
- if(nvl(chartLeftAxisLabel).length()<=0) {
- chartLeftAxisLabel = nvl(dct.getYAxis());
- chartLeftAxisLabel = (chartLeftAxisLabel.indexOf("|")!=-1)?chartLeftAxisLabel.substring(0,chartLeftAxisLabel.indexOf("|")):"";
- }
- }
- }
-
- }
- //Object uniqueElements [] = ts.toArray();
- //SortedSet s = Collections.synchronizedSortedSet(ts);
- uniqueElements = ts.toArray();
- } else {
- DataColumnType dct = null;
- List yTextSeries = reportRuntime.getChartDisplayNamesList(AppConstants.CHART_ALL_COLUMNS, formValues);
- //if(columnValuesList.size() == 1) {
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- dct = (DataColumnType) iter.next();
-
- if(!(nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND))) {
- if((dct.isChartSeries()!=null && dct.isChartSeries().booleanValue()) || (dct.getChartSeq()!=null && dct.getChartSeq()>0) ) {
-
- if(nvl(dct.getChartColor()).length()>0) hasCustomizedChartColor = true;
- if(hasCustomizedChartColor) {
- //duplicates are avoided
- if(!ts.contains(dct.getDisplayName()+"|"+nvl(dct.getChartColor())))
- ts.add(dct.getDisplayName()+"|"+nvl(dct.getChartColor()));
- } else {
- //duplicates are avoided
- if(!ts.contains(dct.getDisplayName()))
- ts.add(dct.getDisplayName());
- }
- if(nvl(chartLeftAxisLabel).length()<=0) {
- chartLeftAxisLabel = nvl(dct.getYAxis());
- chartLeftAxisLabel = (chartLeftAxisLabel.indexOf("|")!=-1)?chartLeftAxisLabel.substring(0,chartLeftAxisLabel.indexOf("|")):"";
- }
- columnMap.put(dct.getDisplayName(), dct.getColId());
- /*
- ts.add(dct.getDisplayName());
- if(nvl(chartLeftAxisLabel).length()<=0) {
- chartLeftAxisLabel = nvl(dct.getYAxis());
- chartLeftAxisLabel = (chartLeftAxisLabel.indexOf("|")!=-1)?chartLeftAxisLabel.substring(0,chartLeftAxisLabel.indexOf("|")):"";
- }
- columnMap.put(dct.getDisplayName(), dct.getColId());
- */
- }
- }
-
- }
- //SortedSet s = Collections.synchronizedSortedSet(ts);
- uniqueElements = ts.toArray();
-
- }
-
- wholeScript.append("<!DOCTYPE html>\n");
- wholeScript.append("<html>\n");
- wholeScript.append("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF8\">\n");
- wholeScript.append("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n");
- wholeScript.append("<link href=\""+ AppUtils.getBaseFolderURL() +"d3/css/nv.d3.css\" rel=\"stylesheet\" type=\"text/css\">\n");
- //wholeScript.append("")
- wholeScript.append("<style>\n " +
- " body { \n" +
- " overflow-y:scroll; \n" +
- " } \n" +
- " text { \n" +
- " font: 12px sans-serif; \n" +
- " } \n" +
- " svg { \n" +
- " display: block;\n" +
- " } \n" +
- " #chart"+reportRuntime.getReportID()+" svg { \n" +
- " height: "+ (nvl(height).length()>0?(height.endsWith("px")?height:height+"px"):"420px") + "; \n" +
- " width: "+ (nvl(width).length()>0?(width.endsWith("px")?width:width+"px"):"700px") + "; \n" +
- " min-width: 100px; \n" +
- " min-height: 100px; \n" +
- " } \n" +
- " tr.z-row-over > td.z-row-inner, tr.z-row-over > .z-cell {" +
- " background-color: rgb(255, 255, 255); "+
- "} \n");
-
- wholeScript.append(".nodatadiv {\n");
- wholeScript.append(" display: table-cell;\n");
- wholeScript.append(" width: 700px;\n");
- wholeScript.append(" height:370px;\n");
- wholeScript.append(" text-align:center;\n");
- wholeScript.append(" vertical-align: middle;\n");
- wholeScript.append("}\n");
- wholeScript.append(".nodatainner {\n");
- wholeScript.append(" padding: 10px;\n");
- wholeScript.append("}\n");
-
- wholeScript.append(" </style> \n" );
- wholeScript.append("<body> \n");
- if(showTitle)
- wholeScript.append("<div align=\"center\"><H3>" + title +"</H3></div>");
-
- wholeScript.append("<div id=\"chart"+reportRuntime.getReportID()+"\"> <svg></svg> </div> \n");
- //js files
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/d3.v3.min.js\"></script>");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/nv.d3.min.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/tooltip.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/utils.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/axis.min.js\"></script> \n");
- //wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/discreteBar.js\"></script> \n");
- //wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/discreteBarChart.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/multiChart.js\"></script> \n");
- //json
- wholeScript.append("<script> \n");
- wholeScript.append("historicalBarChart = [ \n");
- //wholeScript.append("{ \n");
- // data
- ArrayList dataSeries = new ArrayList();
-
- String uniqueElement = "";
- for (int i = 0; i < uniqueElements.length; i++) {
- uniqueElement = (String)uniqueElements[i];
- if(multipleSeries && (nvl(chartRightAxisLabel).length() > 0))
- dataSeries.add(new StringBuffer(" { \"type\":\"bar\", \"key\": \""+ (hasCustomizedChartColor?(uniqueElement.indexOf("|")!=-1?uniqueElement.substring(0, uniqueElement.indexOf("|")):uniqueElement):uniqueElement) +"\", \"yAxis\": \""+(i+1)+"\", "+ (hasCustomizedChartColor?("\"color\": \""+uniqueElement.substring(uniqueElement.indexOf("|")+1) + "\","):"")+"\"values\": ["));
- else
- dataSeries.add(new StringBuffer(" { \"type\":\"bar\", \"key\": \""+ (hasCustomizedChartColor?(uniqueElement.indexOf("|")!=-1?uniqueElement.substring(0, uniqueElement.indexOf("|")):uniqueElement):uniqueElement) +"\", \"yAxis\": \""+(1)+"\", "+ (hasCustomizedChartColor?("\"color\": \""+uniqueElement.substring(uniqueElement.indexOf("|")+1) + "\","):"")+"\"values\": ["));
- }
-
- // added to load all date elements
- HashMap<String, HashMap<String, String>> dataSeriesMap = new HashMap<String, HashMap<String, String>>();
-
- for (int i = 0; i < uniqueElements.length; i++) {
- if(multipleSeries && (nvl(chartRightAxisLabel).length() > 0))
- dataSeriesMap.put((String) uniqueElements[i], new HashMap<String, String>());
- //dataSeries.add(new StringBuffer(" { \"type\":\"bar\", \"key\": \""+ uniqueElements[i] +"\", \"yAxis\": \""+(i+1)+"\", \"values\": ["));
- else
- dataSeriesMap.put((String) uniqueElements[i], new HashMap<String, String>());
-
- //dataSeries.add(new StringBuffer(" { \"type\":\"bar\", \"key\": \""+ uniqueElements[i] +"\", \"yAxis\": \""+(1)+"\", \"values\": ["));
- }
-
- String dateStr = null;
- java.util.Date date = null;
-
- final int YEARFLAG = 1;
- final int MONTHFLAG = 2;
- final int DAYFLAG = 3;
- final int HOURFLAG = 4;
- final int MINFLAG = 5;
- final int SECFLAG = 6;
- final int MILLISECFLAG = 7;
- final int DAYOFTHEWEEKFLAG = 8;
- final int FLAGDATE = 9;
-
- int flagNoDate = 0;
-
- int MAXNUM = 0;
- int YAXISNUM = 0;
- int flagNull = 0;
-
- double YAXISDOUBLENUM = 0.0;
- double MAXDOUBLENUM = 0.0;
- int MAXNUMDECIMALPLACES = 0;
-
- int formatFlag = 0;
-
- TreeSet<String> dateStrList = new TreeSet<String>();
- // added to store all date elements
- SortedSet<String> sortSet = new TreeSet<String>();
- int count = 0;
- if(flag!= 1) {
- HashMap dataSeriesStrMap = new HashMap();
- HashMap dataSeriesOverAllMap = new HashMap();
- String valueDataSeries = "";
-
- for (int j = 0; j < uniqueElements.length; j++) {
- dataSeriesStrMap = new HashMap();
- for (int i = 0; i < ds.getRowCount(); i++) {
- flagNoDate = 0;
- YAXISNUM = 0;
- YAXISDOUBLENUM = 0.0;
- flagNull= 0;
- dateStr = ds.getString(i, 1);
- if(timeAxis) {
- date = getDateFromDateStr(dateStr);
- formatFlag = getFlagFromDateStr(dateStr);
- }
- uniqueElement = (String)uniqueElements[j];
- if(date==null) {
- //continue;
- flagNoDate = 1;
- int pos = 0;
- //if(!((String)uniqueElementsList.get(i)).equals(dateStr)) {
- for (int f=0 ; f< uniqueXAxisElements.length; f++) {
- if(uniqueXAxisElements[f].equals(dateStr)){
- pos = f ;
- break;
- }
- }
- /*for(int f=0; f<uniqueElementsList.size() && f < pos; f++)
- {
- StringBuffer strBuf = ((StringBuffer)dataSeries.get(j));
- if(strBuf.indexOf((String)uniqueElementsList.get(f)) < 0 ) {
- dataSeriesStrMap.put((String)uniqueElementsList.get(f), value);
- //((StringBuffer) dataSeries.get(j)).append ("{ \"x\":\"" + (String)uniqueElementsList.get(f) + "\" , \"y\": null },");
- }
- }*/
- //}
-
- dateStrList.add("'"+dateStr+"'");
- //uniqueElement = (String)uniqueElements[j];
- try {
- YAXISNUM = Integer.parseInt(ds.getString(i, columnMap.get((hasCustomizedChartColor?(uniqueElement.indexOf("|")!=-1?uniqueElement.substring(0, uniqueElement.indexOf("|")):uniqueElement):uniqueElement))));
- //if(MAXNUM < YAXISNUM) MAXNUM = YAXISNUM;
- if(MAXDOUBLENUM < YAXISNUM) MAXDOUBLENUM = YAXISNUM;
- } catch (NumberFormatException ex) {
- try {
- YAXISDOUBLENUM = Double.parseDouble(ds.getString(i, columnMap.get((hasCustomizedChartColor?(uniqueElement.indexOf("|")!=-1?uniqueElement.substring(0, uniqueElement.indexOf("|")):uniqueElement):uniqueElement))));
- MAXNUMDECIMALPLACES = getNumberOfDecimalPlaces(YAXISDOUBLENUM);
- if(MAXDOUBLENUM < YAXISDOUBLENUM) MAXDOUBLENUM = YAXISDOUBLENUM;
- } catch (NumberFormatException ex1) {
- flagNull = 1;
- }
- //flagNull = 1;
- }
- /* For Non-date type value enclose with double quotes */
- // ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":\"" + dateStr + "\" , \"y\":" + (flagNull==0?(YAXISDOUBLENUM>0?YAXISDOUBLENUM:YAXISNUM):null) +"}, ");
- if(logScale) {
- // ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":\"" + dateStr + "\" , \"y\":" + (flagNull==0?(YAXISDOUBLENUM>0?new Double(Math.log10(YAXISDOUBLENUM)).toString():(YAXISNUM>0?new Double(Math.log10(new Integer(YAXISNUM).doubleValue())).toString():null)):null) +"}, ");
- valueDataSeries = "{ \"x\":\"" + dateStr + "\" , \"y\":" + (flagNull == 0 ? (YAXISDOUBLENUM>0?new Double(Math.log10(YAXISDOUBLENUM)).toString():new Double(Math.log10(new Double(YAXISNUM>0?YAXISNUM:1).doubleValue())).toString()): null) +"}, ";
- dataSeriesStrMap.put(dateStr, valueDataSeries);
- } else {
- //((StringBuffer) dataSeries.get(j)).append ("{ \"x\":\"" + dateStr + "\" , \"y\":" + (flagNull==0?(YAXISDOUBLENUM>0?YAXISDOUBLENUM:YAXISNUM):null) +"}, ");
- valueDataSeries = "{ \"x\":\"" + dateStr + "\" , \"y\":" + (flagNull == 0 ? (YAXISDOUBLENUM>0?YAXISDOUBLENUM:YAXISNUM): null) +"}, ";
- dataSeriesStrMap.put(dateStr, valueDataSeries);
-
- }
-
- dataSeriesOverAllMap.put(uniqueElements[j], dataSeriesStrMap);
-
- //((StringBuffer) dataSeries.get(j)).append ("{ \"x\":\"" + dateStr + "\" , \"y\":\"" + ds.getString(i, columnMap.get((String)uniqueElements[j])) +"\"}, ");
- } else {
-
- if(!barRealTimeAxis) { // true - non-time
- if(!dateStrList.contains(new Long(date.getTime()).toString())) {
- dateStrList.add(new Long(date.getTime()).toString());
- for (int k = 0; k < uniqueElements.length; k++) {
- //((StringBuffer) dataSeries.get(k)).append ("{ \"x\":" + date.getTime() + " , \"y\":null}, ");
- HashMap<String, String> dataMap = dataSeriesMap.get((String) uniqueElements[k]);
- dataMap.put(date.getTime()+"", "null");
-
- }
- }
- }
- //if(ds.getString(i, 2).equals(uniqueElements[j])) {
- /*if(!dateStrList.contains(new Long(date.getTime()).toString())) {
- for (int k = 0; k < uniqueElements.length; k++) {
- ((StringBuffer) dataSeries.get(k)).append ("{ \"x\":" + date.getTime() + " , \"y\":null}, ");
- }
- }*/
- //dateStrList.add(new Long(date.getTime()).toString());
- try {
- YAXISNUM = Integer.parseInt(ds.getString(i, columnMap.get(((hasCustomizedChartColor||nvl(chartRightAxisLabel).length()>0) && (uniqueElement.lastIndexOf("|") != -1)?uniqueElement.substring(0, uniqueElement.lastIndexOf("|")):uniqueElement))));
- dateStrList.add(new Long(date.getTime()).toString());
- //if(MAXNUM < YAXISNUM) MAXNUM = YAXISNUM;
- if(MAXDOUBLENUM < YAXISNUM) MAXDOUBLENUM = YAXISNUM;
- } catch (NumberFormatException ex) {
- try {
- YAXISDOUBLENUM = Double.parseDouble(ds.getString(i, columnMap.get(((hasCustomizedChartColor||nvl(chartRightAxisLabel).length()>0) && (uniqueElement.lastIndexOf("|") != -1) ?uniqueElement.substring(0, uniqueElement.lastIndexOf("|")):uniqueElement))));
- MAXNUMDECIMALPLACES = getNumberOfDecimalPlaces(YAXISDOUBLENUM);
- if(MAXDOUBLENUM < YAXISDOUBLENUM) MAXDOUBLENUM = YAXISDOUBLENUM;
- } catch (NumberFormatException ex1) {
- flagNull = 1;
- }
-
- //flagNull = 1;
- }
- HashMap<String, String> dataMap = dataSeriesMap.get((String) uniqueElements[j]);
- if(logScale) {
- dataMap.put(date.getTime()+"", (flagNull == 0 ? (YAXISDOUBLENUM>0?new Double(Math.log10(YAXISDOUBLENUM)).toString():(YAXISNUM>0?new Double(Math.log10(new Integer(YAXISNUM).doubleValue())).toString():null)): "null"));
- } else {
- dataMap.put(date.getTime()+"", (flagNull == 0 ? (YAXISDOUBLENUM>0?new Double(YAXISDOUBLENUM).toString():new Integer(YAXISNUM).toString()): "null"));
- }
-
-
- // ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + date.getTime() + " , \"y\":" + (flagNull==0?(YAXISDOUBLENUM>0?YAXISDOUBLENUM:YAXISNUM):null) +"}, ");
-
- //((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + date.getTime() + " , \"y\":" + ds.getString(i, columnMap.get((String)uniqueElements[j])) +"}, ");
- }
- //}
- }
- }
- for(int kI = 0; kI < uniqueElements.length; kI++) {
- HashMap dataSeriesStrMap1 = (HashMap) dataSeriesOverAllMap.get(uniqueElements[kI]);
- for (int kL = 0; kL < uniqueXAxisElements.length; kL++) {
- if(dataSeriesStrMap1.containsKey(uniqueXAxisElements[kL])) {
- ((StringBuffer) dataSeries.get(kI)).append ((String)dataSeriesStrMap1.get(uniqueXAxisElements[kL]));
- } else {
- ((StringBuffer) dataSeries.get(kI)).append ("{ \"x\":\"" + uniqueXAxisElements[kL] + "\" , \"y\": null }, ");
- }
- }
- }
-
- } else {
- HashMap dataSeriesStrMap = new HashMap();
- HashMap dataSeriesOverAllMap = new HashMap();
- String valueDataSeries = "";
- for (int j = 0; j < uniqueElements.length; j++) {
- dataSeriesStrMap = new HashMap();
-
- for (int i = 0; i < ds.getRowCount(); i++) {
- flagNoDate = 0;
- YAXISNUM = 0;
- YAXISDOUBLENUM = 0.0;
- flagNull= 0;
- //flagSecondNull = 0;
- dateStr = ds.getString(i, 1);
- if(timeAxis) {
- date = getDateFromDateStr(dateStr);
- formatFlag = getFlagFromDateStr(dateStr);
- }
- uniqueElement = (String)uniqueElements[j];
- if(date==null) {
- //continue;
- flagNoDate = 1;
- int pos = 0;
- //if(!((String)uniqueElementsList.get(i)).equals(dateStr)) {
- for (int f=0 ; f< uniqueXAxisElements.length; f++) {
- if(uniqueXAxisElements[f].equals(dateStr)){
- pos = f ;
- break;
- }
- }
- /*for(int f=0; f<uniqueElementsList.size() && f < pos; f++)
- {
- StringBuffer strBuf = ((StringBuffer)dataSeries.get(j));
- if(strBuf.indexOf((String)uniqueElementsList.get(f)) < 0 ) {
- dataSeriesStrMap.put((String)uniqueElementsList.get(f), value);
- //((StringBuffer) dataSeries.get(j)).append ("{ \"x\":\"" + (String)uniqueElementsList.get(f) + "\" , \"y\": null },");
- }
- }*/
- //}
-
- if(ds.getString(i, 2).equals(((hasCustomizedChartColor||nvl(chartRightAxisLabel).length()>0) && (uniqueElement.lastIndexOf("|") != -1) ?uniqueElement.substring(0, uniqueElement.lastIndexOf("|")):uniqueElement))) {
- dateStrList.add("'"+dateStr+"'");
- try {
- YAXISNUM = Integer.parseInt(ds.getString(i, 3));
- if(MAXDOUBLENUM < YAXISNUM) MAXDOUBLENUM = YAXISNUM;
- } catch (NumberFormatException ex) {
- try {
- YAXISDOUBLENUM = Double.parseDouble(ds.getString(i, 3));
- MAXNUMDECIMALPLACES = getNumberOfDecimalPlaces(YAXISDOUBLENUM);
- if(MAXDOUBLENUM < YAXISDOUBLENUM) MAXDOUBLENUM = YAXISDOUBLENUM;
- } catch (NumberFormatException ex1) {
- flagNull = 1;
- }
-
- //flagNull = 1;
- }
-
- if(logScale) {
- if(timeAxis) {
- //((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + dateStr + " , \"y\":" + (flagNull == 0 ? (YAXISDOUBLENUM>0?new Double(Math.log10(YAXISDOUBLENUM)).toString():new Double(Math.log10(new Double(YAXISNUM>0?YAXISNUM:1).doubleValue())).toString()): null) +"}, ");
- valueDataSeries = "{ \"x\":" + dateStr + " , \"y\":" + (flagNull == 0 ? (YAXISDOUBLENUM>0?new Double(Math.log10(YAXISDOUBLENUM)).toString():new Double(Math.log10(new Double(YAXISNUM>0?YAXISNUM:1).doubleValue())).toString()): null) +"}, ";
- dataSeriesStrMap.put(dateStr, valueDataSeries);
- } else {
- // ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":\"" + dateStr + "\" , \"y\":" + (flagNull == 0 ? (YAXISDOUBLENUM>0?new Double(Math.log10(YAXISDOUBLENUM)).toString():new Double(Math.log10(new Double(YAXISNUM>0?YAXISNUM:1).doubleValue())).toString()): null) +"}, ");
- valueDataSeries = "{ \"x\":\"" + dateStr + "\" , \"y\":" + (flagNull == 0 ? (YAXISDOUBLENUM>0?new Double(Math.log10(YAXISDOUBLENUM)).toString():new Double(Math.log10(new Double(YAXISNUM>0?YAXISNUM:1).doubleValue())).toString()): null) +"}, ";
- dataSeriesStrMap.put(dateStr, valueDataSeries);
- }
- } else {
- if(timeAxis) {
- //((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + dateStr + " , \"y\":" + (flagNull == 0 ? (YAXISDOUBLENUM>0?YAXISDOUBLENUM:YAXISNUM): null) +"}, ");
- valueDataSeries = "{ \"x\":" + dateStr + " , \"y\":" + (flagNull == 0 ? (YAXISDOUBLENUM>0?YAXISDOUBLENUM:YAXISNUM): null) +"}, ";
- dataSeriesStrMap.put(dateStr, valueDataSeries);
-
- } else {
- //((StringBuffer) dataSeries.get(j)).append ("{ \"x\":\"" + dateStr + "\" , \"y\":" + (flagNull == 0 ? (YAXISDOUBLENUM>0?YAXISDOUBLENUM:YAXISNUM): null) +"}, ");
- valueDataSeries = "{ \"x\":\"" + dateStr + "\" , \"y\":" + (flagNull == 0 ? (YAXISDOUBLENUM>0?YAXISDOUBLENUM:YAXISNUM): null) +"}, ";
- dataSeriesStrMap.put(dateStr, valueDataSeries);
-
- }
- }
-
- /*if(ds.getString(i, 2).equals(uniqueElements[j])) {
- dateStrList.add("'"+dateStr+"'");
- ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":\"" + dateStr + "\" , \"y\":\"" + ds.getString(i, 3) +"\"}, ");
- */
- }
- dataSeriesOverAllMap.put(uniqueElements[j], dataSeriesStrMap);
- } else {
- //date = MMDDYYYYFormat.parse(ds.getString(i, 1), new ParsePosition(0));
- if(!barRealTimeAxis) { // true - non-time
- if(!dateStrList.contains(new Long(date.getTime()).toString())) {
- dateStrList.add(new Long(date.getTime()).toString());
- for (int k = 0; k < uniqueElements.length; k++) {
- //((StringBuffer) dataSeries.get(k)).append ("{ \"x\":" + date.getTime() + " , \"y\":null}, ");
- HashMap<String, String> dataMap = dataSeriesMap.get((String) uniqueElements[k]);
- dataMap.put(date.getTime()+"", "null");
-
- }
- }
- }
- if(ds.getString(i, 2).equals(((hasCustomizedChartColor||nvl(chartRightAxisLabel).length()>0) && (uniqueElement.lastIndexOf("|") != -1) ?uniqueElement.substring(0, uniqueElement.lastIndexOf("|")):uniqueElement))) {
- dateStrList.add(new Long(date.getTime()).toString());
- try {
- YAXISNUM = Integer.parseInt(ds.getString(i, 3));
- if(MAXDOUBLENUM < YAXISNUM) MAXDOUBLENUM = YAXISNUM;
- } catch (NumberFormatException ex) {
- try {
- YAXISDOUBLENUM = Double.parseDouble(ds.getString(i, 3));
- MAXNUMDECIMALPLACES = getNumberOfDecimalPlaces(YAXISDOUBLENUM);
- if(MAXDOUBLENUM < YAXISDOUBLENUM) MAXDOUBLENUM = YAXISDOUBLENUM;
- } catch (NumberFormatException ex1) {
- flagNull = 1;
- }
-
- //flagNull = 1;
- }
-
- //if(ds.getString(i, 2).equals(uniqueElements[j])) {
- // dateStrList.add("'"+dateStr+"'");
- HashMap<String, String> dataMap = dataSeriesMap.get((String) uniqueElements[j]);
- if(logScale) {
- dataMap.put(date.getTime()+"", (flagNull == 0 ? (YAXISDOUBLENUM>0?new Double(Math.log10(YAXISDOUBLENUM)).toString():new Double(Math.log10(new Double(YAXISNUM>0?YAXISNUM:1).doubleValue())).toString()): "null"));
- } else {
- if(dataMap.containsKey(new String(""+date.getTime())) && dataMap.get(new String(""+date.getTime())).equals("null")) {
- dataMap.remove(date.getTime());
- }
- dataMap.put(date.getTime()+"", (flagNull == 0 ? (YAXISDOUBLENUM>0?new Double(YAXISDOUBLENUM).toString():new Integer(YAXISNUM).toString()): "null"));
- //System.out
- // .println(dataMap + " " + dataSeriesMap);
- //}
- }
- // ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + date.getTime() + " , \"y\":" + (flagNull == 0 ? (YAXISDOUBLENUM>0?YAXISDOUBLENUM:YAXISNUM): null) +"}, ");
-
-
- //((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + date.getTime() + " , \"y\":" + ds.getString(i, 3) +"}, ");
- } else if (AppUtils.nvl(ds.getString(i, 2)).length()<=0) {
- dateStrList.add(new Long(date.getTime()).toString());
- HashMap<String, String> dataMap1 = null;
- String uniqueElement1 = "";
- for (int j1 = 0; j1 < uniqueElements.length; j1++) {
- uniqueElement1 = (String)uniqueElements[j];
- if(ds.getString(i, 2).equals(((hasCustomizedChartColor||nvl(chartRightAxisLabel).length()>0) && (uniqueElement1.lastIndexOf("|") != -1) ?uniqueElement1.substring(0, uniqueElement1.lastIndexOf("|")):uniqueElement1))) {
- dataMap1 = dataSeriesMap.get((String) uniqueElements[j1]);
- if(!dataMap1.containsKey(new String(""+date.getTime())))
- dataMap1.put(date.getTime()+"", "null");
- }
- }
- }
- }
- // dataSeriesOverAllMap.put(uniqueElements[j], dataSeriesMap);
- }
-
- }
- for(int kI = 0; kI < uniqueElements.length; kI++) {
- HashMap dataSeriesStrMap1 = (HashMap) dataSeriesOverAllMap.get(uniqueElements[kI]);
- for (int kL = 0; kL < uniqueXAxisElements.length; kL++) {
- if(dataSeriesStrMap1.containsKey(uniqueXAxisElements[kL])) {
- ((StringBuffer) dataSeries.get(kI)).append ((String)dataSeriesStrMap1.get(uniqueXAxisElements[kL]));
- } else {
- ((StringBuffer) dataSeries.get(kI)).append ("{ \"x\":\"" + uniqueXAxisElements[kL] + "\" , \"y\": null }, ");
- }
- }
- }
- }
-
- StringBuffer dateStrBuf = new StringBuffer("");
- /*if(count == 1) {
- Long initialDate = Long.parseLong((String)ds.getString(0, 0));
- Long endDate = Long.parseLong((String) ds.getString(ds.getRowCount(), 0));
- java.util.Date date1 = null;
-
- while ( initialDate <= endDate) {
- //System.out.println("********** " + df.format(initialDate));
- date1 = new java.util.Date(initialDate.longValue() * 1000);
- initialDate = initialDate + HOUR;
-
- dateStrBuf.append(initialDate+",");
- sortSet.add(""+initialDate);
- //DateUtils.addHours(date1, 1);
- }
- }*/
-
- if(dateStrList.size()>0) {
- SortedSet<String> s = Collections.synchronizedSortedSet(dateStrList);
- Object[] dateElements = (Object[]) s.toArray();
-
- String element = "";
- /* if not date value */
- if(!timeAxis) {
- for (int i = 0; i < dateElements.length; i++) {
- dateStrBuf.append(dateElements[i]+",");
- }
- } else {
- if(!barRealTimeAxis || (flagNoDate == 1)) { // non-time
- for (int i = 0; i < dateElements.length; i++) {
- dateStrBuf.append(dateElements[i]+",");
- }
- } else {
- Long initialDate = Long.parseLong((String)dateElements[0]);
- Long endDate = Long.parseLong((String) dateElements[dateElements.length-1]);
- java.util.Date date1 = null;
- //first value
- date1 = new java.util.Date(initialDate.longValue());
- /* DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss Z");
- System.out.println(formatter.format(new java.util.Date(initialDate.longValue())));
- */ //initialDate = initialDate + HOUR;
-
- dateStrBuf.append(initialDate+",");
- sortSet.add(""+initialDate);
-
- // DateUtils.
-
- while ( initialDate <= endDate) {
- //System.out.println("********** " + df.format(initialDate));
- //date1 = new java.util.Date(initialDate.longValue() * 1000);
- date1 = new java.util.Date(initialDate.longValue());
- if(formatFlag==HOURFLAG)
- date1 = DateUtils.addHours(date1, 1);
- else if (formatFlag == DAYFLAG)
- date1 = DateUtils.addDays(date1, 1);
- else if (formatFlag == MONTHFLAG)
- date1 = DateUtils.addMonths(date1, 1);
- else if (formatFlag == YEARFLAG)
- date1 = DateUtils.addMonths(date1, 1);
- initialDate = date1.getTime();
-
- if(initialDate <= endDate) {
- dateStrBuf.append(initialDate+",");
- sortSet.add(""+initialDate);
- }
- //DateUtils.addHours(date1, 1);
- }
- //DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
- //df.setTimeZone(TimeZone.getTimeZone("UTC"));
- //java.util.Date date1 = new java.util.Date(initialDate.longValue() * 1000);
- //java.util.Date d = df.
- //for ()
- }
- }
- dateStrBuf.deleteCharAt(dateStrBuf.length()-1);
- }
-
- if(timeAxis) {
- //if(!barRealTimeAxis) { // false - non-time
- Object[] dateAllElements = (Object[]) sortSet.toArray();
-
- for (int i = 0; i < uniqueElements.length; i++) {
- HashMap<String, String> dataMap = dataSeriesMap.get((String)uniqueElements[i]);
- for (int j=0; j<dateAllElements.length;j++) {
- //if(strBuf.toString().indexOf((String) dateAllElements[j]) == -1) {
- if(!dataMap.containsKey((String) dateAllElements[j])) {
- dataMap.put((String) dateAllElements[j], "null");
- //((StringBuffer) dataSeries.get(i)).append ("{ \"x\":" + dateAllElements[j] + " , \"y\":null}, ");
- }
- }
- }
- //}
- }
- String valueStr = "";
- for (int i = 0; i < uniqueElements.length; i++) {
- HashMap<String, String> dataMap = dataSeriesMap.get((String)uniqueElements[i]);
- Set<String> keySet = dataMap.keySet();
- ArrayList<String> keySortedList = new ArrayList<String>(new TreeSet<String>(keySet));
-
- for (int k=0; k < keySortedList.size(); k++) {
- valueStr = dataSeriesMap.get((String)uniqueElements[i]).get(keySortedList.get(k));
- if(valueStr.equals("null"))
- valueStr = null;
- else {
- //if(logScale)
- //valueStr = new Double(Math.log10(new Double(valueStr).doubleValue())).toString();
- }
- ((StringBuffer) dataSeries.get(i)).append ("{ \"x\":" + keySortedList.get(k) + " , \"y\":" + valueStr +"}, ");
- // ((StringBuffer) dataSeries.get(i)).append ("{ \"x\":" + keySortedList.get(k) + " , \"y\":" + valueStr +"}, ");
- }
-
- // ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + date.getTime() + " , \"y\":" + (flagNull == 0 ? (YAXISDOUBLENUM>0?YAXISDOUBLENUM:YAXISNUM): null) +"}, ");
- }
-
- for (int i = 0; i < uniqueElements.length; i++) {
- StringBuffer strBuf = ((StringBuffer) dataSeries.get(i));
- ((StringBuffer) dataSeries.get(i)).deleteCharAt(((StringBuffer) dataSeries.get(i)).lastIndexOf(","));
- if(i < (uniqueElements.length -1) ) {
- ((StringBuffer) dataSeries.get(i)).append("] } , \n");
- }
- else {
- ((StringBuffer) dataSeries.get(i)).append("] } \n");
- }
- }
- if(ds.getRowCount() > 0) {
- for (int i = 0; i < uniqueElements.length; i++) {
- wholeScript.append((StringBuffer)dataSeries.get(i));
- }
- }
-
-
- wholeScript.append("]; \n");
-
- //add global variable
- wholeScript.append("var chart; \n");
- //javascript to create Bar Chart
- wholeScript.append("nv.addGraph(function() { \n");
- if(horizontalBar /*&& flagNoDate == 1*/)
- wholeScript.append(" chart = nv.models.multiBarHorizontalChart() \n");
- else /*if (flagNoDate == 1)*/
- wholeScript.append(" chart = nv.models.multiBarChart() \n");
- /*else
- wholeScript.append(" var chart = nv.models.multiBarTimeSeriesChart() \n");*/
-
- wholeScript.append(" .margin({top: "+ topMargin +", right: "+ rightMargin +", bottom: "+ bottomMargin +", left: " + leftMargin +"}) \n");
- if(showLegend) {
- wholeScript.append(" .showLegend(true) \n ");
- } else {
- wholeScript.append(" .showLegend(false) \n ");
- }
- if(!horizontalBar && barReduceXAxisLabels)
- wholeScript.append(" .reduceXTicks(true) \n ");
- else if (!horizontalBar) {
- wholeScript.append(" .reduceXTicks(false) \n ");
- //wholeScript.append(" chart.lines1.forceY(["+(nvl(reportRuntime.getRangeAxisLowerLimit()).length()<=0?"0":reportRuntime.getRangeAxisLowerLimit()) +", "+ (nvl(reportRuntime.getRangeAxisUpperLimit()).length()<=0?UPPER_RANGE:reportRuntime.getRangeAxisUpperLimit()) + "]); \n" +
- double UPPER_RANGE = 0;
- if(Math.ceil((MAXDOUBLENUM+(MAXDOUBLENUM*25/100))/100) * 100 >= 1) {
- UPPER_RANGE = Math.ceil(MAXDOUBLENUM+(MAXDOUBLENUM*25/100));
- } else UPPER_RANGE = 1;
- wholeScript.append(" .forceY(["+(nvl(reportRuntime.getRangeAxisLowerLimit()).length()<=0?"0":reportRuntime.getRangeAxisLowerLimit()) +", "+ (nvl(reportRuntime.getRangeAxisUpperLimit()).length()<=0?UPPER_RANGE:reportRuntime.getRangeAxisUpperLimit()) + "])\n");
- }
- if(!animation) {
- wholeScript.append(" .delay(0) \n ");
- }
- if(showControls) {
- wholeScript.append(" .showControls(true) \n ");
- } else if (!showControls){
- wholeScript.append(" .showControls(false) \n ");
- }
- if(stacked && !logScale)
- wholeScript.append(" .stacked(true)\n ");
- else if(!stacked || logScale)
- wholeScript.append(" .stacked(false)\n ");
- if(logScale) {
- wholeScript.append(" .logScale(true)\n ");
- } else {
- wholeScript.append(" .logScale(false)\n ");
- }
-
- if(AppUtils.nvl(reportRuntime.getLegendPosition()).length()>=0 && reportRuntime.getLegendPosition().equals("right")) {
- wholeScript.append(" .legendPos('right')\n" );
- } else {
- wholeScript.append(" .legendPos('top')\n" );
- }
- if(uniqueElements.length <= 10) {
- wholeScript.append(" .color(d3.scale.category10().range()); \n" +
- " chart.xAxis\n");
- } else if (uniqueElements.length <= 20) {
- wholeScript.append(" .color(d3.scale.category50().range()); \n" +
- " chart.xAxis\n");
- } else {
- wholeScript.append(" .color(d3.scale.category50().range()); \n" +
- " chart.xAxis\n");
-
- }
-
- if(flagNoDate == 0)
- wholeScript.append(" .tickValues(["+ dateStrBuf.toString() + "])\n ");
- else {
- wholeScript.append(" .tickValues(["+ dateStrBuf.toString() + "])\n ");
- }
- if(staggerLabels) {
- wholeScript.append(" .staggerLabels(true) \n");
- } else {
- wholeScript.append(" .staggerLabels(false) \n");
- }
- if(!horizontalBar) {
- if(showMaxMin) {
- wholeScript.append(" .showMaxMin(true) \n ");
- } else {
- wholeScript.append(" .showMaxMin(false) \n ");
- }
- }
- if(nvl(rotateLabels).length()>0) {
- wholeScript.append(" .rotateLabels("+ rotateLabels+ ") \n ");
- } else {
- wholeScript.append(" .rotateLabels(\"0\") \n ");
- }
- //wholeScript.append(" .axisLabel('" + legendColumnName + "')");
- if(flagNoDate == 1 || !timeAxis) {
- wholeScript.append(";\n");
- } else {
- wholeScript.append("\n .tickFormat(function(d) { \n");
- if(timeAxis) {
- if(formatFlag==HOURFLAG)
- wholeScript.append(" return d3.time.format('%x %H')(new Date(d)) }); \n");
- else if(formatFlag==MINFLAG)
- wholeScript.append(" return d3.time.format('%x %H:%M')(new Date(d)) }); \n");
- else if(formatFlag==SECFLAG)
- wholeScript.append(" return d3.time.format('%X')(new Date(d)) }); \n");
- else if(formatFlag==MONTHFLAG)
- wholeScript.append(" return d3.time.format('%b %y')(new Date(d)) }); \n");
- else
- wholeScript.append(" return d3.time.format('%x')(new Date(d)) }); \n");
-
- } else {
- wholeScript.append(" return d; }); \n");
- }
- }
-
- if(nvl(chartRightAxisLabel).length() > 0) {
- //if(flagNoDate == 1)
- wholeScript.append(" chart.yAxis\n");
- //else
- // wholeScript.append(" chart.yAxis1\n");
- if(logScale) {
- wholeScript.append(" .logScale(true)\n ");
- } else {
- wholeScript.append(" .logScale(false)\n ");
- }
-
- wholeScript.append(" .axisLabel('" + chartLeftAxisLabel + "') \n" +
- " .tickFormat(d3.format(',.0f')); \n");
- /*" chart.yAxis2\n " +
- " .axisLabel('" + chartRightAxisLabel + "') \n" +
- " .tickFormat(d3.format(',.0f')); \n");*/
-
-
- } else {
- //if(flagNoDate == 1)
- wholeScript.append(" chart.yAxis\n");
- //else
- // wholeScript.append(" chart.yAxis1\n");
- if(logScale) {
- wholeScript.append(" .logScale(true)\n ");
- } else {
- wholeScript.append(" .logScale(false)\n ");
- }
- wholeScript.append(" .axisLabel('" + chartLeftAxisLabel + "') \n");
-
- if(MAXDOUBLENUM <=5 && MAXNUMDECIMALPLACES == 0 ) MAXNUMDECIMALPLACES = 2;
- if( MAXNUMDECIMALPLACES >=3 ) MAXNUMDECIMALPLACES = 2;
- if(!logScale)
- wholeScript.append(" .tickFormat(d3.format(',."+MAXNUMDECIMALPLACES+"f')); \n");
- else
- wholeScript.append(" .tickFormat(d3.format(',." + precision + "f')); \n");
- //" .tickFormat(d3.format(',.0f')); \n");
- }
- wholeScript.append(" d3.select('#chart"+reportRuntime.getReportID()+" svg') \n" +
- " .datum(historicalBarChart) \n" );
- if(animation)
- wholeScript.append(" .transition().duration(1000) \n" );
- else
- wholeScript.append(" .transition().duration(0) \n" );
- wholeScript.append(" .call(chart); \n" +
- "nv.utils.windowResize(chart.update); \n" +
- "return chart; \n" +
- "}); \n");
- wholeScript.append("function redraw() { \n");
- //wholeScript.append(" nv.utils.windowResize(chart.update); \n");
- wholeScript.append(" d3.select('#chart"+reportRuntime.getReportID()+" svg') \n") ;
- wholeScript.append(" .datum(historicalBarChart) \n");
- wholeScript.append(" .transition().duration(500) \n");
- wholeScript.append(" .call(chart); \n");
- wholeScript.append("} \n");
- wholeScript.append("\n");
- wholeScript.append(" setInterval(function () { \n");
- wholeScript.append(" redraw(); \n");
- wholeScript.append(" }, 1500) \n");
-
- wholeScript.append("if(historicalBarChart.length <= 0 ) {\n");
- wholeScript.append(" document.getElementById(\"chart"+reportRuntime.getReportID()+"\").innerHTML = \"<div id='noData'><b>No Data Available</b></div>\";\n");
- wholeScript.append(" document.getElementById(\"chart"+reportRuntime.getReportID()+"\").className=\"nodatadiv\";\n");
- wholeScript.append(" document.getElementById(\"nodata\").className=\"nodatainner\";\n");
- wholeScript.append("}\n");
- wholeScript.append("</script> </body></html> \n");
-
- } else if (chartType.equals(AppConstants.GT_TIME_SERIES)) {
-
- // get category if not give the column name for the data column use this to develop series.
- boolean hasCategoryAxis = reportRuntime.hasSeriesColumn();
-
-
- final int YEARFLAG = 1;
- final int MONTHFLAG = 2;
- final int DAYFLAG = 3;
- final int HOURFLAG = 4;
- final int MINFLAG = 5;
- final int SECFLAG = 6;
- final int MILLISECFLAG = 7;
- final int DAYOFTHEWEEKFLAG = 8;
- final int FLAGDATE = 9;
-
- int flag = 0;
- flag = hasCategoryAxis?1:0;
- String uniqueElements [] = null;
- //TreeSet ts = new TreeSet();
- ArrayList ts = new ArrayList<String>();
- HashMap<String, String> columnMap = new HashMap();
- //check timeAxis
- String dateStr = null;
- java.util.Date date = null;
- if( ds.getRowCount() > 0) {
- dateStr = ds.getString(0, 1);
- if(!timeAxis) {
- date = getDateFromDateStr(dateStr);
- if(date!=null) {
- reportRuntime.setTimeAxis(true);
- timeAxis = reportRuntime.isTimeAxis();
-
-
- }
- }
- }
-
- ArrayList<String> ts1 = new ArrayList();
- ArrayList uniqueElementsList = new ArrayList();
- Object uniqueXAxisElements[] = null;
- String uniqueXAxisStr = "";
- if(!timeAxis){
- for (int i = 0; i < ds.getRowCount(); i++) {
- uniqueXAxisStr = ds.getString(i, 0);
- ts1.add(uniqueXAxisStr);
- }
- }
- uniqueElementsList.addAll(ts1);
- uniqueXAxisElements = ts1.toArray();
- //test start
- /* int TOTAL = 0;
- int VALUE = 0;
- int flagNull = 0;
- String KEY = "";
- String COLOR = "";
- TreeSet<String> colorList = new TreeSet<String>();
- for (int i = 0; i < ds.getRowCount(); i++) {
- VALUE = 0;
- try {
- VALUE = Integer.parseInt(ds.getString(i, 2));
- TOTAL = TOTAL+VALUE;
- } catch (NumberFormatException ex) {
- flagNull = 1;
- }
- KEY = ds.getString(i, 0);
- try {
- if(ds.getString(i, "chart_color")!=null) {
- colorList.add(KEY+"|"+ds.getString(i, "chart_color"));
- }
- } catch (ArrayIndexOutOfBoundsException ex) {
- System.out.println("No Chart Color");
- }
- wholeScript.append("{ \""+ "key" +"\":\""+ KEY+"\", \""+ "y" +"\":"+VALUE+"}, \n");
-
- }
- StringBuffer color = new StringBuffer("");
- if(colorList.size()>0) {
- SortedSet<String> s = Collections.synchronizedSortedSet(colorList);
- Object[] colorElements = (Object[]) s.toArray();
-
- String element = "";
-
- for (int i = 0; i < colorElements.length; i++) {
- element = ((String)colorElements[i]);
- color.append("'"+element.substring(element.indexOf("|")+1)+"',");
- }
- color.deleteCharAt(color.length()-1);
- }*/
-
- //test end
- boolean hasCustomizedChartColor = false;
- if(flag == 1) {
- StringBuffer catStr = new StringBuffer("");
- String color="";
- for (int i = 0; i < ds.getRowCount(); i++) {
- catStr = new StringBuffer("");
- catStr.append(ds.getString(i, 2));
- try {
- if(ds.getString(i, "chart_color")!=null) {
- color = ds.getString(i, "chart_color");
- hasCustomizedChartColor = true;
- catStr.append("|"+color);
- }
- } catch (ArrayIndexOutOfBoundsException ex) {
- //System.out.println("No Chart Color");
- }
-
- if(catStr.length()>0) {
- //duplicates are avoided
- if(!ts.contains(catStr.toString()))
- ts.add(catStr.toString());
-
- }
- }
- //Object uniqueElements [] = ts.toArray();
- //SortedSet s = Collections.synchronizedSortedSet(ts);
- //uniqueElements = (String[]) ts.toArray();
- DataColumnType dct = null;
- List yTextSeries = reportRuntime.getChartDisplayNamesList(AppConstants.CHART_ALL_COLUMNS, formValues);
- if(yTextSeries.size()==1) {
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- dct = (DataColumnType) iter.next();
- //System.out.println(dct.getDisplayName() + " " + yText);
- if(!(nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND))) {
- if(nvl(chartLeftAxisLabel).length()<=0) {
- chartLeftAxisLabel = nvl(dct.getYAxis());
- chartLeftAxisLabel = (chartLeftAxisLabel.indexOf("|")!=-1)?chartLeftAxisLabel.substring(0,chartLeftAxisLabel.indexOf("|")):"";
- }
- }
- }
- }
- Object tempArray[] = ts.toArray();
- uniqueElements = Arrays.copyOf(tempArray, tempArray.length, String[].class);
-
- } else {
- DataColumnType dct = null;
-
- List yTextSeries = reportRuntime.getChartDisplayNamesList(AppConstants.CHART_ALL_COLUMNS, formValues);
- //if(columnValuesList.size() == 1) {
- int dctIndex = 0;
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- dct = (DataColumnType) iter.next();
- //System.out.println(dct.getDisplayName() + " " + yText);
- if(!(nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND))) {
- if(yTextSeries.contains((String)dct.getDisplayName())) {
- if(nvl(dct.getChartColor()).length()>0) hasCustomizedChartColor = true;
- if(hasCustomizedChartColor) {
- //duplicates are avoided
- if(!ts.contains(dct.getDisplayName()+"|"+nvl(dct.getChartColor())))
- ts.add(dct.getDisplayName()+"|"+nvl(dct.getChartColor()));
- } else {
- //duplicates are avoided
- if(!ts.contains(dct.getDisplayName()))
- ts.add(dct.getDisplayName());
- }
- if(nvl(chartLeftAxisLabel).length()<=0) {
- chartLeftAxisLabel = nvl(dct.getYAxis());
- chartLeftAxisLabel = (chartLeftAxisLabel.indexOf("|")!=-1)?chartLeftAxisLabel.substring(0,chartLeftAxisLabel.indexOf("|")):"";
- }
- if(nvl(chartRightAxisLabel).length()>0) {
- String dctYAxis = nvl(dct.getYAxis());
- String yAxis = (dctYAxis.indexOf("|")!=-1)?dctYAxis.substring(0,dctYAxis.indexOf("|")):dctYAxis;
- if(chartRightAxisLabel.equals(yAxis)) {
- if(ts.contains(dct.getDisplayName())) {
- if(hasCustomizedChartColor) {
- ts.set(dctIndex, dct.getDisplayName()+"|R|"+nvl(dct.getChartColor()));
- } else {
- ts.set(dctIndex, dct.getDisplayName()+"|R");
- }
- }
- }
- }
- columnMap.put(dct.getDisplayName(), dct.getColId());
- }
- dctIndex++;
- }
-
- }
-
- //SortedSet s = Collections.synchronizedSortedSet(ts);
- Object tempArray[] = ts.toArray();
- uniqueElements = Arrays.copyOf(tempArray, tempArray.length, String[].class);
- //uniqueElements = (String[]) ts.toArray();
-
- }
-
- wholeScript.append("<!DOCTYPE html>\n");
- wholeScript.append("<html>\n");
- wholeScript.append("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF8\">\n");
- wholeScript.append("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n");
- wholeScript.append("<link href=\""+ AppUtils.getBaseFolderURL() +"d3/css/nv.d3.css\" rel=\"stylesheet\" type=\"text/css\">\n");
- wholeScript.append("<style>\n " +
- " body { \n" +
- " overflow-y:scroll; \n" +
- " } \n" +
- " text { \n" +
- " font: 12px sans-serif; \n" +
- " } \n" +
- " svg { \n" +
- " display: block;\n" +
- " } \n" +
- " #chart"+reportRuntime.getReportID()+" svg { \n" +
- " height: "+ (nvl(height).length()>0?(height.endsWith("px")?height:height+"px"):"420px") + "; \n" +
- " width: "+ (nvl(width).length()>0?(width.endsWith("px")?width:width+"px"):"700px") + "; \n" +
- " min-width: 100px; \n" +
- " min-height: 100px; \n" +
- " } \n" +
- " tr.z-row-over > td.z-row-inner, tr.z-row-over > .z-cell {" +
- " background-color: rgb(255, 255, 255); "+
- "}\n");
- wholeScript.append(".nodatadiv {\n");
- wholeScript.append(" display: table-cell;\n");
- wholeScript.append(" width: 700px;\n");
- wholeScript.append(" height:370px;\n");
- wholeScript.append(" text-align:center;\n");
- wholeScript.append(" vertical-align: middle;\n");
- wholeScript.append("}\n");
- wholeScript.append(".nodatainner {\n");
- wholeScript.append(" padding: 10px;\n");
- wholeScript.append("}\n");
-
- wholeScript.append(" </style> \n" );
-
- wholeScript.append("<body> \n");
-
- if(showTitle)
- wholeScript.append("<div align=\"center\"><H3>" + title +"</H3></div>");
-
-
- wholeScript.append("<div id=\"chart"+reportRuntime.getReportID()+"\"> <svg></svg> </div> \n");
- //js files
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/d3.v3.min.js\"></script>\n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/nv.d3.min.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/axis.min.js\"></script> \n");
- //wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/cumulativeLineChart.js\"></script> \n");
- //if(multipleSeries)
- //wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/multiChart.js\"></script> \n");
-
- //json
- wholeScript.append("<script> \n");
-
- wholeScript.append("historicalBarChart = [ \n");
- //wholeScript.append("{ \n");
- ArrayList dataSeries = new ArrayList();
- String uniqueElement = "";
-
- String [] uniqueRevElements = null;
- //Added to make sure order appears same as legend
- /*if(nvl(subType).length() > 0 && subType.equals("area")) {
- uniqueRevElements = reverse((String[])uniqueElements);
- } else {*/
- uniqueRevElements = (String[])uniqueElements;
- //}
-
- int RIGHTAXISSERIES = 0;
- for (int i = 0; i < uniqueRevElements.length; i++) {
- //element.substring(element.indexOf("|")+1)
- uniqueElement = (String)uniqueRevElements[i];
- if(multipleSeries && (nvl(chartRightAxisLabel).length() > 0)) {
- if(nvl(subType).length() > 0 && subType.equals("area")) {
- if(nvl(uniqueElement).indexOf("|R") !=-1)
- dataSeries.add(new StringBuffer(" { \"type\":\"line\", \"key\": \""+ ((uniqueElement.indexOf("|") != -1)?uniqueElement.substring(0, uniqueElement.indexOf("|")):uniqueElement) +"\", \"yAxis\": \""+(2)+"\", "+ (hasCustomizedChartColor && (uniqueElement.lastIndexOf("|") != -1) ?("\"color\": \""+uniqueElement.substring(uniqueElement.lastIndexOf("|")+1) + "\","):"")+" \"values\": ["));
- else
- dataSeries.add(new StringBuffer(" { \"type\":\"line\", \"key\": \""+ ((uniqueElement.indexOf("|") != -1)?uniqueElement.substring(0, uniqueElement.indexOf("|")):uniqueElement) +"\", \"yAxis\": \""+(1)+"\", "+ (hasCustomizedChartColor && (uniqueElement.lastIndexOf("|") != -1) ?("\"color\": \""+uniqueElement.substring(uniqueElement.lastIndexOf("|")+1) + "\","):"")+" \"values\": ["));
- } else {
- if(nvl(uniqueElement).indexOf("|R") !=-1)
- dataSeries.add(new StringBuffer(" { \"type\":\"line\", \"key\": \""+ ((uniqueElement.indexOf("|") != -1)?uniqueElement.substring(0, uniqueElement.indexOf("|")):uniqueElement) +"\", \"yAxis\": \""+(2)+"\","+ (hasCustomizedChartColor && (uniqueElement.lastIndexOf("|") != -1) ?("\"color\": \""+uniqueElement.substring(uniqueElement.lastIndexOf("|")+1) + "\","):"")+" \"values\": ["));
- else
- dataSeries.add(new StringBuffer(" { \"type\":\"line\", \"key\": \""+ ((uniqueElement.indexOf("|") != -1)?uniqueElement.substring(0, uniqueElement.indexOf("|")):uniqueElement) +"\", \"yAxis\": \""+(1)+"\","+ (hasCustomizedChartColor && (uniqueElement.lastIndexOf("|") != -1) ?("\"color\": \""+uniqueElement.substring(uniqueElement.lastIndexOf("|")+1) + "\","):"")+" \"values\": ["));
- }
- RIGHTAXISSERIES = dataSeries.size()-1;
- //dataSeries.add(new StringBuffer(" { \"type\":\"line\", \"key\": \""+ ((DataColumnType)columnMap.get(i)).getDisplayName() +"\", \"yAxis\": \""+(i+1)+"\", \"values\": ["));
- }
- else {
- dataSeries.add(new StringBuffer(" { \"type\":\"line\", \"key\": \""+ ((uniqueElement.indexOf("|")!= -1)?uniqueElement.substring(0, uniqueElement.indexOf("|")):uniqueElement) +"\", \"yAxis\": \""+(1)+"\","+ (hasCustomizedChartColor && (uniqueElement.lastIndexOf("|") != -1)?("\"color\": \""+uniqueElement.substring(uniqueElement.lastIndexOf("|")+1) + "\","):"")+"\"values\": ["));
- }
-
- }
- /*StringBuffer dataSeries1 = new StringBuffer("");
- dataSeries1.append(" { key: \"Series1\",values: [");
- StringBuffer dataSeries2 = new StringBuffer("");
- dataSeries2.append(" { key: \"Series2\", values: [");
- StringBuffer dataSeries3 = new StringBuffer("");
- dataSeries3.append(" { key: \"Series3\", values: [");
- */
-
-
- //long minTime = 1000000000000000L;
- int MAXNUM = 0;
- double MAXDOUBLENUM = 0.0;
- int YAXISNUM = 0;
- double YAXISDOUBLENUM = 0.0;
- int MAXNUMDECIMALPLACES = 0;
- int flagNull = 0;
- int flagSecondNull = 0;
- TreeSet dateList = new TreeSet();
- int formatFlag = 0;
- if(flag!= 1) {
- for (int j = 0; j < uniqueRevElements.length; j++) {
- for (int i = 0; i < ds.getRowCount(); i++) {
- flagNull = 0;
- flagSecondNull=0;
- YAXISNUM = 0;
- YAXISDOUBLENUM = 0.0;
- dateStr = "";
- date = null;
- dateStr = ds.getString(i, 1);
- if(timeAxis) {
- date = getDateFromDateStr(dateStr);
- formatFlag = getFlagFromDateStr(dateStr);
- }
- if(date==null && timeAxis) continue;
-
-
- //if(ds.getString(i, 2).equals(uniqueElements[j])) {
- //if(minTime > date.getTime())
- // minTime = date.getTime();
- uniqueElement = (String)uniqueRevElements[j];
- try {
- YAXISNUM = Integer.parseInt(ds.getString(i, columnMap.get(((hasCustomizedChartColor||nvl(chartRightAxisLabel).length()>0) && (uniqueElement.lastIndexOf("|") != -1)?uniqueElement.substring(0, uniqueElement.lastIndexOf("|")):uniqueElement))));
- if(MAXDOUBLENUM < YAXISNUM) MAXDOUBLENUM = YAXISNUM;
- } catch (NumberFormatException ex) {
- try {
- YAXISDOUBLENUM = Double.parseDouble(ds.getString(i, columnMap.get(((hasCustomizedChartColor||nvl(chartRightAxisLabel).length()>0) && (uniqueElement.lastIndexOf("|") != -1) ?uniqueElement.substring(0, uniqueElement.lastIndexOf("|")):uniqueElement))));
- if(RIGHTAXISSERIES!=j) {
- MAXNUMDECIMALPLACES = getNumberOfDecimalPlaces(YAXISDOUBLENUM);
- if(MAXDOUBLENUM < YAXISDOUBLENUM) MAXDOUBLENUM = YAXISDOUBLENUM;
- }
- } catch (NumberFormatException ex1) {
- flagNull = 1;
- }
- }
-
- if(date==null) {
- dateList.add(dateStr);
- ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":\"" + dateStr + "\" , \"y\":" + (flagNull==0?(YAXISDOUBLENUM>0?YAXISDOUBLENUM:YAXISNUM):null) +"}, ");
- } else {
- dateList.add(new Long(date.getTime()).toString());
- ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + date.getTime() + " , \"y\":" + (flagNull==0?(YAXISDOUBLENUM>0?YAXISDOUBLENUM:YAXISNUM):null) +"}, ");
- }
-
-
-
- if(nvl(subType).length() > 0 && subType.equals("area")) {
-
- if(flagNull!=1) {
- if(i<ds.getRowCount()-1) {
- try {
- YAXISNUM = Integer.parseInt(ds.getString(i+1, columnMap.get(((hasCustomizedChartColor||nvl(chartRightAxisLabel).length()>0) && (uniqueElement.lastIndexOf("|") != -1)?uniqueElement.substring(0, uniqueElement.lastIndexOf("|")):uniqueElement))));
- if(MAXDOUBLENUM < YAXISNUM) MAXDOUBLENUM = YAXISNUM;
- } catch (NumberFormatException ex) {
- try {
- YAXISDOUBLENUM = Double.parseDouble(ds.getString(i+1, columnMap.get(((hasCustomizedChartColor||nvl(chartRightAxisLabel).length()>0) && (uniqueElement.lastIndexOf("|") != -1) ?uniqueElement.substring(0, uniqueElement.lastIndexOf("|")):uniqueElement))));
- if(RIGHTAXISSERIES!=j) {
- MAXNUMDECIMALPLACES = getNumberOfDecimalPlaces(YAXISDOUBLENUM);
- if(MAXDOUBLENUM < YAXISDOUBLENUM) MAXDOUBLENUM = YAXISDOUBLENUM;
- }
- } catch (NumberFormatException ex1) {
- flagSecondNull = 1;
- }
- }
-
- if(flagSecondNull==1 && date == null) {
- ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":\"" + dateStr + "\" , \"y\":" + null +"}, ");
- } else if( flagSecondNull == 1){
- ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + date.getTime() + " , \"y\":" + null +"}, ");
- }
- }
- } else {
- if(i<ds.getRowCount()-1) {
- dateStr = ds.getString(i+1, 1);
-
- if(!timeAxis) {
- ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":\"" + dateStr + "\" , \"y\":" + null +"}, ");
- } else {
- date = getDateFromDateStr(dateStr);
- ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + date.getTime() + " , \"y\":" + null +"}, ");
- }
- //((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + date.getTime() + " , \"y\":" + null +"}, ");
- }
- }
-
- }
-
-
- //}
- }
- //((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + minTime + " , \"y\":" + 0 +"}, ");
- }
-
- } else {
- for (int j = 0; j < uniqueRevElements.length; j++) {
- for (int i = 0; i < ds.getRowCount(); i++) {
- YAXISNUM = 0;
- YAXISDOUBLENUM = 0.0;
- flagNull= 0;
- flagSecondNull = 0;
- dateStr = ds.getString(i, 1);
- if(timeAxis) {
- date = getDateFromDateStr(dateStr);
- formatFlag = getFlagFromDateStr(dateStr);
- }
-
- if(date==null && timeAxis) continue;
-
- uniqueElement = (String)uniqueRevElements[j];
- //date = MMDDYYYYFormat.parse(ds.getString(i, 1), new ParsePosition(0));
- if(ds.getString(i, 2).equals(((hasCustomizedChartColor||nvl(chartRightAxisLabel).length()>0) && (uniqueElement.lastIndexOf("|") != -1) ?uniqueElement.substring(0, uniqueElement.lastIndexOf("|")):uniqueElement))) {
- //if(minTime > date.getTime())
- // minTime = date.getTime();
- try {
- YAXISNUM = Integer.parseInt(ds.getString(i, 3));
- if(MAXDOUBLENUM < YAXISNUM) MAXDOUBLENUM = YAXISNUM;
- } catch (NumberFormatException ex) {
- try {
- YAXISDOUBLENUM = Double.parseDouble(ds.getString(i, 3));
- if(RIGHTAXISSERIES!=j) {
- MAXNUMDECIMALPLACES = getNumberOfDecimalPlaces(YAXISDOUBLENUM);
- if(MAXDOUBLENUM < YAXISDOUBLENUM) MAXDOUBLENUM = YAXISDOUBLENUM;
-
- }
- } catch (NumberFormatException ex1) {
- flagNull = 1;
- }
- }
-
- if(date==null) {
- dateList.add(dateStr);
- ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + dateStr + " , \"y\":" + (flagNull==0?(YAXISDOUBLENUM!=0.0?YAXISDOUBLENUM:YAXISNUM):null) +"}, ");
- } else {
- dateList.add(new Long(date.getTime()).toString());
- ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + date.getTime() + " , \"y\":" + (flagNull==0?(YAXISDOUBLENUM!=0.0?YAXISDOUBLENUM:YAXISNUM):null) +"}, ");
- }
-
-
- if(nvl(subType).length() > 0 && subType.equals("area")) {
-
- if(flagNull!=1) {
- if(i<ds.getRowCount()-1) {
- for (int k = i+1; k < ds.getRowCount(); k++) {
- if (ds.getString(k, 2).equals(((hasCustomizedChartColor||nvl(chartRightAxisLabel).length()>0) && (uniqueElement.lastIndexOf("|") != -1) ?uniqueElement.substring(0, uniqueElement.lastIndexOf("|")):uniqueElement))) {
- try {
- YAXISNUM = Integer.parseInt(ds.getString(k, 3));
- if(MAXDOUBLENUM < YAXISNUM) MAXDOUBLENUM = YAXISNUM;
- } catch (NumberFormatException ex) {
- try {
- YAXISDOUBLENUM = Double.parseDouble(ds.getString(k, 3));
- if(RIGHTAXISSERIES!=j) {
- MAXNUMDECIMALPLACES = getNumberOfDecimalPlaces(YAXISDOUBLENUM);
- if(MAXDOUBLENUM < YAXISDOUBLENUM) MAXDOUBLENUM = YAXISDOUBLENUM;
- }
- } catch (NumberFormatException ex1) {
- flagSecondNull = 1;
- }
- }
- break;
- }
- }
-
- if(date==null && flagSecondNull==1){
- ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + dateStr + " , \"y\":" + null +"}, ");
- } else if(flagSecondNull == 1){
- ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + date.getTime() + " , \"y\":" + null +"}, ");
- }
- //}
- }
- } else {
- if(i<ds.getRowCount()-1) {
- for (int k = i+1; k < ds.getRowCount(); k++) {
- if (ds.getString(k, 2).equals(((hasCustomizedChartColor||nvl(chartRightAxisLabel).length()>0) && (uniqueElement.lastIndexOf("|") != -1) ?uniqueElement.substring(0, uniqueElement.lastIndexOf("|")):uniqueElement))) {
- dateStr = ds.getString(k, 1);
- if(!timeAxis) {
- ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + date.getTime() + " , \"y\":" + null +"}, ");
- break;
- } else {
- date = getDateFromDateStr(dateStr);
- ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + date.getTime() + " , \"y\":" + null +"}, ");
- break;
- }
- }
- }
- }
- }
- }
-
- }
- }
- // ((StringBuffer) dataSeries.get(j)).append ("{ \"x\":" + minTime + " , \"y\":" + 0 +"}, ");
-
- }
-/* if(ds.getString(i, 2).equals("Series1")) {
- dataSeries1.append("[ " + date.getTime() + " , " + ds.getString(i, 3) +"], ");
- } else if (ds.getString(i, 2).equals("Series2")) {
- dataSeries2.append("[ " + date.getTime() + " , " + ds.getString(i, 3) +"], ");
- } else if (ds.getString(i, 2).equals("Series3")) {
- dataSeries3.append("[ " + date.getTime() + " , " + ds.getString(i, 3) +"], ");
- }
-*/ }
-
- for (int i = 0; i < uniqueRevElements.length; i++) {
- StringBuffer strBuf = ((StringBuffer) dataSeries.get(i));
- ((StringBuffer) dataSeries.get(i)).deleteCharAt(((StringBuffer) dataSeries.get(i)).lastIndexOf(","));
- if(i < (uniqueRevElements.length -1) ) {
- ((StringBuffer) dataSeries.get(i)).append("] } , \n");
- }
- else {
- ((StringBuffer) dataSeries.get(i)).append("] } \n");
- }
- }
-
- for (int i = 0; i < uniqueRevElements.length; i++) {
- wholeScript.append((StringBuffer)dataSeries.get(i));
- }
-/* wholeScript.append(dataSeries1);
- wholeScript.append(dataSeries2);
- wholeScript.append(dataSeries3);
-*/ wholeScript.append("];\n");
-
- /* Sorting is commented out.*/
- StringBuffer dateStrBuf = new StringBuffer("");
- if(dateList.size()>0) {
- //SortedSet<String> s = Collections.synchronizedSortedSet(dateList);
- Object[] dateElements = (Object[]) dateList.toArray();
-
- String element = "";
-
- for (int i = 0; i < dateElements.length; i++) {
- dateStrBuf.append(dateElements[i]+",");
- }
- dateStrBuf.deleteCharAt(dateStrBuf.length()-1);
- }
-
- wholeScript.append(" var chart;\n");
- wholeScript.append("nv.addGraph(function() { \n");
- //" var chart = nv.models.cumulativeLineChart() \n" + nv.models.lineWithFocusChart()
-// " chart = nv.models.lineChart() \n" +
- if(nvl(subType).length() > 0 && subType.equals("area")) {
- wholeScript.append(" chart = nv.models.stackedAreaChart() \n");
- if(showControls) {
- wholeScript.append(" .showControls(true) \n ");
- } else {
- wholeScript.append(" .showControls(false) \n ");
- }
- } else {
- wholeScript.append(" chart = nv.models.multiChart() \n");
- if(nvl(chartRightAxisLabel).length() > 0) {
- wholeScript.append(" .dualaxis(true) \n ");
- } else {
- wholeScript.append(" .dualaxis(false) \n ");
- }
-
- if(AppUtils.nvl(reportRuntime.getLegendPosition()).length()>=0 && reportRuntime.getLegendPosition().equals("right")) {
- wholeScript.append(" .legendPos('right')\n" );
- } else {
- wholeScript.append(" .legendPos('top')\n" );
- }
-
-
- }
-
- wholeScript.append(" .margin({top: "+ topMargin +", right: "+ rightMargin +", bottom: "+ bottomMargin +", left: " + leftMargin +"}) \n");
- if(showLegend) {
- wholeScript.append(" .showLegend(true) \n ");
- } else {
- wholeScript.append(" .showLegend(false) \n ");
- }
-
- if(nvl(subType).length() > 0 && subType.equals("area")) {
- if( MAXNUMDECIMALPLACES >=3 ) {
- wholeScript.append(" .yAxisTooltipFormat(d3.format(',.3f')) \n");
- } else {
- wholeScript.append(" .yAxisTooltipFormat(d3.format(',."+MAXNUMDECIMALPLACES+ "f')) \n");
- }
-
- wholeScript.append(".x (function(d) {return d.x;}) \n" +
- ".y (function(d) {return d.y;}) \n");
- }
-
- //" .x(function(d) { return d[0] }) \n" +
- //" .y(function(d) { return d[1] }) \n" +
- //" .forceY("+(nvl(reportRuntime.getRangeAxisLowerLimit()).length()<=0?"0":reportRuntime.getRangeAxisLowerLimit()) +", "+ Math.ceil((MAXNUM+(MAXNUM*25/100))/100) * 100 + ") \n" + // reportRuntime.getRangeAxisUpperLimit()+") \n" +
- wholeScript.append(" .color(d3.scale.category10().range()); \n");
- if(!(nvl(subType).length() > 0 && subType.equals("area"))) {
- double UPPER_RANGE = 0;
- if(Math.ceil((MAXDOUBLENUM+(MAXDOUBLENUM*25/100))/100) * 100 >= 1) {
- UPPER_RANGE = Math.ceil(MAXDOUBLENUM+(MAXDOUBLENUM*25/100));
- } else UPPER_RANGE = 1;
-
- wholeScript.append(" chart.lines1.forceY(["+(nvl(reportRuntime.getRangeAxisLowerLimit()).length()<=0?"0":reportRuntime.getRangeAxisLowerLimit()) +", "+ (nvl(reportRuntime.getRangeAxisUpperLimit()).length()<=0?UPPER_RANGE:reportRuntime.getRangeAxisUpperLimit()) + "]); \n" +
- " chart.lines2.forceY([0,1]); \n");
- }
- wholeScript.append(" chart.xAxis\n");
- if(reportRuntime.isShowXaxisLabel()) {
- // X axis label is commented for time-being. This should be derived from request parameter.
- //" .axisLabel('" + legendColumnName + "') \n" +
- wholeScript.append(" .axisLabel('" + legendColumnName + "') \n");
- } else {
- wholeScript.append(" .axisLabel('') \n");
- }
- if(reportRuntime.isAddXAxisTickers()) {
- wholeScript.append(" .tickValues(["+ dateStrBuf.toString()+ "])\n ");
- } else {
- //wholeScript.append(" .tickValues([])\n ");
- }
- if(staggerLabels) {
- wholeScript.append(" .staggerLabels(true) \n");
- } else {
- wholeScript.append(" .staggerLabels(false) \n");
- }
- if(showMaxMin) {
- wholeScript.append(" .showMaxMin(true) \n ");
- } else {
- wholeScript.append(" .showMaxMin(false) \n ");
- }
-
- if(nvl(rotateLabels).length()>0) {
- wholeScript.append(" .rotateLabels("+ rotateLabels+ ") \n ");
- } else {
- wholeScript.append(" .rotateLabels(\"0\") \n ");
- }
-
- wholeScript.append(" .tickFormat(function(d) { \n");
- if(formatFlag==HOURFLAG)
- wholeScript.append(" return d3.time.format('%x %H')(new Date(d)) }); \n");
- else if(formatFlag==MINFLAG)
- wholeScript.append(" return d3.time.format('%x %H:%M')(new Date(d)) }); \n");
- else if(formatFlag==SECFLAG)
- wholeScript.append(" return d3.time.format('%x %X')(new Date(d)) }); \n");
- else if(formatFlag==MONTHFLAG)
- wholeScript.append(" return d3.time.format('%b %y')(new Date(d)) }); \n");
-
- else if(timeAxis)
- wholeScript.append(" return d3.time.format('%x')(new Date(d)) }); \n");
- else
- wholeScript.append(" return d; }); \n");
- if(nvl(chartRightAxisLabel).length() > 0) {
- if(nvl(subType).length() > 0 && subType.equals("area")) {
- wholeScript.append(" chart.yAxis\n");
- } else {
- wholeScript.append(" chart.yAxis1\n");
- }
- wholeScript.append(" .axisLabel('" + chartLeftAxisLabel + "') \n");
- //if(nvl(subType).length() > 0 && subType.equals("area")) {
- if(MAXDOUBLENUM <=5 && MAXNUMDECIMALPLACES == 0 ) MAXNUMDECIMALPLACES = 2;
- if( MAXNUMDECIMALPLACES >=3 ) MAXNUMDECIMALPLACES = 2;
- wholeScript.append(" .tickFormat(d3.format(',."+MAXNUMDECIMALPLACES+"f')); \n");
- /*} else {
- wholeScript.append(" .tickFormat(d3.format(',.2f')); \n");
- }*/
- // " .tickFormat(function (d) {return d;} ); \n");
- //" .tickFormat(function(d) {if (d >= 1000) return Math.round(d/1000)+\"K\"; else return d;}); \n");
- if(!(nvl(subType).length() > 0 && subType.equals("area"))) {
- wholeScript.append(" chart.yAxis2\n " +
- " .axisLabel('" + chartRightAxisLabel + "') \n" +
- " .tickFormat(d3.format(',.02f')); \n");
- //" .tickFormat(function(d) {if (d >= 1000) return Math.round(d/1000)+\"K\"; else return d;}); \n");
- //" .tickFormat(function(d) {if( d <= 1) return Math.round(d*100)+\"%\"; else return d;}); \n");
- // " .tickFormat(function(d) { return d;}); \n");
- }
-
-
- } else {
- if(nvl(subType).length() > 0 && subType.equals("area")) {
- wholeScript.append(" chart.yAxis\n");
- } else {
- wholeScript.append(" chart.yAxis1\n");
- }
- wholeScript.append(" .axisLabel('" + chartLeftAxisLabel + "') \n");
- //if(nvl(subType).length() > 0 && subType.equals("area")) {
- if(MAXDOUBLENUM <=5 && MAXNUMDECIMALPLACES == 0 ) MAXNUMDECIMALPLACES = 2;
- if( MAXNUMDECIMALPLACES >=3 ) {
- MAXNUMDECIMALPLACES = 2;
- }
- wholeScript.append(" .tickFormat(d3.format(',."+MAXNUMDECIMALPLACES+"f')); \n");
- /*} else {
- wholeScript.append(" .tickFormat(d3.format(',.2f')); \n");
- }*/
- //" .tickFormat(function(d) {if (d >= 1000) return Math.round(d/1000)+\"K\"; else return d;}); \n");
- }
- wholeScript.append(" d3.select('#chart"+reportRuntime.getReportID()+" svg') \n" +
- " .datum(historicalBarChart) \n" );
- if(animation)
- wholeScript.append(" .transition().duration(1000) \n" );
- wholeScript.append(" .call(chart); \n" +
- "nv.utils.windowResize(chart.update); \n" +
- "return chart; \n" +
- "}); \n");
-
- wholeScript.append("function redraw() { \n");
- //wholeScript.append(" nv.utils.windowResize(chart.update); \n");
- wholeScript.append(" d3.select('#chart"+reportRuntime.getReportID()+" svg') \n") ;
- wholeScript.append(" .datum(historicalBarChart) \n");
- wholeScript.append(" .transition().duration(500) \n");
- wholeScript.append(" .call(chart); \n");
- wholeScript.append("} \n");
- wholeScript.append("\n");
- wholeScript.append(" setInterval(function () { \n");
- wholeScript.append(" redraw(); \n");
- wholeScript.append(" }, 1500) \n");
-
- wholeScript.append("if(historicalBarChart.length <= 0 ) {\n");
- wholeScript.append(" document.getElementById(\"chart"+reportRuntime.getReportID()+"\").innerHTML = \"<div id='noData'><b>No Data Available</b></div>\";\n");
- wholeScript.append(" document.getElementById(\"chart"+reportRuntime.getReportID()+"\").className=\"nodatadiv\";\n");
- wholeScript.append(" document.getElementById(\"nodata\").className=\"nodatainner\";\n");
- wholeScript.append("}\n");
-
- wholeScript.append("</script> </body> </html> \n");
-
- } else if (chartType.equals(AppConstants.GT_PIE) || chartType.equals(AppConstants.GT_PIE_3D)) {
- wholeScript.append("<!DOCTYPE html>\n");
- wholeScript.append("<html>\n");
- wholeScript.append("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF8\">\n");
- wholeScript.append("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n");
- wholeScript.append("<link href=\""+ AppUtils.getBaseFolderURL() +"d3/css/nv.d3.css\" rel=\"stylesheet\" type=\"text/css\">\n");
- wholeScript.append("<style>\n " +
- " body { \n" +
- " overflow-y:scroll; \n" +
- " } \n" +
- " text { \n" +
- " font: 12px sans-serif; \n" +
- " } \n" +
- " tr.z-row-over > td.z-row-inner, tr.z-row-over > .z-cell {" +
- " background-color: rgb(255, 255, 255); "+
- "} "+
- " svg { display: block; } " +
- " #chart"+reportRuntime.getReportID()+" svg { \n" +
- " height: "+ (nvl(height).length()>0?(height.endsWith("px")?height:height+"px"):"420px") + "; \n" +
- " width: "+ (nvl(width).length()>0?(width.endsWith("px")?width:width+"px"):"700px") + "; \n" +
- " min-width: 100px; \n" +
- " min-height: 100px; \n" +
- " } \n" +
- " </style> \n" );
- wholeScript.append("<body> \n");
-
- if(showTitle)
- wholeScript.append("<div align=\"center\"><H3>" + title +"</H3></div>");
-
- wholeScript.append("<div id=\"chart"+reportRuntime.getReportID()+"\"><svg></svg></div>");
- //"<svg id=\"test2\"></svg>\n");
- //js files
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/d3.v3.min.js\"></script>\n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/nv.d3.min.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/legend.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/pie.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/pieChart.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/utils.js\"></script> \n");
- wholeScript.append("<script> \n");
-
- wholeScript.append("historicalBarChart = [ \n");
- double TOTAL = 0;
- double VALUE = 0;
- int flagNull = 0;
- String KEY = "";
- String COLOR = "";
- TreeSet<String> colorList = new TreeSet<String>();
- for (int i = 0; i < ds.getRowCount(); i++) {
- VALUE = 0;
- try {
- VALUE = Double.parseDouble(ds.getString(i, 2));
- TOTAL = TOTAL+VALUE;
- } catch (NumberFormatException ex) {
- flagNull = 1;
- }
- KEY = ds.getString(i, 0);
- try {
- if(ds.getString(i, "chart_color")!=null) {
- colorList.add(KEY+"|"+ds.getString(i, "chart_color"));
- }
- } catch (ArrayIndexOutOfBoundsException ex) {
- //System.out.println("No Chart Color");
- }
- wholeScript.append("{ \""+ "key" +"\":\""+ KEY+"\", \""+ "y" +"\":"+VALUE+"}, \n");
-
- }
- StringBuffer color = new StringBuffer("");
- if(colorList.size()>0) {
- SortedSet<String> s = Collections.synchronizedSortedSet(colorList);
- Object[] colorElements = (Object[]) s.toArray();
-
- String element = "";
-
- for (int i = 0; i < colorElements.length; i++) {
- element = ((String)colorElements[i]);
- color.append("'"+element.substring(element.lastIndexOf("|")+1)+"',");
- }
- color.deleteCharAt(color.length()-1);
- }
-
- wholeScript.append("];\n");
-
-
- wholeScript.append("var chart; \n");
- wholeScript.append("nv.addGraph(function() { \n" +
- " var width1= 700, height1=720; \n" +
- " chart = nv.models.pieChart() \n" +
- " .margin({top: "+ topMargin +", right: "+ rightMargin +", bottom: "+ bottomMargin +", left: " + leftMargin +"}) \n" +
-
- //" .x(function(d) { return d.key +\" \"+ Math.round(d.y/"+TOTAL+" *100) + \"%\" }) \n" +
- " .x(function(d) { return d.key }) \n" +
- " .y(function(d) { return d.y }) \n");
- if(colorList.size()>0) {
- wholeScript.append(" .color(["+ color.toString() + "] ) \n");
- }
- //wholeScript.append(" .values(function(d) { return d }) \n");
- //" .color(d3.scale.category10().range()); \n" +
- if(showLegend) {
- wholeScript.append(" chart.showLegend(true);\n ");
- } else {
- wholeScript.append(" chart.showLegend(false);\n ");
- }
-
- //wholeScript.append("chart.showLegend(false);\n" +
- //" .width(width1) \n" +
- //" .height(height1); \n" +
- wholeScript.append(" d3.select('#chart"+reportRuntime.getReportID()+" svg') \n" +
- " .datum(historicalBarChart) \n");
- if(animation)
- wholeScript.append(" .transition().duration(1200) \n" );
-/* " .attr(\"width\", width1) \n" +
- " .attr(\"height\", height1) \n" +
-*/ wholeScript.append(" .call(chart); \n" +
- " nv.utils.windowResize(chart.update);\n"+
- "return chart; \n" +
- "}); \n");
-
- wholeScript.append("function redraw() { \n");
- //wholeScript.append(" nv.utils.windowResize(chart.update); \n");
- wholeScript.append(" d3.select('#chart"+reportRuntime.getReportID()+" svg') \n") ;
- wholeScript.append(" .datum(historicalBarChart) \n");
- wholeScript.append(" .transition().duration(500) \n");
- wholeScript.append(" .call(chart); \n");
- wholeScript.append("} \n");
- wholeScript.append("\n");
- wholeScript.append(" setInterval(function () { \n");
- wholeScript.append(" redraw(); \n");
- wholeScript.append(" }, 1500) \n");
-
-
-
- wholeScript.append("if(historicalBarChart.length <= 0 ) {\n");
- wholeScript.append(" document.getElementById(\"chart"+reportRuntime.getReportID()+"\").innerHTML = \"<div id='noData'><b>No Data Available</b></div>\";\n");
- wholeScript.append(" document.getElementById(\"chart"+reportRuntime.getReportID()+"\").className=\"nodatadiv\";\n");
- wholeScript.append(" document.getElementById(\"nodata\").className=\"nodatainner\";\n");
- wholeScript.append("}\n");
-
- wholeScript.append("</script> </body> </html> \n");
-
- } else if (chartType.equals(AppConstants.GT_ANNOTATION_CHART) || chartType.equals(AppConstants.GT_FLEX_TIME_CHARTS)) {
-
- boolean timeCharts = chartType.equals(AppConstants.GT_FLEX_TIME_CHARTS);
-
- String dateStr = null;
- java.util.Date date = null;
-
- final int YEARFLAG = 1;
- final int MONTHFLAG = 2;
- final int DAYFLAG = 3;
- final int HOURFLAG = 4;
- final int MINFLAG = 5;
- final int SECFLAG = 6;
- final int MILLISECFLAG = 7;
- final int DAYOFTHEWEEKFLAG = 8;
- final int FLAGDATE = 9;
-
- int flagNoDate = 0;
-
- int MAXNUM = 0;
- int YAXISNUM = 0;
- int flagNull = 0;
-
- double YAXISDOUBLENUM = 0.0;
- double MAXDOUBLENUM = 0.0;
- int MAXNUMDECIMALPLACES = 0;
-
- int formatFlag = 0;
-
- TreeSet<String> dateStrList = new TreeSet<String>();
- // added to store all date elements
- SortedSet<String> sortSet = new TreeSet<String>();
- int count = 0;
-
- int flag = 0;
- boolean hasCategoryAxis = reportRuntime.hasSeriesColumn();
- flag = hasCategoryAxis?1:0;
-
-
- String anomalyText = "";
-
- StringBuffer dataStrBuf = new StringBuffer("");
- StringBuffer annotationsStrBuf = new StringBuffer("");
-
- String xAxisLabel = (reportRuntime.getChartLegendColumn()!=null)?reportRuntime.getChartLegendColumn().getDisplayName():"";
-
- //finding actual string
- String actualText = "";
- DataColumnType dct = null;
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- dct = (DataColumnType) iter.next();
- if((dct.getChartSeq()!=null && dct.getChartSeq() >=0) && !AppUtils.nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND)) {
- //if(AppUtils.nvl(dct.getDisplayName()).toLowerCase().contains("actual")) {
- actualText = dct.getDisplayName();
- break;
- //}
- }
- }
-
- int anomalyRec = 0;
- int columnIndex = 1;
- ArrayList columnNames = new ArrayList();
- ArrayList columnValues = new ArrayList();
- Set set = null;
- String columnName = "";
- String columnValue = "";
- long minDate = 0L;
- long maxDate = 0L;
- StringBuffer seriesBuffer = new StringBuffer("");
-
- for (int i = 0; i < ds.getRowCount(); i++) {
- columnNames = new ArrayList();
- columnValues = new ArrayList();
- columnName = "";
- columnValue = "";
- columnIndex = 1;
- anomalyText = "";
- dateStr = ds.getString(i, 0);
- date = getDateFromDateStr(dateStr);
- if(date.getTime() > maxDate )
- maxDate = date.getTime();
-
- formatFlag = getFlagFromDateStr(dateStr);
-
-
- for (;columnIndex<ds.getColumnCount();columnIndex++) {
- columnName = ds.getColumnName(columnIndex);
- if(!timeCharts && !columnName.toLowerCase().equals("anomaly_text")) {
- columnNames.add(columnName);
- columnValues.add(AppUtils.nvls(ds.getString(i, columnIndex), "null"));
- } else if (timeCharts) {
- columnNames.add(columnName);
- columnValues.add(AppUtils.nvls(ds.getString(i, columnIndex), "null"));
- }
- }
-/* actual = ds.getString(i, "actual");
- //forecast = ds.getString(i, "forecast");
- upperBound = ds.getString(i, "upperBound");
- lowerBound = ds.getString(i, "lowerBound");
-
-*/ if(!timeCharts)
- anomalyText = ds.getString(i, "anomaly_text");
- //dataStrBuf.append(" [new Date(moment(\""+dateStr+"\")),"+ actual /*+","+ forecast*/+","+ lowerBound +","+ upperBound +"],\n");
- dataStrBuf.append(" [new Date(moment(\""+dateStr+"\"))");
- for(int c=0; c< columnNames.size(); c++ ) {
- columnName = (String) columnNames.get(c);
- columnValue = (String) columnValues.get(c);
- for (Iterator iter1 = l.iterator(); iter1.hasNext();) {
- dct = (DataColumnType) iter1.next();
- if((dct.getChartSeq()!=null && dct.getChartSeq() >=0) && !AppUtils.nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND)) {
- if((!timeCharts && !AppUtils.nvl(dct.getColId()).toLowerCase().equals("anomaly_text")) && AppUtils.nvl(dct.getColId()).toLowerCase().equals(columnName.toLowerCase())) {
- dataStrBuf.append(","+columnValue);
- break;
- } else if(timeCharts && AppUtils.nvl(dct.getColId()).toLowerCase().equals(columnName.toLowerCase())){
- dataStrBuf.append(","+columnValue);
- //break;
- }
- }
- }
- }
-
- dataStrBuf.append("],\n");
- if(!timeCharts) {
- if(AppUtils.nvl(anomalyText).length()>0) {
- ++anomalyRec;
- annotationsStrBuf.append("anns.push( {\n");
- annotationsStrBuf.append(" series: '"+actualText+"',\n");
- annotationsStrBuf.append(" x: moment(\""+dateStr+"\"),\n");
- annotationsStrBuf.append(" shortText: '"+ IntToLetter(anomalyRec).toUpperCase() +"',\n");
- annotationsStrBuf.append(" text: '"+ anomalyText + "'\n");
- annotationsStrBuf.append("});\n");
- //anomalyRec++;
- }
-
- }
- }
-
- //if(!timeCharts)
- //anomalyRec = anomalyRec - 1;
-
- minDate = maxDate - (new Long(reportRuntime.getZoomIn()).longValue()*60*60*1000);
- System.out.println(new java.util.Date(maxDate) + " " + new java.util.Date(minDate) + " " + reportRuntime.getZoomIn());
- if(dataStrBuf.lastIndexOf(",")!= -1)
- dataStrBuf.deleteCharAt(dataStrBuf.lastIndexOf(","));
-
- wholeScript = new StringBuffer("");
- wholeScript.append("<!DOCTYPE html>\n");
- wholeScript.append("<html>\n");
- wholeScript.append(" <head>\n");
- //wholeScript.append("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7; IE=EmulateIE9\">\n");
- wholeScript.append("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n");
- wholeScript.append("<script type=\"text/javascript\" src=\""+ AppUtils.getBaseFolderURL() +"dy3/js/dygraph-combined.js\"></script>\n");
- wholeScript.append("<script type=\"text/javascript\" src=\""+ AppUtils.getBaseFolderURL() +"dy3/js/moment.min.js\"></script>\n");
- wholeScript.append("<script type=\"text/javascript\" src=\""+ AppUtils.getBaseFolderURL() +"dy3/js/interaction.min.js\"></script>\n");
-
- wholeScript.append("<script type=\"text/javascript\">\n");
- if(AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("30min")) {
- wholeScript.append("var click=2;\n");
- } else if (AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("hourly")) {
- wholeScript.append("var click=3;\n");
- } else if (AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("daily")) {
- wholeScript.append("var click=3;\n");
- } else
- wholeScript.append("var click=3;\n");
- //wholeScript.append(" var click=0;\n");
- wholeScript.append(" function downV3(event, g, context) { \n");
- wholeScript.append(" context.initializeMouseDown(event, g, context); \n");
- wholeScript.append(" if (event.altKey || event.shiftKey) { \n");
- wholeScript.append(" var minDate = g.xAxisRange()[0]; \n");
- wholeScript.append(" var maxDate = g.xAxisRange()[1]; \n");
- if(AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("daily")) {
- wholeScript.append(" if(((maxDate-minDate)/(1000*60*60*24)) > 6) \n");
- wholeScript.append(" Dygraph.startZoom(event, g, context); \n");
- } else if(AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("hourly")) {
- wholeScript.append(" if(((maxDate-minDate)/(1000*60*60)) > 6) \n");
- wholeScript.append(" Dygraph.startZoom(event, g, context); \n");
- } else if(AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("30min")) {
- wholeScript.append(" if(((maxDate-minDate)/(1000*60*60*2)) > 6) \n");
- wholeScript.append(" Dygraph.startZoom(event, g, context); \n");
-
- } else {
- wholeScript.append(" if(((maxDate-minDate)/(1000*60*60)) > 6) \n");
- wholeScript.append(" Dygraph.startZoom(event, g, context); \n");
- }
- if(AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("30min")) {
- wholeScript.append(" click=2;\n");
- } else if (AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("hourly")) {
- wholeScript.append(" click=3;\n");
- } else if (AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("daily")) {
- wholeScript.append(" click=3;\n");
- } else
- wholeScript.append(" click=3;\n");
- wholeScript.append(" } else if (event.ctrlKey) {\n");
-
-
- wholeScript.append(" click++;\n");
- wholeScript.append(" if(click == 1)\n");
- wholeScript.append(" zoom_custom(3600);\n");
- wholeScript.append(" else if(click == 2)\n");
- wholeScript.append(" zoom_custom(12*3600);\n");
- wholeScript.append(" else if(click == 3)\n");
- wholeScript.append(" zoom_custom(86400);\n");
- wholeScript.append(" else if (click == 4)\n");
- wholeScript.append(" zoom_custom(7*86400);\n");
- wholeScript.append(" else if (click == 5)\n");
- wholeScript.append(" zoom_custom(30*86400);\n");
- wholeScript.append(" else if (click == 6)\n");
- wholeScript.append(" zoom_custom(90*86400);\n");
- wholeScript.append(" else if (click == 7)\n");
- wholeScript.append(" zoom_custom(180*86400);\n");
- wholeScript.append(" else if (click == 8)\n");
- wholeScript.append(" zoom_custom(365*86400);\n");
- wholeScript.append(" else if (click == 10)\n");
- wholeScript.append(" zoom_custom(5*365*86400);\n");
- wholeScript.append(" else { \n");
- wholeScript.append(" reset();\n");
- wholeScript.append(" }\n");
- //wholeScript.append(" \n");
- wholeScript.append(" } else {\n");
- wholeScript.append(" Dygraph.startPan(event, g, context); \n");
- wholeScript.append(" } \n");
- wholeScript.append(" } \n");
- wholeScript.append("</script>\n ");
- wholeScript.append("<style type=\"text/css\">\n");
- wholeScript.append(".annotation {\n");
- wholeScript.append("}");
- wholeScript.append(".dygraph-title {\n");
- wholeScript.append("color: black;\n");
- wholeScript.append("font-weight:bold; \n");
- wholeScript.append("}\n");
- wholeScript.append(".dygraph-axis-label-x { ");
- wholeScript.append("-webkit-transform:rotate(-0deg);");
- wholeScript.append("display:block;");
- /*position:absolute;
- right:-5px;
- top:15px;*/
- wholeScript.append("}\n");
-
- int widthInt = 0;
- if(nvl(width).length() > 0) {
- try {
- widthInt = new Integer(width).intValue();
- } catch(Exception ex) {
- if(width.endsWith("px")) {
- try {
- widthInt = new Integer(width.substring(0, width.indexOf("px")));
- } catch (Exception ex1) {
- widthInt = 700;
- }
- } else {
- widthInt = 700;
- }
- }
- } else widthInt = 700;
-
- wholeScript.append(".dygraph-legend {\n");
- wholeScript.append(" left: "+(widthInt-200)+"px !important;\n");
- wholeScript.append(" top: 5px !important;\n");
- wholeScript.append("}\n");
-
- wholeScript.append(".nodatadiv {\n");
- wholeScript.append(" display: table-cell;\n");
- wholeScript.append(" width: 700px;\n");
- wholeScript.append(" height:370px;\n");
- wholeScript.append(" text-align:center;\n");
- wholeScript.append(" vertical-align: middle;\n");
- wholeScript.append("}\n");
- wholeScript.append(".nodatainner {\n");
- wholeScript.append(" padding: 10px;\n");
- wholeScript.append("}\n");
-
- wholeScript.append("canvas {\n");
- wholeScript.append(" -webkit-touch-callout: none; \n");
- wholeScript.append(" -webkit-user-select: none;\n");
- wholeScript.append(" -khtml-user-select: none;\n");
- wholeScript.append(" -moz-user-select: none;\n");
- wholeScript.append(" user-select: none;\n");
- wholeScript.append(" user-select: none;\n");
- wholeScript.append(" outline: none;\n");
- wholeScript.append(" -webkit-tap-highlight-color: rgba(255, 255, 255, 0); /* mobile webkit */\n");
- wholeScript.append("}\n");
- wholeScript.append("</style>\n");
- wholeScript.append("</head>\n");
- wholeScript.append("<body> \n");
-
-/* if(showTitle)
- wholeScript.append(" <p align=\"center\"><b> " + (AppUtils.nvl(reportRuntime.getReportTitle()).length()>0?reportRuntime.getReportTitle():reportRuntime.getReportName()) + "</b></p>\n");
-*/
- wholeScript.append(" <table>\n");
- if(showTitle) {
- wholeScript.append(" <tr> \n ");
- wholeScript.append(" <td> \n ");
- wholeScript.append(" <div class=\"dygraph-label dygraph-title\" align=\"center\">"+title+"</div> \n");
- wholeScript.append(" </td> \n ");
- }
-
- wholeScript.append(" </tr> \n ");
-
- wholeScript.append(" <tr> \n ");
- wholeScript.append(" <td> \n ");
- if(AppUtils.nvl(reportRuntime.getLegendPosition()).length()<=0 || reportRuntime.getLegendPosition().equals("top")) {
- wholeScript.append(" <div id=\"labelDiv"+reportRuntime.getReportID()+"\"></div>\n");
- }
- wholeScript.append(" <div id=\"message"+reportRuntime.getReportID()+"\"></div> \n");
- wholeScript.append(" </td> \n ");
-
- wholeScript.append(" </tr> \n ");
- wholeScript.append(" <tr>\n");
- wholeScript.append(" <td>\n");
-
- int heightInt = 0;
- if(nvl(height).length() > 0) {
- try {
- heightInt = new Integer(height).intValue();
- heightInt -= 50;
- } catch(Exception ex) {
- if(height.endsWith("px")) {
- try {
- heightInt = new Integer(height.substring(0, height.indexOf("px")));
- heightInt -= 50;
- } catch (Exception ex1) {
- heightInt = 420;
- }
- } else {
- heightInt = 420;
- }
- }
- } else heightInt = 420;
- if(AppUtils.nvl(reportRuntime.getLegendPosition()).length()>=0 && reportRuntime.getLegendPosition().equals("right")) {
- wholeScript.append(" <div id=\"div_g"+reportRuntime.getReportID()+"\" style=\"width:"+ (widthInt-250)+ "px; \n" );
- } else {
- wholeScript.append(" <div id=\"div_g"+reportRuntime.getReportID()+"\" style=\"width:"+ (widthInt)+ "px; \n" );
- }
- wholeScript.append(" height:"+ heightInt +"px;\"></div> \n");
- wholeScript.append(" </td>\n");
- if(AppUtils.nvl(reportRuntime.getLegendPosition()).length()>=0 && reportRuntime.getLegendPosition().equals("right")) {
- wholeScript.append(" <td valign=\"top\">\n");
- wholeScript.append(" <div id=\"labelDiv3716\" valign=\"top\" style=\"width:250px;height:"+ heightInt +"px;\"></div>\n");
- wholeScript.append(" </td>\n");
- }
- wholeScript.append(" </tr>\n");
- if(anomalyRec > 0) {
- wholeScript.append(" <tr>\n");
- wholeScript.append(" <td>\n");
- wholeScript.append(" <table>\n");
- wholeScript.append(" <tr>\n");
- wholeScript.append(" <td align=\"center\"><font size=\"2px\"><B><align=\"center\">Anomaly Description</align></B></font></td>\n");
- wholeScript.append(" </tr>\n");
- wholeScript.append(" <tr>\n");
- wholeScript.append(" <td><div id=\"list"+reportRuntime.getReportID()+"\" style=\"width:" + widthInt + "px; height:50px;\"></div></td>\n" );
- wholeScript.append(" </tr>\n");
- wholeScript.append(" </table>\n");
- wholeScript.append(" </td>\n");
- wholeScript.append(" </tr>\n");
- }
- wholeScript.append(" </table>\n");
-
- wholeScript.append(" <script type=\"text/javascript\">\n");
- wholeScript.append(" Dygraph.addEvent(document, \"mousewheel\", function() { lastClickedGraph = null; });\n");
- wholeScript.append(" Dygraph.addEvent(document, \"click\", function() { lastClickedGraph = null; });\n");
- wholeScript.append(" var data = []; \n");
- wholeScript.append(" data = [\n ");
- wholeScript.append( dataStrBuf.toString());
- wholeScript.append(" ];\n");
- wholeScript.append(" if(data.length > 0 ) { \n");
- wholeScript.append(" var orig_range = [ data[0][0].valueOf(), data[data.length - 1][0].valueOf() ];\n");
- if(!timeCharts) {
- wholeScript.append(" function nameAnnotation(ann) { \n");
- wholeScript.append(" return ann.shortText; \n");
- //wholeScript.append(" var m = moment(ann.x);\n");
- //wholeScript.append(" return \"(\" + ann.series + \", \" + m.format(\"YYYY-MM-DD HH\"); + \")\"; \n");
- wholeScript.append(" }\n");
- wholeScript.append(" anns = [];\n");
- }
- wholeScript.append(" var graph_initialized = false;\n");
- wholeScript.append(" if(navigator.platform == 'iPad') { ");
- wholeScript.append(" g = new Dygraph(\n");
- wholeScript.append(" document.getElementById(\"div_g"+reportRuntime.getReportID()+"\"),\n");
- //data here
- /*wholeScript.append(" [\n");
- wholeScript.append(dataStrBuf.toString());
- wholeScript.append(" ],\n");*/
- wholeScript.append(" data , \n");
- wholeScript.append(" {\n");
-
- //Labels here
-
- dct = null;
- StringBuffer labelStrBuf = new StringBuffer("");
- StringBuffer colorsStrBuf = new StringBuffer("");
- StringBuffer visibilityStrBuf = new StringBuffer("");
- int countChartValues = 0;
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- dct = (DataColumnType) iter.next();
- if((dct.getChartSeq()!=null && dct.getChartSeq() >=0) || AppUtils.nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND)) {
- if(!AppUtils.nvl(dct.getDisplayName()).toLowerCase().equals("anomaly_text")) {
- countChartValues++;
- labelStrBuf.append("'"+ dct.getDisplayName()+"',");
- if(!AppUtils.nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND))
- colorsStrBuf.append("'"+ AppUtils.nvl(dct.getChartColor())+"',");
- visibilityStrBuf.append("true,");
- }
- }
- }
- if(labelStrBuf.indexOf(",")!=-1) {
- labelStrBuf.deleteCharAt(labelStrBuf.lastIndexOf(","));
- visibilityStrBuf.deleteCharAt(visibilityStrBuf.lastIndexOf(","));
- }
- if(colorsStrBuf.indexOf(",")!=-1)
- colorsStrBuf.deleteCharAt(colorsStrBuf.lastIndexOf(","));
- //if(showTitle)
- //wholeScript.append("title: '" + (AppUtils.nvl(reportRuntime.getReportTitle()).length()>0?reportRuntime.getReportTitle():reportRuntime.getReportName()) + "',\n");
- wholeScript.append("maxNumberWidth:6,\n");
- wholeScript.append("xAxisHeight: 70,\n");
- wholeScript.append("yAxisLabelWidth: 70,\n");
- wholeScript.append("xAxisLabelWidth: 45,\n");
- wholeScript.append("axes: {\n");
- wholeScript.append("x: {\n");
- wholeScript.append(" axisLabelFormatter: function(d, gran) {\n");
- wholeScript.append(" var month = d.getMonth()+1;\n");
- wholeScript.append(" var day = d.getDate();\n");
- wholeScript.append(" var year = d.getFullYear();\n");
- wholeScript.append(" var hour = d.getHours();\n");
- wholeScript.append(" var minutes = d.getMinutes();\n");
- wholeScript.append(" var seconds = d.getSeconds();\n");
- wholeScript.append(" var wholeString = Dygraph.zeropad(month)+'/'+Dygraph.zeropad(day);\n");
- // wholeScript.append(" if(hour >= 0 && minutes > 0 && seconds > 0) {\n");
- //wholeScript.append(" wholeString += ' ' + Dygraph.zeropad(hour) + ':'+Dygraph.zeropad(minutes)+':'+Dygraph.zeropad(seconds);\n");
- //wholeScript.append(" } else if (hour >= 0 && minutes > 0 && seconds == 0) {\n");
- if(AppUtils.nvl(reportRuntime.getTimeAxisType()).length()==0 || AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("hourly"))
- wholeScript.append(" wholeString += ' ' + Dygraph.zeropad(hour) + ':'+Dygraph.zeropad(minutes);\n");
- //wholeScript.append(" } else if (hour >= 0 && (minutes >= 0 && seconds > 0)) {\n");
- //wholeScript.append(" wholeString += ' ' + Dygraph.zeropad(hour) + ':'+Dygraph.zeropad(minutes)+':'+Dygraph.zeropad(seconds);\n");
- //wholeScript.append(" } else if (hour >= 0) { \n");
- //wholeScript.append(" wholeString += ' ' + Dygraph.zeropad(hour); \n");
- //wholeScript.append(" } \n");
- wholeScript.append(" return wholeString; \n");
- wholeScript.append(" },\n");
- wholeScript.append(" ticker: function (a, b, pixels, opts, dygraph, vals) { \n ");
- wholeScript.append(" if(((b-a)/(1000*60*60)) <= 6) { \n");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.THIRTY_MINUTELY, opts, dygraph); \n");
- wholeScript.append(" } else if(((b-a)/(1000*60*60)) <= 12) { \n");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.HOURLY, opts, dygraph); \n");
- wholeScript.append(" } else if (((b-a)/(1000*60*60)) <= 25) \n ");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.TWO_HOURLY, opts, dygraph); \n ");
- wholeScript.append(" else if(((b-a)/(1000*60*60)) <= 78) \n ");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.SIX_HOURLY, opts, dygraph); \n ");
- wholeScript.append(" else if(((b-a)/(1000*60*60*24)) <= 12)\n");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.DAILY, opts, dygraph); \n");
- wholeScript.append(" else if(((b-a)/(1000*60*60*24)) <= 90) \n");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.WEEKLY, opts, dygraph); \n");
- wholeScript.append(" else \n");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.MONTHLY, opts, dygraph); \n");
- wholeScript.append(" }, \n");
- wholeScript.append(" valueFormatter: function(ms) { \n");
- wholeScript.append(" return new Date(ms).strftime(\"%m/%d/%Y %H:%M\"); \n");
- wholeScript.append( " }\n" );
- wholeScript.append(" }\n");
- wholeScript.append("},\n");
- wholeScript.append(" interactionModel : { \n");
- wholeScript.append(" 'mousedown' : downV4,\n");
- wholeScript.append(" touchstart : newDygraphTouchstart,\n");
- wholeScript.append(" touchend : Dygraph.defaultInteractionModel.touchend,\n");
- wholeScript.append(" touchmove : Dygraph.defaultInteractionModel.touchmove\n");
- //wholeScript.append(" 'dblclick' : dblClickV3,\n");
- //wholeScript.append(" 'mousewheel' : scrollV3\n");
-
- /*wholeScript.append(" 'mousedown' : downV3,\n");
- wholeScript.append(" 'mousemove' : moveV3,\n");
- wholeScript.append(" 'mouseup' : upV3,\n");
- wholeScript.append(" 'click' : clickV3,\n");
- wholeScript.append(" 'dblclick' : dblClickV3,\n");
- wholeScript.append(" 'mousewheel' : scrollV3\n");*/
- wholeScript.append("},\n");
- /*wholeScript.append(" zoomCallback: function(minDate, maxDate, yRanges) { \n");
- if(AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("daily")) {
- wholeScript.append(" if(((maxDate-minDate)/(1000*60*60*24)) < 6) { \n");
- wholeScript.append(" maxDate = new Date(minDate).setMinutes(6*24*60);\n");
- wholeScript.append(" g.updateOptions({\n");
- wholeScript.append(" interactionModel: {},\n");
- wholeScript.append(" dateWindow: [minDate, maxDate]\n");
- wholeScript.append(" });\n");
- } else if (AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("hourly")) {
- wholeScript.append(" if(((maxDate-minDate)/(1000*60*60)) <= 6) { \n");
- wholeScript.append(" maxDate = new Date(minDate).setMinutes(360);\n");
- wholeScript.append(" g.updateOptions({\n");
- wholeScript.append(" interactionModel: {},\n");
- wholeScript.append(" dateWindow: [minDate, maxDate]\n");
- wholeScript.append(" });\n");
- } else if (AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("30min")) {
- wholeScript.append(" if(((maxDate-minDate)/(1000*60*60)) <= 3) { \n");
- wholeScript.append(" maxDate = new Date(minDate).setMinutes(180);\n");
- wholeScript.append(" g.updateOptions({\n");
- wholeScript.append(" interactionModel: {},\n");
- wholeScript.append(" dateWindow: [minDate, maxDate]\n");
- wholeScript.append(" });\n");
- } else if (AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("weekly")) {
- wholeScript.append(" if(((maxDate-minDate)/(1000*60*60*24)) < 7) { \n");
- wholeScript.append(" maxDate = new Date(minDate).setMinutes(7*24*60);\n");
- wholeScript.append(" g.updateOptions({\n");
- wholeScript.append(" interactionModel: {},\n");
- wholeScript.append(" dateWindow: [minDate, maxDate]\n");
- wholeScript.append(" });\n");
- }
- wholeScript.append(" } else {\n");
- wholeScript.append(" g.updateOptions({\n");
- wholeScript.append(" interactionModel : {\n");
- wholeScript.append(" 'mousedown' : downV3,\n");
- wholeScript.append(" 'mousemove' : moveV3,\n");
- wholeScript.append(" 'mouseup' : upV3,\n");
- wholeScript.append(" 'click' : clickV3,\n");
- wholeScript.append(" 'dblclick' : dblClickV3,\n");
- wholeScript.append(" 'mousewheel' : scrollV3\n");
- wholeScript.append(" }\n");
- wholeScript.append(" });\n");
- wholeScript.append(" } \n");
- wholeScript.append(" } ,\n");*/
- wholeScript.append("dateWindow: ["+minDate+", "+maxDate+"],\n");
- wholeScript.append("labels: ["+ labelStrBuf +"],\n");
- wholeScript.append("labelsDiv: \"labelDiv"+reportRuntime.getReportID()+"\",\n");
- wholeScript.append("labelsShowZeroValues: true,\n");
- if(AppUtils.nvl(reportRuntime.getLegendPosition()).length()>=0 && reportRuntime.getLegendPosition().equals("right")) {
- wholeScript.append("labelsSeparateLines: true,\n");
- }
- wholeScript.append("labelsDivWidth: 200,\n");
-
- wholeScript.append("animatedZooms: true,\n");
- wholeScript.append("strokeWidth: 3.0,\n");
- wholeScript.append("strokeBorderWidth: 2.0,\n");
- /*wholeScript.append(" labelsDivStyles: { \n");
- wholeScript.append(" 'backgroundColor': 'rgba(200, 200, 255, 0.75)',\n");
- wholeScript.append(" 'padding': '4px',\n");
- wholeScript.append(" 'border': '1px solid black',\n");
- wholeScript.append(" 'borderRadius': '10px',\n");
- wholeScript.append(" 'boxShadow': '4px 4px 4px #888',\n");
- wholeScript.append(" 'width': '50px'\n");
- wholeScript.append("}, \n");
- */
- wholeScript.append("visibility: ["+ visibilityStrBuf +"],\n");
- if(colorsStrBuf.length() > 0 && colorsStrBuf.length()>=(countChartValues*3+5))
- wholeScript.append("colors: ["+ colorsStrBuf +"],\n");
-
- wholeScript.append(" legend: 'always', \n");
- //Yaxis label here
- wholeScript.append(" ylabel: '"+ chartLeftAxisLabel +"' , \n");
-
- //Xaxis label here
- wholeScript.append(" xlabel: '"+ xAxisLabel +"' , \n");
-
- //draw points
- wholeScript.append(" drawPoints: true, \n");
-
- //stacked graph
- wholeScript.append(" stackedGraph: false, \n");
-
- dct = null;
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- dct = (DataColumnType) iter.next();
- if(!(nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND))) {
- if(!AppUtils.nvl(dct.getDisplayName()).toLowerCase().equals("anomaly_text")) {
- if(dct.getChartSeq()!=null && dct.getChartSeq() >=0) {
- wholeScript.append(" '"+ dct.getDisplayName() + "': {\n");
- if(AppUtils.nvl(dct.getChartLineType()).length()>0)
- wholeScript.append(" strokePattern: Dygraph.DASHED_LINE,\n");
- if(dct.isIsRangeAxisFilled()!=null && dct.isIsRangeAxisFilled().booleanValue()) {
- wholeScript.append(" fillGraph: true\n");
- }
- wholeScript.append(" },\n");
- }
- }
- }
- }
-
-/* //each labels
- wholeScript.append(" 'Forecast': {\n");
-
- //if dashed line
- wholeScript.append(" strokePattern: Dygraph.DASHED_LINE,\n");
-
- //if fillable
- wholeScript.append(" fillGraph: true\n");
-
- // close each labels
- wholeScript.append(" }\n");
-*/
- // callback method
- if(anomalyRec > 0) {
- wholeScript.append(" drawCallback: function(g, is_initial) { \n");
- wholeScript.append(" if (is_initial) { \n");
- wholeScript.append(" graph_initialized = true; \n");
- wholeScript.append(" if (anns.length > 0) { \n");
- wholeScript.append(" g.setAnnotations(anns); \n");
- wholeScript.append(" }\n");
- wholeScript.append(" }\n");
-
- wholeScript.append(" var anns1 = g.annotations();\n");
- //wholeScript.append(" var html = \"\";\n");
- wholeScript.append(" var html = \"<select id='x' size='1' style='width: "+ widthInt +"px; font-family : courier; font-size:8pt; font-weight:bold;'>\";\n");
- wholeScript.append(" for (var i = anns1.length-1; i >= 0 ; i--) {\n");
- wholeScript.append(" var name = nameAnnotation(anns1[i]);\n");
- //wholeScript.append(" html += \"<span id='\" + name + \"'>\"\n");
- wholeScript.append(" if(i==anns1.length-1)\n");
- wholeScript.append(" html += \"<option value='\" + name + \"' selected ><font size=1>\" \n");
- wholeScript.append(" else \n");
- wholeScript.append(" html += \"<option value='\" + name + \"'><font size=1>\" \n");
- wholeScript.append(" html += name \n");
- //wholeScript.append(" html += name + \": \" + (anns1[i].shortText || '(icon)')\n");
- //wholeScript.append(" html += \" -> \" + anns1[i].text + \"</span><br/>\";\n");
- wholeScript.append(" html += \"&nbsp;:&nbsp;\" + anns1[i].text + \"</font></option>\";\n");
- wholeScript.append(" }\n");
- wholeScript.append(" html += \"</select>\" \n");
- wholeScript.append(" document.getElementById(\"list"+reportRuntime.getReportID()+"\").innerHTML = html;\n");
- wholeScript.append(" }\n");
-
-
- wholeScript.append(" }\n");
- wholeScript.append(" )\n");
-
- //push annotations
- wholeScript.append(annotationsStrBuf.toString());
-
- wholeScript.append(" if (graph_initialized) {\n");
- wholeScript.append(" g.setAnnotations(anns);\n");
- wholeScript.append(" } \n");
- //upate handler script
-
- wholeScript.append(" var saveBg = '';\n");
- wholeScript.append(" var num = 0;\n");
- wholeScript.append(" g.updateOptions( {\n");
- wholeScript.append(" annotationMouseOverHandler: function(ann) { \n");
- //wholeScript.append(" document.getElementById(nameAnnotation(ann)).style.fontWeight = 'bold';\n");
- //wholeScript.append(" saveBg = ann.div.style.backgroundColor;\n");
- //wholeScript.append(" ann.div.style.backgroundColor = '#ddd';\n");
- wholeScript.append(" var selectobject = document.getElementById(\"x\");\n");
- wholeScript.append(" for(var i=0; i<selectobject.length;i++) {\n ");
- wholeScript.append(" if(selectobject.options[i].value == nameAnnotation(ann)) {\n ");
- wholeScript.append(" selectobject.options[i].selected = true; \n ");
- wholeScript.append(" } ");
- wholeScript.append(" } ");
-
- wholeScript.append(" },\n");
- wholeScript.append(" annotationMouseOutHandler: function(ann) {\n");
- wholeScript.append(" document.getElementById(nameAnnotation(ann)).style.fontWeight = 'normal';\n");
- wholeScript.append(" ann.div.style.backgroundColor = saveBg;\n");
- //wholeScript.append(" var selectobject = document.getElementById(\"x\");\n");
- //wholeScript.append(" for(var i=0; i<selectobject.length;i++) {\n ");
- //wholeScript.append(" if(selectobject.options[i].value == nameAnnotation(ann)) {\n ");
- //wholeScript.append(" selectobject.options[i].selected = false; \n ");
- //wholeScript.append(" } ");
- //wholeScript.append(" } ");
-
- wholeScript.append(" }\n");
- }
- wholeScript.append(" });\n");
-
- //Other devices
- wholeScript.append("} else { \n");
-
- wholeScript.append(" g = new Dygraph(\n");
- wholeScript.append(" document.getElementById(\"div_g"+reportRuntime.getReportID()+"\"),\n");
- //data here
- /*wholeScript.append(" [\n");
- wholeScript.append(dataStrBuf.toString());
- wholeScript.append(" ],\n");*/
- wholeScript.append(" data , \n");
- wholeScript.append(" {\n");
-
- //Labels here
-
- dct = null;
- labelStrBuf = new StringBuffer("");
- colorsStrBuf = new StringBuffer("");
- visibilityStrBuf = new StringBuffer("");
- countChartValues = 0;
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- dct = (DataColumnType) iter.next();
- if((dct.getChartSeq()!=null && dct.getChartSeq() >=0) || AppUtils.nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND)) {
- if(!AppUtils.nvl(dct.getDisplayName()).toLowerCase().equals("anomaly_text")) {
- countChartValues++;
- labelStrBuf.append("'"+ dct.getDisplayName()+"',");
- if(!AppUtils.nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND))
- colorsStrBuf.append("'"+ AppUtils.nvl(dct.getChartColor())+"',");
- visibilityStrBuf.append("true,");
- }
- }
- }
- if(labelStrBuf.indexOf(",")!=-1) {
- labelStrBuf.deleteCharAt(labelStrBuf.lastIndexOf(","));
- visibilityStrBuf.deleteCharAt(visibilityStrBuf.lastIndexOf(","));
- }
- if(colorsStrBuf.indexOf(",")!=-1)
- colorsStrBuf.deleteCharAt(colorsStrBuf.lastIndexOf(","));
- //if(showTitle)
- //wholeScript.append("title: '" + (AppUtils.nvl(reportRuntime.getReportTitle()).length()>0?reportRuntime.getReportTitle():reportRuntime.getReportName()) + "',\n");
- wholeScript.append("maxNumberWidth:6,\n");
- wholeScript.append("xAxisHeight: 70,\n");
- wholeScript.append("yAxisLabelWidth: 70,\n");
- wholeScript.append("xAxisLabelWidth: 45,\n");
- wholeScript.append("axes: {\n");
- wholeScript.append("x: {\n");
- wholeScript.append(" axisLabelFormatter: function(d, gran) {\n");
- wholeScript.append(" var month = d.getMonth()+1;\n");
- wholeScript.append(" var day = d.getDate();\n");
- wholeScript.append(" var year = d.getFullYear();\n");
- wholeScript.append(" var hour = d.getHours();\n");
- wholeScript.append(" var minutes = d.getMinutes();\n");
- wholeScript.append(" var seconds = d.getSeconds();\n");
- wholeScript.append(" var wholeString = Dygraph.zeropad(month)+'/'+Dygraph.zeropad(day);\n");
- // wholeScript.append(" if(hour >= 0 && minutes > 0 && seconds > 0) {\n");
- //wholeScript.append(" wholeString += ' ' + Dygraph.zeropad(hour) + ':'+Dygraph.zeropad(minutes)+':'+Dygraph.zeropad(seconds);\n");
- //wholeScript.append(" } else if (hour >= 0 && minutes > 0 && seconds == 0) {\n");
- if(AppUtils.nvl(reportRuntime.getTimeAxisType()).length()==0 || AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("hourly"))
- wholeScript.append(" wholeString += ' ' + Dygraph.zeropad(hour) + ':'+Dygraph.zeropad(minutes);\n");
- //wholeScript.append(" } else if (hour >= 0 && (minutes >= 0 && seconds > 0)) {\n");
- //wholeScript.append(" wholeString += ' ' + Dygraph.zeropad(hour) + ':'+Dygraph.zeropad(minutes)+':'+Dygraph.zeropad(seconds);\n");
- //wholeScript.append(" } else if (hour >= 0) { \n");
- //wholeScript.append(" wholeString += ' ' + Dygraph.zeropad(hour); \n");
- //wholeScript.append(" } \n");
- wholeScript.append(" return wholeString; \n");
- wholeScript.append(" },\n");
- wholeScript.append(" ticker: function (a, b, pixels, opts, dygraph, vals) { \n ");
- wholeScript.append(" if(((b-a)/(1000*60*60)) <= 6) { \n");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.THIRTY_MINUTELY, opts, dygraph); \n");
- wholeScript.append(" } else if(((b-a)/(1000*60*60)) <= 12) { \n");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.HOURLY, opts, dygraph); \n");
- wholeScript.append(" } else if (((b-a)/(1000*60*60)) <= 25) \n ");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.TWO_HOURLY, opts, dygraph); \n ");
- wholeScript.append(" else if(((b-a)/(1000*60*60)) <= 78) \n ");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.SIX_HOURLY, opts, dygraph); \n ");
- wholeScript.append(" else if(((b-a)/(1000*60*60*24)) <= 12)\n");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.DAILY, opts, dygraph); \n");
- wholeScript.append(" else if(((b-a)/(1000*60*60*24)) <= 90) \n");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.WEEKLY, opts, dygraph); \n");
- wholeScript.append(" else \n");
- wholeScript.append(" return Dygraph.getDateAxis(a, b, Dygraph.MONTHLY, opts, dygraph); \n");
- wholeScript.append(" }, \n");
- wholeScript.append(" valueFormatter: function(ms) { \n");
- wholeScript.append(" return new Date(ms).strftime(\"%m/%d/%Y %H:%M\"); \n");
- wholeScript.append( " }\n" );
- wholeScript.append(" }\n");
- wholeScript.append("},\n");
- wholeScript.append(" interactionModel : { \n");
-
- wholeScript.append(" 'mousedown' : downV3,\n");
- wholeScript.append(" 'mousemove' : moveV3,\n");
- wholeScript.append(" 'mouseup' : upV3,\n");
- wholeScript.append(" 'click' : clickV3,\n");
- wholeScript.append(" 'dblclick' : dblClickV3,\n");
- wholeScript.append(" 'mousewheel' : scrollV3\n");
- wholeScript.append("},\n");
- wholeScript.append(" zoomCallback: function(minDate, maxDate, yRanges) { \n");
- if(AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("daily")) {
- wholeScript.append(" if(((maxDate-minDate)/(1000*60*60*24)) < 6) { \n");
- wholeScript.append(" maxDate = new Date(minDate).setMinutes(6*24*60);\n");
- wholeScript.append(" g.updateOptions({\n");
- wholeScript.append(" interactionModel: {},\n");
- wholeScript.append(" dateWindow: [minDate, maxDate]\n");
- wholeScript.append(" });\n");
- } else if (AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("hourly")) {
- wholeScript.append(" if(((maxDate-minDate)/(1000*60*60)) <= 6) { \n");
- wholeScript.append(" maxDate = new Date(minDate).setMinutes(360);\n");
- wholeScript.append(" g.updateOptions({\n");
- wholeScript.append(" interactionModel: {},\n");
- wholeScript.append(" dateWindow: [minDate, maxDate]\n");
- wholeScript.append(" });\n");
- } else if (AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("30min")) {
- wholeScript.append(" if(((maxDate-minDate)/(1000*60*60)) <= 3) { \n");
- wholeScript.append(" maxDate = new Date(minDate).setMinutes(180);\n");
- wholeScript.append(" g.updateOptions({\n");
- wholeScript.append(" interactionModel: {},\n");
- wholeScript.append(" dateWindow: [minDate, maxDate]\n");
- wholeScript.append(" });\n");
- } else if (AppUtils.nvl(reportRuntime.getTimeAxisType()).equals("weekly")) {
- wholeScript.append(" if(((maxDate-minDate)/(1000*60*60*24)) < 7) { \n");
- wholeScript.append(" maxDate = new Date(minDate).setMinutes(7*24*60);\n");
- wholeScript.append(" g.updateOptions({\n");
- wholeScript.append(" interactionModel: {},\n");
- wholeScript.append(" dateWindow: [minDate, maxDate]\n");
- wholeScript.append(" });\n");
- }
- wholeScript.append(" } else {\n");
- wholeScript.append(" g.updateOptions({\n");
- wholeScript.append(" interactionModel : {\n");
- wholeScript.append(" 'mousedown' : downV3,\n");
- wholeScript.append(" 'mousemove' : moveV3,\n");
- wholeScript.append(" 'mouseup' : upV3,\n");
- wholeScript.append(" 'click' : clickV3,\n");
- wholeScript.append(" 'dblclick' : dblClickV3,\n");
- wholeScript.append(" 'mousewheel' : scrollV3\n");
- wholeScript.append(" }\n");
- wholeScript.append(" });\n");
- wholeScript.append(" } \n");
- wholeScript.append(" } ,\n");
- wholeScript.append("dateWindow: ["+minDate+", "+maxDate+"],\n");
- wholeScript.append("labels: ["+ labelStrBuf +"],\n");
- wholeScript.append("labelsDiv: \"labelDiv"+reportRuntime.getReportID()+"\",\n");
- wholeScript.append("labelsShowZeroValues: true,\n");
- if(AppUtils.nvl(reportRuntime.getLegendPosition()).length()>=0 && reportRuntime.getLegendPosition().equals("right")) {
- wholeScript.append("labelsSeparateLines: true,\n");
- }
- wholeScript.append("labelsDivWidth: 200,\n");
-
-
- wholeScript.append("animatedZooms: true,\n");
- wholeScript.append("strokeWidth: 3.0,\n");
- wholeScript.append("strokeBorderWidth: 2.0,\n");
-
- /*wholeScript.append(" labelsDivStyles: { \n");
- wholeScript.append(" 'backgroundColor': 'rgba(200, 200, 255, 0.75)',\n");
- wholeScript.append(" 'padding': '4px',\n");
- wholeScript.append(" 'border': '1px solid black',\n");
- wholeScript.append(" 'borderRadius': '10px',\n");
- wholeScript.append(" 'boxShadow': '4px 4px 4px #888',\n");
- wholeScript.append(" 'width': '50px'\n");
- wholeScript.append("}, \n");
- */
- wholeScript.append("visibility: ["+ visibilityStrBuf +"],\n");
- if(colorsStrBuf.length() > 0 && colorsStrBuf.length()>=(countChartValues*3+5))
- wholeScript.append("colors: ["+ colorsStrBuf +"],\n");
-
- wholeScript.append(" legend: 'always', \n");
- //Yaxis label here
- wholeScript.append(" ylabel: '"+ chartLeftAxisLabel +"' , \n");
-
- //Xaxis label here
- wholeScript.append(" xlabel: '"+ xAxisLabel +"' , \n");
-
-
- //draw points
- wholeScript.append(" drawPoints: true, \n");
-
- //stacked graph
- wholeScript.append(" stackedGraph: false, \n");
-
- dct = null;
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- dct = (DataColumnType) iter.next();
- if(!(nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND))) {
- if(!AppUtils.nvl(dct.getDisplayName()).toLowerCase().equals("anomaly_text")) {
- if(dct.getChartSeq()!=null && dct.getChartSeq() >=0) {
- wholeScript.append(" '"+ dct.getDisplayName() + "': {\n");
- if(AppUtils.nvl(dct.getChartLineType()).length()>0)
- wholeScript.append(" strokePattern: Dygraph.DASHED_LINE,\n");
- if(dct.isIsRangeAxisFilled()!=null && dct.isIsRangeAxisFilled().booleanValue()) {
- wholeScript.append(" fillGraph: true\n");
- }
- wholeScript.append(" },\n");
- }
- }
- }
- }
-
-/* //each labels
- wholeScript.append(" 'Forecast': {\n");
-
- //if dashed line
- wholeScript.append(" strokePattern: Dygraph.DASHED_LINE,\n");
-
- //if fillable
- wholeScript.append(" fillGraph: true\n");
-
- // close each labels
- wholeScript.append(" }\n");
-*/
- // callback method
- if(anomalyRec > 0) {
- wholeScript.append(" drawCallback: function(g, is_initial) { \n");
- wholeScript.append(" if (is_initial) { \n");
- wholeScript.append(" graph_initialized = true; \n");
- wholeScript.append(" if (anns.length > 0) { \n");
- wholeScript.append(" g.setAnnotations(anns); \n");
- wholeScript.append(" }\n");
- wholeScript.append(" }\n");
-
- wholeScript.append(" var anns1 = g.annotations();\n");
- //wholeScript.append(" var html = \"\";\n");
- wholeScript.append(" var html = \"<select id='x' size='1' style='width: "+ widthInt +"px; font-family : courier; font-size:8pt; font-weight:bold;'>\";\n");
- wholeScript.append(" for (var i = anns1.length-1; i >= 0 ; i--) {\n");
- wholeScript.append(" var name = nameAnnotation(anns1[i]);\n");
- //wholeScript.append(" html += \"<span id='\" + name + \"'>\"\n");
- wholeScript.append(" if(i==anns1.length-1)\n");
- wholeScript.append(" html += \"<option value='\" + name + \"' selected ><font size=1>\" \n");
- wholeScript.append(" else \n");
- wholeScript.append(" html += \"<option value='\" + name + \"'><font size=1>\" \n");
- wholeScript.append(" html += name \n");
- //wholeScript.append(" html += name + \": \" + (anns1[i].shortText || '(icon)')\n");
- //wholeScript.append(" html += \" -> \" + anns1[i].text + \"</span><br/>\";\n");
- wholeScript.append(" html += \"&nbsp;:&nbsp;\" + anns1[i].text + \"</font></option>\";\n");
- wholeScript.append(" }\n");
- wholeScript.append(" html += \"</select>\" \n");
- wholeScript.append(" document.getElementById(\"list"+reportRuntime.getReportID()+"\").innerHTML = html;\n");
- wholeScript.append(" }\n");
-
-
- wholeScript.append(" }\n");
- wholeScript.append(" )\n");
-
- //push annotations
- wholeScript.append(annotationsStrBuf.toString());
-
- wholeScript.append(" if (graph_initialized) {\n");
- wholeScript.append(" g.setAnnotations(anns);\n");
- wholeScript.append(" } \n");
- //upate handler script
-
- wholeScript.append(" var saveBg = '';\n");
- wholeScript.append(" var num = 0;\n");
- wholeScript.append(" g.updateOptions( {\n");
- wholeScript.append(" annotationMouseOverHandler: function(ann) { \n");
- //wholeScript.append(" document.getElementById(nameAnnotation(ann)).style.fontWeight = 'bold';\n");
- //wholeScript.append(" saveBg = ann.div.style.backgroundColor;\n");
- //wholeScript.append(" ann.div.style.backgroundColor = '#ddd';\n");
- wholeScript.append(" var selectobject = document.getElementById(\"x\");\n");
- wholeScript.append(" for(var i=0; i<selectobject.length;i++) {\n ");
- wholeScript.append(" if(selectobject.options[i].value == nameAnnotation(ann)) {\n ");
- wholeScript.append(" selectobject.options[i].selected = true; \n ");
- wholeScript.append(" } ");
- wholeScript.append(" } ");
-
- wholeScript.append(" },\n");
- wholeScript.append(" annotationMouseOutHandler: function(ann) {\n");
- //wholeScript.append(" document.getElementById(nameAnnotation(ann)).style.fontWeight = 'normal';\n");
- wholeScript.append(" ann.div.style.backgroundColor = saveBg;\n");
- //wholeScript.append(" var selectobject = document.getElementById(\"x\");\n");
- //wholeScript.append(" for(var i=0; i<selectobject.length;i++) {\n ");
- //wholeScript.append(" if(selectobject.options[i].value == nameAnnotation(ann)) {\n ");
- //wholeScript.append(" selectobject.options[i].selected = false; \n ");
- //wholeScript.append(" } ");
- //wholeScript.append(" } ");
-
- wholeScript.append(" }\n");
- }
- wholeScript.append(" });\n");
-
-
- wholeScript.append("} \n");
- //}
- wholeScript.append("} else {\n");
- wholeScript.append("document.getElementById(\"message"+ reportRuntime.getReportID()+"\").display = \"none\";\n");
- wholeScript.append("document.getElementById(\"labelDiv"+ reportRuntime.getReportID()+"\").display=\"none\";\n");
- wholeScript.append("document.getElementById(\"div_g"+reportRuntime.getReportID()+"\").display=\"none\";\n");
-
- wholeScript.append("document.getElementById(\"div_g"+reportRuntime.getReportID()+"\").innerHTML = \"<div id='noData'><b>No Data Available</b></div>\";\n");
- wholeScript.append("document.getElementById(\"div_g"+reportRuntime.getReportID()+"\").className=\"nodatadiv\";\n");
- wholeScript.append("document.getElementById(\"nodata\").className=\"nodatainner\";\n");
- if(!timeCharts)
- wholeScript.append("document.getElementById(\"list"+reportRuntime.getReportID()+"\").display=\"none\";\n");
- wholeScript.append("}\n");
- wholeScript.append(" </script>\n");
- wholeScript.append(" </body>\n");
- wholeScript.append("</html>");
-
-
- } else if (chartType.equals(AppConstants.GT_SCATTER)) {
-
- wholeScript.append("<link href=\""+ AppUtils.getBaseFolderURL() +"d3/css/nv.d3.css\" rel=\"stylesheet\" type=\"text/css\">\n");
- wholeScript.append("<style>\n " +
- " body { \n" +
- " overflow-y:scroll; \n" +
- " } \n" +
- " text { \n" +
- " font: 12px sans-serif; \n" +
- " } \n" +
- " tr.z-row-over > td.z-row-inner, tr.z-row-over > .z-cell {" +
- " background-color: rgb(255, 255, 255); "+
- "} "+
- " svg { display: block; } " +
- " #chart1 svg { \n" +
- " height: 420px; \n" +
- " width: 800px; \n" +
- " min-width: 100px; \n" +
- " min-height: 100px; \n" +
- " } \n" +
-
- " </style> \n" );
- wholeScript.append("<body> \n");
- wholeScript.append("<div id=\"chart1\"><svg></svg></div>");
- //js files
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/d3.v2.js\"></script>\n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/nv.d3.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/tooltip.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/utils.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/legend.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/axis.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/distribution.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/scatter.js\"></script> \n");
- wholeScript.append("<script src=\""+ AppUtils.getBaseFolderURL() +"d3/js/models/scatterChart.js\"></script> \n");
- wholeScript.append("<script> \n");
- wholeScript.append("nv.addGraph(function() { \n" +
- " var width1=900, height1=220; \n" +
- " var chart = nv.models.scatterChart() \n" +
- " .showDistX(true) \n" +
- " .showDistY(true) \n" +
- " .useVoronoi(true) \n" +
- " .color(d3.scale.category10().range()); \n" +
-/* " .width(width1) \n" +
- " .height(height1); \n" +
-*/ " chart.xAxis\n" +
- " .axisLabel('" +legendColumnName + "')\n" +
- " .tickFormat(d3.format('.02f'));\n" +
- " chart.yAxis\n" +
- " .axisLabel('" + chartLeftAxisLabel + "')\n" +
- " .tickFormat(d3.format('.02f'));\n" +
- " d3.select('#chart1 svg') \n" +
- " .datum(getData()) \n" );
- if(animation)
- wholeScript.append(" .transition().duration(1200) \n" );
-/* " .attr(\"width\", width1) \n" +
- " .attr(\"height\", height1) \n" +
-*/ wholeScript.append(" .call(chart); \n" +
- " nv.utils.windowResize(chart.update);\n"+
- "return chart; \n" +
- "}); \n");
-
- String dateStr = "";
- Object uniqueElements [] = null;
- TreeSet ts = new TreeSet();
- for (int i = 0; i < ds.getRowCount(); i++) {
- dateStr = ds.getString(i, 2);
- if(dateStr.length()>0)
- ts.add(dateStr);
- }
- SortedSet s = Collections.synchronizedSortedSet(ts);
- uniqueElements = s.toArray();
-
- wholeScript.append(" function getData() { \n " +
- " var data = [];\n ");
- for (int i = 0; i < uniqueElements.length; i++) {
- wholeScript.append(" data.push( {key:'"+ uniqueElements[i]+ "', values:[]})\n");
- }
-
-
- for (int i = 0; i < ds.getRowCount(); i++) {
- for (int k = 0; k < uniqueElements.length; k++) {
- if(ds.getString(i, 2).equals(uniqueElements[k])) {
- wholeScript.append("data["+k+"].values.push({x:"+ ds.getString(i, 1) +",y:"+ds.getString(i, 3) + ", size: Math.random() });\n");
- }
- }
- }
-
- wholeScript.append("return data; } </script></body>\n");
- } else if (chartType.equals(AppConstants.GT_HIERARCHICAL_SUNBURST)) {
-
- StringBuffer dataStr = new StringBuffer("");
- StringBuffer groupBuffer = new StringBuffer("");
- StringBuffer s = new StringBuffer("");
- dataStr.append("{");
- dataStr.append(" \"ss4262\":{\n");
- String mid = "";
- String mid_old = "";
- String level = "-1";
- String level_old = "-1";
- String eid = "";
- for (int i = 0; i < ds.getRowCount(); i++) {
- mid = ds.getString(i, "mid");
- level = ds.getString(i, "level1");
- eid = ds.getString(i, "eid");
- if(mid.equals(mid_old)) {
- dataStr.append("\""+ eid +"\": 9956,\n");
- } else {
- if(dataStr.lastIndexOf(",")!= -1)
- dataStr.deleteCharAt(dataStr.lastIndexOf(","));
- //if(Integer.parseInt(level_old)==Integer.parseInt(level))
- //dataStr.append("},\n");
- if (Integer.parseInt(level_old)<Integer.parseInt(level))
- dataStr.append("},\n");
- dataStr.append("\""+ mid +"\": { \n");
- }
-
- mid_old = mid;
- level_old = level;
- }
- if(dataStr.toString().endsWith(","))
- dataStr.deleteCharAt(dataStr.lastIndexOf(","));
- dataStr.append("}\n");
- dataStr.append("}\n");
- try {
- String formattedReportName = new HtmlStripper().stripSpecialCharacters(reportRuntime.getReportName());
- String formattedDate = new SimpleDateFormat("MMddyyyyHHmm").format(new java.util.Date());
- String filename=formattedReportName+formattedDate+user_id+".json";
- String filenamepath = AppUtils.getExcelTemplatePath()+"../../json/"+filename;
- System.out.println("filenamepath " + filenamepath);
- BufferedWriter out = new BufferedWriter(new FileWriter(filenamepath));
- out.write(dataStr.toString());
- out.close();
- request.getSession().setAttribute("jsonFileName", filename);
- } catch (IOException e) {
- e.printStackTrace();
- System.out.println("Exception ");
- }
- } else if (chartType.equals(AppConstants.GT_HIERARCHICAL)) {
-
- StringBuffer dataStr = new StringBuffer("");
- StringBuffer groupBuffer = new StringBuffer("");
- StringBuffer s = new StringBuffer("");
- dataStr.append("{");
- dataStr.append(" \"groups\":[");
-
- for (int i = 0; i < ds.getRowCount(); i++) {
- if(ds.getString(i,"group_ind").equals("Y")) {
- groupBuffer.append(" { \"name\": \""+ ds.getString(i,"ei1") +"\" },\n");
- }
-
- }
- groupBuffer.deleteCharAt(groupBuffer.lastIndexOf(","));
- dataStr.append(groupBuffer.toString());
- dataStr.append("],");
- dataStr.append("\"nodes\":[");
- int rowCount = ds.getRowCount();
- for (int i = 0; i < ds.getRowCount(); i++) {
- s.append("{ \"name\": \""+ ds.getString(i,"ei1") +"\" , \"group\":"+ ds.getString(i,"groups") +", \"level\":2 }");
- if (i < (rowCount-1)) s.append(",");
- dataStr.append(s);
- s = new StringBuffer("");
- }
-
- dataStr.append("],");
- dataStr.append("\"links\":[");
- for (int i = 0; i < ds.getRowCount(); i++) {
- s.append("{ \"source\": "+ ds.getString(i,"source") +" , \"target\":"+ ds.getString(i,"target") +", \"value\":2 }");
- if (i < (rowCount-1)) s.append(",");
- dataStr.append(s);
- s = new StringBuffer("");
- }
- dataStr.append("]}");
- try {
- String formattedReportName = new HtmlStripper().stripSpecialCharacters(reportRuntime.getReportName());
- String formattedDate = new SimpleDateFormat("MMddyyyyHHmm").format(new java.util.Date());
- String filename=formattedReportName+formattedDate+user_id+".json";
- String filenamepath = AppUtils.getExcelTemplatePath()+"../../json/"+filename;
- System.out.println("filenamepath " + filenamepath);
- BufferedWriter out = new BufferedWriter(new FileWriter(filenamepath));
- out.write(dataStr.toString());
- out.close();
- request.getSession().setAttribute("jsonFileName", filename);
- } catch (IOException e) {
- e.printStackTrace();
- System.out.println("Exception ");
- }
- }
-
- }
- }
- try {
- BufferedWriter out = new BufferedWriter(new FileWriter("test.txt"));
- out.write(wholeScript.toString());
- out.close();
- } catch (IOException e) {
- e.printStackTrace();
- System.out.println("Exception ");
- }
- return wholeScript.toString();
- }
-
- public String nvl(String s) {
- return (s == null) ? "" : s;
- }
-
- public String nvl(String s, String sDefault) {
- return nvl(s).equals("") ? sDefault : s;
- }
-
- public static String nvls(String s) {
- return (s == null) ? "" : s;
- }
-
- public static String nvls(String s, String sDefault) {
- return nvls(s).equals("") ? sDefault : s;
- }
-
- public boolean getFlagInBoolean(String s) {
- return nvl(s).toUpperCase().startsWith("Y") || nvl(s).toLowerCase().equals("true");
- }
-
- public DataSet loadChartData(String userId, HttpServletRequest request) throws RaptorException {
- if (nvl(getChartType()).length() == 0)
- return null;
- //TODO: display chart function to be added.
- //if (!getDisplayChart())
- // return null;
-
- String sql = null;
- sql = generateChartSQL(userId, request);
- logger.debug(EELFLoggerDelegate.debugLogger, ("SQL generated " + sql));
- String dbInfo = reportRuntime.getDBInfo();
- DataSet ds = ConnectionUtils.getDataSet(sql, dbInfo);
- if(ds.getRowCount()<=0) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("********************************************************************************"));
- logger.debug(EELFLoggerDelegate.debugLogger, (getChartType().toUpperCase()+" - " + "Report ID : " + reportRuntime.getReportID() + " DATA IS EMPTY" ));
- logger.debug(EELFLoggerDelegate.debugLogger, ("QUERY - " + sql));
- logger.debug(EELFLoggerDelegate.debugLogger, ("********************************************************************************"));
- }
-
- return ds;
- } // loadChartData
-
- public String generateChartSQL(String userId, HttpServletRequest request ) throws RaptorException {
- List reportCols = reportRuntime.getAllColumns();
- List chartValueCols = getChartValueColumnsList(AppConstants.CHART_ALL_COLUMNS, null); // parameter is 0 has this requires all columns.
- String reportSQL = reportRuntime.getWholeSQL();
-
- //Add order by clause
- Pattern re1 = Pattern.compile("(^[\r\n]*|([\\s]))[Oo][Rr][Dd][Ee][Rr](.*?[^\r\n]*)[Bb][Yy]",Pattern.DOTALL);
- //Pattern re1 = Pattern.compile("order(.*?[^\r\n]*)by", Pattern.DOTALL);
- Matcher matcher = re1.matcher(reportSQL);
- //Pattern re1 = Pattern.compile("(^[\r\n]*|([\\s]))[Oo][Rr][Dd][Ee][Rr][Tt](.*?[^\r\n]*)[Bb][Yy]",Pattern.DOTALL);
- //int startPoint = sql.length()-30;
-
- reportSQL = reportSQL + " ";
- reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Ss][Ee][Ll][Ee][Cc][Tt]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" SELECT ");
- //reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Ff][Rr][Oo][Mm]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" FROM ");
- reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Rr][Ee]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" WHERE ");
- reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Nn]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" WHEN ");
- reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Aa][Nn][Dd]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" AND ");
-
- if(!reportRuntime.getReportType().equals(AppConstants.RT_HIVE)) {
- int startPoint = reportSQL.lastIndexOf(" FROM ");
- if(startPoint <= 0) {
- startPoint = reportSQL.lastIndexOf(" from ");
- }
- if(startPoint <= 0) {
- startPoint = reportSQL.lastIndexOf("from ");
- }
- if(startPoint <= 0) {
- startPoint = reportSQL.lastIndexOf("FROM ");
- }
-
- if (!matcher.find(startPoint)) {
- reportSQL = reportSQL + " ORDER BY 1" ;
- }
- }
- reportRuntime.setWholeSQL(reportSQL);
-
- logger.debug(EELFLoggerDelegate.debugLogger, (" *************************************************************************************** "));
- logger.debug(EELFLoggerDelegate.debugLogger, ("WHOLE_SQL" + reportSQL));
- logger.debug(EELFLoggerDelegate.debugLogger, (" *************************************************************************************** "));
-
- if (reportRuntime.getFormFieldList() != null) {
- for (Iterator iter = reportRuntime.getFormFieldList().getFormField().iterator(); iter.hasNext();) {
- FormFieldType fft = (FormFieldType) iter.next();
- String fieldId = fft.getFieldId();
- String fieldDisplay = reportRuntime.getFormFieldDisplayName(fft);
- String formfield_value = "";
- formfield_value = AppUtils.getRequestNvlValue(request, fieldId);
- String paramValue = nvl(formfield_value);
- if(paramValue.length()>0) {
- /*sql = Utils.replaceInString(sql, "'" + fieldDisplay + "'", nvl(
- paramValue, "NULL"));*/
- reportSQL = Utils.replaceInString(reportSQL, fieldDisplay, nvl(
- paramValue, "NULL"));
- }
- /*sql = Utils.replaceInString(sql, "'" + fieldDisplay + "'", nvl(
- paramValue, "NULL"));*/
- reportSQL = Utils.replaceInString(reportSQL, "'" + fieldDisplay + "'", nvl(
- paramValue, "NULL"));
- reportSQL = Utils.replaceInString(reportSQL, fieldDisplay , nvl(
- paramValue, "NULL"));
- }
- }
- logger.debug(EELFLoggerDelegate.debugLogger, ("SQL " + reportSQL));
- String legendCol = "1 a";
- // String valueCol = "1";
- StringBuffer groupCol = new StringBuffer();
- StringBuffer seriesCol = new StringBuffer();
- StringBuffer valueCols = new StringBuffer();
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- String colName = getColumnSelectStr(dc, request);
- if (nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND))
- legendCol = getSelectExpr(dc, colName)+" " + dc.getColId();
- // if(dc.getChartSeq()>0)
- // valueCol = "NVL("+colName+", 0) "+dc.getColId();
- if ((!nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND))
- && (dc.getChartSeq()!=null && dc.getChartSeq().intValue() <= 0) && dc.isGroupBreak()) {
- groupCol.append(", ");
- groupCol.append(colName + " " + dc.getColId());
- }
- } // for
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if(dc.isChartSeries()!=null && dc.isChartSeries().booleanValue()) {
- //System.out.println("*****************, "+ " " +getColumnSelectStr(dc, paramValues)+ " "+ getSelectExpr(dc,getColumnSelectStr(dc, paramValues)));
- seriesCol.append(", "+ getSelectExpr(dc,getColumnSelectStr(dc, request))+ " " + dc.getColId());
- }
- }
-
- /*for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if(!dc.isChartSeries() && !(nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND))) {
- //System.out.println("*****************, "+ " " +getColumnSelectStr(dc, paramValues)+ " "+ getSelectExpr(dc,getColumnSelectStr(dc, paramValues)));
- seriesCol.append(", "+ formatChartColumn(getSelectExpr(dc,getColumnSelectStr(dc, paramValues)))+ " " + dc.getColId());
- }
- }*/
-
- for (Iterator iter = chartValueCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- String colName = getColumnSelectStr(dc, request);
- String paramValue = "";
- if(AppUtils.nvl(colName).startsWith("[")) {
- if (reportRuntime.getFormFieldList() != null) {
- for (Iterator iterC = reportRuntime.getFormFieldList().getFormField().iterator(); iterC.hasNext();) {
- FormFieldType fft = (FormFieldType) iterC.next();
- String fieldId = fft.getFieldId();
- String fieldDisplay = reportRuntime.getFormFieldDisplayName(fft);
- String formfield_value = "";
- if(AppUtils.nvl(fieldDisplay).equals(colName)) {
- formfield_value = AppUtils.getRequestNvlValue(request, fieldId);
- paramValue = nvl(formfield_value);
- }
- }
-
- }
-
- seriesCol.append("," + (AppUtils.nvl(paramValue).length()>0? paramValue:"null") + " " + dc.getColId());
- } else {
- //valueCols.append(", NVL(" + formatChartColumn(colName) + ",0) " + dc.getColId());
- seriesCol.append("," + (AppUtils.nvl(paramValue).length()>0? paramValue:formatChartColumn(colName)) + " " + dc.getColId());
- }
- } // for
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- String colName = dc.getDisplayName();
- String colValue = getColumnSelectStr(dc, request);
- //String colName = getColumnSelectStr(dc, formGrid);
- if(colName.equals(AppConstants.RI_CHART_TOTAL_COL))
- seriesCol.append(", " + AppConstants.RI_CHART_TOTAL_COL + " " + AppConstants.RI_CHART_TOTAL_COL );
- if (colName.equals(AppConstants.RI_CHART_COLOR))
- seriesCol.append(", " + colValue + " " + AppConstants.RI_CHART_COLOR );
- if(colName.equals(AppConstants.RI_CHART_MARKER_START))
- seriesCol.append(", " + AppConstants.RI_CHART_MARKER_START + " " + AppConstants.RI_CHART_MARKER_START );
- if(colName.equals(AppConstants.RI_CHART_MARKER_END))
- seriesCol.append(", " + AppConstants.RI_CHART_MARKER_END + " " + AppConstants.RI_CHART_MARKER_END );
- if(colName.equals(AppConstants.RI_CHART_MARKER_TEXT_LEFT))
- seriesCol.append(", " + AppConstants.RI_CHART_MARKER_TEXT_LEFT + " " + AppConstants.RI_CHART_MARKER_TEXT_LEFT );
- if(colName.equals(AppConstants.RI_CHART_MARKER_TEXT_RIGHT))
- seriesCol.append(", " + AppConstants.RI_CHART_MARKER_TEXT_RIGHT + " " + AppConstants.RI_CHART_MARKER_TEXT_RIGHT );
- //if(colName.equals(AppConstants.RI_ANOMALY_TEXT))
- //seriesCol.append(", " + AppConstants.RI_ANOMALY_TEXT + " " + AppConstants.RI_ANOMALY_TEXT );
- }
-
- //debugLogger.debug("ReportSQL Chart " + reportSQL );
- /*for (Iterator iter = chartValueCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- String colName = getColumnSelectStr(dc, paramValues);
- //valueCols.append(", NVL(" + formatChartColumn(colName) + ",0) " + dc.getColId());
- valueCols.append("," + formatChartColumn(colName) + " " + dc.getColId());
- } // for
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- String colName = getColumnSelectStr(dc, paramValues);
- //if(colName.equals(AppConstants.RI_CHART_TOTAL_COL) || colName.equals(AppConstants.RI_CHART_COLOR)) {
- if(colName.equals(AppConstants.RI_CHART_TOTAL_COL))
- valueCols.append(", " + AppConstants.RI_CHART_TOTAL_COL + " " + AppConstants.RI_CHART_TOTAL_COL );
- if (colName.equals(AppConstants.RI_CHART_COLOR))
- valueCols.append(", " + AppConstants.RI_CHART_COLOR + " " + AppConstants.RI_CHART_COLOR );
- if (colName.equals(AppConstants.RI_CHART_INCLUDE))
- valueCols.append(", " + AppConstants.RI_CHART_INCLUDE + " " + AppConstants.RI_CHART_INCLUDE );
- //}
- }*/
- String final_sql = "";
- reportSQL = Utils.replaceInString(reportSQL, " from ", " FROM ");
- reportSQL = Utils.replaceInString(reportSQL, " From ", " FROM ");
- reportSQL = Utils.replaceInString(reportSQL, " select ", " SELECT ");
- reportSQL = Utils.replaceInString(reportSQL, " union ", " UNION ");
- //reportSQL = reportSQL.replaceAll("[\\s]*\\(", "(");
-// if(reportSQL.indexOf("UNION") != -1) {
-// if(reportSQL.indexOf("FROM(")!=-1)
-// final_sql += " "+reportSQL.substring(reportSQL.indexOf("FROM(") );
-// else if (reportSQL.indexOf("FROM (")!=-1)
-// final_sql += " "+reportSQL.substring(reportSQL.indexOf("FROM (") );
-// //TODO ELSE THROW ERROR
-// }
-// else {
-// final_sql += " "+reportSQL.substring(reportSQL.toUpperCase().indexOf(" FROM "));
-// }
- int pos = 0;
- int pos_first_select = 0;
- int pos_dup_select = 0;
- int pos_prev_select = 0;
- int pos_last_select = 0;
- if (reportSQL.indexOf("FROM", pos)!=-1) {
- pos = reportSQL.indexOf("FROM", pos);
- pos_dup_select = reportSQL.lastIndexOf("SELECT",pos);
- pos_first_select = reportSQL.indexOf("SELECT");//,pos);
- logger.debug(EELFLoggerDelegate.debugLogger, ("pos_select " + pos_first_select + " " + pos_dup_select));
- if(pos_dup_select > pos_first_select) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("********pos_dup_select ********" + pos_dup_select));
- //pos_dup_select1 = pos_dup_select;
- pos_prev_select = pos_first_select;
- pos_last_select = pos_dup_select;
- while (pos_last_select > pos_prev_select) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("pos_last , pos_prev " + pos_last_select + " " + pos_prev_select));
- pos = reportSQL.indexOf("FROM", pos+2);
- pos_prev_select = pos_last_select;
- pos_last_select = reportSQL.lastIndexOf("SELECT",pos);
- logger.debug(EELFLoggerDelegate.debugLogger, ("in WHILE LOOP LAST " + pos_last_select));
- }
- }
-
- }
- final_sql += " "+reportSQL.substring(pos);
- logger.debug(EELFLoggerDelegate.debugLogger, ("Final SQL " + final_sql));
- String sql = "SELECT " + legendCol + ", " + legendCol+"_1" + seriesCol.toString()+ nvl(valueCols.toString(), ", 1")
- + groupCol.toString()
- + final_sql;
- logger.debug(EELFLoggerDelegate.debugLogger, ("Final sql in generateChartSQL " +sql));
-
- return sql;
- } // generateChartSQL
-
- private String getColumnSelectStr(DataColumnType dc, HttpServletRequest request) {
- //String colName = dc.isCalculated() ? dc.getColName()
- // : ((nvl(dc.getTableId()).length() > 0) ? (dc.getTableId() + "." + dc
- // .getColName()) : dc.getColName());
- String colName = dc.getColName();
- String paramValue = null;
- //if (dc.isCalculated()) {
- if (reportRuntime.getFormFieldList() != null) {
- for (Iterator iter = reportRuntime.getFormFieldList().getFormField().iterator(); iter.hasNext();) {
- FormFieldType fft = (FormFieldType) iter.next();
- String fieldId = fft.getFieldId();
- String fieldDisplay = reportRuntime.getFormFieldDisplayName(fft);
- String formfield_value = "";
- formfield_value = AppUtils.getRequestNvlValue(request, fieldId);
- paramValue = nvl(formfield_value);
- if(paramValue.length()>0) {
- /*sql = Utils.replaceInString(sql, "'" + fieldDisplay + "'", nvl(
- paramValue, "NULL"));*/
- colName = Utils.replaceInString(colName, "'" + fieldDisplay + "'", "'"+nvl(
- paramValue, "NULL")+"'");
- colName = Utils.replaceInString(colName, fieldDisplay, nvl(
- paramValue, "NULL"));
- }
- }
- return colName;
- }
- //}
- return colName;
- } // getColumnSelectStr
-
-
-
- public String getSelectExpr(DataColumnType dct) {
- // String colName =
- // dct.isCalculated()?dct.getColName():((nvl(dct.getTableId()).length()>0)?(dct.getTableId()+"."+dct.getColName()):dct.getColName());
- return getSelectExpr(dct, dct.getColName() /* colName */);
- } // getSelectExpr
-
- private String getSelectExpr(DataColumnType dct, String colName) {
- String colType = dct.getColType();
- if (colType.equals(AppConstants.CT_CHAR)
- || ((nvl(dct.getColFormat()).length() == 0) && (!colType
- .equals(AppConstants.CT_DATE))))
- return colName;
- else
- return "DATE_FORMAT(" + colName + ", '"
- + nvl(dct.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT) + "')";
- } // getSelectExpr
-
- private String formatChartColumn(String colName) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("Format Chart Column Input colName " + colName));
- colName = colName.trim();
- colName = Utils.replaceInString(colName, "TO_CHAR", "to_char");
- colName = Utils.replaceInString(colName, "to_number", "TO_NUMBER");
- //reportSQL = reportSQL.replaceAll("[\\s]*\\(", "(");
- colName = colName.replaceAll(",[\\s]*\\(", ",(");
- StringBuffer colNameBuf = new StringBuffer(colName);
- int pos = 0, posFormatStart = 0, posFormatEnd = 0;
- String format = "";
-
- if(colNameBuf.indexOf("999")==-1 && colNameBuf.indexOf("990")==-1) {
- logger.debug(EELFLoggerDelegate.debugLogger, (" return colName " + colNameBuf.toString()));
- return colNameBuf.toString();
- }
-
- while (colNameBuf.indexOf("to_char")!=-1) {
- if(colNameBuf.indexOf("999")!=-1 || colNameBuf.indexOf("990")!=-1) {
- pos = colNameBuf.indexOf("to_char");
- colNameBuf.insert(pos, " TO_NUMBER ( CR_RAPTOR.SAFE_TO_NUMBER (");
- pos = colNameBuf.indexOf("to_char");
- colNameBuf.replace(pos, pos+7, "TO_CHAR");
- //colName = Utils.replaceInString(colNameBuf.toString(), "to_char", " TO_NUMBER ( CR_RAPTOR.SAFE_TO_NUMBER ( TO_CHAR ");
- logger.debug(EELFLoggerDelegate.debugLogger, ("After adding to_number " + colNameBuf.toString()));
- //posFormatStart = colNameBuf.lastIndexOf(",'")+1;
- posFormatStart = colNameBuf.indexOf(",'", pos)+1;
- posFormatEnd = colNameBuf.indexOf(")",posFormatStart);
- logger.debug(EELFLoggerDelegate.debugLogger, (posFormatStart + " " + posFormatEnd + " "+ pos));
- format = colNameBuf.substring(posFormatStart, posFormatEnd);
- //posFormatEnd = colNameBuf.indexOf(")",posFormatEnd);
- colNameBuf.insert(posFormatEnd+1, " ," + format + ") , "+ format + ")");
- logger.debug(EELFLoggerDelegate.debugLogger, ("colNameBuf " + colNameBuf.toString()));
- }
- }
- logger.debug(EELFLoggerDelegate.debugLogger, (" return colName " + colNameBuf.toString()));
- return colNameBuf.toString();
- }
-
- public List getChartValueColumnsList( int filter, HashMap formValues) { /*filter; all=0;create without new chart =1; createNewChart=2 */
- List reportCols = reportRuntime.getAllColumns();
-
- ArrayList chartValueCols = new ArrayList();
- int flag = 0;
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- flag = 0;
- DataColumnType dc = (DataColumnType) iter.next();
-// if(filter == 2 || filter == 1) {
- flag = reportRuntime.getDependsOnFormFieldFlag(dc, formValues);
-
- if( (dc.getChartSeq()!=null && dc.getChartSeq()> 0) && flag == 0 && !(nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND))) {
- if(nvl(dc.getChartGroup()).length()<=0) {
- if( filter == 2 && (dc.isCreateInNewChart()!=null && dc.isCreateInNewChart().booleanValue())) {
- chartValueCols.add(dc);
- } else if (filter == 1 && (dc.isCreateInNewChart()==null || !dc.isCreateInNewChart().booleanValue())) {
- chartValueCols.add(dc);
- }
- else if(filter == 0) chartValueCols.add(dc);
- } else chartValueCols.add(dc);
- }
-// } else
-// chartValueCols.add(dc);
- } // for
- Collections.sort(chartValueCols, new ChartSeqComparator());
- return chartValueCols;
- } // getChartValueColumnsList
-
- public String parseTitle(String title, HashMap formValues) {
- Set set = formValues.entrySet();
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry<String,String>) iter.next();
- if(title.indexOf("["+ entry.getKey() + "]")!= -1) {
- title = Utils.replaceInString(title, "["+entry.getKey()+"]", nvl(
- (String) entry.getValue(), ""));
- }
- }
- return title;
- }
-
- public java.util.Date getDateFromDateStr(String dateStr) {
- SimpleDateFormat MMDDYYYYFormat = new SimpleDateFormat("MM/dd/yyyy");
- SimpleDateFormat EEEMMDDYYYYFormat = new SimpleDateFormat("EEE, MM/dd/yyyy"); //2012-11-01 00:00:00
- SimpleDateFormat YYYYMMDDFormat = new SimpleDateFormat("yyyy/MM/dd");
- SimpleDateFormat MONYYYYFormat = new SimpleDateFormat("MMM yyyy");
- SimpleDateFormat MMYYYYFormat = new SimpleDateFormat("MM/yyyy");
- SimpleDateFormat MMMMMDDYYYYFormat = new SimpleDateFormat("MMMMM dd, yyyy");
- SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- SimpleDateFormat timestampHrFormat = new SimpleDateFormat("yyyy-MM-dd HH");
- SimpleDateFormat timestampDayFormat = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat DDMONYYYYFormat = new SimpleDateFormat("dd-MMM-yyyy");
- SimpleDateFormat MONTHYYYYFormat = new SimpleDateFormat("MMMMM, yyyy");
- SimpleDateFormat MMDDYYYYHHFormat = new SimpleDateFormat("MM/dd/yyyy HH");
- SimpleDateFormat MMDDYYYYHHMMSSFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
- SimpleDateFormat MMDDYYYYHHMMFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm");
- SimpleDateFormat YYYYMMDDHHMMSSFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
- SimpleDateFormat YYYYMMDDHHMMFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm");
- SimpleDateFormat DDMONYYYYHHMMSSFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
- SimpleDateFormat DDMONYYYYHHMMFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm");
- SimpleDateFormat MMDDYYFormat = new SimpleDateFormat("MM/dd/yy");
- SimpleDateFormat MMDDYYHHMMFormat = new SimpleDateFormat("MM/dd/yy HH:mm");
- SimpleDateFormat MMDDYYHHMMSSFormat = new SimpleDateFormat("MM/dd/yy HH:mm:ss");
- SimpleDateFormat timestampFormat1 = new SimpleDateFormat("yyyy-M-d.HH.mm. s. S");
- SimpleDateFormat timestamp_W_dash = new SimpleDateFormat("yyyyMMddHHmmss");
- SimpleDateFormat MMDDYYYYHHMMZFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm z");
- SimpleDateFormat YYYYFormat = new SimpleDateFormat("yyyy");
- java.util.Date date = null;
-
- int formatFlag = 0;
-
- final int YEARFLAG = 1;
- final int MONTHFLAG = 2;
- final int DAYFLAG = 3;
- final int HOURFLAG = 4;
- final int MINFLAG = 5;
- final int SECFLAG = 6;
- final int MILLISECFLAG = 7;
- final int DAYOFTHEWEEKFLAG = 8;
- final int FLAGDATE = 9;
- /*int yearFlag = 1;
- int monthFlag = 2;
- int dayFlag = 3;
- int hourFlag = 4;
- int minFlag = 5;
- int secFlag = 6;
- int milliSecFlag = 7;
- int dayoftheweekFlag = 8;
- int flagDate = 10;
- */
-
- date = MMDDYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- if(date==null) {
- date = EEEMMDDYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYOFTHEWEEKFLAG;
- }
- if(date==null) {
- date = MMDDYYYYHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
- if(date==null) {
- //MMDDYYYYHHFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- date = MMDDYYYYHHFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = HOURFLAG;
- }
- if(date==null) {
- date = MMDDYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = YYYYMMDDFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = timestampFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
- if(date==null) {
- date = timestampHrFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = HOURFLAG;
- }
- if(date==null) {
- date = timestampDayFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
-
- if(date==null) {
- date = MONYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MONTHFLAG;
- }
- if(date==null) {
- date = MMYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MONTHFLAG;
- }
- if(date==null) {
- date = MMMMMDDYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = MONTHYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MONTHFLAG;
- }
-
- if(date==null) {
- date = YYYYMMDDHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = YYYYMMDDHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = DDMONYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = DDMONYYYYHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = DDMONYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
-
- if(date==null) {
- date = MMDDYYHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = MMDDYYHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = MMDDYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
-
- if(date==null) {
- date = timestampFormat1.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = MMDDYYYYHHMMZFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = YYYYFormat.parse(dateStr, new ParsePosition(0));
- /* Some random numbers should not satisfy this year format. */
- if(dateStr.length()>4) date = null;
- if(date!=null) formatFlag = YEARFLAG;
- }
- if(date==null) {
- date = timestamp_W_dash.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
- if(date==null)
- date = null;
- return date;
- }
-
- public int getFlagFromDateStr(String dateStr) {
- SimpleDateFormat MMDDYYYYFormat = new SimpleDateFormat("MM/dd/yyyy");
- SimpleDateFormat EEEMMDDYYYYFormat = new SimpleDateFormat("EEE, MM/dd/yyyy"); //2012-11-01 00:00:00
- SimpleDateFormat YYYYMMDDFormat = new SimpleDateFormat("yyyy/MM/dd");
- SimpleDateFormat MONYYYYFormat = new SimpleDateFormat("MMM yyyy");
- SimpleDateFormat MMYYYYFormat = new SimpleDateFormat("MM/yyyy");
- SimpleDateFormat MMMMMDDYYYYFormat = new SimpleDateFormat("MMMMM dd, yyyy");
- SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- SimpleDateFormat timestampHrFormat = new SimpleDateFormat("yyyy-MM-dd HH");
- SimpleDateFormat timestampDayFormat = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat DDMONYYYYFormat = new SimpleDateFormat("dd-MMM-yyyy");
- SimpleDateFormat MONTHYYYYFormat = new SimpleDateFormat("MMMMM, yyyy");
- SimpleDateFormat MMDDYYYYHHFormat = new SimpleDateFormat("MM/dd/yyyy HH");
- SimpleDateFormat MMDDYYYYHHMMSSFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
- SimpleDateFormat MMDDYYYYHHMMFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm");
- SimpleDateFormat YYYYMMDDHHMMSSFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
- SimpleDateFormat YYYYMMDDHHMMFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm");
- SimpleDateFormat DDMONYYYYHHMMSSFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
- SimpleDateFormat DDMONYYYYHHMMFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm");
- SimpleDateFormat MMDDYYFormat = new SimpleDateFormat("MM/dd/yy");
- SimpleDateFormat MMDDYYHHMMFormat = new SimpleDateFormat("MM/dd/yy HH:mm");
- SimpleDateFormat MMDDYYHHMMSSFormat = new SimpleDateFormat("MM/dd/yy HH:mm:ss");
- SimpleDateFormat timestampFormat1 = new SimpleDateFormat("yyyy-M-d.HH.mm. s. S");
- SimpleDateFormat timestamp_W_dash = new SimpleDateFormat("yyyyMMddHHmmss");
- SimpleDateFormat MMDDYYYYHHMMZFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm z");
- SimpleDateFormat YYYYFormat = new SimpleDateFormat("yyyy");
- java.util.Date date = null;
-
- int formatFlag = 0;
-
- final int YEARFLAG = 1;
- final int MONTHFLAG = 2;
- final int DAYFLAG = 3;
- final int HOURFLAG = 4;
- final int MINFLAG = 5;
- final int SECFLAG = 6;
- final int MILLISECFLAG = 7;
- final int DAYOFTHEWEEKFLAG = 8;
- final int FLAGDATE = 9;
- /*int yearFlag = 1;
- int monthFlag = 2;
- int dayFlag = 3;
- int hourFlag = 4;
- int minFlag = 5;
- int secFlag = 6;
- int milliSecFlag = 7;
- int dayoftheweekFlag = 8;
- int flagDate = 10;
- */
-
- date = MMDDYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- if(date==null) {
- date = EEEMMDDYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYOFTHEWEEKFLAG;
- }
- if(date==null) {
- date = MMDDYYYYHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
- if(date==null) {
- //MMDDYYYYHHFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- date = MMDDYYYYHHFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = HOURFLAG;
- }
- if(date==null) {
- date = MMDDYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = YYYYMMDDFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = timestampFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
- if(date==null) {
- date = timestampHrFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = HOURFLAG;
- }
- if(date==null) {
- date = timestampDayFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = MONYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MONTHFLAG;
- }
- if(date==null) {
- date = MMYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MONTHFLAG;
- }
- if(date==null) {
- date = MMMMMDDYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = MONTHYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MONTHFLAG;
- }
-
- if(date==null) {
- date = YYYYMMDDHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = YYYYMMDDHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = DDMONYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = DDMONYYYYHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = DDMONYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
-
- if(date==null) {
- date = MMDDYYHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = MMDDYYHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = MMDDYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
-
- if(date==null) {
- date = timestampFormat1.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = MMDDYYYYHHMMZFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = YYYYFormat.parse(dateStr, new ParsePosition(0));
- /* Some random numbers should not satisfy this year format. */
- if(dateStr.length()>4) date = null;
- if(date!=null) formatFlag = YEARFLAG;
- }
- if(date==null) {
- date = timestamp_W_dash.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
- if(date==null)
- date = null;
- return formatFlag;
- }
-
- public static String[] reverse(String[] arr) {
- List<String> list = Arrays.asList(arr);
- Collections.reverse(list);
- return (String[])list.toArray();
- }
-
- public int getNumberOfDecimalPlaces(double num) {
- Double d = num;
- String[] splitter = d.toString().split("\\.");
- splitter[0].length(); // Before Decimal Count
- splitter[1].length(); // After Decimal Count
- return splitter[1].length();
- }
-
- public boolean getBooleanValue(String s) {
- return getBooleanValue(s,null);
- }
-
- public boolean getBooleanValue(String s, Boolean defaultValue) {
- s = nvl(s);
- if(s.length()<=0 && defaultValue!=null) return defaultValue.booleanValue();
- else if(s.length()<=0) return false;
- else {
- if(s.toUpperCase().startsWith("Y") || s.toLowerCase().equals("true"))
- return true;
- else
- return false;
- }
- }
-
-
- public String IntToLetter(int Int) {
- if (Int<27){
- return Character.toString((char)(Int+96));
- } else {
- if (Int%26==0) {
- return IntToLetter((Int/26)-1)+IntToLetter((Int%26)+1);
- } else {
- return IntToLetter(Int/26)+IntToLetter(Int%26);
- }
- }
- }
-
-
-
-
- private void clearReportRuntimeBackup(HttpServletRequest request) {
- //Session sess = Sessions.getCurrent(true)getCurrent();
- //HttpSession session = (HttpSession)sess.getNativeSession();
- HttpSession session = request.getSession();
- 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 static synchronized java.util.HashMap getRequestParametersMap(ReportRuntime rr, HttpServletRequest request)
- {
- HashMap valuesMap = new HashMap();
-
- ReportFormFields rff = rr.getReportFormFields();
-
- int idx = 0;
- FormField ff = null;
-
- Map fieldNameMap = new HashMap();
- int countOfFields = 0 ;
-
-
- for(rff.resetNext(); rff.hasNext(); idx++) {
- ff = rff.getNext();
- fieldNameMap.put(ff.getFieldName(), ff.getFieldDisplayName());
- countOfFields++;
- }
-
- List formParameter = new ArrayList();
- String formField = "";
- for(int i = 0 ; i < rff.size(); i++) {
- ff = ((FormField)rff.getFormField(i));
- formField = ff.getFieldName();
- boolean isMultiValue = false;
- isMultiValue = ff.getFieldType().equals(FormField.FFT_CHECK_BOX)
- || ff.getFieldType().equals(FormField.FFT_LIST_MULTI);
- boolean isTextArea = (ff.getFieldType().equals(FormField.FFT_TEXTAREA) && rr.getReportDefType()
- .equals(AppConstants.RD_SQL_BASED));
-
- if(request.getParameterValues(formField) != null && isMultiValue ) {
- String[] vals = request.getParameterValues(formField);
- StringBuffer value = new StringBuffer("");
- if(!AppUtils.getRequestFlag(request, AppConstants.RI_RESET_ACTION)) {
-
- if ( isMultiValue ) {
- value.append("(");
- }
- for(int j = 0 ; j < vals.length; j++) {
- if(isMultiValue) value.append("'");
- try {
- if(vals[j] !=null && vals[j].length() > 0) {
- vals[j] = Utils.oracleSafe(vals[j]);
- value.append(java.net.URLDecoder.decode(vals[j], "UTF-8"));// + ",";
- }
- else
- value.append(vals[j]);
- } catch (UnsupportedEncodingException ex) {value.append(vals[j]);}
- catch (IllegalArgumentException ex1){value.append(vals[j]);}
- catch (Exception ex2){
- value.append(vals[j]);
- }
-
-
- if(isMultiValue) value.append("'");
-
- if(j != vals.length -1) {
- value.append(",");
- }
- }
- if(vals.length > 0) {
- value.append(")");
- }
- }
-
- //value = value.substring(0 , value.length());
-
- valuesMap.put(fieldNameMap.get(formField), value.toString());
- value = new StringBuffer("");
- } else if(request.getParameter(formField) != null) {
- if(isTextArea) {
- String value = "";
- value = request.getParameter(formField);
-
- value = Utils.oracleSafe(value);
- value = "('" + Utils.replaceInString(value, ",", "'|'") + "')";
- value = Utils.replaceInString(value, "|", ",");
- valuesMap.put(fieldNameMap.get(formField), value);
- value = "";
- } else {
- String value = "";
- if(!AppUtils.getRequestFlag(request, AppConstants.RI_RESET_ACTION))
- value = request.getParameter(formField);
- valuesMap.put(fieldNameMap.get(formField), Utils.oracleSafe(value));
- }
-
- } else {
- valuesMap.put(fieldNameMap.get(formField), "" );
- }
-
- }
-
- return valuesMap;
-
- }
-
-}
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartGen.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartGen.java
deleted file mode 100644
index c395000e..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartGen.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import java.io.PrintWriter;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.servlet.http.HttpSession;
-
-import org.openecomp.portalsdk.analytics.system.Globals;
-import org.openecomp.portalsdk.analytics.util.DataSet;
-import org.openecomp.portalsdk.analytics.util.Log;
-
-public class ChartGen extends org.openecomp.portalsdk.analytics.RaptorObject {
-
- public static String generateChart(String chartType, HttpSession session, DataSet ds,
- String xText, String yLabelLeftAxis, String yLabelRightAxis, List yTextSeries,
- List yTextColor, List yTextSeriesAxis, String groupText, String chartTitle,
- PrintWriter pw,List columnValuesList, boolean hasCategoryAxis, boolean isMultiSeries,
- List allColumnsList, String downloadFileName, boolean totalOnlyChart, int deviceType, HashMap additionalChartOptionsMap) {
- return generateChart(chartType, session, ds, xText, yLabelLeftAxis, yLabelRightAxis,
- yTextSeries, yTextColor, yTextSeriesAxis, groupText, chartTitle, pw, Globals
- .getDefaultChartWidth(), Globals.getDefaultChartHeight(), columnValuesList, hasCategoryAxis, isMultiSeries, allColumnsList, downloadFileName,totalOnlyChart, deviceType, additionalChartOptionsMap);
- } // generateChart
-
- public static String generateChart(String chartType, HttpSession session, DataSet ds,
- String xText, String yLabelLeftAxis, String yLabelRightAxis, List yTextSeries,
- List yTextColor, List yTextSeriesAxis, String groupText, String chartTitle,
- PrintWriter pw, int width, int height, List columnValuesList, boolean hasCategoryAxis, boolean isMultiSeries,
- List allColumnsList, String downloadFileName,boolean totalOnlyChart, int deviceType, HashMap additionalChartOptionsMap) {
- try {
- Class chartGenClass = null;
-
-
- Class[] argumentTypes = { String.class, HttpSession.class, DataSet.class,
- String.class, String.class, String.class, List.class, List.class,
- List.class, String.class, String.class, PrintWriter.class, int.class,
- int.class, List.class, boolean.class, boolean.class, List.class,
- String.class, boolean.class, int.class, HashMap.class };
-
- Method method = chartGenClass.getMethod("generateChart", argumentTypes);
- Object[] arguments = { chartType, session, ds, xText, yLabelLeftAxis,
- yLabelRightAxis, yTextSeries, yTextColor, yTextSeriesAxis, groupText,
- chartTitle, pw, new Integer(width), new Integer(height), columnValuesList, new Boolean(hasCategoryAxis), new Boolean(isMultiSeries), allColumnsList, downloadFileName, new Boolean(totalOnlyChart), new Integer(deviceType), additionalChartOptionsMap };
-
- return (String) method.invoke(chartGenClass, arguments);
- } catch (Exception e) {
- e.printStackTrace();
- Log.write("ERROR [ChartGen.generateChart] " + e.getMessage());
- return null;
- }
- } // generateChart
-
-} // ChartGen
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSON.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSON.java
deleted file mode 100644
index 85f8dc8a..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSON.java
+++ /dev/null
@@ -1,448 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import java.util.ArrayList;
-
-class Row {
- private String displayValue;
- private String dataType;
- private String colId;
- //private boolean visible;
-
-
- /*public boolean isVisible() {
- return visible;
- }
- public void setVisible(boolean visible) {
- this.visible = visible;
- }*/
- public String getDisplayValue() {
- return displayValue;
- }
- public void setDisplayValue(String displayValue) {
- this.displayValue = displayValue;
- }
- public String getDataType() {
- return dataType;
- }
- public void setDataType(String dataType) {
- this.dataType = dataType;
- }
- public String getColId() {
- return colId;
- }
- public void setColId(String colId) {
- this.colId = colId;
- }
-
-
-}
-class IndexValueJSON {
- private int index;
- private String value;
- private String title;
- public int getIndex() {
- return index;
- }
- public void setIndex(int index) {
- this.index = index;
- }
- public String getValue() {
- return value;
- }
- public void setValue(String value) {
- this.value = value;
- }
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
-
-}
-
-class DomainAxisJSON extends IndexValueJSON {}
-
-class ChartColumnJSON extends IndexValueJSON {}
-
-class ChartTypeJSON extends IndexValueJSON {}
-
-class PieChartOptions {
-
-}
-
-public class ChartJSON {
-
- private String reportID;
- private String reportName;
- private String reportDescr;
- private String reportTitle;
- private String reportSubTitle;
- private ArrayList <FormFieldJSON> formFieldList;
- private ArrayList <ChartColumnJSON> chartColumnJSONList;
- private String formfield_comments;
- private int totalRows;
- private String chartSqlWhole;
- private boolean chartAvailable;
- private ChartTypeJSON chartTypeJSON;
- private BarChartOptions barChartOptions;
- private PieChartOptions pieChartOptions;
- private TimeSeriesChartOptions timeSeriesChartOptions;
- private FlexTimeSeriesChartOptions flexTimeSeriesChartOptions;
- private CommonChartOptions commonChartOptions;
- private String width;
- private String height;
- private boolean animation;
- private String rotateLabels;
- private boolean staggerLabels;
- private boolean showTitle;
- private DomainAxisJSON domainAxisJSON;
- private CategoryAxisJSON categoryAxisJSON;
- private boolean hasCategoryAxis;
-
-
- public boolean isHasCategoryAxis() {
- return hasCategoryAxis;
- }
- public void setHasCategoryAxis(boolean hasCategoryAxis) {
- this.hasCategoryAxis = hasCategoryAxis;
- }
- private ArrayList <RangeAxisJSON> rangeAxisList;
- private ArrayList <ArrayList<Row>> wholeList;
-
- private String primaryAxisLabel;
- private String secondaryAxisLabel;
- private String minRange;
- private String maxRange;
- //private int topMargin;
- //private int bottomMargin;
- //private int leftMargin;
- //private int rightMargin;
-
- /*private boolean showMaxMin;
- private boolean showLegend;
- private boolean showControls;
- private String topMargin;
- private String bottomMargin;
- private String leftMargin;
- private String rightMargin;
- private String subType;
- private boolean stacked;
- private boolean horizontalBar;
- private boolean barRealTimeAxis;
- private boolean barReduceXAxisLabels;
- private boolean timeAxis;*/
-
- public String getReportID() {
- return reportID;
- }
- public void setReportID(String reportID) {
- this.reportID = reportID;
- }
- public String getReportName() {
- return reportName;
- }
- public void setReportName(String reportName) {
- this.reportName = reportName;
- }
- public String getReportDescr() {
- return reportDescr;
- }
- public void setReportDescr(String reportDescr) {
- this.reportDescr = reportDescr;
- }
- public String getReportTitle() {
- return reportTitle;
- }
- public void setReportTitle(String reportTitle) {
- this.reportTitle = reportTitle;
- }
- public String getReportSubTitle() {
- return reportSubTitle;
- }
- public void setReportSubTitle(String reportSubTitle) {
- this.reportSubTitle = reportSubTitle;
- }
- public ArrayList<FormFieldJSON> getFormFieldList() {
- return formFieldList;
- }
- public void setFormFieldList(ArrayList<FormFieldJSON> formFieldList) {
- this.formFieldList = formFieldList;
- }
- public String getFormfield_comments() {
- return formfield_comments;
- }
- public void setFormfield_comments(String formfield_comments) {
- this.formfield_comments = formfield_comments;
- }
- public int getTotalRows() {
- return totalRows;
- }
- public void setTotalRows(int totalRows) {
- this.totalRows = totalRows;
- }
- public String getChartSqlWhole() {
- return chartSqlWhole;
- }
- public void setChartSqlWhole(String chartSqlWhole) {
- this.chartSqlWhole = chartSqlWhole;
- }
- public boolean isChartAvailable() {
- return chartAvailable;
- }
- public void setChartAvailable(boolean chartAvailable) {
- this.chartAvailable = chartAvailable;
- }
- public String getWidth() {
- return width;
- }
- public void setWidth(String width) {
- this.width = width;
- }
- public String getHeight() {
- return height;
- }
- public void setHeight(String height) {
- this.height = height;
- }
- public boolean isAnimation() {
- return animation;
- }
- public void setAnimation(boolean animation) {
- this.animation = animation;
- }
- public String getRotateLabels() {
- return rotateLabels;
- }
- public void setRotateLabels(String rotateLabels) {
- this.rotateLabels = rotateLabels;
- }
- public boolean isStaggerLabels() {
- return staggerLabels;
- }
- public void setStaggerLabels(boolean staggerLabels) {
- this.staggerLabels = staggerLabels;
- }
- public boolean isShowTitle() {
- return showTitle;
- }
- public void setShowTitle(boolean showTitle) {
- this.showTitle = showTitle;
- }
- /*public boolean isShowMaxMin() {
- return showMaxMin;
- }
- public void setShowMaxMin(boolean showMaxMin) {
- this.showMaxMin = showMaxMin;
- }
- public boolean isShowLegend() {
- return showLegend;
- }
- public void setShowLegend(boolean showLegend) {
- this.showLegend = showLegend;
- }
- public boolean isShowControls() {
- return showControls;
- }
- public void setShowControls(boolean showControls) {
- this.showControls = showControls;
- }
- public String getTopMargin() {
- return topMargin;
- }
- public void setTopMargin(String topMargin) {
- this.topMargin = topMargin;
- }
- public String getBottomMargin() {
- return bottomMargin;
- }
- public void setBottomMargin(String bottomMargin) {
- this.bottomMargin = bottomMargin;
- }
- public String getLeftMargin() {
- return leftMargin;
- }
- public void setLeftMargin(String leftMargin) {
- this.leftMargin = leftMargin;
- }
- public String getRightMargin() {
- return rightMargin;
- }
- public void setRightMargin(String rightMargin) {
- this.rightMargin = rightMargin;
- }
-
- public String getSubType() {
- return subType;
- }
- public void setSubType(String subType) {
- this.subType = subType;
- }
- public boolean isStacked() {
- return stacked;
- }
- public void setStacked(boolean stacked) {
- this.stacked = stacked;
- }
- public boolean isHorizontalBar() {
- return horizontalBar;
- }
- public void setHorizontalBar(boolean horizontalBar) {
- this.horizontalBar = horizontalBar;
- }
- public boolean isBarRealTimeAxis() {
- return barRealTimeAxis;
- }
- public void setBarRealTimeAxis(boolean barRealTimeAxis) {
- this.barRealTimeAxis = barRealTimeAxis;
- }
- public boolean isBarReduceXAxisLabels() {
- return barReduceXAxisLabels;
- }
- public void setBarReduceXAxisLabels(boolean barReduceXAxisLabels) {
- this.barReduceXAxisLabels = barReduceXAxisLabels;
- }
- public boolean isTimeAxis() {
- return timeAxis;
- }
- public void setTimeAxis(boolean timeAxis) {
- this.timeAxis = timeAxis;
- }*/
- public ChartTypeJSON getChartTypeJSON() {
- return chartTypeJSON;
- }
- public void setChartTypeJSON(ChartTypeJSON chartTypeJSON) {
- this.chartTypeJSON = chartTypeJSON;
- }
- public String getChartType() {
- return chartTypeJSON.getValue();
- }
- public DomainAxisJSON getDomainAxisJSON() {
- return domainAxisJSON;
- }
- public void setDomainAxisJSON(DomainAxisJSON domainAxisJSON) {
- this.domainAxisJSON = domainAxisJSON;
- }
- public CategoryAxisJSON getCategoryAxisJSON() {
- return categoryAxisJSON;
- }
- public void setCategoryAxisJSON(CategoryAxisJSON categoryAxisJSON) {
- this.categoryAxisJSON = categoryAxisJSON;
- }
- public ArrayList<RangeAxisJSON> getRangeAxisList() {
- return rangeAxisList;
- }
- public void setRangeAxisList(ArrayList<RangeAxisJSON> rangeAxisList) {
- this.rangeAxisList = rangeAxisList;
- }
- public String getPrimaryAxisLabel() {
- return primaryAxisLabel;
- }
- public void setPrimaryAxisLabel(String primaryAxisLabel) {
- this.primaryAxisLabel = primaryAxisLabel;
- }
- public String getSecondaryAxisLabel() {
- return secondaryAxisLabel;
- }
- public void setSecondaryAxisLabel(String secondaryAxisLabel) {
- this.secondaryAxisLabel = secondaryAxisLabel;
- }
- public String getMinRange() {
- return minRange;
- }
- public void setMinRange(String minRange) {
- this.minRange = minRange;
- }
- public String getMaxRange() {
- return maxRange;
- }
- public void setMaxRange(String maxRange) {
- this.maxRange = maxRange;
- }
- /*public ArrayList<Row> getRowList() {
- return rowList;
- }
- public void setRowList(ArrayList<Row> rowList) {
- this.rowList = rowList;
- }*/
-
- public ArrayList<ArrayList<Row>> getWholeList() {
- return wholeList;
- }
- public void setWholeList(ArrayList<ArrayList<Row>> wholeList) {
- this.wholeList = wholeList;
- }
- //private ArrayList<ColumnHeader> reportDataColumns;
- //private ArrayList<Map<String,Object>> reportDataRows;
- public ArrayList<ChartColumnJSON> getChartColumnJSONList() {
- return chartColumnJSONList;
- }
- public void setChartColumnJSONList(ArrayList<ChartColumnJSON> chartColumnJSONList) {
- this.chartColumnJSONList = chartColumnJSONList;
- }
-
- public BarChartOptions getBarChartOptions() {
- return barChartOptions;
- }
- public void setBarChartOptions(BarChartOptions barChartOptions) {
- this.barChartOptions = barChartOptions;
- }
- public PieChartOptions getPieChartOptions() {
- return pieChartOptions;
- }
- public void setPieChartOptions(PieChartOptions pieChartOptions) {
- this.pieChartOptions = pieChartOptions;
- }
- public TimeSeriesChartOptions getTimeSeriesChartOptions() {
- return timeSeriesChartOptions;
- }
- public void setTimeSeriesChartOptions(TimeSeriesChartOptions timeSeriesChartOptions) {
- this.timeSeriesChartOptions = timeSeriesChartOptions;
- }
- public FlexTimeSeriesChartOptions getFlexTimeSeriesChartOptions() {
- return flexTimeSeriesChartOptions;
- }
- public void setFlexTimeSeriesChartOptions(FlexTimeSeriesChartOptions flexTimeSeriesChartOptions) {
- this.flexTimeSeriesChartOptions = flexTimeSeriesChartOptions;
- }
- public CommonChartOptions getCommonChartOptions() {
- return commonChartOptions;
- }
- public void setCommonChartOptions(CommonChartOptions commonChartOptions) {
- this.commonChartOptions = commonChartOptions;
- }
-
- public String getDomainAxis() {
- if(getDomainAxisJSON() !=null)
- return getDomainAxisJSON().getValue();
- else
- return "";
- }
-
- public String getCategoryAxis() {
- if(getCategoryAxisJSON()!=null)
- return getCategoryAxisJSON().getValue();
- else
- return "";
- }
-
-}
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSONHelper.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSONHelper.java
deleted file mode 100644
index d08626c1..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSONHelper.java
+++ /dev/null
@@ -1,1550 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import java.io.UnsupportedEncodingException;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.openecomp.portalsdk.analytics.error.RaptorException;
-import org.openecomp.portalsdk.analytics.model.ReportHandler;
-import org.openecomp.portalsdk.analytics.model.base.ChartSeqComparator;
-import org.openecomp.portalsdk.analytics.system.AppUtils;
-import org.openecomp.portalsdk.analytics.system.ConnectionUtils;
-import org.openecomp.portalsdk.analytics.util.AppConstants;
-import org.openecomp.portalsdk.analytics.util.DataSet;
-import org.openecomp.portalsdk.analytics.util.Utils;
-import org.openecomp.portalsdk.analytics.xmlobj.DataColumnType;
-import org.openecomp.portalsdk.analytics.xmlobj.FormFieldType;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.web.support.UserUtils;
-
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-
-
-
-public class ChartJSONHelper {
-
- EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ChartJSONHelper.class);
-
- private ReportRuntime reportRuntime;
- private String chartType;
-
- public static final long HOUR = 3600*1000;
- public static final long DAY = 3600*1000*24;
- public static final long MONTH = 3600*1000*24*31;
- public static final long YEAR = 3600*1000*24*365;
-
-
- public ChartJSONHelper() {
-
- }
-
- /**
- * @return the chartType
- */
- public String getChartType() {
- return chartType;
- }
-
- /**
- * @param chartType the chartType to set
- */
- public void setChartType(String chartType) {
- this.chartType = chartType;
- }
-
- public ChartJSONHelper(ReportRuntime rr) {
- this.reportRuntime = rr;
- }
-
- public String generateJSON(String reportID, HttpServletRequest request, boolean showData) throws RaptorException {
- //From annotations chart
- clearReportRuntimeBackup(request);
-
- //HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest();
- final Long user_id = new Long((long) UserUtils.getUserId(request));
- //String action = request.getParameter(AppConstants.RI_ACTION);
- //String reportID = AppUtils.getRequestValue(request, AppConstants.RI_REPORT_ID);
-
- ReportHandler rh = new ReportHandler();
- //ReportData reportData = null;
- HashMap<String, String> chartOptionsMap = new HashMap<String, String>();
- try {
- if(reportID !=null) {
- reportRuntime = rh.loadReportRuntime(request, reportID, true, 1);
- setChartType(reportRuntime.getChartType());
- //reportData = reportRuntime.loadReportData(0, user_id.toString(), 10000,request, false);
- }
-
-
-
- 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";
-
-
- 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);
-
-
- } catch (RaptorException ex) {
- ex.printStackTrace();
- }
- return generateJSON(reportRuntime, chartOptionsMap, request, showData);
- }
-
- public String generateJSON(ReportRuntime reportRuntime, HttpServletRequest request, boolean showData) throws RaptorException {
-
- 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";
-
- HashMap<String,String> chartOptionsMap = new HashMap<String, String>();
- chartOptionsMap.put("width", reportRuntime.getChartWidth());
- chartOptionsMap.put("height", reportRuntime.getChartHeight());
- chartOptionsMap.put("animation", new Boolean(reportRuntime.isAnimateAnimatedChart()).toString());
- chartOptionsMap.put("rotateLabels", rotateLabelsStr);
- chartOptionsMap.put("staggerLabels", "false");
- chartOptionsMap.put("showMaxMin", "false");
- chartOptionsMap.put("showControls", new Boolean(reportRuntime.displayBarControls()).toString());
- chartOptionsMap.put("showLegend", new Boolean(!reportRuntime.hideChartLegend()).toString());
- chartOptionsMap.put("topMargin", reportRuntime.getTopMargin()!=null?reportRuntime.getTopMargin().toString():"30");
- chartOptionsMap.put("bottomMargin", reportRuntime.getBottomMargin()!=null?reportRuntime.getBottomMargin().toString():"50");
- chartOptionsMap.put("leftMargin", reportRuntime.getLeftMargin()!=null?reportRuntime.getLeftMargin().toString():"100");
- chartOptionsMap.put("rightMargin", reportRuntime.getRightMargin()!=null?reportRuntime.getRightMargin().toString():"160");
- chartOptionsMap.put("showTitle", new Boolean(reportRuntime.displayChartTitle()).toString());
- chartOptionsMap.put("subType", (AppUtils.nvl(reportRuntime.getTimeSeriesRender()).equals("area")?reportRuntime.getTimeSeriesRender():""));
- chartOptionsMap.put("stacked", new Boolean(reportRuntime.isChartStacked()).toString());
- chartOptionsMap.put("horizontalBar", new Boolean(reportRuntime.isHorizontalOrientation()).toString());
- chartOptionsMap.put("timeAxis", new Boolean(reportRuntime.isTimeAxis()).toString());
- chartOptionsMap.put("barReduceXAxisLabels", new Boolean(reportRuntime.isLessXaxisTickers()).toString());
-
- chartOptionsMap.put("logScale", new Boolean(reportRuntime.isLogScale()).toString());
- chartOptionsMap.put("precision", "2");
-
-
-
- return generateJSON(reportRuntime, chartOptionsMap, request, showData);
- }
-
- public String generateJSON(ReportRuntime reportRuntime, HashMap<String,String> chartOptionsMap, HttpServletRequest request, boolean showData) throws RaptorException {
-
- //String width, String height, boolean animation, String rotateLabels, boolean staggerLabels, boolean showMaxMin, boolean showLegend, boolean showControls, String topMargin, String bottomMargin, boolean showTitle, String subType
- String userId = AppUtils.getUserID(request);
- String width = chartOptionsMap.get("width");
- String height = chartOptionsMap.get("height");
- boolean animation = getBooleanValue(chartOptionsMap.get("animation"), true);
- String rotateLabels = chartOptionsMap.get("rotateLabels");
- boolean staggerLabels = getBooleanValue(chartOptionsMap.get("staggerLabels"));
- boolean showMaxMin = getBooleanValue(chartOptionsMap.get("showMaxMin"), false);
- boolean showLegend = getBooleanValue(chartOptionsMap.get("showLegend"), true);
- boolean showControls = getBooleanValue(chartOptionsMap.get("showControls"), true);
- String topMargin = chartOptionsMap.get("topMargin");
- String bottomMargin = chartOptionsMap.get("bottomMargin");
- String leftMargin = chartOptionsMap.get("leftMargin");
- String rightMargin = chartOptionsMap.get("rightMargin");
- boolean showTitle = getBooleanValue(chartOptionsMap.get("showTitle"), true);
- String subType = chartOptionsMap.get("subType");
- boolean stacked = getBooleanValue(chartOptionsMap.get("stacked"), false);
- boolean horizontalBar = getBooleanValue(chartOptionsMap.get("horizontalBar"), false);
- boolean barRealTimeAxis = getBooleanValue(chartOptionsMap.get("barRealTimeAxis"), true);
- boolean barReduceXAxisLabels= getBooleanValue(chartOptionsMap.get("barReduceXAxisLabels"), false);
- boolean timeAxis = getBooleanValue(chartOptionsMap.get("timeAxis"), true);
-
-
- boolean logScale = getBooleanValue(chartOptionsMap.get("logScale"), false);
-
- int precision = 2;
-
- try {
- precision = Integer.parseInt(chartOptionsMap.get("precision"));
- } catch (NumberFormatException ex) {
-
- }
-
- final Long user_id = new Long((long) UserUtils.getUserId(request));
-
- HttpSession session = null;
- session = request.getSession();
- String chartType = reportRuntime.getChartType();
- List l = reportRuntime.getAllColumns();
- List lGroups = reportRuntime.getAllChartGroups();
- HashMap mapYAxis = reportRuntime.getAllChartYAxis(reportRuntime.getReportParamValues());
- //ReportParamValues reportParamValues = reportRuntime.getReportParamValues();
- String chartLeftAxisLabel = reportRuntime.getFormFieldFilled(nvl(reportRuntime.getChartLeftAxisLabel()));
- String chartRightAxisLabel = reportRuntime.getFormFieldFilled(nvl(reportRuntime.getChartRightAxisLabel()));
-
- boolean multipleSeries = reportRuntime.isMultiSeries();
-
- java.util.HashMap formValues = null;
- formValues = getRequestParametersMap(reportRuntime, request);
-
-
- String legendColumnName = (reportRuntime.getChartLegendColumn()!=null)?reportRuntime.getChartLegendColumn().getDisplayName():"Legend Column";
- boolean displayChart = reportRuntime.getDisplayChart();
- HashMap additionalChartOptionsMap = new HashMap();
-
- StringBuffer wholeScript = new StringBuffer("");
-
- String title = reportRuntime.getReportTitle();
-
- title = parseTitle(title, formValues);
- ObjectMapper mapper = new ObjectMapper();
- ChartJSON chartJSON = new ChartJSON();
- String sql = "";
- if(displayChart) {
- DataSet ds = null;
- if(showData) {
-
- try {
- if (!(chartType.equals(AppConstants.GT_HIERARCHICAL) || chartType.equals(AppConstants.GT_HIERARCHICAL_SUNBURST) || chartType.equals(AppConstants.GT_ANNOTATION_CHART))) {
- sql = generateChartSQL(userId, request );
- ds = (DataSet) loadChartData(new Long(user_id).toString(), request);
- } else if(chartType.equals(AppConstants.GT_ANNOTATION_CHART)) {
- sql = reportRuntime.getWholeSQL();
- String reportSQL = reportRuntime.getWholeSQL();
- String dbInfo = reportRuntime.getDBInfo();
- ds = ConnectionUtils.getDataSet(reportSQL, dbInfo);
- if(ds.getRowCount()<=0) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("********************************************************************************"));
- logger.info(EELFLoggerDelegate.debugLogger, (chartType.toUpperCase()+" - " + "Report ID : " + reportRuntime.getReportID() + " DATA IS EMPTY" ));
- logger.info(EELFLoggerDelegate.debugLogger, ("QUERY - " + reportSQL));
- logger.info(EELFLoggerDelegate.debugLogger, ("********************************************************************************"));
- }
- } else if(chartType.equals(AppConstants.GT_HIERARCHICAL)||chartType.equals(AppConstants.GT_HIERARCHICAL_SUNBURST)) {
- sql = reportRuntime.getWholeSQL();
- String reportSQL = reportRuntime.getWholeSQL();
- String dbInfo = reportRuntime.getDBInfo();
- ds = ConnectionUtils.getDataSet(reportSQL, dbInfo);
- }
- } catch (RaptorException ex) {
- //throw new RaptorException("Error while loading chart data", ex);
- logger.error(EELFLoggerDelegate.debugLogger, ("********************************************************************************"));
- logger.error(EELFLoggerDelegate.debugLogger, (chartType.toUpperCase()+" - " + "Report ID : " + reportRuntime.getReportID() + " ERROR THROWN FOR GIVEN QUERY "));
- logger.error(EELFLoggerDelegate.debugLogger, ("QUERY - " + reportRuntime.getWholeSQL()));
- logger.error(EELFLoggerDelegate.debugLogger, ("ERROR STACK TRACE" + ex.getMessage()));
- logger.error(EELFLoggerDelegate.debugLogger, ("********************************************************************************"));
-
- }
- if(ds==null) {
- //displayChart = false;
- if(chartType.equals(AppConstants.GT_ANNOTATION_CHART))
- ds = new DataSet();
- else
- displayChart = false;
- }
- }
- if(displayChart) {
-
- chartJSON.setReportID(reportRuntime.getReportID());
- chartJSON.setReportName(reportRuntime.getReportName());
- chartJSON.setReportDescr(reportRuntime.getReportDescr());
- chartJSON.setReportTitle(reportRuntime.getReportTitle());
- chartJSON.setReportSubTitle(reportRuntime.getReportSubTitle());
-
- List<DataColumnType> dcList = reportRuntime.getOnlyVisibleColumns();
- int countIndex = 0;
- ArrayList<ChartColumnJSON> chartColumnJSONList = new ArrayList<ChartColumnJSON>();
- for(Iterator iter = dcList.iterator(); iter.hasNext(); ) {
- ChartColumnJSON ccJSON = new ChartColumnJSON();
- DataColumnType dc = (DataColumnType) iter.next();
- ccJSON.setIndex(countIndex);
- ccJSON.setValue(dc.getColId());
- ccJSON.setTitle(dc.getDisplayName());
- countIndex++;
- chartColumnJSONList.add(ccJSON);
- }
- chartJSON.setChartColumnJSONList(chartColumnJSONList);
- /* setting formfields show only showForm got triggered*/
- /*ArrayList<IdNameValue> formFieldValues = new ArrayList<IdNameValue>();
- ArrayList<FormFieldJSON> formFieldJSONList = new ArrayList<FormFieldJSON>();
- if(reportRuntime.getReportFormFields()!=null) {
- formFieldJSONList = new ArrayList<FormFieldJSON>(reportRuntime.getReportFormFields().size());
- for (Iterator iter = reportRuntime.getReportFormFields().iterator(); iter.hasNext();) {
- formFieldValues = new ArrayList<IdNameValue>();
- FormField ff = (FormField) iter.next();
- ff.setDbInfo(reportRuntime.getDbInfo());
- FormFieldJSON ffJSON = new FormFieldJSON();
- ffJSON.setFieldId(ff.getFieldName());
- ffJSON.setFieldType(ff.getFieldType());
- ffJSON.setFieldDisplayName(ff.getFieldDisplayName());
- ffJSON.setHelpText(ff.getHelpText());
- ffJSON.setValidationType(ff.getValidationType());
- //ffJSON.setTriggerOtherFormFields(ff.getDependsOn());
- IdNameList lookup = null;
- lookup = ff.getLookupList();
- String selectedValue = "";
- String oldSQL = "";
- IdNameList lookupList = null;
- boolean readOnly = false;
- if(lookup!=null) {
- if(!ff.hasPredefinedList) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = lu.getSql();
- oldSQL = lu.getSql();
- reportRuntime.setTriggerFormFieldCheck( reportRuntime.getReportFormFields(), ff);
- ffJSON.setTriggerOtherFormFields(ff.isTriggerOtherFormFields());
- SQL = reportRuntime.parseAndFillReq_Session_UserValues(request, SQL, userId);
- SQL = reportRuntime.parseAndFillWithCurrentValues(request, SQL, ff);
- String defaultSQL = lu.getDefaultSQL();
- defaultSQL = reportRuntime.parseAndFillReq_Session_UserValues(request, defaultSQL, userId);
- defaultSQL = reportRuntime.parseAndFillWithCurrentValues(request, SQL, ff);
- lookup = new IdNameSql(-1,SQL,defaultSQL);
-
- lookupList = lookup;
- try {
- lookup.loadUserData(0, "", ff.getDbInfo(), ff.getUserId());
- } catch (Exception e ){ e.printStackTrace(); //throw new RaptorRuntimeException(e);
- }
- }
- lookup.trimToSize();
-
- String[] requestValue = request.getParameterValues(ff.getFieldName());
-
- if(lookup != null && lookup.size() > 0) {
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- readOnly = value.isReadOnly();
- if(requestValue != null && Arrays.asList(requestValue).contains(value.getId())) {
- //if(value.getId().equals(requestValue))
- value.setDefaultValue(true);
- }
- if(!(ff.getFieldType().equals(FormField.FFT_CHECK_BOX) || ff.getFieldType().equals(FormField.FFT_COMBO_BOX) || ff.getFieldType().equals(FormField.FFT_LIST_BOX)
- || ff.getFieldType().equals(FormField.FFT_LIST_MULTI)) && value.isDefaultValue())
- formFieldValues.add(value);
- else if(ff.getFieldType().equals(FormField.FFT_CHECK_BOX) || ff.getFieldType().equals(FormField.FFT_COMBO_BOX) || ff.getFieldType().equals(FormField.FFT_LIST_BOX)
- || ff.getFieldType().equals(FormField.FFT_LIST_MULTI)) {
- formFieldValues.add(value);
- }
- //break;
- }
- } else {
- if(requestValue!=null && requestValue.length>0) {
- IdNameValue value = new IdNameValue(requestValue[0], requestValue[0], true, false);
- formFieldValues.add(value);
- }
- }
-
- } else {
- String[] requestValue = request.getParameterValues(ff.getFieldName());
- if(requestValue!=null && requestValue.length>0) {
- IdNameValue value = new IdNameValue(requestValue[0], requestValue[0], true, false);
- formFieldValues.add(value);
- }
- }
- if(!ff.hasPredefinedList) {
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- }
-
-
-
- ffJSON.setFormFieldValues(formFieldValues);
- formFieldJSONList.add(ffJSON);
- } // for
- }
- chartJSON.setFormFieldList(formFieldJSONList);
- chartJSON.setChartSqlWhole(sql);*/
- chartJSON.setChartAvailable(displayChart);
-
- ChartTypeJSON chartTypeJSON = new ChartTypeJSON();
- chartTypeJSON.setIndex(0);
- chartTypeJSON.setTitle("");
- chartTypeJSON.setValue(chartType);
- chartJSON.setChartTypeJSON(chartTypeJSON);
- chartJSON.setWidth(width);
- chartJSON.setHeight(height);
- chartJSON.setAnimation(animation);
- chartJSON.setRotateLabels(rotateLabels);
- chartJSON.setStaggerLabels(staggerLabels);
- chartJSON.setShowTitle(showTitle);
- DomainAxisJSON domainAxisJSON = new DomainAxisJSON();
- domainAxisJSON.setIndex(0);
- if(reportRuntime.getChartLegendColumn()!=null)
- domainAxisJSON.setTitle(reportRuntime.getChartLegendColumn().getDisplayName());
- else
- domainAxisJSON.setTitle("");
- if(reportRuntime.getChartLegendColumn()!=null)
- domainAxisJSON.setValue(reportRuntime.getChartLegendColumn().getColId());
- else
- domainAxisJSON.setValue("");
- chartJSON.setDomainAxisJSON(domainAxisJSON);
-
-
- List<DataColumnType> reportCols = reportRuntime.getAllColumns();
- boolean hasSeriesColumn = false;
- //ArrayList<Item>
- for (Iterator<DataColumnType> iter = reportCols.iterator(); iter
- .hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
- if(dct.isChartSeries()!=null && dct.isChartSeries().booleanValue()) {
- chartJSON.setHasCategoryAxis(true);
- CategoryAxisJSON categoryAxisJSON = new CategoryAxisJSON();
- categoryAxisJSON.setIndex(0);
- categoryAxisJSON.setTitle(dct.getDisplayName());
- categoryAxisJSON.setValue(dct.getColId());
- chartJSON.setCategoryAxisJSON(categoryAxisJSON);
- }
- //allColumns
- //.add(new Item(dct.getColId(), dct.getDisplayName()));
- }
- //chartJSON.setCategoryAxis(categoryAxis);
- //chartJSON.set
-
- List<DataColumnType> chartValueCols = reportRuntime.getChartValueColumnsList(AppConstants.CHART_ALL_COLUMNS, null);
- DataColumnType dct_RangeAxis = null;
- //int noChart = 0;
- //if(chartValueCols.size()<=0) {
- //chartValueCols.addAll(reportCols);
- //noChart = 1;
- //}
- if(chartValueCols.size() <= 0) {
- chartValueCols = reportCols;
- }
- ArrayList<RangeAxisJSON> rangeAxisJSONList = new ArrayList<RangeAxisJSON>();
- for (int k = 0; k < chartValueCols.size(); k++) {
- dct_RangeAxis = chartValueCols.get(k);
- RangeAxisJSON rangeAxisJSON = new RangeAxisJSON();
-
- RangeAxisLabelJSON rangeAxisLabelJSON = new RangeAxisLabelJSON();
- rangeAxisLabelJSON.setIndex(0);
- rangeAxisLabelJSON.setTitle(dct_RangeAxis.getDisplayName());
- rangeAxisLabelJSON.setValue(dct_RangeAxis.getColId());
- rangeAxisJSON.setRangeAxisLabelJSON(rangeAxisLabelJSON);
- RangeLineTypeJSON rangeLineTypeJSON = new RangeLineTypeJSON();
- rangeLineTypeJSON.setIndex(0);
- rangeLineTypeJSON.setTitle("");
- rangeLineTypeJSON.setValue(dct_RangeAxis.getChartLineType());
- rangeAxisJSON.setRangeLineTypeJSON(rangeLineTypeJSON);
-
- RangeColorJSON rangeColorJSON = new RangeColorJSON();
- rangeColorJSON.setIndex(0);
- rangeColorJSON.setTitle("");
- rangeColorJSON.setValue(dct_RangeAxis.getChartColor());
- rangeAxisJSON.setRangeColorJSON(rangeColorJSON);
- String chartGroup = "";
- chartGroup = AppUtils.nvl(dct_RangeAxis.getChartGroup());
- if(chartGroup.indexOf("|")!=-1)
- chartGroup = chartGroup.substring(0, chartGroup.indexOf("|"));
-
-
- rangeAxisJSON.setRangeChartGroup(chartGroup);
- String yAxis = "";
- yAxis = AppUtils.nvl(dct_RangeAxis.getYAxis());
- if(yAxis.indexOf("|")!=-1)
- yAxis = yAxis.substring(0, yAxis.indexOf("|"));
-
- rangeAxisJSON.setRangeYAxis(yAxis);
- rangeAxisJSON.setShowAsArea((dct_RangeAxis.isIsRangeAxisFilled()!=null && dct_RangeAxis.isIsRangeAxisFilled().booleanValue())?true:false);
- rangeAxisJSONList.add(rangeAxisJSON);
- }
- CommonChartOptions commonChartOptions = new CommonChartOptions();
- commonChartOptions.setLegendPosition(AppUtils.nvl(reportRuntime.getLegendPosition()).length()>0?reportRuntime.getLegendPosition().toLowerCase():"top");
- String legendLabelAngle = "";
- legendLabelAngle = reportRuntime.getLegendLabelAngle().toLowerCase();
- commonChartOptions.setLegendLabelAngle(AppUtils.nvl(legendLabelAngle).length()>0?legendLabelAngle:"up45");
- commonChartOptions.setHideLegend(reportRuntime.hideChartLegend());
- commonChartOptions.setAnimateAnimatedChart(reportRuntime.isAnimateAnimatedChart());
- commonChartOptions.setTopMargin(reportRuntime.getTopMargin()!=null?reportRuntime.getTopMargin():new Integer("30"));
- commonChartOptions.setBottomMargin(reportRuntime.getBottomMargin()!=null?reportRuntime.getBottomMargin():new Integer("50"));
- commonChartOptions.setLeftMargin(reportRuntime.getLeftMargin()!=null?reportRuntime.getLeftMargin():new Integer("100"));
- commonChartOptions.setRightMargin(reportRuntime.getRightMargin()!=null?reportRuntime.getRightMargin():new Integer("60"));
- chartJSON.setCommonChartOptions(commonChartOptions);
-
- if(chartType.equals(AppConstants.GT_BAR_3D)) {
- BarChartOptions barChartOptions = new BarChartOptions();
- barChartOptions.setDisplayBarControls(reportRuntime.displayBarControls()?true:false);
- barChartOptions.setMinimizeXAxisTickers(reportRuntime.isLessXaxisTickers()?true:false);
- barChartOptions.setStackedChart(reportRuntime.isChartStacked()?true:false);
- barChartOptions.setTimeAxis(reportRuntime.isTimeAxis()?true:false);
- barChartOptions.setVerticalOrientation(reportRuntime.isVerticalOrientation()?true:false);
- barChartOptions.setxAxisDateType(reportRuntime.isXAxisDateType()?true:false);
- barChartOptions.setyAxisLogScale(reportRuntime.isLogScale()?true:false);
- chartJSON.setBarChartOptions(barChartOptions);
- chartJSON.setTimeSeriesChartOptions(null);
- chartJSON.setPieChartOptions(null);
- chartJSON.setFlexTimeSeriesChartOptions(null);
-
- } else if(chartType.equals(AppConstants.GT_TIME_SERIES)) {
- TimeSeriesChartOptions timeSeriesChartOptions = new TimeSeriesChartOptions();
- timeSeriesChartOptions.setAddXAxisTicker(reportRuntime.isAddXAxisTickers());
- timeSeriesChartOptions.setLineChartRenderer(AppUtils.nvl(reportRuntime.getTimeSeriesRender()).length()>0?reportRuntime.getTimeSeriesRender():"line");
- timeSeriesChartOptions.setMultiSeries(reportRuntime.isMultiSeries());
- timeSeriesChartOptions.setNonTimeAxis(reportRuntime.isTimeAxis());
- timeSeriesChartOptions.setShowXAxisLabel(reportRuntime.isShowXaxisLabel());
- chartJSON.setBarChartOptions(null);
- chartJSON.setTimeSeriesChartOptions(timeSeriesChartOptions);
- chartJSON.setPieChartOptions(null);
- chartJSON.setFlexTimeSeriesChartOptions(null);
- } else if(chartType.equals(AppConstants.GT_ANNOTATION_CHART) || chartType.equals(AppConstants.GT_FLEX_TIME_CHARTS)) {
- FlexTimeSeriesChartOptions flexTimeSeriesChartOptions = new FlexTimeSeriesChartOptions();
- flexTimeSeriesChartOptions.setZoomIn(reportRuntime.getZoomIn()!=null?reportRuntime.getZoomIn():new Integer("25"));
- String timeAxisTypeStr = "";
- timeAxisTypeStr = reportRuntime.getTimeAxisType().toLowerCase();
- flexTimeSeriesChartOptions.setTimeAxisType(timeAxisTypeStr);
- chartJSON.setBarChartOptions(null);
- chartJSON.setTimeSeriesChartOptions(null);
- chartJSON.setPieChartOptions(null);
- chartJSON.setFlexTimeSeriesChartOptions(flexTimeSeriesChartOptions);
- }
- chartJSON.setRangeAxisList(rangeAxisJSONList);
- chartJSON.setPrimaryAxisLabel(reportRuntime.getChartLeftAxisLabel());
- chartJSON.setSecondaryAxisLabel(reportRuntime.getChartRightAxisLabel());
- chartJSON.setMinRange(reportRuntime.getRangeAxisLowerLimit());
- chartJSON.setMaxRange(reportRuntime.getRangeAxisUpperLimit());
-
- if(showData) {
- ArrayList<ArrayList<Row>> wholeList = new ArrayList<ArrayList<Row>>();
-
- ArrayList<Row> rowList = new ArrayList<Row>();
- if(showData) {
- for (int i = 0; i < ds.getRowCount(); i++) {
- rowList = new ArrayList<Row>();
- for (int j = 0; j<ds.getColumnCount(); j++) {
- Row row = new Row();
- row.setColId(ds.getColumnName(j));
- row.setDisplayValue(ds.getString(i, j));
- row.setDataType(ds.getColumnType(j));
- rowList.add(row);
- }
- wholeList.add(rowList);
-
- }
-
- chartJSON.setWholeList(wholeList);
- }
- }
-
-
-
-
-
- }
- } else {
- // chart is not visible
- chartJSON.setReportID(reportRuntime.getReportID());
- chartJSON.setReportName(reportRuntime.getReportName());
- chartJSON.setReportDescr(reportRuntime.getReportDescr());
- chartJSON.setReportTitle(reportRuntime.getReportTitle());
- chartJSON.setReportSubTitle(reportRuntime.getReportSubTitle());
- chartJSON.setChartAvailable(displayChart);
- ChartTypeJSON chartTypeJSON = new ChartTypeJSON();
- chartTypeJSON.setIndex(0);
- chartTypeJSON.setTitle("");
- chartTypeJSON.setValue(chartType);
- chartJSON.setChartTypeJSON(chartTypeJSON);
- }
- //mapper.setVisibility(JsonMethod.FIELD, Visibility.ANY);
- //mapper.setVisibilityChecker(mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE));
- mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- String jsonInString = "";
- try {
- jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(chartJSON);
- } catch (Exception ex) {
- ex.printStackTrace();
-
- }
-
- return jsonInString;
- }
-
- public String nvl(String s) {
- return (s == null) ? "" : s;
- }
-
- public String nvl(String s, String sDefault) {
- return nvl(s).equals("") ? sDefault : s;
- }
-
- public static String nvls(String s) {
- return (s == null) ? "" : s;
- }
-
- public static String nvls(String s, String sDefault) {
- return nvls(s).equals("") ? sDefault : s;
- }
-
- public boolean getFlagInBoolean(String s) {
- return nvl(s).toUpperCase().startsWith("Y") || nvl(s).toLowerCase().equals("true");
- }
-
- public DataSet loadChartData(String userId, HttpServletRequest request) throws RaptorException {
- if (nvl(getChartType()).length() == 0)
- return null;
- //TODO: display chart function to be added.
- //if (!getDisplayChart())
- // return null;
-
- String sql = null;
- sql = generateChartSQL(userId, request);
- logger.debug(EELFLoggerDelegate.debugLogger, ("SQL generated " + sql));
- String dbInfo = reportRuntime.getDBInfo();
- DataSet ds = ConnectionUtils.getDataSet(sql, dbInfo);
- if(ds.getRowCount()<=0) {
- logger.info(EELFLoggerDelegate.debugLogger, ("********************************************************************************"));
- logger.info(EELFLoggerDelegate.debugLogger, (getChartType().toUpperCase()+" - " + "Report ID : " + reportRuntime.getReportID() + " DATA IS EMPTY"));
- logger.info(EELFLoggerDelegate.debugLogger, ("QUERY - " + sql));
- logger.info(EELFLoggerDelegate.debugLogger, ("********************************************************************************"));
- }
-
- return ds;
- } // loadChartData
-
- public String generateChartSQL(String userId, HttpServletRequest request ) throws RaptorException {
- List reportCols = reportRuntime.getAllColumns();
- List chartValueCols = getChartValueColumnsList(AppConstants.CHART_ALL_COLUMNS, null); // parameter is 0 has this requires all columns.
- String reportSQL = reportRuntime.getWholeSQL();
-
- //Add order by clause
- Pattern re1 = Pattern.compile("(^[\r\n]*|([\\s]))[Oo][Rr][Dd][Ee][Rr](.*?[^\r\n]*)[Bb][Yy]",Pattern.DOTALL);
- //Pattern re1 = Pattern.compile("order(.*?[^\r\n]*)by", Pattern.DOTALL);
- Matcher matcher = re1.matcher(reportSQL);
- //Pattern re1 = Pattern.compile("(^[\r\n]*|([\\s]))[Oo][Rr][Dd][Ee][Rr][Tt](.*?[^\r\n]*)[Bb][Yy]",Pattern.DOTALL);
- //int startPoint = sql.length()-30;
-
- reportSQL = reportSQL + " ";
- reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Ss][Ee][Ll][Ee][Cc][Tt]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" SELECT ");
- //reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Ff][Rr][Oo][Mm]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" FROM ");
- reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Rr][Ee]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" WHERE ");
- reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Nn]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" WHEN ");
- reportSQL = Pattern.compile("(^[\r\n]*|([\\s]))[Aa][Nn][Dd]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(reportSQL).replaceAll(" AND ");
-
- if(!reportRuntime.getReportType().equals(AppConstants.RT_HIVE)) {
- int startPoint = reportSQL.lastIndexOf(" FROM ");
- if(startPoint <= 0) {
- startPoint = reportSQL.lastIndexOf(" from ");
- }
- if(startPoint <= 0) {
- startPoint = reportSQL.lastIndexOf("from ");
- }
- if(startPoint <= 0) {
- startPoint = reportSQL.lastIndexOf("FROM ");
- }
-
- if (!matcher.find(startPoint)) {
- reportSQL = reportSQL + " ORDER BY 1" ;
- }
- }
- reportRuntime.setWholeSQL(reportSQL);
-
- logger.debug(EELFLoggerDelegate.debugLogger, (" *************************************************************************************** "));
- logger.debug(EELFLoggerDelegate.debugLogger, ("WHOLE_SQL" + reportSQL));
- logger.debug(EELFLoggerDelegate.debugLogger, (" *************************************************************************************** "));
-
- if (reportRuntime.getFormFieldList() != null) {
- for (Iterator iter = reportRuntime.getFormFieldList().getFormField().iterator(); iter.hasNext();) {
- FormFieldType fft = (FormFieldType) iter.next();
- String fieldId = fft.getFieldId();
- String fieldDisplay = reportRuntime.getFormFieldDisplayName(fft);
- String formfield_value = "";
- formfield_value = AppUtils.getRequestNvlValue(request, fieldId);
- String paramValue = nvl(formfield_value);
- if(paramValue.length()>0) {
- /*sql = Utils.replaceInString(sql, "'" + fieldDisplay + "'", nvl(
- paramValue, "NULL"));*/
- reportSQL = Utils.replaceInString(reportSQL, fieldDisplay, nvl(
- paramValue, "NULL"));
- }
- /*sql = Utils.replaceInString(sql, "'" + fieldDisplay + "'", nvl(
- paramValue, "NULL"));*/
- reportSQL = Utils.replaceInString(reportSQL, "'" + fieldDisplay + "'", nvl(
- paramValue, "NULL"));
- reportSQL = Utils.replaceInString(reportSQL, fieldDisplay , nvl(
- paramValue, "NULL"));
- }
- }
- logger.debug(EELFLoggerDelegate.debugLogger, ("SQL " + reportSQL));
- String legendCol = "1 a";
- // String valueCol = "1";
- StringBuffer groupCol = new StringBuffer();
- StringBuffer seriesCol = new StringBuffer();
- StringBuffer valueCols = new StringBuffer();
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- String colName = getColumnSelectStr(dc, request);
- if (nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND))
- legendCol = getSelectExpr(dc, colName)+" " + dc.getColId();
- // if(dc.getChartSeq()>0)
- // valueCol = "NVL("+colName+", 0) "+dc.getColId();
- if ((!nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND))
- && (dc.getChartSeq()!=null && dc.getChartSeq().intValue() <= 0) && dc.isGroupBreak()) {
- groupCol.append(", ");
- groupCol.append(colName + " " + dc.getColId());
- }
- } // for
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if(dc.isChartSeries()!=null && dc.isChartSeries().booleanValue()) {
- //System.out.println("*****************, "+ " " +getColumnSelectStr(dc, paramValues)+ " "+ getSelectExpr(dc,getColumnSelectStr(dc, paramValues)));
- seriesCol.append(", "+ getSelectExpr(dc,getColumnSelectStr(dc, request))+ " " + dc.getColId());
- }
- }
-
- /*for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if(!dc.isChartSeries() && !(nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND))) {
- //System.out.println("*****************, "+ " " +getColumnSelectStr(dc, paramValues)+ " "+ getSelectExpr(dc,getColumnSelectStr(dc, paramValues)));
- seriesCol.append(", "+ formatChartColumn(getSelectExpr(dc,getColumnSelectStr(dc, paramValues)))+ " " + dc.getColId());
- }
- }*/
-
- for (Iterator iter = chartValueCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- String colName = getColumnSelectStr(dc, request);
- String paramValue = "";
- if(AppUtils.nvl(colName).startsWith("[")) {
- if (reportRuntime.getFormFieldList() != null) {
- for (Iterator iterC = reportRuntime.getFormFieldList().getFormField().iterator(); iterC.hasNext();) {
- FormFieldType fft = (FormFieldType) iterC.next();
- String fieldId = fft.getFieldId();
- String fieldDisplay = reportRuntime.getFormFieldDisplayName(fft);
- String formfield_value = "";
- if(AppUtils.nvl(fieldDisplay).equals(colName)) {
- formfield_value = AppUtils.getRequestNvlValue(request, fieldId);
- paramValue = nvl(formfield_value);
- }
- }
-
- }
-
- seriesCol.append("," + (AppUtils.nvl(paramValue).length()>0? paramValue:"null") + " " + dc.getColId());
- } else {
- //valueCols.append(", NVL(" + formatChartColumn(colName) + ",0) " + dc.getColId());
- seriesCol.append("," + (AppUtils.nvl(paramValue).length()>0? paramValue:formatChartColumn(colName)) + " " + dc.getColId());
- }
- } // for
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- String colName = dc.getDisplayName();
- String colValue = getColumnSelectStr(dc, request);
- //String colName = getColumnSelectStr(dc, formGrid);
- if(colName.equals(AppConstants.RI_CHART_TOTAL_COL))
- seriesCol.append(", " + AppConstants.RI_CHART_TOTAL_COL + " " + AppConstants.RI_CHART_TOTAL_COL );
- if (colName.equals(AppConstants.RI_CHART_COLOR))
- seriesCol.append(", " + colValue + " " + AppConstants.RI_CHART_COLOR );
- if(colName.equals(AppConstants.RI_CHART_MARKER_START))
- seriesCol.append(", " + AppConstants.RI_CHART_MARKER_START + " " + AppConstants.RI_CHART_MARKER_START );
- if(colName.equals(AppConstants.RI_CHART_MARKER_END))
- seriesCol.append(", " + AppConstants.RI_CHART_MARKER_END + " " + AppConstants.RI_CHART_MARKER_END );
- if(colName.equals(AppConstants.RI_CHART_MARKER_TEXT_LEFT))
- seriesCol.append(", " + AppConstants.RI_CHART_MARKER_TEXT_LEFT + " " + AppConstants.RI_CHART_MARKER_TEXT_LEFT );
- if(colName.equals(AppConstants.RI_CHART_MARKER_TEXT_RIGHT))
- seriesCol.append(", " + AppConstants.RI_CHART_MARKER_TEXT_RIGHT + " " + AppConstants.RI_CHART_MARKER_TEXT_RIGHT );
- //if(colName.equals(AppConstants.RI_ANOMALY_TEXT))
- //seriesCol.append(", " + AppConstants.RI_ANOMALY_TEXT + " " + AppConstants.RI_ANOMALY_TEXT );
- }
-
- //debugLogger.debug("ReportSQL Chart " + reportSQL );
- /*for (Iterator iter = chartValueCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- String colName = getColumnSelectStr(dc, paramValues);
- //valueCols.append(", NVL(" + formatChartColumn(colName) + ",0) " + dc.getColId());
- valueCols.append("," + formatChartColumn(colName) + " " + dc.getColId());
- } // for
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- String colName = getColumnSelectStr(dc, paramValues);
- //if(colName.equals(AppConstants.RI_CHART_TOTAL_COL) || colName.equals(AppConstants.RI_CHART_COLOR)) {
- if(colName.equals(AppConstants.RI_CHART_TOTAL_COL))
- valueCols.append(", " + AppConstants.RI_CHART_TOTAL_COL + " " + AppConstants.RI_CHART_TOTAL_COL );
- if (colName.equals(AppConstants.RI_CHART_COLOR))
- valueCols.append(", " + AppConstants.RI_CHART_COLOR + " " + AppConstants.RI_CHART_COLOR );
- if (colName.equals(AppConstants.RI_CHART_INCLUDE))
- valueCols.append(", " + AppConstants.RI_CHART_INCLUDE + " " + AppConstants.RI_CHART_INCLUDE );
- //}
- }*/
- String final_sql = "";
- reportSQL = Utils.replaceInString(reportSQL, " from ", " FROM ");
- reportSQL = Utils.replaceInString(reportSQL, " From ", " FROM ");
- reportSQL = Utils.replaceInString(reportSQL, " select ", " SELECT ");
- reportSQL = Utils.replaceInString(reportSQL, " union ", " UNION ");
- //reportSQL = reportSQL.replaceAll("[\\s]*\\(", "(");
-// if(reportSQL.indexOf("UNION") != -1) {
-// if(reportSQL.indexOf("FROM(")!=-1)
-// final_sql += " "+reportSQL.substring(reportSQL.indexOf("FROM(") );
-// else if (reportSQL.indexOf("FROM (")!=-1)
-// final_sql += " "+reportSQL.substring(reportSQL.indexOf("FROM (") );
-// //TODO ELSE THROW ERROR
-// }
-// else {
-// final_sql += " "+reportSQL.substring(reportSQL.toUpperCase().indexOf(" FROM "));
-// }
- int pos = 0;
- int pos_first_select = 0;
- int pos_dup_select = 0;
- int pos_prev_select = 0;
- int pos_last_select = 0;
- if (reportSQL.indexOf("FROM", pos)!=-1) {
- pos = reportSQL.indexOf("FROM", pos);
- pos_dup_select = reportSQL.lastIndexOf("SELECT",pos);
- pos_first_select = reportSQL.indexOf("SELECT");//,pos);
- logger.debug(EELFLoggerDelegate.debugLogger, ("pos_select " + pos_first_select + " " + pos_dup_select));
- if(pos_dup_select > pos_first_select) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("********pos_dup_select ********" + pos_dup_select));
- //pos_dup_select1 = pos_dup_select;
- pos_prev_select = pos_first_select;
- pos_last_select = pos_dup_select;
- while (pos_last_select > pos_prev_select) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("pos_last , pos_prev " + pos_last_select + " " + pos_prev_select));
- pos = reportSQL.indexOf("FROM", pos+2);
- pos_prev_select = pos_last_select;
- pos_last_select = reportSQL.lastIndexOf("SELECT",pos);
- logger.debug(EELFLoggerDelegate.debugLogger, ("in WHILE LOOP LAST " + pos_last_select));
- }
- }
-
- }
- final_sql += " "+reportSQL.substring(pos);
- logger.debug(EELFLoggerDelegate.debugLogger, ("Final SQL " + final_sql));
- String sql = "SELECT " + legendCol + ", " + legendCol+"_1" + seriesCol.toString()+ nvl(valueCols.toString(), ", 1")
- + groupCol.toString()
- + final_sql;
- logger.debug(EELFLoggerDelegate.debugLogger, ("Final sql in generateChartSQL " +sql));
-
- return sql;
- } // generateChartSQL
-
- private String getColumnSelectStr(DataColumnType dc, HttpServletRequest request) {
- //String colName = dc.isCalculated() ? dc.getColName()
- // : ((nvl(dc.getTableId()).length() > 0) ? (dc.getTableId() + "." + dc
- // .getColName()) : dc.getColName());
- String colName = dc.getColName();
- String paramValue = null;
- //if (dc.isCalculated()) {
- if (reportRuntime.getFormFieldList() != null) {
- for (Iterator iter = reportRuntime.getFormFieldList().getFormField().iterator(); iter.hasNext();) {
- FormFieldType fft = (FormFieldType) iter.next();
- String fieldId = fft.getFieldId();
- String fieldDisplay = reportRuntime.getFormFieldDisplayName(fft);
- String formfield_value = "";
- formfield_value = AppUtils.getRequestNvlValue(request, fieldId);
- paramValue = nvl(formfield_value);
- if(paramValue.length()>0) {
- /*sql = Utils.replaceInString(sql, "'" + fieldDisplay + "'", nvl(
- paramValue, "NULL"));*/
- colName = Utils.replaceInString(colName, "'" + fieldDisplay + "'", "'"+nvl(
- paramValue, "NULL")+"'");
- colName = Utils.replaceInString(colName, fieldDisplay, nvl(
- paramValue, "NULL"));
- }
- }
- return colName;
- }
- //}
- return colName;
- } // getColumnSelectStr
-
-
-
- public String getSelectExpr(DataColumnType dct) {
- // String colName =
- // dct.isCalculated()?dct.getColName():((nvl(dct.getTableId()).length()>0)?(dct.getTableId()+"."+dct.getColName()):dct.getColName());
- return getSelectExpr(dct, dct.getColName() /* colName */);
- } // getSelectExpr
-
- private String getSelectExpr(DataColumnType dct, String colName) {
- String colType = dct.getColType();
- if (colType.equals(AppConstants.CT_CHAR)
- || ((nvl(dct.getColFormat()).length() == 0) && (!colType
- .equals(AppConstants.CT_DATE))))
- return colName;
- else
- return "TO_CHAR(" + colName + ", '"
- + nvl(dct.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT) + "')";
- } // getSelectExpr
-
- private String formatChartColumn(String colName) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("Format Chart Column Input colName " + colName));
- colName = colName.trim();
- colName = Utils.replaceInString(colName, "TO_CHAR", "to_char");
- colName = Utils.replaceInString(colName, "to_number", "TO_NUMBER");
- //reportSQL = reportSQL.replaceAll("[\\s]*\\(", "(");
- colName = colName.replaceAll(",[\\s]*\\(", ",(");
- StringBuffer colNameBuf = new StringBuffer(colName);
- int pos = 0, posFormatStart = 0, posFormatEnd = 0;
- String format = "";
-
- if(colNameBuf.indexOf("999")==-1 && colNameBuf.indexOf("990")==-1) {
- logger.debug(EELFLoggerDelegate.debugLogger, (" return colName " + colNameBuf.toString()));
- return colNameBuf.toString();
- }
-
- while (colNameBuf.indexOf("to_char")!=-1) {
- if(colNameBuf.indexOf("999")!=-1 || colNameBuf.indexOf("990")!=-1) {
- pos = colNameBuf.indexOf("to_char");
- colNameBuf.insert(pos, " TO_NUMBER ( CR_RAPTOR.SAFE_TO_NUMBER (");
- pos = colNameBuf.indexOf("to_char");
- colNameBuf.replace(pos, pos+7, "TO_CHAR");
- //colName = Utils.replaceInString(colNameBuf.toString(), "to_char", " TO_NUMBER ( CR_RAPTOR.SAFE_TO_NUMBER ( TO_CHAR ");
- logger.debug(EELFLoggerDelegate.debugLogger, ("After adding to_number " + colNameBuf.toString()));
- //posFormatStart = colNameBuf.lastIndexOf(",'")+1;
- posFormatStart = colNameBuf.indexOf(",'", pos)+1;
- posFormatEnd = colNameBuf.indexOf(")",posFormatStart);
- logger.debug(EELFLoggerDelegate.debugLogger, (posFormatStart + " " + posFormatEnd + " "+ pos));
- format = colNameBuf.substring(posFormatStart, posFormatEnd);
- //posFormatEnd = colNameBuf.indexOf(")",posFormatEnd);
- colNameBuf.insert(posFormatEnd+1, " ," + format + ") , "+ format + ")");
- logger.debug(EELFLoggerDelegate.debugLogger, ("colNameBuf " + colNameBuf.toString()));
- }
- }
- logger.debug(EELFLoggerDelegate.debugLogger, (" return colName " + colNameBuf.toString()));
- return colNameBuf.toString();
- }
-
- public List getChartValueColumnsList( int filter, HashMap formValues) { /*filter; all=0;create without new chart =1; createNewChart=2 */
- List reportCols = reportRuntime.getAllColumns();
-
- ArrayList chartValueCols = new ArrayList();
- int flag = 0;
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- flag = 0;
- DataColumnType dc = (DataColumnType) iter.next();
-// if(filter == 2 || filter == 1) {
- flag = reportRuntime.getDependsOnFormFieldFlag(dc, formValues);
-
- if( (dc.getChartSeq()!=null && dc.getChartSeq()> 0) && flag == 0 && !(nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND))) {
- if(nvl(dc.getChartGroup()).length()<=0) {
- if( filter == 2 && (dc.isCreateInNewChart()!=null && dc.isCreateInNewChart().booleanValue())) {
- chartValueCols.add(dc);
- } else if (filter == 1 && (dc.isCreateInNewChart()==null || !dc.isCreateInNewChart().booleanValue())) {
- chartValueCols.add(dc);
- }
- else if(filter == 0) chartValueCols.add(dc);
- } else chartValueCols.add(dc);
- }
-// } else
-// chartValueCols.add(dc);
- } // for
- Collections.sort(chartValueCols, new ChartSeqComparator());
- return chartValueCols;
- } // getChartValueColumnsList
-
- public String parseTitle(String title, HashMap formValues) {
- Set set = formValues.entrySet();
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry<String,String>) iter.next();
- if(title.indexOf("["+ entry.getKey() + "]")!= -1) {
- title = Utils.replaceInString(title, "["+entry.getKey()+"]", nvl(
- (String) entry.getValue(), ""));
- }
- }
- return title;
- }
-
- public java.util.Date getDateFromDateStr(String dateStr) {
- SimpleDateFormat MMDDYYYYFormat = new SimpleDateFormat("MM/dd/yyyy");
- SimpleDateFormat EEEMMDDYYYYFormat = new SimpleDateFormat("EEE, MM/dd/yyyy"); //2012-11-01 00:00:00
- SimpleDateFormat YYYYMMDDFormat = new SimpleDateFormat("yyyy/MM/dd");
- SimpleDateFormat MONYYYYFormat = new SimpleDateFormat("MMM yyyy");
- SimpleDateFormat MMYYYYFormat = new SimpleDateFormat("MM/yyyy");
- SimpleDateFormat MMMMMDDYYYYFormat = new SimpleDateFormat("MMMMM dd, yyyy");
- SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- SimpleDateFormat timestampHrFormat = new SimpleDateFormat("yyyy-MM-dd HH");
- SimpleDateFormat timestampDayFormat = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat DDMONYYYYFormat = new SimpleDateFormat("dd-MMM-yyyy");
- SimpleDateFormat MONTHYYYYFormat = new SimpleDateFormat("MMMMM, yyyy");
- SimpleDateFormat MMDDYYYYHHFormat = new SimpleDateFormat("MM/dd/yyyy HH");
- SimpleDateFormat MMDDYYYYHHMMSSFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
- SimpleDateFormat MMDDYYYYHHMMFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm");
- SimpleDateFormat YYYYMMDDHHMMSSFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
- SimpleDateFormat YYYYMMDDHHMMFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm");
- SimpleDateFormat DDMONYYYYHHMMSSFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
- SimpleDateFormat DDMONYYYYHHMMFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm");
- SimpleDateFormat MMDDYYFormat = new SimpleDateFormat("MM/dd/yy");
- SimpleDateFormat MMDDYYHHMMFormat = new SimpleDateFormat("MM/dd/yy HH:mm");
- SimpleDateFormat MMDDYYHHMMSSFormat = new SimpleDateFormat("MM/dd/yy HH:mm:ss");
- SimpleDateFormat timestampFormat1 = new SimpleDateFormat("yyyy-M-d.HH.mm. s. S");
- SimpleDateFormat MMDDYYYYHHMMZFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm z");
- SimpleDateFormat YYYYFormat = new SimpleDateFormat("yyyy");
- java.util.Date date = null;
-
- int formatFlag = 0;
-
- final int YEARFLAG = 1;
- final int MONTHFLAG = 2;
- final int DAYFLAG = 3;
- final int HOURFLAG = 4;
- final int MINFLAG = 5;
- final int SECFLAG = 6;
- final int MILLISECFLAG = 7;
- final int DAYOFTHEWEEKFLAG = 8;
- final int FLAGDATE = 9;
- /*int yearFlag = 1;
- int monthFlag = 2;
- int dayFlag = 3;
- int hourFlag = 4;
- int minFlag = 5;
- int secFlag = 6;
- int milliSecFlag = 7;
- int dayoftheweekFlag = 8;
- int flagDate = 10;
- */
-
- date = MMDDYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- if(date==null) {
- date = EEEMMDDYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYOFTHEWEEKFLAG;
- }
- if(date==null) {
- date = MMDDYYYYHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
- if(date==null) {
- //MMDDYYYYHHFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- date = MMDDYYYYHHFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = HOURFLAG;
- }
- if(date==null) {
- date = MMDDYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = YYYYMMDDFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = timestampFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
- if(date==null) {
- date = timestampHrFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = HOURFLAG;
- }
- if(date==null) {
- date = timestampDayFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
-
- if(date==null) {
- date = MONYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MONTHFLAG;
- }
- if(date==null) {
- date = MMYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MONTHFLAG;
- }
- if(date==null) {
- date = MMMMMDDYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = MONTHYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MONTHFLAG;
- }
-
- if(date==null) {
- date = YYYYMMDDHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = YYYYMMDDHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = DDMONYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = DDMONYYYYHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = DDMONYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
-
- if(date==null) {
- date = MMDDYYHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = MMDDYYHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = MMDDYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
-
- if(date==null) {
- date = timestampFormat1.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = MMDDYYYYHHMMZFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = YYYYFormat.parse(dateStr, new ParsePosition(0));
- /* Some random numbers should not satisfy this year format. */
- if(dateStr.length()>4) date = null;
- if(date!=null) formatFlag = YEARFLAG;
- }
- if(date==null)
- date = null;
- return date;
- }
-
- public int getFlagFromDateStr(String dateStr) {
- SimpleDateFormat MMDDYYYYFormat = new SimpleDateFormat("MM/dd/yyyy");
- SimpleDateFormat EEEMMDDYYYYFormat = new SimpleDateFormat("EEE, MM/dd/yyyy"); //2012-11-01 00:00:00
- SimpleDateFormat YYYYMMDDFormat = new SimpleDateFormat("yyyy/MM/dd");
- SimpleDateFormat MONYYYYFormat = new SimpleDateFormat("MMM yyyy");
- SimpleDateFormat MMYYYYFormat = new SimpleDateFormat("MM/yyyy");
- SimpleDateFormat MMMMMDDYYYYFormat = new SimpleDateFormat("MMMMM dd, yyyy");
- SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- SimpleDateFormat timestampHrFormat = new SimpleDateFormat("yyyy-MM-dd HH");
- SimpleDateFormat timestampDayFormat = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat DDMONYYYYFormat = new SimpleDateFormat("dd-MMM-yyyy");
- SimpleDateFormat MONTHYYYYFormat = new SimpleDateFormat("MMMMM, yyyy");
- SimpleDateFormat MMDDYYYYHHFormat = new SimpleDateFormat("MM/dd/yyyy HH");
- SimpleDateFormat MMDDYYYYHHMMSSFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
- SimpleDateFormat MMDDYYYYHHMMFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm");
- SimpleDateFormat YYYYMMDDHHMMSSFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
- SimpleDateFormat YYYYMMDDHHMMFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm");
- SimpleDateFormat DDMONYYYYHHMMSSFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
- SimpleDateFormat DDMONYYYYHHMMFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm");
- SimpleDateFormat MMDDYYFormat = new SimpleDateFormat("MM/dd/yy");
- SimpleDateFormat MMDDYYHHMMFormat = new SimpleDateFormat("MM/dd/yy HH:mm");
- SimpleDateFormat MMDDYYHHMMSSFormat = new SimpleDateFormat("MM/dd/yy HH:mm:ss");
- SimpleDateFormat timestampFormat1 = new SimpleDateFormat("yyyy-M-d.HH.mm. s. S");
- SimpleDateFormat MMDDYYYYHHMMZFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm z");
- SimpleDateFormat YYYYFormat = new SimpleDateFormat("yyyy");
- java.util.Date date = null;
-
- int formatFlag = 0;
-
- final int YEARFLAG = 1;
- final int MONTHFLAG = 2;
- final int DAYFLAG = 3;
- final int HOURFLAG = 4;
- final int MINFLAG = 5;
- final int SECFLAG = 6;
- final int MILLISECFLAG = 7;
- final int DAYOFTHEWEEKFLAG = 8;
- final int FLAGDATE = 9;
- /*int yearFlag = 1;
- int monthFlag = 2;
- int dayFlag = 3;
- int hourFlag = 4;
- int minFlag = 5;
- int secFlag = 6;
- int milliSecFlag = 7;
- int dayoftheweekFlag = 8;
- int flagDate = 10;
- */
-
- date = MMDDYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- if(date==null) {
- date = EEEMMDDYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYOFTHEWEEKFLAG;
- }
- if(date==null) {
- date = MMDDYYYYHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
- if(date==null) {
- //MMDDYYYYHHFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- date = MMDDYYYYHHFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = HOURFLAG;
- }
- if(date==null) {
- date = MMDDYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = YYYYMMDDFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = timestampFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
- if(date==null) {
- date = timestampHrFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = HOURFLAG;
- }
- if(date==null) {
- date = timestampDayFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = MONYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MONTHFLAG;
- }
- if(date==null) {
- date = MMYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MONTHFLAG;
- }
- if(date==null) {
- date = MMMMMDDYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
- if(date==null) {
- date = MONTHYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MONTHFLAG;
- }
-
- if(date==null) {
- date = YYYYMMDDHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = YYYYMMDDHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = DDMONYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = DDMONYYYYHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = DDMONYYYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
-
- if(date==null) {
- date = MMDDYYHHMMSSFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = MMDDYYHHMMFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = MMDDYYFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = DAYFLAG;
- }
-
- if(date==null) {
- date = timestampFormat1.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = SECFLAG;
- }
-
- if(date==null) {
- date = MMDDYYYYHHMMZFormat.parse(dateStr, new ParsePosition(0));
- if(date!=null) formatFlag = MINFLAG;
- }
-
- if(date==null) {
- date = YYYYFormat.parse(dateStr, new ParsePosition(0));
- /* Some random numbers should not satisfy this year format. */
- if(dateStr.length()>4) date = null;
- if(date!=null) formatFlag = YEARFLAG;
- }
- if(date==null)
- date = null;
- return formatFlag;
- }
-
- public static String[] reverse(String[] arr) {
- List<String> list = Arrays.asList(arr);
- Collections.reverse(list);
- return (String[])list.toArray();
- }
-
- public int getNumberOfDecimalPlaces(double num) {
- Double d = num;
- String[] splitter = d.toString().split("\\.");
- splitter[0].length(); // Before Decimal Count
- splitter[1].length(); // After Decimal Count
- return splitter[1].length();
- }
-
- public boolean getBooleanValue(String s) {
- return getBooleanValue(s,null);
- }
-
- public boolean getBooleanValue(String s, Boolean defaultValue) {
- s = nvl(s);
- if(s.length()<=0 && defaultValue!=null) return defaultValue.booleanValue();
- else if(s.length()<=0) return false;
- else {
- if(s.toUpperCase().startsWith("Y") || s.toLowerCase().equals("true"))
- return true;
- else
- return false;
- }
- }
-
-
- public String IntToLetter(int Int) {
- if (Int<27){
- return Character.toString((char)(Int+96));
- } else {
- if (Int%26==0) {
- return IntToLetter((Int/26)-1)+IntToLetter((Int%26)+1);
- } else {
- return IntToLetter(Int/26)+IntToLetter(Int%26);
- }
- }
- }
-
-
-
-
- private void clearReportRuntimeBackup(HttpServletRequest request) {
- //Session sess = Sessions.getCurrent(true)getCurrent();
- //HttpSession session = (HttpSession)sess.getNativeSession();
- HttpSession session = request.getSession();
- 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 static synchronized java.util.HashMap getRequestParametersMap(ReportRuntime rr, HttpServletRequest request)
- {
- HashMap valuesMap = new HashMap();
-
- ReportFormFields rff = rr.getReportFormFields();
-
- int idx = 0;
- FormField ff = null;
-
- Map fieldNameMap = new HashMap();
- int countOfFields = 0 ;
-
-
- for(rff.resetNext(); rff.hasNext(); idx++) {
- ff = rff.getNext();
- fieldNameMap.put(ff.getFieldName(), ff.getFieldDisplayName());
- countOfFields++;
- }
-
- List formParameter = new ArrayList();
- String formField = "";
- for(int i = 0 ; i < rff.size(); i++) {
- ff = ((FormField)rff.getFormField(i));
- formField = ff.getFieldName();
- boolean isMultiValue = false;
- isMultiValue = ff.getFieldType().equals(FormField.FFT_CHECK_BOX)
- || ff.getFieldType().equals(FormField.FFT_LIST_MULTI);
- boolean isTextArea = (ff.getFieldType().equals(FormField.FFT_TEXTAREA) && rr.getReportDefType()
- .equals(AppConstants.RD_SQL_BASED));
-
- if(request.getParameterValues(formField) != null && isMultiValue ) {
- String[] vals = request.getParameterValues(formField);
- StringBuffer value = new StringBuffer("");
- if(!AppUtils.getRequestFlag(request, AppConstants.RI_RESET_ACTION)) {
-
- if ( isMultiValue ) {
- value.append("(");
- }
- for(int j = 0 ; j < vals.length; j++) {
- if(isMultiValue) value.append("'");
- try {
- if(vals[j] !=null && vals[j].length() > 0) {
- vals[j] = Utils.oracleSafe(vals[j]);
- value.append(java.net.URLDecoder.decode(vals[j], "UTF-8"));// + ",";
- }
- else
- value.append(vals[j]);
- } catch (UnsupportedEncodingException ex) {value.append(vals[j]);}
- catch (IllegalArgumentException ex1){value.append(vals[j]);}
- catch (Exception ex2){
- value.append(vals[j]);
- }
-
-
- if(isMultiValue) value.append("'");
-
- if(j != vals.length -1) {
- value.append(",");
- }
- }
- if(vals.length > 0) {
- value.append(")");
- }
- }
-
- //value = value.substring(0 , value.length());
-
- valuesMap.put(fieldNameMap.get(formField), value.toString());
- value = new StringBuffer("");
- } else if(request.getParameter(formField) != null) {
- if(isTextArea) {
- String value = "";
- value = request.getParameter(formField);
-
- value = Utils.oracleSafe(value);
- value = "('" + Utils.replaceInString(value, ",", "'|'") + "')";
- value = Utils.replaceInString(value, "|", ",");
- valuesMap.put(fieldNameMap.get(formField), value);
- value = "";
- } else {
- String value = "";
- if(!AppUtils.getRequestFlag(request, AppConstants.RI_RESET_ACTION))
- value = request.getParameter(formField);
- valuesMap.put(fieldNameMap.get(formField), Utils.oracleSafe(value));
- }
-
- } else {
- valuesMap.put(fieldNameMap.get(formField), "" );
- }
-
- }
-
- return valuesMap;
-
- }
-
-}
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartWebRuntime.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartWebRuntime.java
deleted file mode 100644
index 3fb24402..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartWebRuntime.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.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.openecomp.portalsdk.analytics.error.RaptorException;
-import org.openecomp.portalsdk.analytics.model.ReportHandler;
-import org.openecomp.portalsdk.analytics.system.AppUtils;
-import org.openecomp.portalsdk.analytics.util.AppConstants;
-import org.openecomp.portalsdk.analytics.view.ReportData;
-import org.openecomp.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 StringBuffer whereClause = new StringBuffer("");
- // 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<String, Object>();
-
- //from chart generator retrieves list of charts to render
- public ArrayList chartList;
- public ArrayList infoList;
-
- private String totalSql;
-
-
- //
- private String drilldown_index = "0";
-
- public List getRolesCommaSeperated(HttpServletRequest request) {
- HashMap roles = UserUtils.getRoles(request);
- List roleList = null;
- StringBuffer roleBuf = new StringBuffer("");
- int count = 0;
- 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 = (!action.equals("chart.json") || action.equals("chart.data.json"));
-
-
-
- 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, String>();
-
- 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) {
- StringBuffer title = new StringBuffer("");
- title.append(reportRuntime.getReportName());
- }
-
- if(! (action.equals("chart.json") || action.equals("chart.data.json"))) {
-
-
- //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 ArrayList getChartList() {
- return chartList;
- }
-
- /**
- * @param chartList the chartList to set
- */
- public void setChartList(ArrayList chartList) {
- this.chartList = chartList;
- }
-
- /**
- * @return the infoList
- */
- public ArrayList getInfoList() {
- return infoList;
- }
-
- /**
- * @param infoList the infoList to set
- */
- public void setInfoList(ArrayList 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(HashMap<String,String> chartOptionsMap, HttpServletRequest request) {
-
- ChartD3Helper chartHelper = new ChartD3Helper(reportRuntime);
- chartHelper.setChartType(reportRuntime.getChartType());
- try {
- return chartHelper.createVisualization(reportRuntime, chartOptionsMap, request);
- } catch(RaptorException ex) {
- ex.printStackTrace();
- }
- return "";
-
- }
-
- 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 "";
-
- }
-
- }
-
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/CommonChartOptions.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/CommonChartOptions.java
deleted file mode 100644
index e8ba2ee5..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/CommonChartOptions.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-public class CommonChartOptions {
-
- private String legendPosition = "top";
- private String legendLabelAngle = "up45";
- private boolean hideLegend = false;
- private boolean animateAnimatedChart = true;
- private int topMargin = 30;
- private int bottomMargin = 50;
- private int leftMargin = 100;
- private int rightMargin = 60;
-
- public String getLegendPosition() {
- return legendPosition;
- }
- public void setLegendPosition(String legendPosition) {
- this.legendPosition = legendPosition;
- }
- public String getLegendLabelAngle() {
- return legendLabelAngle;
- }
- public void setLegendLabelAngle(String legendLabelAngle) {
- this.legendLabelAngle = legendLabelAngle;
- }
- public boolean isHideLegend() {
- return hideLegend;
- }
- public void setHideLegend(boolean hideLegend) {
- this.hideLegend = hideLegend;
- }
- public boolean isAnimateAnimatedChart() {
- return animateAnimatedChart;
- }
- public void setAnimateAnimatedChart(boolean animateAnimatedChart) {
- this.animateAnimatedChart = animateAnimatedChart;
- }
- public int getTopMargin() {
- return topMargin;
- }
- public void setTopMargin(int topMargin) {
- this.topMargin = topMargin;
- }
- public int getBottomMargin() {
- return bottomMargin;
- }
- public void setBottomMargin(int bottomMargin) {
- this.bottomMargin = bottomMargin;
- }
- public int getLeftMargin() {
- return leftMargin;
- }
- public void setLeftMargin(int leftMargin) {
- this.leftMargin = leftMargin;
- }
- public int getRightMargin() {
- return rightMargin;
- }
- public void setRightMargin(int rightMargin) {
- this.rightMargin = rightMargin;
- }
-}
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ErrorJSONRuntime.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ErrorJSONRuntime.java
deleted file mode 100644
index d619c4e0..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ErrorJSONRuntime.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-public class ErrorJSONRuntime {
-
- private String errormessage;
- private String stacktrace;
-
- public String getErrormessage() {
- return errormessage;
- }
- public void setErrormessage(String errormessage) {
- this.errormessage = errormessage;
- }
- public String getStacktrace() {
- return stacktrace;
- }
- public void setStacktrace(String stacktrace) {
- this.stacktrace = stacktrace;
- }
-
-
-
-
-}
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FlexTimeSeriesChartOptions.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FlexTimeSeriesChartOptions.java
deleted file mode 100644
index 3b3060bb..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FlexTimeSeriesChartOptions.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-public class FlexTimeSeriesChartOptions {
- private int zoomIn = 25;
- private String timeAxisType = "";
- public int getZoomIn() {
- return zoomIn;
- }
- public void setZoomIn(int zoomIn) {
- this.zoomIn = zoomIn;
- }
- public String getTimeAxisType() {
- return timeAxisType;
- }
- public void setTimeAxisType(String timeAxisType) {
- this.timeAxisType = timeAxisType;
- }
-
-}
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FormField.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FormField.java
deleted file mode 100644
index ea215679..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FormField.java
+++ /dev/null
@@ -1,2111 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-/* ===========================================================================================
- * This class is part of <I>RAPTOR (Rapid Application Programming Tool for OLAP Reporting)</I>
- * Raptor : This tool is used to generate different kinds of reports with lot of utilities
- * ===========================================================================================
- *
- * -------------------------------------------------------------------------------------------
- * FormField.java - This class is used to generate all types of form field.
- * -------------------------------------------------------------------------------------------
- *
- * Created By : Stan Pishamanov
- * Modified & Maintained By : Sundar Ramalingam
- *
- * Changes
- * -------
- * 18-Aug-2009 : Version 8.5 (Sundar); Populating predefined formfields bug has been resolved.
- * 13-Aug-2009 : Version 8.5 (RS); Form field chaining is supported even for hidden variables.
- * 13-Aug-2009 : Version 8.5 (RS); Nothing changed just comment.
- * 10-Aug-2009 : Version 9.0 (RS); required logic is added for Multiple Dropdown.
- * 06-Aug-2009 : Version 9.0 (RS); B getAjaxHtml is added for converting form field chain from Iframe to AJAX.
- * 08-Jun-2009 : Version 8.3 (RS); Hidden formfields now is displayed even when the sql is not provided.
- *
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.openecomp.portalsdk.analytics.error.RaptorRuntimeException;
-import org.openecomp.portalsdk.analytics.error.UserDefinedException;
-import org.openecomp.portalsdk.analytics.model.base.IdNameList;
-import org.openecomp.portalsdk.analytics.model.base.IdNameLookup;
-import org.openecomp.portalsdk.analytics.model.base.IdNameSql;
-import org.openecomp.portalsdk.analytics.model.base.IdNameValue;
-import org.openecomp.portalsdk.analytics.system.AppUtils;
-import org.openecomp.portalsdk.analytics.system.ConnectionUtils;
-import org.openecomp.portalsdk.analytics.system.Globals;
-import org.openecomp.portalsdk.analytics.util.DataSet;
-import org.openecomp.portalsdk.analytics.util.Utils;
-import org.openecomp.portalsdk.analytics.xmlobj.JavascriptItemType;
-
-public class FormField extends org.openecomp.portalsdk.analytics.RaptorObject implements Serializable {
- private static final String HTML_FORM = "formd";
-
- private String fieldName = null;
-
- private String fieldDisplayName = null;
-
- private String fieldType = FFT_TEXT_W_POPUP;
-
- private String validationType = VT_NONE;
-
- private boolean required = false;
-
- public boolean hasPredefinedList = false;
-
- private String defaultValue = null;
-
- private Calendar rangeStartDate = null;
-
- private Calendar rangeEndDate = null;
-
- private String rangeStartDateSQL = null;
-
- private String rangeEndDateSQL = null;
-
- private String fieldDefaultSQL = null;
-
- private String multiSelectListSize = null;
-
- private String helpText = null;
-
- private IdNameList lookupList = null;
-
- private String dbInfo = null;
-
- private String userId = null;
-
- private boolean visible = true;
-
- private String dependsOn = null;
-
- private boolean triggerOtherFormFields = false;
-
- private boolean triggerThisFormfield = false;
-
- // Form field types
- public static final String FFT_TEXT_W_POPUP = "TEXT_WITH_POPUP";
-
- public static final String FFT_TEXT = "TEXT";
-
- public static final String FFT_TEXTAREA = "TEXTAREA";
-
- public static final String FFT_COMBO_BOX = "COMBO_BOX";
-
- public static final String FFT_LIST_BOX = "LIST_BOX";
-
- public static final String FFT_RADIO_BTN = "RADIO_BTN";
-
- public static final String FFT_CHECK_BOX = "CHECK_BOX";
-
- public static final String FFT_LIST_MULTI = "LIST_MULTI_SELECT";
-
- public static final String FFT_HIDDEN = "HIDDEN";
-
- public static final String FFT_BLANK = "BLANK";
-
- // Validation types
- public static final String VT_NONE = "NONE";
-
- public static final String VT_DATE = "DATE";
-
- public static final String VT_TIMESTAMP_HR = "TIMESTAMP_HR";
-
- public static final String VT_TIMESTAMP_MIN = "TIMESTAMP_MIN";
-
- public static final String VT_TIMESTAMP_SEC = "TIMESTAMP_SEC";
-
- public static final String VT_INT = "INTEGER";
-
- public static final String VT_INT_POSITIVE = "POSITIVE_INTEGER";
-
- public static final String VT_INT_NON_NEGATIVE = "NON_NEGATIVE_INTEGER";
-
- public static final String VT_FLOAT = "FLOAT";
-
- public static final String VT_FLOAT_POSITIVE = "POSITIVE_FLOAT";
-
- public static final String VT_FLOAT_NON_NEGATIVE = "NON_NEGATIVE_FLOAT";
-
- private FormField(String fieldName, String fieldDisplayName, String fieldType,
- String validationType, boolean required, String defaultValue, String helpText, boolean visible, String dependsOn, Calendar rangeStartDate, Calendar rangeEndDate,
- String rangeStartDateSQL, String rangeEndDateSQL, String multiSelectListSize ) {
- //super();
- this (fieldName,fieldDisplayName,fieldType,validationType,required,defaultValue,helpText, dependsOn, rangeStartDate, rangeEndDate, rangeStartDateSQL, rangeEndDateSQL, multiSelectListSize);
- setVisible(visible);
- } // FormField
-
- private FormField(String fieldName, String fieldDisplayName, String fieldType,
- String validationType, boolean required, String defaultValue, String helpText, String dependsOn, Calendar rangeStartDate, Calendar rangeEndDate,
- String rangeStartDateSQL, String rangeEndDateSQL, String multiSelectListSize ) {
- super();
- setFieldName(fieldName);
- setFieldDisplayName(fieldDisplayName);
- setFieldType(nvl(fieldType, FFT_TEXT));
- setValidationType(validationType);
- setRequired(required);
- setDefaultValue(defaultValue);
- setHelpText(helpText);
- setDependsOn(dependsOn);
- setRangeStartDate(rangeStartDate);
- setRangeEndDate(rangeEndDate);
- setRangeStartDateSQL(rangeStartDateSQL);
- setRangeEndDateSQL(rangeEndDateSQL);
- setMultiSelectListSize(multiSelectListSize);
- }
- public FormField(String fieldName, String fieldDisplayName, String fieldType,
- String validationType, boolean required, String defaultValue, String helpText,
- List predefinedValues, boolean visible, String dependsOn, Calendar rangeStartDate, Calendar rangeEndDate,
- String rangeStartDateSQL, String rangeEndDateSQL, String multiSelectListSize) {
- this(fieldName, fieldDisplayName, fieldType, validationType, required, defaultValue,
- helpText,visible, dependsOn, rangeStartDate, rangeEndDate, rangeStartDateSQL, rangeEndDateSQL, multiSelectListSize);
- if (predefinedValues != null)
- setPredefinedListLookup(predefinedValues);
- } // FormField
-
- public FormField(String fieldName, String fieldDisplayName, String fieldType,
- String validationType, boolean required, String defaultValue, String helpText,
- String lookupSql, boolean visible, String dependsOn, Calendar rangeStartDate, Calendar rangeEndDate,
- String rangeStartDateSQL, String rangeEndDateSQL, String multiSelectListSize ) {
- this(fieldName, fieldDisplayName, fieldType, validationType, required, defaultValue,
- helpText,visible, dependsOn, rangeStartDate, rangeEndDate, rangeStartDateSQL, rangeEndDateSQL, multiSelectListSize);
- if (defaultValue!=null && defaultValue.length()>10 && defaultValue.substring(0,10).trim().toLowerCase().startsWith("select")) {
- setFieldDefaultSQL(defaultValue);
- setDefaultValue("");
- }
- setLookupList(new IdNameSql(lookupSql,defaultValue));
- } // FormField
-
- public FormField(String fieldName, String fieldDisplayName, String fieldType,
- String validationType, boolean required, String defaultValue, String helpText,
- String dbTableName, String dbIdField, String dbNameField, String dbSortByField, boolean visible, String dependsOn, Calendar rangeStartDate, Calendar rangeEndDate,
- String rangeStartDateSQL, String rangeEndDateSQL, String multiSelectListSize) {
- this(fieldName, fieldDisplayName, fieldType, validationType, required, defaultValue,
- helpText,dbTableName,dbIdField,dbNameField,dbSortByField, dependsOn, rangeStartDate, rangeEndDate, rangeStartDateSQL, rangeEndDateSQL, multiSelectListSize);
- setVisible(visible);
- }
-
- public FormField(String fieldName, String fieldDisplayName, String fieldType,
- String validationType, boolean required, String defaultValue, String helpText,
- String dbTableName, String dbIdField, String dbNameField, String dbSortByField, String dependsOn,
- Calendar rangeStartDate, Calendar rangeEndDate,
- String rangeStartDateSQL, String rangeEndDateSQL, String multiSelectListSize ) {
- this(fieldName, fieldDisplayName, fieldType, validationType, required, defaultValue,
- helpText,dependsOn, rangeStartDate, rangeEndDate, rangeStartDateSQL, rangeEndDateSQL, multiSelectListSize);
- //if(dependsOn !=null){ this.dependsOn = dependsOn; }else { this.dependsOn = ""
- if (defaultValue!=null && defaultValue.length()>10 && defaultValue.substring(0,10).trim().toLowerCase().startsWith("select")) {
- setFieldDefaultSQL(defaultValue);
- setDefaultValue("");
- if(fieldType.equals(FFT_TEXT))
- setLookupList(new IdNameLookup(dbTableName, dbIdField, dbNameField, dbSortByField,defaultValue,true));
- else
- setLookupList(new IdNameLookup(dbTableName, dbIdField, dbNameField, dbSortByField,defaultValue,false));
- }
- else {
- if(fieldType.equals(FFT_TEXT))
- setLookupList(new IdNameLookup(dbTableName, dbIdField, dbNameField, dbSortByField, true));
- else
- setLookupList(new IdNameLookup(dbTableName, dbIdField, dbNameField, dbSortByField, false));
- }
-
- this.setRangeStartDate(rangeStartDate);
- this.setRangeEndDate(rangeEndDate);
- this.setRangeStartDateSQL(rangeStartDateSQL);
- this.setRangeEndDateSQL(rangeEndDateSQL);
-
- } // FormField
-
-
- private void setPredefinedListLookup(List predefinedValues) {
- IdNameList lookup = new IdNameList();
- for (Iterator iter = predefinedValues.iterator(); iter.hasNext();) {
- String value = (String) iter.next();
- lookup.addValue(value, value);
- } // for
- setHasPredefinedList(true);
- setLookupList(lookup);
- } // setPredefinedListLookup
-
- public String getFieldName() {
- return fieldName;
- }
-
- public String getFieldDisplayName() {
- return fieldDisplayName;
- }
-
- public String getFieldType() {
- return fieldType;
- }
-
- public String getValidationType() {
- return validationType;
- }
-
- public boolean isRequired() {
- return required;
- }
-
- public String getDefaultValue() {
- return defaultValue;
- }
-
- public String getHelpText() {
- return helpText;
- }
-
- public IdNameList getLookupList() {
- return lookupList;
- }
-
- public void setFieldName(String fieldName) {
- this.fieldName = fieldName;
- }
-
- public void setFieldDisplayName(String fieldDisplayName) {
- this.fieldDisplayName = fieldDisplayName;
- }
-
- public void setFieldType(String fieldType) {
- this.fieldType = fieldType;
- }
-
- public void setValidationType(String validationType) {
- this.validationType = nvl(validationType, VT_NONE);
- }
-
- public void setRequired(boolean required) {
- this.required = required;
- }
-
- public void setDefaultValue(String defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- public void setHelpText(String helpText) {
- this.helpText = helpText;
- }
-
- public void setLookupList(IdNameList lookupList) {
- this.lookupList = lookupList;
- }
-
- public void setDefaultList(IdNameList lookupList) {
- this.lookupList = lookupList;
- }
-
- public String getBaseSQL() {
- return (lookupList == null) ? null : lookupList.getBaseSQL();
- } // getBaseSQL
-
- public String getBaseWholeSQL() {
- return (lookupList == null) ? null : lookupList.getBaseWholeSQL();
- } // getBaseWholeSQL
-
- public String getBaseWholeReadonlySQL() {
- return (lookupList == null) ? null : lookupList.getBaseWholeReadonlySQL();
- } // getBaseWholeReadonlySQL
-
- public String getBaseSQLForPDFExcel() {
- return (lookupList == null) ? null : lookupList.getBaseSQLForPDFExcel(getFieldType().equals(FFT_LIST_MULTI)||getFieldType().equals(FFT_CHECK_BOX)?true:false);
- } // getBaseSQLForPDFExcel
-
- public String getDisplayNameHtml() {
- if (nvl(helpText).length() > 0)
- return "<a title=\"" + helpText + "\">" + fieldDisplayName + "</a>";
- else
- return fieldDisplayName;
- } // getDisplayNameHtml
-
- /*public String getHtml() throws RaptorRuntimeException {
- return getHtml("" , null, null, false);
- } // getHtml*/
-
- public String getHtml(String fieldValue, HashMap formValues, ReportRuntime rr)throws RaptorRuntimeException {
- return getHtml(fieldValue,formValues, rr, false);
- }
-
- public String getHelpLink(String fieldName) {
- //return "<a href=\"#\" onclick=\"javascript:ShowContent('" + fieldName + "_div')\"><img src=\""+AppUtils.getBaseFolderURL()+"images/quickhelp_dk.gif\" width=\"12\" height=\"12\" alt=\"\" border=\"0\" class=\"qh-element\" /></a>";
- return ((getHelpText()!=null && getHelpText().length()>0)? "tooltipText=\""+ getHelpText()+"\">": ">");
- //return ((getHelpText()!=null && getHelpText().length()>0)? "<img src=\"static/fusion/raptor/images/quickhelp_lt.gif\" tooltipText=\""+ getHelpText() + "\"/>": "");
- }
-
-
- public String getCallableAfterChainingJavascript(String fieldName, ReportRuntime rr) {
- JavascriptItemType javascriptItemType = null;
- StringBuffer callJavascriptText = new StringBuffer("");
- if(rr.getJavascriptList()!=null) {
- for (Iterator iter = rr.getJavascriptList().getJavascriptItem().iterator(); iter.hasNext();) {
- javascriptItemType = (JavascriptItemType)iter.next();
- if(javascriptItemType.getFieldId().equals(fieldName)) {
- if(nvl(javascriptItemType.getCallText()).toLowerCase().startsWith("afterchaining"))
- callJavascriptText.append(" "+javascriptItemType.getCallText());
- }
- }
- }
- return callJavascriptText.toString()+" ";
- }
- public String getCallableJavascript(String fieldName, ReportRuntime rr) {
- JavascriptItemType javascriptItemType = null;
- StringBuffer callJavascriptText = new StringBuffer("");
- if(rr.getJavascriptList()!=null) {
- for (Iterator iter = rr.getJavascriptList().getJavascriptItem().iterator(); iter.hasNext();) {
- javascriptItemType = (JavascriptItemType)iter.next();
- if(javascriptItemType.getFieldId().equals(fieldName)) {
- if(!nvl(javascriptItemType.getCallText()).toLowerCase().startsWith("afterchaining"))
- callJavascriptText.append(" "+javascriptItemType.getCallText());
- }
- }
- }
- return callJavascriptText.toString()+" ";
- }
-
- public String getCallableOnChangeJavascript(String fieldName, ReportRuntime rr) {
- String callText = getCallableJavascript(fieldName, rr);
- if(callText != null && callText.trim().toLowerCase().indexOf("onchange")>=0) {
- Pattern re1 = Pattern.compile("\\=(.*?)\\)");
- Matcher matcher = re1.matcher(callText);
- while (matcher.find()) {
- callText = matcher.group();
- if(callText!=null && callText.startsWith("=\"")) {
- callText = callText.substring(2);
- } else if (callText!=null)
- callText = callText.substring(1);
- }
- callText = callText.replaceAll("this", "documentForm."+fieldName);
- } else callText = null;
- return callText;
- }
-
- public String getAjaxHtml(String fieldValue, HashMap formValues, ReportRuntime rr, boolean inSchedule) throws RaptorRuntimeException {
- fieldValue = nvl(fieldValue, defaultValue);
- String readOnly = "ff_readonly";
- try {
- if(fieldValue !=null && fieldValue.length() > 0)
- fieldValue = java.net.URLDecoder.decode(fieldValue, "UTF-8");
- } catch (UnsupportedEncodingException ex) {}
- catch (IllegalArgumentException ex1){}
- catch (Exception ex2){}
- if (fieldType.equals(FFT_COMBO_BOX)) {
- StringBuffer sb = new StringBuffer();
- //System.out.println("COMBO BOX " + fieldName);
- String oldSQL = "";
- if (!required)
- sb.append("obj.options[obj.options.length] = new Option('-->select value<--','');");
-
- IdNameList lookup = getLookupList();
- try {
- if(!hasPredefinedList) {
- //if(dependsOn != null && dependsOn != "") {
- //if(dependsOn != null && dependsOn != "" ) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = "";
- SQL = lu.getSql();
- /*if(nvl(fieldValue,"").length()<=0)
- SQL = lu.getSql();
- else
- SQL = lu.getBaseSQLForPDFExcel(false);
- */
- //System.out.println("FORMFIELD 6666667 First" + ((IdNameSql)lookup).getSql());
- oldSQL = lu.getSql();
- //SQL = Utils.replaceInString(SQL, "[VALUE]", fieldValue);
- if(formValues != null) {
- Set set = formValues.entrySet();
- String value = "";
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry) iter.next();
- value = (String) entry.getValue();
- if(inSchedule) {
- try {
- value = java.net.URLDecoder.decode(Utils.oracleSafe(value), "UTF-8");
- } catch (UnsupportedEncodingException ex) {
-
- }
- }
- if (value!=null && (value.length() <=0 || value.equals("NULL"))) {
- value = "NULL";
- SQL = Utils.replaceInString(SQL, "'["+entry.getKey()+"]'", value);
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", value);
- } else {
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", value);
- }
- }
- lookup = new IdNameSql(-1,SQL,lu.getDefaultSQL());
- }
- //}
- lookupList = lookup;
-
- //}
- try {
- lookup.loadUserData(0, "", getDbInfo(), getUserId());
- } catch (Exception e ){ e.printStackTrace(); //throw new RaptorRuntimeException(e);
- }
- }
- lookup.trimToSize();
-
- String selectedValue = "";
- int count = 0;
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- if(value != null && value.getId() != null && value.getName() != null ) {
- /*if (count == 0 && required) {
- selectedValue = value.getId();
- count++;
- } else if (nvl(fieldValue).length()>0){
- if (fieldValue != null && fieldValue.equals(value.getId())){
- selectedValue = value.getId();
- }
- count++;
- } else {
- count++;
- } */
- if (count == 0) {
- if(required){
- selectedValue = value.getId();
- }
- count++;
- }
- sb.append("obj.options[obj.options.length] = new Option('" + Utils.singleQuoteEncode(value.getName())+"','"+Utils.singleQuoteEncode(value.getId())+"');");
- if ((fieldValue != null && fieldValue.equals(value.getId()))){
- sb.append("obj.options[obj.options.length-1].selected=true;");
- selectedValue = value.getId();
- }
- if(value.isReadOnly())
- sb.append("obj.disabled=true;");
- else
- sb.append("obj.disabled=false;");
-
- }
- } // for
- if (formValues.containsKey(fieldDisplayName)){
- formValues.remove(fieldDisplayName);
- }
- formValues.put(fieldDisplayName, selectedValue);
- } catch (Exception e) {
- //throw new RaptorRuntimeException(e);
- }
- if(!hasPredefinedList) {
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- }
- //System.out.println("FORMFIELD 6666667 " + ((IdNameSql)lookup).getSql());
- if( isVisible())
- return sb.toString();
- else return "";
- } else if (fieldType.equals(FFT_LIST_MULTI)) {
- StringBuffer sb = new StringBuffer();
- String oldSQL = "";
-
- fieldValue = '|' + fieldValue + '|';
- IdNameList lookup = getLookupList();
- try {
- if(!hasPredefinedList) {
- //if(dependsOn != null && dependsOn != "") {
- //if(dependsOn != null && dependsOn != "" ) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = "";
- SQL = lu.getSql();
- /*if(nvl(fieldValue,"").length()<=0)
- SQL = lu.getSql();
- else
- SQL = lu.getBaseSQLForPDFExcel(false);
- SQL = Utils.replaceInString(SQL, "[VALUE]", fieldValue);
- */
- oldSQL = lu.getSql();
- if(formValues != null) {
- Set set = formValues.entrySet();
- String value = "";
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry) iter.next();
- value = (String) entry.getValue();
- if(inSchedule) { //('1347')
- try {
- value = java.net.URLDecoder.decode(value, "UTF-8");
- } catch (UnsupportedEncodingException ex) {
-
- }
- }
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", value);
- }
- lookup = new IdNameSql(-1,SQL,lu.getDefaultSQL());
- }
- //}
- lookupList = lookup;
- //}
-
- lookup.loadUserData(0, "", getDbInfo(),getUserId());
- }
-
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- sb.append("obj.options[obj.options.length] = new Option('" + Utils.singleQuoteEncode(value.getName()) +"','"+Utils.singleQuoteEncode(value.getId())+"');");
- if (fieldValue.indexOf('|' + value.getId() + '|') >= 0)
- sb.append("obj.options[obj.options.length-1].selected=true;");
- if(value.isReadOnly())
- sb.append("obj.disabled=true;");
- else
- sb.append("obj.disabled=false;");
-
- } // for
-
- // lookup.clearData();
- } catch (Exception e) {
- //throw new RaptorRuntimeException(e);
- }
- if(!hasPredefinedList) {
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- }
- if(isVisible())
- return sb.toString();
- else
- return "";
- } else if (fieldType.equals(FFT_TEXT_W_POPUP)) {
- //System.out.println("TEXT POPUP " + fieldName);
- String oldSQL = "";
- IdNameValue idNamevalue = null;
- String fieldDefValue="";
- String fieldDefDisplay="";
- try {
- IdNameList lookup = getLookupList();
- if(dependsOn != null && dependsOn != "" ) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = getBaseWholeSQL();
- if(SQL.toLowerCase().indexOf(readOnly) != -1) {
- SQL = getBaseWholeReadonlySQL();
- }
- oldSQL = lu.getSql();
- if(formValues != null) {
- Set set = formValues.entrySet();
- String value = "";
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry) iter.next();
- value = (String) entry.getValue();
- if(inSchedule) {
- try {
- value = java.net.URLDecoder.decode(Utils.oracleSafe(value), "UTF-8");
- } catch (UnsupportedEncodingException ex) {
-
- }
- }
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", value);
-// if(SQL.indexOf("'"+"["+entry.getKey()+"]"+"'")!=-1) {
- if(SQL.indexOf("'"+"["+entry.getKey()+"]"+"'")!=-1 || SQL.indexOf("'"+"["+entry.getKey())!=-1 || SQL.indexOf(entry.getKey()+"]"+"'")!=-1
- || SQL.indexOf("'%"+"["+entry.getKey()+"]"+"%'")!=-1 || SQL.indexOf("'%"+"["+entry.getKey())!=-1 || SQL.indexOf(entry.getKey()+"]"+"%'")!=-1
- || SQL.indexOf("'_"+"["+entry.getKey()+"]"+"_'")!=-1 || SQL.indexOf("'_"+"["+entry.getKey())!=-1 || SQL.indexOf(entry.getKey()+"]"+"_'")!=-1
- || SQL.indexOf("'%_"+"["+entry.getKey()+"]"+"_%'")!=-1 || SQL.indexOf("'%_"+"["+entry.getKey())!=-1 || SQL.indexOf(entry.getKey()+"]"+"_%'")!=-1) {
-
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", nvl(
- value, "NULL"));
- } else {
- // Added to prevent SQL Injection
- if(SQL.indexOf("["+entry.getKey()+"]")!=-1) {
- try {
- double vD = Double.parseDouble(value);
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", nvl(
- value, "NULL"));
- } catch (NumberFormatException ex) {
- throw new UserDefinedException("Expected number, Given String for the form field \"" + "["+entry.getKey()+"]"+"\"");
- }
- }
- }
- }
- if(getFieldDefaultSQL()!=null && (fieldValue == null || fieldValue.trim().equalsIgnoreCase("null")|| fieldValue.trim().length()<=0))
- lookup = new IdNameSql(-1,SQL,lu.getDefaultSQL());
- else
- lookup = new IdNameSql(-1,SQL,null);
- }
- }
- //lookupList = lookup;
-
- if(getFieldDefaultSQL()!=null && (fieldValue == null || fieldValue.trim().equalsIgnoreCase("null")|| fieldValue.trim().length()<=0)) {
- lookup.loadUserData(0, "", getDbInfo(), getUserId());
- for (lookup.resetNext(); lookup.hasNext();) {
- idNamevalue = lookup.getNext();
- break;
-
- }
- fieldDefValue = nvl(idNamevalue.getId());
- fieldDefDisplay = nvl(idNamevalue.getName());
- } else {
- try {
- // -2 indicates to run the whole sql for matching value
- lookup.loadUserData(-2, "", getDbInfo(), getUserId());
- lookup.trimToSize();
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- if(value != null && value.getId() != null && value.getName() != null ) {
- fieldDefValue = nvl(value.getId());
- if (fieldValue != null && fieldValue.equals(value.getId())) {
- fieldDefDisplay = nvl(value.getName());
- break;
- }
- else {
- fieldDefValue = "";
- fieldDefDisplay = "";
- }
- }
- }
- if (fieldDefDisplay == null || fieldDefDisplay.length()<=0) {
- fieldDefDisplay = nvl(fieldDefValue);
- }
-
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
-
- } catch (Exception e) {
- //throw new RaptorRuntimeException(e);
- }
-
-
- //----- END ---//
-
-
- if(getFieldDefaultSQL()!=null && (fieldValue == null || fieldValue.trim().equalsIgnoreCase("null")|| fieldValue.length()<=0)) {
- fieldDefValue = nvl((idNamevalue!=null)?idNamevalue.getId():"");
- fieldDefDisplay = nvl((idNamevalue!=null)?idNamevalue.getName():"");
- } else {
- if(fieldValue == null || fieldValue.trim().equalsIgnoreCase("null")|| fieldValue.length()<=0) fieldValue="";
- fieldDefValue = nvl(fieldDefValue);
- fieldDefDisplay = nvl(fieldDefDisplay);
- }
-
- }
- }catch(Exception e) { //throw new RaptorRuntimeException(e);
- }
- if(isVisible()) {
- /* return "<input type=text class=\"text\" size=30 maxlength=50 id=\"" + fieldName +"\" name=\"" + fieldName + "\" value=\""
- + nvl(fieldDefValue) + "\">\n" + "<a href=\"javascript:showArgPopupNew('"
- + fieldName + "', 'document.formd." + fieldName
- + "')\"><img border=0 src=\"" + AppUtils.getImgFolderURL()
- + "shareicon.gif\" " + getHelpLink(fieldName);
- */
- return "obj.value=\""+Utils.singleQuoteEncode(nvl(fieldDefValue))+"\";";
-
- } else
- return "";
- } else if (fieldType.equals(FFT_HIDDEN) || fieldType.equals(FFT_TEXT) || fieldType.equals(FFT_TEXTAREA) ) {
- StringBuffer sb = new StringBuffer();
- String oldSQL = "";
- try {
- IdNameList lookup = getLookupList();
- //if(dependsOn != null && dependsOn != "") {
- //if(dependsOn != null && dependsOn != "" ) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = lu.getSql();
- //System.out.println("SQL HIDDEN 1 " + SQL);
- oldSQL = lu.getSql();
- if(formValues != null) {
- Set set = formValues.entrySet();
- String value = "";
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry) iter.next();
- value = (String) entry.getValue();
- if(value == null || value.trim().length()<=0) {
- value = "NULL";
- }
- if(inSchedule) {
- try {
- value = java.net.URLDecoder.decode(value, "UTF-8");
- } catch (UnsupportedEncodingException ex) {
-
- }
- }
- //System.out.println("HIDDEN " + "["+entry.getKey()+"]" + "-" + value);
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", value);
- }
-
- lookup = new IdNameSql(-1,SQL,lu.getDefaultSQL());
- }
- //System.out.println("SQL HIDDEN 2 " + SQL);
- //}
- lookupList = lookup;
- //}
- if(nvl(fieldValue).length()>0 && (dependsOn == null || dependsOn.length()<=0)) {
- sb.append((fieldValue!=null)?"obj.value=\""+nvl(fieldValue)+"\";":"");
- } else if (lookup != null) {
- lookup.loadUserData(0, "", getDbInfo(), getUserId());
- int iCnt = 0;
- for (lookup.resetNext(); lookup.hasNext(); iCnt++) {
- IdNameValue value = lookup.getNext();
- //System.out.println("HIDDEN " + value.getId() + " " + value.getName());
- sb.append((value!=null)?"obj.value=\""+nvl(value.getId())+"\";":"");
- if(value.isReadOnly())
- sb.append("obj.disabled=true;");
- else
- sb.append("obj.disabled=false;");
- break;
- } // for
- if(lookup.size()<=0) {
- sb.append("obj.value=\"\"");
-
- }
- } else {
- sb.append((fieldValue!=null)?"obj.value=\""+Utils.singleQuoteEncode(nvl(fieldValue))+"\";":"");
- }
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- // lookup.clearData();
- } catch (Exception e) {
- //throw new RaptorRuntimeException(e);
- }
- //if(isVisible())
- return sb.toString() ;
- } else if (fieldType.equals(FFT_LIST_BOX)) {
- StringBuffer sb = new StringBuffer();
- //System.out.println("COMBO BOX " + fieldName);
- String oldSQL = "";
- if (!required)
- sb.append("obj.options[obj.options.length] = new Option('-->select value<--','');");
-
- IdNameList lookup = getLookupList();
- try {
- if(!hasPredefinedList) {
- //if(dependsOn != null && dependsOn != "") {
- //if(dependsOn != null && dependsOn != "" ) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = "";
- SQL = lu.getSql();
- /*if(nvl(fieldValue,"").length()<=0)
- SQL = lu.getSql();
- else
- SQL = lu.getBaseSQLForPDFExcel(false);
- */
- //System.out.println("FORMFIELD 6666667 First" + ((IdNameSql)lookup).getSql());
- oldSQL = lu.getSql();
- //SQL = Utils.replaceInString(SQL, "[VALUE]", fieldValue);
- if(formValues != null) {
- Set set = formValues.entrySet();
- String value = "";
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry) iter.next();
- value = (String) entry.getValue();
- if(inSchedule) {
- try {
- value = java.net.URLDecoder.decode(Utils.oracleSafe(value), "UTF-8");
- } catch (UnsupportedEncodingException ex) {
-
- }
- }
- if (value!=null && (value.length() <=0 || value.equals("NULL"))) {
- value = "NULL";
- SQL = Utils.replaceInString(SQL, "'["+entry.getKey()+"]'", value);
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", value);
- } else {
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", value);
- }
- }
- lookup = new IdNameSql(-1,SQL,lu.getDefaultSQL());
- }
- //}
- lookupList = lookup;
-
- //}
- try {
- lookup.loadUserData(0, "", getDbInfo(), getUserId());
- } catch (Exception e ){ e.printStackTrace(); //throw new RaptorRuntimeException(e);
- }
- }
- lookup.trimToSize();
-
- String selectedValue = "";
- int count = 0;
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- if(value != null && value.getId() != null && value.getName() != null ) {
- /*if (count == 0 && required) {
- selectedValue = value.getId();
- count++;
- } else if (nvl(fieldValue).length()>0){
- if (fieldValue != null && fieldValue.equals(value.getId())){
- selectedValue = value.getId();
- }
- count++;
- } else {
- count++;
- } */
- if (count == 0) {
- if(required){
- selectedValue = value.getId();
- }
- count++;
- }
- sb.append("obj.options[obj.options.length] = new Option('" + Utils.singleQuoteEncode(value.getName())+"','"+Utils.singleQuoteEncode(value.getId())+"');");
- if ((fieldValue != null && fieldValue.equals(value.getId()))){
- sb.append("obj.options[obj.options.length-1].selected=true;");
- selectedValue = value.getId();
- }
- if(value.isReadOnly())
- sb.append("obj.disabled=true;");
- else
- sb.append("obj.disabled=false;");
-
- }
- } // for
- if (formValues.containsKey(fieldDisplayName)){
- formValues.remove(fieldDisplayName);
- }
- formValues.put(fieldDisplayName, selectedValue);
- } catch (Exception e) {
- //throw new RaptorRuntimeException(e);
- }
- if(!hasPredefinedList) {
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- }
- //System.out.println("FORMFIELD 6666667 " + ((IdNameSql)lookup).getSql());
- if( isVisible())
- return sb.toString();
- else return "";
- }
-
- return "";
- }
-
- public String getHtml(String fieldValue, HashMap formValues, ReportRuntime rr, boolean inSchedule) throws RaptorRuntimeException {
- fieldValue = nvl(fieldValue, defaultValue);
- int MILLIS_IN_DAY = 1000 * 60 * 60 * 24;
- String readOnlyInSql = "ff_readonly";
- boolean readOnly = false;
- try {
- if(fieldValue !=null && fieldValue.length() > 0)
- fieldValue = java.net.URLDecoder.decode(fieldValue, "UTF-8");
- } catch (UnsupportedEncodingException ex) {}
- catch (IllegalArgumentException ex1){}
- catch (Exception ex2){}
- //System.out.println(fieldName + " " + fieldType + " " + fieldValue);
- if (fieldType.equals(FFT_TEXT_W_POPUP)) {
- //System.out.println("TEXT POPUP " + fieldName);
- String oldSQL = "";
- IdNameValue idNamevalue = null;
- String fieldDefValue="";
- String fieldDefDisplay="";
- IdNameList lookup = null;
- try {
- lookup = getLookupList();
- if(!hasPredefinedList) {
- if(dependsOn != null && dependsOn != "" ) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = getBaseWholeSQL();
- if(SQL.toLowerCase().indexOf(readOnlyInSql) != -1) {
- SQL = getBaseWholeReadonlySQL();
- }
- oldSQL = lu.getSql();
- if(formValues != null) {
- Set set = formValues.entrySet();
- String value = "";
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry) iter.next();
- value = (String) entry.getValue();
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", value);
-// if(SQL.indexOf("'"+"["+entry.getKey()+"]"+"'")!=-1) {
- if(SQL.indexOf("'"+"["+entry.getKey()+"]"+"'")!=-1 || SQL.indexOf("'"+"["+entry.getKey())!=-1 || SQL.indexOf(entry.getKey()+"]"+"'")!=-1
- || SQL.indexOf("'%"+"["+entry.getKey()+"]"+"%'")!=-1 || SQL.indexOf("'%"+"["+entry.getKey())!=-1 || SQL.indexOf(entry.getKey()+"]"+"%'")!=-1
- || SQL.indexOf("'_"+"["+entry.getKey()+"]"+"_'")!=-1 || SQL.indexOf("'_"+"["+entry.getKey())!=-1 || SQL.indexOf(entry.getKey()+"]"+"_'")!=-1
- || SQL.indexOf("'%_"+"["+entry.getKey()+"]"+"_%'")!=-1 || SQL.indexOf("'%_"+"["+entry.getKey())!=-1 || SQL.indexOf(entry.getKey()+"]"+"_%'")!=-1) {
-
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", nvl(
- value, "NULL"));
- } else {
- // Added to prevent SQL Injection
- if(SQL.indexOf("["+entry.getKey()+"]")!=-1) {
- try {
- double vD = Double.parseDouble(value);
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", nvl(
- value, "NULL"));
- } catch (NumberFormatException ex) {
- throw new UserDefinedException("Expected number, Given String for the form field \"" + "["+entry.getKey()+"]"+"\"");
- }
- }
- }
- }
- if(getFieldDefaultSQL()!=null && (fieldValue == null || fieldValue.trim().equalsIgnoreCase("null")|| fieldValue.trim().length()<=0))
- lookup = new IdNameSql(-1,SQL,lu.getDefaultSQL());
- else
- lookup = new IdNameSql(-1,SQL,null);
- }
- }
- //lookupList = lookup;
-
- if(getFieldDefaultSQL()!=null && (fieldValue == null || fieldValue.trim().equalsIgnoreCase("null")|| fieldValue.trim().length()<=0)) {
- lookup.loadUserData(0, "", getDbInfo(), getUserId());
- for (lookup.resetNext(); lookup.hasNext();) {
- idNamevalue = lookup.getNext();
- break;
-
- }
- fieldDefValue = nvl(idNamevalue.getId());
- fieldDefDisplay = nvl(idNamevalue.getName());
- } else {
- try {
- // -2 indicates to run the whole sql for matching value
- lookup.loadUserData(-2, "", getDbInfo(), getUserId());
- } catch (Exception e) {
- //throw new RaptorRuntimeException(e);
- }
-
- lookup.trimToSize();
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- if(value != null && value.getId() != null && value.getName() != null ) {
- fieldDefValue = nvl(value.getId());
- if (fieldValue != null && fieldValue.equals(value.getId())) {
- fieldDefDisplay = nvl(value.getName());
- break;
- }
- else {
- fieldDefValue = "";
- fieldDefDisplay = "";
- }
- }
- }
- if (fieldDefDisplay == null || fieldDefDisplay.length()<=0) {
- fieldDefDisplay = nvl(fieldDefValue);
- }
-
-
-
- //----- END ---//
-
-
- if(getFieldDefaultSQL()!=null && (fieldValue == null || fieldValue.trim().equalsIgnoreCase("null")|| fieldValue.length()<=0)) {
- fieldDefValue = nvl((idNamevalue!=null)?idNamevalue.getId():"");
- fieldDefDisplay = nvl((idNamevalue!=null)?idNamevalue.getName():"");
- } else {
- if(fieldValue == null || fieldValue.trim().equalsIgnoreCase("null")|| fieldValue.length()<=0) fieldValue="";
- fieldDefValue = nvl(fieldDefValue);
- fieldDefDisplay = nvl(fieldDefDisplay);
- }
-
- }
- } else {
- lookup.trimToSize();
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- if(value != null && value.getId() != null && value.getName() != null ) {
- fieldDefValue = nvl(value.getId());
- if (fieldValue != null && fieldValue.equals(value.getId())) {
- fieldDefDisplay = nvl(value.getName());
- break;
- }
- else {
- fieldDefValue = "";
- fieldDefDisplay = "";
- }
- }
- }
- if (fieldDefDisplay == null || fieldDefDisplay.length()<=0) {
- fieldDefDisplay = nvl(fieldDefValue);
- }
- }
- }catch(Exception e) { //throw new RaptorRuntimeException(e);
- }
-
- if(!hasPredefinedList) {
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- }
-
- if(isVisible()) {
- /* return "<input type=text class=\"text\" size=30 maxlength=50 id=\"" + fieldName +"\" name=\"" + fieldName + "\" value=\""
- + nvl(fieldDefValue) + "\">\n" + "<a href=\"javascript:showArgPopupNew('"
- + fieldName + "', 'document.formd." + fieldName
- + "')\"><img border=0 src=\"" + AppUtils.getImgFolderURL()
- + "shareicon.gif\" " + getHelpLink(fieldName);
- */
- String progress = "<div id=\""+fieldName+"_content\" style=\"display:none;width:100%;height:100%;align:center;\"> <img src=\""+AppUtils.getImgFolderURL()+"progress.gif\" border=\"0\" alt=\"Loading, please wait...\" /></div> ";
-
- return progress+"<input type=\"text\" class=\"text\" name=\""+getFieldName()+"_display\" readonly=true value=\""+ fieldDefDisplay +"\""+ getCallableJavascript(getFieldName(), rr) + getHelpLink(fieldName) + " \n "
- +"<input type=\"hidden\" name=\""+getFieldName()+"\" value=\""+nvl(fieldDefValue)+"\"/> \n &nbsp;\n"
- + "<a href=\"javascript:showArgPopupNew('"
- + fieldName + "', 'document.formd." + fieldName
- + "')\"><img border=0 src=\"" + AppUtils.getImgFolderURL()
- + "shareicon.gif\" " + getHelpLink(fieldName);
-
- } else
- return "";
- } else if (fieldType.equals(FFT_TEXT)) {
- IdNameValue value = null;
- String strValue = "";
- boolean avail_ReadOnly = false;
- try {
- IdNameList lookup = getLookupList();
- IdNameSql lu = null;
- String valueSQL = "";
- String oldSQL = "";
- if(lookup instanceof IdNameSql) {
- lu = (IdNameSql) lookup;
- if(lu.getSql().length() > 0) {
- valueSQL = lu.getSql();
- avail_ReadOnly = (valueSQL.toLowerCase().indexOf(readOnlyInSql)!=-1);
- //System.out.println("OLD SQL TEXT" + valueSQL);
- //oldSQL = lu.getSql();
- if(formValues != null) {
- Set set = formValues.entrySet();
- String value1 = "";
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry) iter.next();
- value1 = (String) entry.getValue();
- if (value1.length() <=0) {
- value1 = "NULL";
- valueSQL = Utils.replaceInString(valueSQL, "'["+entry.getKey()+"]'", value1);
- valueSQL = Utils.replaceInString(valueSQL, "["+entry.getKey()+"]", value1);
- } else {
- valueSQL = Utils.replaceInString(valueSQL, "["+entry.getKey()+"]", value1);
- }
- }
- // should be value one.
- //lookup = new IdNameSql(-1,valueSQL,lu.getDefaultSQL());
- }
- }
- //lookupList = lookup;
- //System.out.println("8888888 88 " + valueSQL);
- }
- if(valueSQL!=null && valueSQL.length()>0) {
- DataSet ds = ConnectionUtils.getDataSet(valueSQL.toString(), dbInfo);
- strValue = ds.getString(0,1);
- if(avail_ReadOnly) readOnly = ds.getString(0, 2).toUpperCase().startsWith("Y")||ds.getString(0, 2).toUpperCase().startsWith("T");;
- }
- }catch(Exception e) { //throw new RaptorRuntimeException(e);
- }
- String returnString = "";
- String timestamp ="", timestamphr = "", timestampmin = "", timestampsec = "";
-
- returnString = "<input type=text class=\"text\" size="+(validationType.equals(VT_DATE)?"10":"30") +" maxlength=50 id=\"" + fieldName +"\" name=\""
- + fieldName + "\" id='"+ fieldName + "' "
- + (((validationType.equals(VT_DATE)||validationType.equals(VT_TIMESTAMP_HR) ||validationType.equals(VT_TIMESTAMP_MIN) ||validationType.equals(VT_TIMESTAMP_SEC))&& !inSchedule) ? "" : "")
- + getCallableJavascript(getFieldName(), rr) + " " + (readOnly?" readonly ":" ") + " value=\"";
-
-
- /*if(getFieldDefaultSQL()!=null)
- returnString += nvl(value.getId());
- else
- returnString += fieldValue;
- */
- if(fieldValue!=null && fieldValue.length()>0 && (!(fieldValue.toUpperCase().indexOf("SELECT ")!= -1 && fieldValue.toUpperCase().indexOf("FROM")!= -1)) ) {
- if(validationType.startsWith("TIMESTAMP")) {
- returnString += nvl((fieldValue!=null)?fieldValue.split(" ")[0]:"");
- if(fieldValue!=null && fieldValue.length()>0) {
- timestamp = (fieldValue.split(" ").length > 1)?fieldValue.split(" ")[1]:"";
- String timestampArr[] = timestamp.split(":");
- if((timestampArr.length == 1) || (timestampArr.length == 2) || (timestampArr.length == 3))
- timestamphr = timestampArr[0];
- if((timestampArr.length == 2) || (timestampArr.length == 3))
- timestampmin = timestampArr[1];
- if(timestampArr.length == 3)
- timestampsec = timestampArr[2];
- }
-
- } else returnString += fieldValue;
-
- } else if(getFieldDefaultSQL()!=null) {
-
- if(validationType.startsWith("TIMESTAMP")) {
- returnString += nvl((strValue.length()>0)?strValue.split(" ")[0]:"");
- if(strValue.length()>0) {
- timestamp = (strValue.split(" ").length > 1)?strValue.split(" ")[1]:"";
- String timestampArr[] = timestamp.split(":");
- if((timestampArr.length == 1) || (timestampArr.length == 2) || (timestampArr.length == 3))
- timestamphr = timestampArr[0];
- if((timestampArr.length == 2) || (timestampArr.length == 3))
- timestampmin = timestampArr[1];
- if(timestampArr.length == 3)
- timestampsec = timestampArr[2];
- }
-
- } else if (nvl(strValue).length()>0) {
- returnString += strValue;
- } else
- returnString += nvl((value!=null)?value.getId():"");
- } else if (nvl(strValue).length()>0) {
- returnString += strValue;
- } else
- returnString += nvl((value!=null)?value.getId():"");
-
-
- /*returnString += "\">"
- + (validationType.equals(VT_DATE) ? "\n\t\t\t<a href=\"#\" onClick=\"window.dateField=document."
- + HTML_FORM
- + "."
- + fieldName
- + ";calendar=window.open('"
- + AppUtils.getRaptorActionURL()
- + "popup.calendar','cal','WIDTH=200,HEIGHT=250');return false;\">"
- + "\n\t\t\t\t<img src=\""
- + AppUtils.getImgFolderURL()
- + "calender_icon.gif\" align=absmiddle border=0 width=20 height=20></a>"
- : ""); */
-
- SimpleDateFormat dtf = new SimpleDateFormat("MM/dd/yyyy");
- String stRangeText = this.getRangeStartDate() == null ? null : dtf.format(this.getRangeStartDate().getTime());
- String endRangeText = this.getRangeEndDate() == null ? null : dtf.format(this.getRangeEndDate().getTime());
- /////////////////////////
-
- //get the date sqls
-
- //System.out.println("////////////start range date before Start" + this.getRangeStartDateSQL());
-
- if (this.getRangeStartDateSQL() != null && this.getRangeStartDateSQL().trim().toLowerCase().startsWith("select")){
- //System.out.println("////////////start range date Starting");
- String SQL = this.getRangeStartDateSQL();
- if(formValues != null) {
- Set set = formValues.entrySet();
- String v = "";
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry) iter.next();
- v = (String) entry.getValue();
- //System.out.println("///////// key is " + entry.getKey() + " = " + v);
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", v);
- }
-
- }
- //System.out.println("////////////start range date sql created" + SQL);
- try{
- DataSet ds = ConnectionUtils.getDataSet(SQL.toString(), dbInfo);
- //System.out.println("////////////start range date is : " + ds.get(0));
- dtf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Calendar tStart = Calendar.getInstance();
- tStart.setTime(dtf.parse(ds.getString(0,0)));
- dtf = new SimpleDateFormat("MM/dd/yyyy");
- stRangeText = dtf.format(tStart.getTime().getTime()-MILLIS_IN_DAY);
-
- }catch(Exception e){
- System.out.println("Exception////////// : start range date is : " + e);
- }
- }
-
- if (this.getRangeEndDateSQL() != null && this.getRangeEndDateSQL().trim().toLowerCase().startsWith("select")){
- //System.out.println("////////////end range date Starting");
- String SQL = this.getRangeEndDateSQL();
- if(formValues != null) {
- Set set = formValues.entrySet();
- String v = "";
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry) iter.next();
- v = (String) entry.getValue();
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", v);
- }
-
- }
- try{
- DataSet ds = ConnectionUtils.getDataSet(SQL.toString(), dbInfo);
- //System.out.println("////////////end range date is : " + ds.get(0));
- dtf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Calendar tStart = Calendar.getInstance();
- tStart.setTime(dtf.parse(ds.getString(0,0)));
- dtf = new SimpleDateFormat("MM/dd/yyyy");
- //endRangeText = dtf.format(tStart.getTime());
- endRangeText = dtf.format(tStart.getTime().getTime()+MILLIS_IN_DAY);
- }catch(Exception e){
- System.out.println("Exception////////// : end range date is : " + e);
- }
- }
-
-
- //////////////////////
- String calendarOnClickMethodCall = "";
- String timeStampStr = "";
- if (stRangeText == null || endRangeText == null)
- calendarOnClickMethodCall = "'oCalendar.select(document." + HTML_FORM + "." + fieldName + ", event,\""+ Globals.getCalendarOutputDateFormat() +"\"); return false;'";
- else
- calendarOnClickMethodCall = "'oCalendar=new CalendarPopup(\"calendarDiv\", \"calendarFrame\");oCalendar.setCssPrefix(\"raptor\");oCalendar.addDisabledDates(null, \"" + stRangeText + "\"); oCalendar.addDisabledDates(\"" + endRangeText + "\", null); oCalendar.select(document." + HTML_FORM + "." + fieldName + ", event,\""+ Globals.getCalendarOutputDateFormat() +"\"); return false;'";
- returnString += "\" " + getHelpLink(fieldName)
- + (validationType.equals(VT_DATE) || validationType.equals(VT_TIMESTAMP_HR) || validationType.equals(VT_TIMESTAMP_MIN) || validationType.equals(VT_TIMESTAMP_SEC)
- ? "\n\t\t\t<img src='" + AppUtils.getImgFolderURL()+ "calender_icon.gif' align=absmiddle border=0 width='20' height='20' onClick=" + calendarOnClickMethodCall + " style='cursor:hand'>"
- : "");
- if(validationType.equals(VT_TIMESTAMP_HR) || validationType.equals(VT_TIMESTAMP_MIN) || validationType.equals(VT_TIMESTAMP_SEC) ) {
- //Add Hours/Minutes and Seconds.
- timeStampStr = " <font class=rtabletext>Hour&nbsp;</font><select id = \""+ fieldName+ "_Hr\" name=\""+ fieldName+ "_Hr\" "+ (readOnly?"disabled":"")+" >";
- int hour = 0;
- int t_hr = 0;
- try {
- hour = Integer.parseInt(nvl(rr.getParamValue(fieldName+"_Hr"),"0"));
- if(hour == 0) {
- if(inSchedule) hour = Integer.parseInt(nvl(((String)formValues.get(fieldName+"_Hr")),"0"));
- }
-// System.out.println("Hour =" + hour);
- } catch (NumberFormatException ex) { hour = 0; }
- try {
- t_hr = Integer.parseInt(timestamphr);
-// System.out.println("THR =" + t_hr);
- } catch (NumberFormatException ex) { t_hr = 0;}
-
- if(hour <= 0) hour = t_hr;
- // System.out.println("Form Values 887 " + formValues);
- /*if (formValues.containsKey(fieldDisplayName+"_Hr")){
- formValues.remove(fieldDisplayName+"_Hr");
- formValues.put(fieldDisplayName+"_Hr", hour);
- } else
- formValues.put(fieldDisplayName+"_Hr", hour);
- System.out.println("Form Values 887 " + formValues);
- */
-
- //int t_min = Integer.parseInt(timestampmin);
- //int t_sec = Integer.parseInt(timestampsec);
- for (int i = 0; i < 24; i++) {
- if(i==0) timeStampStr += "<option value=\"" + i + "\""+ ((hour==i)?" selected":"") +">00</option>";
- else if(i<10) timeStampStr += "<option value=\"" + i + "\""+ ((hour==i)?" selected":"") +">" + "0"+i + "</option>";
- else timeStampStr += "<option value=\"" + i + "\""+ ((hour==i)?" selected":"") +">" + i + "</option>";
-
- }
- timeStampStr += "</select>";
- }
- //Minutes
- if( validationType.equals(VT_TIMESTAMP_MIN) || validationType.equals(VT_TIMESTAMP_SEC) ) {
- int minutes = 0;
- int t_min = 0;
- try {
- minutes = Integer.parseInt(nvl(rr.getParamValue(fieldName+"_Min"),"0"));
- if(minutes == 0) {
- if(inSchedule) minutes = Integer.parseInt(nvl(((String)formValues.get(fieldName+"_Min")),"0"));
- }
- } catch (NumberFormatException ex) {minutes = 0;}
- try {
- t_min = Integer.parseInt(timestampmin);
- } catch (NumberFormatException ex) { t_min = 0;}
-
- if(minutes <= 0) minutes = t_min;
- /*if (formValues.containsKey(fieldDisplayName+"_Min")){
- formValues.remove(fieldDisplayName+"_Min");
- formValues.put(fieldDisplayName+"_Min", minutes);
- } else
- formValues.put(fieldDisplayName+"_Min", minutes);
- */
- timeStampStr += " <font class=rtabletext>Min&nbsp;</font><select id = \""+ fieldName+ "_Min\" name=\""+ fieldName+ "_Min\" "+ (readOnly?"disabled":"")+" >";
- for (int i = 0; i < 60; i++) {
- if(i==0) timeStampStr += "<option value=\"" + i + "\""+ ((minutes==i)?" selected":"") +">00</option>";
- else if(i<10) timeStampStr += "<option value=\"" + i + "\""+ ((minutes==i)?" selected":"") +">" + "0"+i + "</option>";
- else timeStampStr += "<option value=\"" + i + "\""+ ((minutes==i)?" selected":"") +">" + i + "</option>";
- }
- timeStampStr += "</select>";
- }
- //Seconds
- if( validationType.equals(VT_TIMESTAMP_SEC) ) {
- int seconds = 0;
- int t_sec = 0;
- try {
- seconds = Integer.parseInt(nvl(rr.getParamValue(fieldName+"_Sec"),"0"));
- if(seconds == 0) {
- if(inSchedule) seconds = Integer.parseInt(nvl(((String)formValues.get(fieldName+"_Sec")),"0"));
- }
- } catch (NumberFormatException ex) {seconds = 0;}
- try {
- t_sec = Integer.parseInt(timestampsec);
- } catch (NumberFormatException ex) { t_sec = 0;}
-
- if(seconds <= 0) seconds = t_sec;
- /*if (formValues.containsKey(fieldDisplayName+"_Sec")){
- formValues.remove(fieldDisplayName+"_Sec");
- formValues.put(fieldDisplayName+"_Sec", seconds);
- } else
- formValues.put(fieldDisplayName+"_Sec", seconds);
- */
- timeStampStr += " <font class=rtabletext>Sec&nbsp;</font><select id = \""+ fieldName+ "_Sec\" name=\""+ fieldName+ "_Sec\" "+ (readOnly?"disabled":"")+" >";
- for (int i = 0; i < 60; i++) {
- if(i==0) timeStampStr += "<option value=\"" + i + "\""+ ((seconds==i)?" selected":"") +">00</option>";
- else if(i<10) timeStampStr += "<option value=\"" + i + "\""+ ((seconds==i)?" selected":"") +">" + "0"+i + "</option>";
- else timeStampStr += "<option value=\"" + i + "\""+ ((seconds==i)?" selected":"") +">" + i + "</option>";
- }
- timeStampStr += "</select>";
- }
-
- returnString += timeStampStr;
- String checkboxStr = "";
- if(inSchedule && (validationType.equals(VT_DATE) || validationType.equals(VT_TIMESTAMP_HR) || validationType.equals(VT_TIMESTAMP_MIN) || validationType.equals(VT_TIMESTAMP_SEC)) ) {
- if(!Globals.isScheduleDateParamAutoIncr()) {
- checkboxStr = /*checkboxStr +" "+ */ "<input type=\"checkbox\" name=\""+getFieldName()+"_auto\" value=\"_auto\" checked/>";
- } else {
- checkboxStr = /*checkboxStr +" "+ */"<input type=\"hidden\" name=\""+getFieldName()+"_auto\" value=\"_auto\"/>";
- }
- /*if(validationType.equals(VT_TIMESTAMP_HR) || validationType.equals(VT_TIMESTAMP_MIN) || validationType.equals(VT_TIMESTAMP_SEC)) {
- checkboxStr = checkboxStr +" "+ "<input type=\"hidden\" name=\""+getFieldName()+"_Hr_auto\" value=\"_auto\"/>";
- }
- if(validationType.equals(VT_TIMESTAMP_MIN) || validationType.equals(VT_TIMESTAMP_SEC)) {
- checkboxStr = checkboxStr +" "+ "<input type=\"hidden\" name=\""+getFieldName()+"_Min_auto\" value=\"_auto\"/>";
- }
- if(validationType.equals(VT_TIMESTAMP_SEC)) {
- checkboxStr = checkboxStr +" "+ "<input type=\"hidden\" name=\""+getFieldName()+"_Sec_auto\" value=\"_auto\"/>";
- }*/
- }
- if(isVisible())
- return returnString+checkboxStr;
- else return "";
- } else if (fieldType.equals(FFT_TEXTAREA)) {
-
- if(nvl(fieldValue).length()>0) {
- fieldValue = Pattern.compile("(^[\r\n])|\\([\\']", Pattern.DOTALL).matcher(fieldValue).replaceAll("");
- fieldValue = Pattern.compile("[\\']\\)", Pattern.DOTALL).matcher(fieldValue).replaceAll("");
- fieldValue = fieldValue.replaceAll("','",","); // changed from "|"
- fieldValue = fieldValue.replaceAll("' , '","\r\n");
- }
-
- if(isVisible())
- return "<textarea rows=4 cols=30 id=\"" + fieldName +"\" name=\"" + fieldName + "\""+ getCallableJavascript(getFieldName(), rr) + getHelpLink(fieldName) + nvl(fieldValue)
- + "</textarea>";
- else
- return "";
- } else if (fieldType.equals(FFT_COMBO_BOX)) {
- StringBuffer sb = new StringBuffer();
- //System.out.println("COMBO BOX " + fieldName);
- String oldSQL = "";
-
- IdNameList lookup = getLookupList();
- try {
- if(!hasPredefinedList) {
- //if(dependsOn != null && dependsOn != "") {
- //if(dependsOn != null && dependsOn != "" ) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = lu.getSql();
- //System.out.println("FORMFIELD 6666667 First" + ((IdNameSql)lookup).getSql());
- oldSQL = lu.getSql();
- if(formValues != null) {
- Set set = formValues.entrySet();
- String value = "";
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry) iter.next();
- value = (String) entry.getValue();
- if (value!=null && (value.length() <=0 || value.equals("NULL"))) {
- value = "NULL";
- SQL = Utils.replaceInString(SQL, "'["+entry.getKey()+"]'", value);
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", value);
- } else {
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", value);
- }
- }
- lookup = new IdNameSql(-1,SQL,lu.getDefaultSQL());
- }
- //}
- lookupList = lookup;
-
-
- //}
- try {
- lookup.loadUserData(0, "", getDbInfo(), getUserId());
- } catch (Exception e ){ e.printStackTrace(); //throw new RaptorRuntimeException(e);
- }
- }
- lookup.trimToSize();
-
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- readOnly = value.isReadOnly();
- break;
- }
-
- String selectedValue = "";
- int count = 0;
- sb.append("<div id=\""+fieldName+"_content\" style=\"display:none;width:100%;height:100%;align:center;\"> <img src=\""+AppUtils.getImgFolderURL()+"progress.gif\" border=\"0\" alt=\"Loading, please wait...\" /></div>");
- sb.append("<select id=\"" + fieldName +"\" name=\"");
- sb.append(fieldName);
- sb.append("\" "+ (readOnly?"disabled":"")+" size=1 " + getCallableJavascript(getFieldName(), rr) + getHelpLink(fieldName));
- if (!required)
- sb.append("<option value=\"\">-->select value<--");
-
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- if(value != null && value.getId() != null && value.getName() != null ) {
- /*if (count == 0 && required) {
- selectedValue = value.getId();
- count++;
- } else if (nvl(fieldValue).length()>0){
- if (fieldValue != null && fieldValue.equals(value.getId())){
- selectedValue = value.getId();
- }
- count++;
- } else {
- count++;
- } */
- if (count == 0) {
- if(required){
- selectedValue = value.getId();
- }
- count++;
- }
- sb.append("<option value=\"");
- sb.append(value.getId());
-
- if (nvl(fieldValue).length()>0) {
- if (fieldValue.equals(value.getId())) { // || (value.isDefaultValue()))
- sb.append("\" selected>");
- selectedValue = value.getId();
- }
- else
- sb.append("\">");
- } else {
- if(value!=null && value.isDefaultValue()) {
- sb.append("\" selected>");
- selectedValue = value.getId();
- } else {
- sb.append("\">");
- }
- }
-
- sb.append(value.getName());
- sb.append("</option>\n");
- }
- } // for
- if (formValues.containsKey(fieldDisplayName)){
- formValues.remove(fieldDisplayName);
- }
- formValues.put(fieldDisplayName, selectedValue);
- } catch (Exception e) {
- //throw new RaptorRuntimeException(e);
- }
- if(!hasPredefinedList) {
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- }
- //System.out.println("FORMFIELD 6666667 " + ((IdNameSql)lookup).getSql());
- if(sb.length()<=0) {
- sb.append("<div id=\""+fieldName+"_content\" style=\"display:none;width:100%;height:100%;align:center;\"> <img src=\""+AppUtils.getImgFolderURL()+"progress.gif\" border=\"0\" alt=\"Loading, please wait...\" /></div>");
- sb.append("<select id=\"" + fieldName +"\" name=\"");
- sb.append(fieldName);
- sb.append("\" "+ (readOnly?"disabled":"")+" size=1 " + getCallableJavascript(getFieldName(), rr) + getHelpLink(fieldName));
- }
-
- sb.append("</select>");
- if( isVisible())
- return sb.toString();
- else return "";
- } else if (fieldType.equals(FFT_LIST_BOX)) {
- StringBuffer sb = new StringBuffer();
- String oldSQL = "";
- IdNameList lookup = null;
-
- lookup = getLookupList();
- String selectedValue = "";
- try {
- if(!hasPredefinedList) {
- //if(dependsOn != null && dependsOn != "") {
- //if(dependsOn != null && dependsOn != "" ) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = lu.getSql();
- oldSQL = lu.getSql();
- if(formValues != null) {
- Set set = formValues.entrySet();
- String value = "";
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry) iter.next();
- value = (String) entry.getValue();
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", value);
- }
- lookup = new IdNameSql(-1,SQL,lu.getDefaultSQL());
- }
- //}
- lookupList = lookup;
- //}
- try {
- lookup.loadUserData(0, "", getDbInfo(), getUserId());
- } catch (Exception e ){ e.printStackTrace(); //throw new RaptorRuntimeException(e);
- }
- }
- lookup.trimToSize();
-
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- readOnly = value.isReadOnly();
- break;
- }
-
- int iCnt = 0;
- sb.append("<select id=\"" + fieldName +"\" name=\"");
- sb.append(fieldName);
- sb.append("\" "+ (readOnly?"disabled":"")+" size=4 " + getCallableJavascript(getFieldName(), rr) + getHelpLink(fieldName));
- if (!required)
- sb.append("<option value=\"\">-->select value<--");
-
- for (lookup.resetNext(); lookup.hasNext(); iCnt++) {
- IdNameValue value = lookup.getNext();
- sb.append("<option value=\"");
- sb.append((value!=null)?value.getId():"");
- if (nvl(fieldValue).length()>0) {
- if (fieldValue.equals((value!=null)?value.getId():"") || (fieldValue.equals("") && required && iCnt == 0)) {
- sb.append("\" selected>");
- selectedValue = value.getId();
- } else {
- sb.append("\">");
- }
- } else {
- if(value!=null && value.isDefaultValue()) {
- sb.append("\" selected>");
- selectedValue = value.getId();
- } else {
- sb.append("\">");
- }
- }
- if (formValues.containsKey(fieldDisplayName)){
- formValues.remove(fieldDisplayName);
- }
- formValues.put(fieldDisplayName, selectedValue);
-
- sb.append((value!=null)?value.getName():"");
- sb.append("</option>\n");
- } // for
-
- // lookup.clearData();
- } catch (Exception e) {
- //throw new RaptorRuntimeException(e);
- }
-
- if(sb.length()<=0) {
- sb.append("<select id=\"" + fieldName +"\" name=\"");
- sb.append(fieldName);
- sb.append("\" "+ (readOnly?"disabled":"")+" size=4 " + getCallableJavascript(getFieldName(), rr) + getHelpLink(fieldName));
- }
-
- sb.append("</select>");
-
- if(!hasPredefinedList) {
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- }
-
- if(isVisible())
- return sb.toString();
- else
- return "";
- } else if (fieldType.equals(FFT_HIDDEN)) {
- StringBuffer sb = new StringBuffer();
- String oldSQL = "";
- String progress = "<div id=\""+fieldName+"_content\" style=\"display:none;width:100%;height:100%;align:center;\"> <img src=\""+AppUtils.getImgFolderURL()+"progress.gif\" border=\"0\" alt=\"Loading, please wait...\" /></div> ";
- sb.append(progress);
- sb.append("<input id=\"" + fieldName +"\" name=\"");
- sb.append(fieldName);
- sb.append("\" type=\"hidden\"");
- IdNameList lookup = null;
-
- try {
- lookup = getLookupList();
- if(lookup != null) {
- //if(dependsOn != null && dependsOn != "") {
- //if(dependsOn != null && dependsOn != "" ) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = lu.getSql();
- //System.out.println("SQL HIDDEN 1 " + SQL);
- oldSQL = lu.getSql();
- if(formValues != null) {
- Set set = formValues.entrySet();
- String value = "";
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry) iter.next();
- value = (String) entry.getValue();
- //System.out.println("HIDDEN " + "["+entry.getKey()+"]" + "-" + value);
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", value);
- }
-
- lookup = new IdNameSql(-1,SQL,lu.getDefaultSQL());
- }
- //System.out.println("SQL HIDDEN 2 " + SQL);
- //}
- lookupList = lookup;
- //}
- if(nvl(fieldValue).length()>0 && (dependsOn == null || dependsOn.length()<=0)) {
- sb.append(" value=\"");
- sb.append((fieldValue!=null)?fieldValue:"");
- sb.append("\">");
- } else if (lookup != null) {
- lookup.loadUserData(0, "", getDbInfo(), getUserId());
- int iCnt = 0;
- for (lookup.resetNext(); lookup.hasNext(); iCnt++) {
- IdNameValue value = lookup.getNext();
- //System.out.println("HIDDEN " + value.getId() + " " + value.getName());
- sb.append(" value=\"");
- sb.append((value!=null)?value.getId():"");
- sb.append("\">");
- break;
- } // for
- if(lookup.size()<=0) {
- sb.append(" value=\"");
- sb.append("\">");
-
- }
- } else {
- sb.append(" value=\"");
- sb.append((fieldValue!=null)?fieldValue:"");
- sb.append("\"/>");
- }
- } else {
- sb.append(" value=\"");
- sb.append((fieldValue!=null)?fieldValue:"");
- sb.append("\"/>");
- }
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- // lookup.clearData();
- } catch (Exception e) {
- sb.append(" value=\"\"/>");
- //throw new RaptorRuntimeException(e);
- }
-
- if(!hasPredefinedList) {
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- }
- //if(isVisible())
- return sb.toString() ;
- } else if (fieldType.equals(FFT_RADIO_BTN)) {
- StringBuffer sb = new StringBuffer();
- if (!required) {
- sb.append("<input id=\"" + fieldName +"\" type=radio name=\"");
- sb.append(fieldName);
- sb.append("\" value=\"\"");
- if (fieldValue.length() == 0)
- sb.append(" checked");
- //sb.append( getCallableJavascript(getFieldName(), rr) );
- sb.append(getHelpLink(fieldName)+ " Any<br>\n");
- }
-
- try {
- IdNameList lookup = getLookupList();
- lookup.loadUserData(0, "", getDbInfo(),getUserId());
- String selectedValue = "";
-
- int iCnt = 0;
- for (lookup.resetNext(); lookup.hasNext(); iCnt++) {
- IdNameValue value = lookup.getNext();
- sb.append("<input id=\"" + fieldName +"\" type=radio name=\"");
- sb.append(fieldName);
- sb.append("\" value=\"");
- sb.append((value!=null)?value.getId():"");
- if (nvl(fieldValue).length()>0) {
- if (fieldValue.equals((value!=null)?value.getId():"") || (fieldValue.equals("") && required && iCnt == 0)) {
- sb.append("\" checked>");
- selectedValue = value.getId();
- } else {
- sb.append("\">");
- }
- } else {
- if(value!=null && value.isDefaultValue()) {
- sb.append("\" checked>");
- selectedValue = value.getId();
- } else {
- sb.append("\">");
- }
- }
- sb.append((value!=null)?value.getName():"");
- sb.append("<br>\n");
- } // for
- if (formValues.containsKey(fieldDisplayName)){
- formValues.remove(fieldDisplayName);
- }
- formValues.put(fieldDisplayName, selectedValue);
-
- // lookup.clearData();
- } catch (Exception e) {
- throw new RaptorRuntimeException(e);
- }
- if(isVisible())
- return sb.toString() ;
- else
- return "";
- } else if (fieldType.equals(FFT_CHECK_BOX)) {
- StringBuffer sb = new StringBuffer();
-
- fieldValue = '|' + fieldValue + '|';
- int count = 0 ;
- try {
- String selectedValue = "";
- IdNameList lookup = getLookupList();
- if(lookup != null) {
- lookup.loadUserData(0, "", getDbInfo(), getUserId());
-
- for (lookup.resetNext(); lookup.hasNext();) {
- count++;
- IdNameValue value = lookup.getNext();
- sb.append("<input id=\"" + fieldName +"\" type=checkbox name=\"");
- sb.append(fieldName);
- sb.append("\" value=\"");
- sb.append((value!=null)?value.getId():"");
-
- if (!fieldValue.equals("||")) {
- if (fieldValue.indexOf('|' + ((value!=null)?value.getId():"") + '|') >= 0) { // || (value.isDefaultValue()))
- sb.append("\" checked " + getHelpLink(fieldName));
- selectedValue = value.getId();
- }
- else
- sb.append("\"" + getHelpLink(fieldName));
- } else {
- if(value!=null && value.isDefaultValue()) {
- sb.append("\" checked " + getHelpLink(fieldName));
- selectedValue = value.getId();
- } else {
- sb.append("\"" + getHelpLink(fieldName));
- }
- }
-
- if(!(/*(value.getName().equals("Y")||value.getName().equals("N")) && */(!lookup.hasNext()) && count == 1))
- sb.append((value!=null)?value.getName():"");
- sb.append("<br>\n");
- } // for
-
- if (formValues.containsKey(fieldDisplayName)){
- formValues.remove(fieldDisplayName);
- }
- formValues.put(fieldDisplayName, selectedValue);
- }
-
- // lookup.clearData();
- } catch (Exception e) {
- throw new RaptorRuntimeException(e);
- }
- if(isVisible())
- return sb.toString();
- else
- return "";
- } else if (fieldType.equals(FFT_LIST_MULTI)) {
- StringBuffer sb = new StringBuffer();
- String oldSQL = "";
-
- fieldValue = '|' + fieldValue + '|';
- IdNameList lookup = getLookupList();
- try {
- if(!hasPredefinedList) {
- //if(dependsOn != null && dependsOn != "") {
- //if(dependsOn != null && dependsOn != "" ) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = lu.getSql();
- oldSQL = lu.getSql();
- if(formValues != null) {
- Set set = formValues.entrySet();
- String value = "";
- for(Iterator iter = set.iterator(); iter.hasNext(); ) {
- Map.Entry entry = (Entry) iter.next();
- value = (String) entry.getValue();
- SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", value);
- }
- lookup = new IdNameSql(-1,SQL,lu.getDefaultSQL());
- }
- //}
- lookupList = lookup;
- //}
-
- lookup.loadUserData(0, "", getDbInfo(),getUserId());
- }
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- readOnly = value.isReadOnly();
- break;
- }
-
- sb.append("<div id=\""+fieldName+"_content\" style=\"display:none;width:100%;height:100%;align:center;\"> <img src=\""+AppUtils.getImgFolderURL()+"progress.gif\" border=\"0\" alt=\"Loading, please wait...\" /></div>");
- sb.append("<select id=\"" + fieldName +"\" name=\"");
- sb.append(fieldName);
- sb.append("\" "+ (readOnly?"disabled":"")+" size=\""+ multiSelectListSize +"\" multiple " + getCallableJavascript(getFieldName(), rr) + getHelpLink(fieldName));
-
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- sb.append("<option value=\"");
- sb.append((value!=null)?value.getId():"");
- if (!fieldValue.equals("||")) {
- if (fieldValue.indexOf('|' + ((value!=null)?value.getId():"") + '|') >= 0) // || (value.isDefaultValue()))
- sb.append("\" selected>");
- else
- sb.append("\">");
- } else {
- if(value!=null && value.isDefaultValue()) {
- sb.append("\" selected>");
- } else {
- sb.append("\">");
- }
- }
- sb.append((value!=null)?value.getName():"");
- sb.append("</option>\n");
- } // for
-
- // lookup.clearData();
- } catch (Exception e) {
- //throw new RaptorRuntimeException(e);
- }
- if(!hasPredefinedList) {
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- }
- if(sb.length()<=0) {
- sb.append("<div id=\""+fieldName+"_content\" style=\"display:none;width:100%;height:100%;align:center;\"> <img src=\""+AppUtils.getImgFolderURL()+"progress.gif\" border=\"0\" alt=\"Loading, please wait...\" /></div>");
- sb.append("<select id=\"" + fieldName +"\" name=\"");
- sb.append(fieldName);
- sb.append("\" "+ (readOnly?"disabled":"")+" size=\""+ multiSelectListSize +"\" multiple " + getCallableJavascript(getFieldName(), rr) + getHelpLink(fieldName));
- }
- sb.append("</select>");
- if(isVisible())
- return sb.toString();
- else
- return "";
- } else if (fieldType.equals(FFT_BLANK)) {
- StringBuffer sb = new StringBuffer();
- sb.append("&nbsp;");
- return sb.toString();
- } else
- throw new org.openecomp.portalsdk.analytics.error.RaptorRuntimeException("FormField.getHtml: Unsupported form field type");
- } // getHtml
-
- public String getValidateJavaScript() {
- StringBuffer javaScript = new StringBuffer();
-
- if (fieldType.equals(FFT_TEXT_W_POPUP) || fieldType.equals(FFT_TEXT)
- || fieldType.equals(FFT_TEXTAREA)) {
- if (required) {
- javaScript.append("\n\tif(document.");
- javaScript.append(HTML_FORM);
- javaScript.append(".");
- javaScript.append(fieldName);
- javaScript.append(".value==\"\") {\n\t\talert(\"Please enter value for ");
- javaScript.append(fieldDisplayName);
- javaScript.append("\");\n\t\tdocument.");
- javaScript.append(HTML_FORM);
- javaScript.append(".");
- javaScript.append(fieldName);
- javaScript.append(".focus();\n\t\tdocument.");
- javaScript.append(HTML_FORM);
- javaScript.append(".");
- javaScript.append(fieldName);
- javaScript.append(".select();\n\t\treturn false;\n\t}\n");
- } // if
-
- if (!validationType.equals(VT_NONE)) {
- javaScript.append("\n\tif(! ");
- if (validationType.equals(VT_DATE)||validationType.equals(VT_TIMESTAMP_HR)||validationType.equals(VT_TIMESTAMP_MIN)||validationType.equals(VT_TIMESTAMP_SEC))
- javaScript.append("checkDate(");
- else if (validationType.equals(VT_INT))
- javaScript.append("checkInteger(");
- else if (validationType.equals(VT_INT_POSITIVE))
- javaScript.append("checkPositiveInteger(");
- else if (validationType.equals(VT_INT_NON_NEGATIVE))
- javaScript.append("checkNonNegativeInteger(");
- else if (validationType.equals(VT_FLOAT))
- javaScript.append("checkFloat(");
- else if (validationType.equals(VT_FLOAT_POSITIVE))
- javaScript.append("checkPositiveFloat(");
- else if (validationType.equals(VT_FLOAT_NON_NEGATIVE))
- javaScript.append("checkNonNegativeFloat(");
- javaScript.append("document.");
- javaScript.append(HTML_FORM);
- javaScript.append(".");
- javaScript.append(fieldName);
- javaScript.append(".value");
- if (validationType.equals(VT_DATE)||validationType.equals(VT_TIMESTAMP_HR)||validationType.equals(VT_TIMESTAMP_MIN)||validationType.equals(VT_TIMESTAMP_SEC))
- javaScript.append(", true");
- javaScript.append(")) {\n\t\talert(\"");
- javaScript.append(fieldDisplayName);
- javaScript.append(" is not a valid ");
- if (validationType.equals(VT_DATE)||validationType.equals(VT_TIMESTAMP_HR)||validationType.equals(VT_TIMESTAMP_MIN)||validationType.equals(VT_TIMESTAMP_SEC))
- javaScript.append("date formatted "+ Globals.getCalendarOutputDateFormat());
- else if (validationType.equals(VT_INT))
- javaScript.append("integer");
- else if (validationType.equals(VT_INT_POSITIVE))
- javaScript.append("integer greater than zero");
- else if (validationType.equals(VT_INT_NON_NEGATIVE))
- javaScript.append("integer greater than or equal to zero");
- else if (validationType.equals(VT_FLOAT))
- javaScript.append("number");
- else if (validationType.equals(VT_FLOAT_POSITIVE))
- javaScript.append("number greater than zero");
- else if (validationType.equals(VT_FLOAT_NON_NEGATIVE))
- javaScript.append("number greater than or equal to zero");
- javaScript.append(".\\nPlease enter a valid value.\");\n\t\tdocument.");
- javaScript.append(HTML_FORM);
- javaScript.append(".");
- javaScript.append(fieldName);
- javaScript.append(".focus();\n\t\tdocument.");
- javaScript.append(HTML_FORM);
- javaScript.append(".");
- javaScript.append(fieldName);
- javaScript.append(".select();\n\t\treturn false;\n\t}\n");
- } // if
- } // if
- else if (fieldType.equals(FFT_CHECK_BOX)) {
- if (required) {
- javaScript.append("\n\tvar isChecked = false;");
- javaScript.append("\n\tfor (var i=0; i < document.");
- javaScript.append(HTML_FORM);
- javaScript.append(".");
- javaScript.append(fieldName);
- javaScript.append(".length; i++) { ");
- javaScript.append("\n\t\tif(document.");
- javaScript.append(HTML_FORM);
- javaScript.append(".");
- javaScript.append(fieldName);
- javaScript.append("[i].checked) {");
- javaScript.append("\n\t\t\tisChecked = true;");
- javaScript.append("\n\t\t\tbreak;");
- javaScript.append("\n\t\t}");
- javaScript.append("\n\t}");
- javaScript.append("\n\tif(!isChecked) {");
- javaScript.append("\n\t\talert(\"Please select at least one ");
- javaScript.append(fieldDisplayName);
- javaScript.append("\");\n\t\treturn false;");
- javaScript.append("\n\t}");
- } // if
- } // else if FFT_CHECK_BOX
- else if (fieldType.equals(FFT_LIST_MULTI)) {
- if (required) {
- javaScript.append("\n\tif(document.");
- javaScript.append(HTML_FORM);
- javaScript.append(".");
- javaScript.append(fieldName);
- javaScript.append(".selectedIndex == -1) {");
- javaScript.append("\n\t\talert(\"Please select at least one ");
- javaScript.append(fieldDisplayName);
- javaScript.append("\");\n\t\treturn false;");
- javaScript.append("\n\t}");
- } // if
- } // else if
-
- return javaScript.toString();
- } // getValidateJavaScript
-
- public void setDbInfo(String dbInfo) {
- this.dbInfo = dbInfo;
- }
-
- public String getDbInfo() {
- return dbInfo;
- }
-
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
- public String getUserId() {
- return userId;
- }
-
-
- public String getFieldDefaultSQL() {
-
- return fieldDefaultSQL;
- }
-
-
- public void setFieldDefaultSQL(String fieldDefaultSQL) {
-
- this.fieldDefaultSQL = fieldDefaultSQL;
- }
-
-
- public boolean isVisible() {
-
- return visible;
- }
-
-
- public void setVisible(boolean visible) {
-
- this.visible = visible;
- }
-
- public String getDependsOn() {
- return dependsOn;
- }
-
- public void setDependsOn(String dependsOn) {
- this.dependsOn = dependsOn;
- }
-
- public Calendar getRangeEndDate() {
- if(rangeEndDate != null)
- rangeEndDate.add(Calendar.DATE, 1);
- return rangeEndDate;
- }
-
- public void setRangeEndDate(Calendar rangeEndDate) {
- this.rangeEndDate = rangeEndDate;
- }
-
- public Calendar getRangeStartDate() {
- if(rangeStartDate != null)
- rangeStartDate.add(Calendar.DATE, -1);
- return rangeStartDate;
- }
-
- public void setRangeStartDate(Calendar rangeStartDate) {
- this.rangeStartDate = rangeStartDate;
- }
-
- public String getRangeEndDateSQL() {
- return rangeEndDateSQL;
- }
-
- public void setRangeEndDateSQL(String rangeEndDateSQL) {
- this.rangeEndDateSQL = rangeEndDateSQL;
- }
-
- public void setMultiSelectListSize(String multiSelectListSize) {
- this.multiSelectListSize = multiSelectListSize;
- }
-
- public String getRangeStartDateSQL() {
- return rangeStartDateSQL;
- }
-
- public void setRangeStartDateSQL(String rangeStartDateSQL) {
- this.rangeStartDateSQL = rangeStartDateSQL;
- }
-
- public boolean isHasPredefinedList() {
- return hasPredefinedList;
- }
-
- public void setHasPredefinedList(boolean hasPredefinedList) {
- this.hasPredefinedList = hasPredefinedList;
- }
-
- public boolean isTriggerOtherFormFields() {
- return triggerOtherFormFields;
- }
-
- public void setTriggerOtherFormFields(boolean triggerOtherFormFields) {
- this.triggerOtherFormFields = triggerOtherFormFields;
- }
-
- public boolean isTriggerThisFormfield() {
- return triggerThisFormfield;
- }
-
- public void setTriggerThisFormfield(boolean triggerThisFormfield) {
- this.triggerThisFormfield = triggerThisFormfield;
- }
-
-
-} // FormField
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FormatProcessor.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FormatProcessor.java
deleted file mode 100644
index 57fec736..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FormatProcessor.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.openecomp.portalsdk.analytics.RaptorObject;
-import org.openecomp.portalsdk.analytics.system.DbUtils;
-import org.openecomp.portalsdk.analytics.system.Globals;
-import org.openecomp.portalsdk.analytics.util.AppConstants;
-import org.openecomp.portalsdk.analytics.util.DataSet;
-import org.openecomp.portalsdk.analytics.view.DataRow;
-import org.openecomp.portalsdk.analytics.view.DataValue;
-import org.openecomp.portalsdk.analytics.view.HtmlFormatter;
-import org.openecomp.portalsdk.analytics.xmlobj.FormatType;
-import org.openecomp.portalsdk.analytics.xmlobj.SemaphoreType;
-
-public class FormatProcessor extends RaptorObject {
-
-
- private SemaphoreType semaphore = null;
-
- private String colType = null;
-
- private String dateFormat = null;
-
- private HtmlFormatter defaultFormatter = null;
-
- private HashMap formatters = null;
-
- private HashMap convertedValues = null;
-
- private boolean attemptNumericConversion = false;
-
- public FormatProcessor(SemaphoreType sem, String colType, String dateFormat,
- boolean attemptNumericConversion) {
-
- super();
-
- if (sem == null)
- return;
-
- this.semaphore = sem;
- this.colType = colType;
- this.dateFormat = dateFormat;
-
- this.attemptNumericConversion = attemptNumericConversion;
- if (attemptNumericConversion)
- for (Iterator iter = semaphore.getFormatList().getFormat().iterator(); iter
- .hasNext();) {
- FormatType fmt = (FormatType) iter.next();
- if (!isNumber(fmt.getLessThanValue())) {
- this.attemptNumericConversion = false;
- break;
- } // if
- } // for
-
- formatters = new HashMap(semaphore.getFormatList().getFormat().size() * 4 / 3);
- convertedValues = new HashMap(semaphore.getFormatList().getFormat().size() * 4 / 3);
-
- for (Iterator iter = semaphore.getFormatList().getFormat().iterator(); iter.hasNext();) {
- FormatType fmt = (FormatType) iter.next();
- if ((fmt.getFormatId() == null) || (fmt.getFormatId().length() <= 0)) {
- defaultFormatter = new HtmlFormatter(fmt.isBold(), fmt.isItalic(), fmt
- .isUnderline(), fmt.getBgColor(), fmt.getFontColor(), fmt
- .getFontFace(), fmt.getFontSize(), fmt.getAlignment());
- } else {
- formatters.put(fmt.getFormatId(), new HtmlFormatter(fmt.isBold(), fmt
- .isItalic(), fmt.isUnderline(), fmt.getBgColor(), fmt.getFontColor(),
- fmt.getFontFace(), fmt.getFontSize(), fmt.getAlignment()));
- convertedValues.put(fmt.getFormatId(), convertValue(fmt.getLessThanValue()));
- }
- } // for
- } // FormatProcessor
-
- private String convertValue(String origValue) {
-
- if (colType.equals(AppConstants.CT_DATE))
- return convertDateValue(origValue);
- else if (colType.equals(AppConstants.CT_NUMBER))
- return convertNumericValue(origValue);
- else if (attemptNumericConversion)
- return convertUnknownValue(origValue);
- else
- return origValue;
- } // convertValue
-
- private String convertDateValue(String origValue) {
-
- // Converts to YYYY-MM-DD if possible
- if (nvl(dateFormat).length() == 0 || nvl(origValue).length() == 0)
- return origValue;
-
- if (dateFormat.equals("MM/DD/YYYY") && origValue.length() == 10)
- // Special processing for the default date format - for saving DB
- // calls
- return origValue.substring(6, 10) + "-" + origValue.substring(0, 2) + "-"
- + origValue.substring(3, 5);
-
- try {
- // DataSet ds = DbUtils.executeQuery("SELECT TO_CHAR(TO_DATE('" + origValue + "', '"
- // + dateFormat + "'), 'YYYY-MM-DD') val FROM DUAL");
-
- String sql = Globals.getGenerateSqlVisualDual();
- DataSet ds = DbUtils.executeQuery("SELECT TO_CHAR(TO_DATE('" + origValue + "', '"
- + dateFormat + "'), 'YYYY-MM-DD') val"+sql);
-
- if (ds.getRowCount() > 0)
- return ds.getString(0, 0);
- } catch (Exception e) {
- }
-
- return origValue;
- } // convertDateValue
-
- private String convertNumericValue(String origValue) {
-
- // Converts to [20 pos.5 pos] if possible
- if (nvl(origValue).length() == 0)
- return origValue;
- boolean isNegative = false;
-
- StringBuffer integerValue = new StringBuffer();
- StringBuffer fractionValue = new StringBuffer();
-
- boolean beforeDecimalPoint = true;
- for (int i = 0; i < origValue.length(); i++) {
- char c = origValue.charAt(i);
- if (c == '.')
- beforeDecimalPoint = false;
- else if (c == '-' && integerValue.length() == 0)
- isNegative = true;
- // else
- // if(c=='0'||c=='1'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7'||c=='8'||c=='9')
- else if (Character.isDigit(c))
- if (beforeDecimalPoint)
- integerValue.append(c);
- else
- fractionValue.append(c);
- } // for
-
- while (integerValue.length() < 20)
- integerValue.insert(0, '0');
-
- while (fractionValue.length() < 5)
- fractionValue.append('0');
-
- integerValue.append('.');
- integerValue.append(fractionValue);
- integerValue.insert(0, (isNegative ? '-' : '+'));
-
- return integerValue.toString();
- } // convertNumericValue
-
- private boolean isNumber(String value) { // As per Raptor def, like
-
- // -$3,270.56
- value = value.trim();
- for (int i = 0; i < value.length(); i++) {
- char c = value.charAt(i);
- if (!(Character.isDigit(c) || c == '.' || c == '-' || c == '+' || c == ','
- || c == '$' || c == '%'))
- return false;
- } // for
-
- return true;
- } // isNumber
-
- private String convertUnknownValue(String origValue) {
-
- return isNumber(origValue) ? convertNumericValue(origValue) : origValue;
- } // convertUnknownValue
-
- private boolean isEqual(String value1, String value2) {
-
- return value1.trim().equals(value2.trim());
- } // isEqual
-
- private boolean isLessThan(String value1, String value2) {
-
- boolean compareAsNumbers = colType.equals(AppConstants.CT_NUMBER);
- if ((!compareAsNumbers) && attemptNumericConversion)
- compareAsNumbers = isNumber(value1) && isNumber(value2);
- if (compareAsNumbers && value1.length()>0 && value2.length()>0) {
- boolean value1IsNegative = (value1.charAt(0) == '-');
- boolean value2IsNegative = (value2.charAt(0) == '-');
- if (value1IsNegative && (!value2IsNegative)) {
- return true;
- }
- else if ((!value1IsNegative) && value2IsNegative) {
- return false;
- }
- return Double.parseDouble(value1)<Double.parseDouble(value2);
- } // if
-
- return (value1.compareTo(value2) < 0);
- } // isEqual
-
- public void setHtmlFormatters(DataValue dv, DataRow dr, boolean formatModified) {
-
- if (semaphore == null)
- return;
-
- HtmlFormatter formatter = defaultFormatter;
- HtmlFormatter anyFormatter = null;
- String sValue = convertValue(dv.getDisplayValue());
-
- String compareColId = semaphore.getComment(); // When Column Id compare is different from formatting.
-
- String targetColId = null;
- if(semaphore.getTarget()!=null)
- targetColId = semaphore.getTarget();
-
- DataValue targetDataValue = null;
- /* compare the column id which is in comment and assign to sValue */
- if(nvl(compareColId).length()>0) {
- for (dr.resetNext(); dr.hasNext();) {
- DataValue dv1 = dr.getNext();
- //add null check
- if(dv1.getColId()!=null) {
- if(dv1.getColId().equals(compareColId))
- sValue = convertValue(dv1.getDisplayValue());
- if(targetColId!=null) {
- if(dv1.getColId().equals(targetColId))
- targetDataValue = dv1;
- }
- }
- }
- }
-
- for (Iterator iter = semaphore.getFormatList().getFormat().iterator(); iter
- .hasNext();) {
- FormatType fmt = (FormatType) iter.next();
- if(fmt.getLessThanValue().length() <= 0) {
- anyFormatter = (HtmlFormatter) formatters.get(fmt.getFormatId());
- anyFormatter.setFormatId(fmt.getFormatId());
- break;
- }
- }
-
- if( anyFormatter == null ) anyFormatter = formatter;
- // String sValue = convertValue(dv.getDisplayValue());
- //if (sValue.length() > 0) {
- for (Iterator iter = semaphore.getFormatList().getFormat().iterator(); iter
- .hasNext();) {
- FormatType fmt = (FormatType) iter.next();
- // For Excel Download
-
- if ((fmt.getFormatId() == null) || (fmt.getFormatId().length() <= 0)) {
- // Default formatter
- continue;
- }
-
- String formatterValue = nvl((String) convertedValues.get(fmt.getFormatId()));
- boolean valueMatched = false;
- if (fmt.getExpression().equals("=")) {
- valueMatched = isEqual(sValue, formatterValue);
- }
-
- else if (fmt.getExpression().equals("<>"))
- valueMatched = (!isEqual(sValue, formatterValue));
- else if (fmt.getExpression().equals(">")) {
- valueMatched = (!(isEqual(sValue, formatterValue) || isLessThan(sValue,
- formatterValue)));
- }
- else if (fmt.getExpression().equals(">=")) {
- valueMatched = /* isEqual(sValue, formatterValue)|| */(!isLessThan(
- sValue, formatterValue));
- }
- else if (fmt.getExpression().equals("<")) {
- valueMatched = isLessThan(sValue, formatterValue);
- }
- else if (fmt.getExpression().equals("<=")) {
- valueMatched = isEqual(sValue, formatterValue)
- || isLessThan(sValue, formatterValue);
- }
- //s_logger.debug("SYSOUT " + " " +sValue +" " +fmt.getBgColor() + " " + fmt.getLessThanValue()+ " " +valueMatched);
- if (fmt.getLessThanValue().length() > 0 && valueMatched) {
- formatter = (HtmlFormatter) formatters.get(fmt.getFormatId());
- formatter.setFormatId(fmt.getFormatId());
- formatModified = true;
- //dv.setFormatId(fmt.getFormatId());
- //dr.setFormatId(fmt.getFormatId());
- //break;
- } else { // if
- if(!formatModified) formatter = anyFormatter;
- //if(!((formatter!=null && formatter!=anyFormatter) || (defaultFormatter!=null && formatter!=defaultFormatter)))
- // formatter = anyFormatter;
- //formatter.setFormatId(anyFormatter.getFormatId());
- }
- /*else if ((fmt.getLessThanValue().length() <= 0)
- && (fmt.getFormatId().length() > 0)) {
- formatter = (HtmlFormatter) formatters.get(fmt.getFormatId());
- System.out.println("---------------lesser "+ fmt.getFormatId()+ " " + fmt.getBgColor());
- dv.setFormatId(fmt.getFormatId());
- dr.setFormatId(fmt.getFormatId());
- // break;
- } // else if*/
- } // for
- /*} else {
- for (Iterator iter = semaphore.getFormatList().getFormat().iterator(); iter
- .hasNext();) {
- FormatType fmt = (FormatType) iter.next();
- if(fmt.getLessThanValue().length()<=0 && fmt.getExpression().length()<=0 && !fmt.isBold() && !fmt.isItalic() && !fmt.isUnderline() && fmt.getFontSize().equals("11")) {
- formatter = defaultFormatter;
- } else
- formatter = anyFormatter;
- }
-
- //formatter.setFormatId(anyFormatter.getFormatId());
- } */
- if(formatter != null) {
- if (semaphore.getSemaphoreType().equals(AppConstants.ST_ROW)) {
-
- if (dr.getRowFormatter() == null || formatter != defaultFormatter) {
- // Making sure the default formatter doesn't overwrite
- // valid row formatter set from another column
- dr.setRowFormatter(formatter);
- dr.setFormatId(formatter.getFormatId());
- // This is added for excel download
- //if (!formatter.equals(defaultFormatter)) {
- dr.setRowFormat(true);
- //}
-
- }
- } else {
- if(nvl(targetColId).length()>0) {
- if(targetDataValue!=null) {
- targetDataValue.setCellFormatter(formatter);
- targetDataValue.setFormatId(formatter.getFormatId());
- //if (!formatter.equals(defaultFormatter)) {
- targetDataValue.setCellFormat(true);
- int count = 0;
- for (dr.resetNext(); dr.hasNext();) {
- DataValue dv1 = dr.getNext();
- //add null check
- if(targetColId!=null) {
- if(dv1.getColId().equals(targetColId))
- dr.setDataValue(count, targetDataValue);
- }
- count++;
- }
- }
- //}
-
- } else {
- dv.setCellFormatter(formatter);
- dv.setFormatId(formatter.getFormatId());
- //if (!formatter.equals(defaultFormatter)) {
- dv.setCellFormat(true);
- //}
- }
- }// else
- }
- } // setHtmlFormatters
-
-} // FormatProcessor
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/Item.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/Item.java
deleted file mode 100644
index 1bc3bbba..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/Item.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-public class Item {
- private String _id;
- private String _name;
-
- public Item() {
- }
-
- public Item(String id, String name) {
- this._id = id;
- this._name = name;
- }
-
- public String getId() {
- return _id;
- }
-
- public void setId(String id) {
- this._id = id;
- }
-
- public String getName() {
- return _name;
- }
-
- public void setName(String name) {
- this._name = name;
- }
-
- public String toString() {
- return _name;
- }
-}
-
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/LookupDBInfo.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/LookupDBInfo.java
deleted file mode 100644
index 118356a7..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/LookupDBInfo.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import org.openecomp.portalsdk.analytics.RaptorObject;
-
-public class LookupDBInfo extends RaptorObject {
- private String tableName = null;
-
- private String fieldName = null;
-
- private String lookupTable = null;
-
- private String lookupIdField = null;
-
- private String lookupNameField = null;
-
- public LookupDBInfo() {
- }
-
- public LookupDBInfo(String tableName, String fieldName, String lookupTable,
- String lookupIdField, String lookupNameField) {
- this();
-
- setTableName(tableName);
- setFieldName(fieldName);
- setLookupTable(lookupTable);
- setLookupIdField(lookupIdField);
- setLookupNameField(lookupNameField);
- } // LookupDBInfo
-
- public String getTableName() {
- return tableName;
- }
-
- public String getFieldName() {
- return fieldName;
- }
-
- public String getLookupTable() {
- return lookupTable;
- }
-
- public String getLookupIdField() {
- return lookupIdField;
- }
-
- public String getLookupNameField() {
- return lookupNameField;
- }
-
- public void setTableName(String tableName) {
- this.tableName = tableName;
- }
-
- public void setFieldName(String fieldName) {
- this.fieldName = fieldName;
- }
-
- public void setLookupTable(String lookupTable) {
- this.lookupTable = lookupTable;
- }
-
- public void setLookupIdField(String lookupIdField) {
- this.lookupIdField = lookupIdField;
- }
-
- public void setLookupNameField(String lookupNameField) {
- this.lookupNameField = lookupNameField;
- }
-
-} // LookupDBInfo
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/RangeAxisJSON.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/RangeAxisJSON.java
deleted file mode 100644
index d9e93f55..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/RangeAxisJSON.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-class RangeColorJSON extends IndexValueJSON {}
-class RangeAxisLabelJSON extends IndexValueJSON {}
-class RangeLineTypeJSON extends IndexValueJSON {}
-
-public class RangeAxisJSON {
-
- private RangeAxisLabelJSON rangeAxisLabelJSON;
- private RangeColorJSON rangeColorJSON;
- private RangeLineTypeJSON rangeLineTypeJSON;
- private String rangeChartGroup;
- private String rangeYAxis;
- private boolean showAsArea;
-
- public RangeAxisLabelJSON getRangeAxisLabelJSON() {
- return rangeAxisLabelJSON;
- }
- public void setRangeAxisLabelJSON(RangeAxisLabelJSON rangeAxisLabelJSON) {
- this.rangeAxisLabelJSON = rangeAxisLabelJSON;
- }
- public RangeColorJSON getRangeColorJSON() {
- return rangeColorJSON;
- }
- public void setRangeColorJSON(RangeColorJSON rangeColorJSON) {
- this.rangeColorJSON = rangeColorJSON;
- }
- public RangeLineTypeJSON getRangeLineTypeJSON() {
- return rangeLineTypeJSON;
- }
- public void setRangeLineTypeJSON(RangeLineTypeJSON rangeLineTypeJSON) {
- this.rangeLineTypeJSON = rangeLineTypeJSON;
- }
- public String getRangeChartGroup() {
- return rangeChartGroup;
- }
- public void setRangeChartGroup(String rangeChartGroup) {
- this.rangeChartGroup = rangeChartGroup;
- }
- public String getRangeYAxis() {
- return rangeYAxis;
- }
- public void setRangeYAxis(String rangeYAxis) {
- this.rangeYAxis = rangeYAxis;
- }
- public boolean isShowAsArea() {
- return showAsArea;
- }
- public void setShowAsArea(boolean showAsArea) {
- this.showAsArea = showAsArea;
- }
-
- public String getRangeAxis() {
- if(getRangeAxisLabelJSON()!=null)
- return getRangeAxisLabelJSON().getValue();
- else
- return "";
- }
-
- public String getRangeColor(){
- if(getRangeColorJSON()!=null)
- return getRangeColorJSON().getValue();
- else
- return "";
- }
-
- public String getRangeLineType(){
- if(getRangeLineTypeJSON()!=null)
- return getRangeLineTypeJSON().getValue();
- else
- return "";
- }
-
-}
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportFormFields.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportFormFields.java
deleted file mode 100644
index 7e185618..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportFormFields.java
+++ /dev/null
@@ -1,366 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.openecomp.portalsdk.analytics.error.RaptorException;
-import org.openecomp.portalsdk.analytics.model.DataCache;
-import org.openecomp.portalsdk.analytics.model.base.ReportWrapper;
-import org.openecomp.portalsdk.analytics.system.AppUtils;
-import org.openecomp.portalsdk.analytics.system.ConnectionUtils;
-import org.openecomp.portalsdk.analytics.system.Globals;
-import org.openecomp.portalsdk.analytics.util.AppConstants;
-import org.openecomp.portalsdk.analytics.util.DataSet;
-import org.openecomp.portalsdk.analytics.util.Utils;
-import org.openecomp.portalsdk.analytics.xmlobj.ColFilterType;
-import org.openecomp.portalsdk.analytics.xmlobj.DataColumnType;
-import org.openecomp.portalsdk.analytics.xmlobj.FormFieldType;
-
-public class ReportFormFields extends Vector {
- private int nextElemIdx = 0;
-
- public ReportFormFields(ReportWrapper rw, HttpServletRequest request) throws RaptorException {
- super();
-
- if (rw.getFormFieldList() != null)
- for (Iterator iter = rw.getFormFieldList().getFormField().iterator(); iter
- .hasNext();) {
- FormFieldType fft = (FormFieldType) iter.next();
-
- String fieldName = fft.getFieldId();
- String fieldDisplayName = fft.getFieldName();
- String fieldType = fft.getFieldType();
- String validationType = fft.getValidationType();
- String mandatory = nvl(fft.getMandatory(), "N");
- String defaultValue = fft.getDefaultValue();
- String fieldSQL = fft.getFieldSQL();
- String fieldDefaultSQL = fft.getFieldDefaultSQL();
- String[] reqParameters = Globals.getRequestParams().split(",");
- String[] sessionParameters = Globals.getSessionParams().split(",");
- String[] scheduleSessionParameters = Globals.getSessionParamsForScheduling().split(",");
- javax.servlet.http.HttpSession session = request.getSession();
- String visible = nvl(fft.getVisible(),"Y");
- String dependsOn = nvl(fft.getDependsOn(), "");
- Calendar rangeStartDate = (fft.getRangeStartDate()==null)?null:fft.getRangeStartDate().toGregorianCalendar();
- Calendar rangeEndDate = (fft.getRangeEndDate()==null)?null:fft.getRangeEndDate().toGregorianCalendar();
- //Calendar rangeEndDate = fft.getRangeEndDate().toGregorianCalendar();
- String rangeStartDateSQL = fft.getRangeStartDateSQL();
- String rangeEndDateSQL = fft.getRangeEndDateSQL();
- String user_id = AppUtils.getUserID(request);
- String multiSelectListSize = fft.getMultiSelectListSize();
-
- //s_logger.debug("ranges are : " + fft.getRangeStartDate() + fft.getRangeEndDate());
- //s_logger.debug("fieldSQL B4" + fieldSQL);
- if(fieldSQL!=null) {
- for (int i = 0; i < reqParameters.length; i++) {
- if(!reqParameters[i].startsWith("ff") && (request.getParameter(reqParameters[i].toUpperCase())!=null && request.getParameter(reqParameters[i].toUpperCase()).length() > 0))
- fieldSQL = Utils.replaceInString(fieldSQL, "[" + reqParameters[i].toUpperCase()+"]", request.getParameter(reqParameters[i].toUpperCase()) );
- else if (request.getParameter(reqParameters[i])!=null && request.getParameter(reqParameters[i]).length() > 0)
- fieldSQL = Utils.replaceInString(fieldSQL, "[" + reqParameters[i].toUpperCase()+"]", request.getParameter(reqParameters[i]) );
- }
-
- for (int i = 0; i < scheduleSessionParameters.length; i++) {
- //s_logger.debug(" Session " + " scheduleSessionParameters[i] " + scheduleSessionParameters[i].toUpperCase() + " " + request.getParameter(scheduleSessionParameters[i]));
- if(request.getParameter(scheduleSessionParameters[i])!=null && request.getParameter(scheduleSessionParameters[i]).trim().length()>0 )
- fieldSQL = Utils.replaceInString(fieldSQL, "[" + scheduleSessionParameters[i].toUpperCase()+"]", request.getParameter(scheduleSessionParameters[i]) );
- if(request.getAttribute(scheduleSessionParameters[i])!=null && ((String)request.getAttribute(scheduleSessionParameters[i])).trim().length()>0 )
- fieldSQL = Utils.replaceInString(fieldSQL, "[" + scheduleSessionParameters[i].toUpperCase()+"]", (String) request.getAttribute(scheduleSessionParameters[i]) );
-
- }
-
- for (int i = 0; i < sessionParameters.length; i++) {
- //if(!sessionParameters[i].startsWith("ff"))
- //fieldSQL = Utils.replaceInString(fieldSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i].toUpperCase()) );
- //else {
- if (session.getAttribute(sessionParameters[i])!=null && ((String)session.getAttribute(sessionParameters[i])).length() > 0) {
- //s_logger.debug(" Session " + " sessionParameters[i] " + sessionParameters[i] + " " + (String)session.getAttribute(sessionParameters[i]));
- fieldSQL = Utils.replaceInString(fieldSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) );
- }
- // }
- }
- fieldSQL = Utils.replaceInString(fieldSQL, "[USERID]", user_id);
- fieldSQL = Utils.replaceInString(fieldSQL, "[USER_ID]", user_id);
- fieldSQL = Utils.replaceInString(fieldSQL, "[LOGGED_USERID]", user_id);
-
- }
-
- if(fieldDefaultSQL!=null) {
- for (int i = 0; i < reqParameters.length; i++) {
- if(!reqParameters[i].startsWith("ff") && (request.getParameter(reqParameters[i].toUpperCase())!=null && request.getParameter(reqParameters[i].toUpperCase()).length() > 0))
- fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[" + reqParameters[i].toUpperCase()+"]", request.getParameter(reqParameters[i].toUpperCase()) );
- else if (request.getParameter(reqParameters[i])!=null && request.getParameter(reqParameters[i]).length() > 0)
- fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[" + reqParameters[i].toUpperCase()+"]", request.getParameter(reqParameters[i]) );
- }
- for (int i = 0; i < scheduleSessionParameters.length; i++) {
- //s_logger.debug(" Session " + " scheduleSessionParameters[i] " + scheduleSessionParameters[i].toUpperCase() + " " + request.getParameter(scheduleSessionParameters[i]));
- if(request.getParameter(scheduleSessionParameters[i])!=null && request.getParameter(scheduleSessionParameters[i]).trim().length()>0 )
- fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[" + scheduleSessionParameters[i].toUpperCase()+"]", request.getParameter(scheduleSessionParameters[i]) );
- if(request.getAttribute(scheduleSessionParameters[i])!=null && ((String)request.getAttribute(scheduleSessionParameters[i])).trim().length()>0 )
- fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[" + scheduleSessionParameters[i].toUpperCase()+"]", (String) request.getAttribute(scheduleSessionParameters[i]) );
-
- }
-
- for (int i = 0; i < sessionParameters.length; i++) {
- //if(!sessionParameters[i].startsWith("ff"))
- //fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i].toUpperCase()) );
- //else
- if (session.getAttribute(sessionParameters[i])!=null && ((String)session.getAttribute(sessionParameters[i])).length() > 0)
- fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) );
- }
-
- fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[USERID]", user_id);
- fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[USER_ID]", user_id);
- fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[LOGGED_USERID]", user_id);
- }
- //s_logger.debug("fieldSQL After" + fieldSQL);
- if(rangeStartDateSQL!=null) {
- for (int i = 0; i < reqParameters.length; i++) {
- if(!reqParameters[i].startsWith("ff") && (request.getParameter(reqParameters[i].toUpperCase())!=null && request.getParameter(reqParameters[i].toUpperCase()).length() > 0))
- rangeStartDateSQL = Utils.replaceInString(rangeStartDateSQL, "[" + reqParameters[i].toUpperCase()+"]", request.getParameter(reqParameters[i].toUpperCase()) );
- else if (request.getParameter(reqParameters[i])!=null && request.getParameter(reqParameters[i]).length() > 0)
- rangeStartDateSQL = Utils.replaceInString(rangeStartDateSQL, "[" + reqParameters[i].toUpperCase()+"]", request.getParameter(reqParameters[i]) );
- }
- for (int i = 0; i < sessionParameters.length; i++) {
- if (session.getAttribute(sessionParameters[i])!=null && ((String)session.getAttribute(sessionParameters[i])).length() > 0)
- rangeStartDateSQL = Utils.replaceInString(rangeStartDateSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) );
- }
- }
- if(rangeEndDateSQL!=null) {
- for (int i = 0; i < reqParameters.length; i++) {
- if(!reqParameters[i].startsWith("ff")&& (request.getParameter(reqParameters[i].toUpperCase())!=null && request.getParameter(reqParameters[i].toUpperCase()).length() > 0))
- rangeEndDateSQL = Utils.replaceInString(rangeEndDateSQL, "[" + reqParameters[i].toUpperCase()+"]", request.getParameter(reqParameters[i].toUpperCase()) );
- else if (request.getParameter(reqParameters[i])!=null && request.getParameter(reqParameters[i]).length() > 0)
- rangeEndDateSQL = Utils.replaceInString(rangeEndDateSQL, "[" + reqParameters[i].toUpperCase()+"]", request.getParameter(reqParameters[i]) );
- }
- for (int i = 0; i < sessionParameters.length; i++) {
- if (session.getAttribute(sessionParameters[i])!=null && ((String)session.getAttribute(sessionParameters[i])).length() > 0)
- rangeEndDateSQL = Utils.replaceInString(rangeEndDateSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) );
- }
- }
- String helpText = fft.getComment();
-
- List predefinedValues = null;
- if (fft.getPredefinedValueList() != null) {
- predefinedValues = fft.getPredefinedValueList().getPredefinedValue();
- if (predefinedValues.size() == 0)
- predefinedValues = null;
- } // if
-
- DataColumnType dct = rw.getColumnById(nvl(fft.getColId()));
-
- boolean basedOnColumn = false;
- if (rw.getReportDefType().equals(AppConstants.RD_SQL_BASED))
- basedOnColumn = (nvl(fft.getColId()).indexOf('.') > 0);
- else
- basedOnColumn = (dct != null);
-
- if (((!basedOnColumn) && (nvl(fieldSQL).length() == 0))
- || predefinedValues != null) {
- if (predefinedValues != null)
- if (nvl(defaultValue).equals(AppConstants.FILTER_MAX_VALUE))
- defaultValue = (String) Collections.max(predefinedValues);
- else if (nvl(defaultValue).equals(AppConstants.FILTER_MIN_VALUE))
- defaultValue = (String) Collections.min(predefinedValues);
- add(new FormField(fieldName, fieldDisplayName, fieldType, validationType,
- mandatory.equals("Y"), defaultValue, helpText, predefinedValues,visible.equals("Y"), dependsOn, rangeStartDate, rangeEndDate, rangeStartDateSQL, rangeEndDateSQL, multiSelectListSize));
- } else if (nvl(fieldSQL).length() > 0) {
- add(new FormField(fieldName, fieldDisplayName, fieldType, validationType,
- mandatory.equals("Y"), fieldDefaultSQL, helpText, fieldSQL,visible.equals("Y"), dependsOn, rangeStartDate, rangeEndDate, rangeStartDateSQL, rangeEndDateSQL, multiSelectListSize));
- } else {
- String lTableName = null;
- String lColumnName = null;
- String lColumnType = null;
- String lColFormat = null;
- if (rw.getReportDefType().equals(AppConstants.RD_SQL_BASED)) {
- String colId = nvl(fft.getColId());
- lTableName = ReportWrapper.getSQLBasedFFTColTableName(colId); // colId.substring(0,
- // colId.indexOf('.'));
- lColumnName = ReportWrapper.getSQLBasedFFTColColumnName(colId); // colId.substring(colId.lastIndexOf('.')+1);
- lColumnType = AppConstants.CT_CHAR;
- try {
- lColumnType = nvl(DataCache.getReportTableDbColumnType(lTableName,
- lColumnName, rw.getDBInfo()), AppConstants.CT_CHAR);
- } catch (Exception e) {
- }
- lColFormat = lColumnType.equals(AppConstants.CT_DATE) ? nvl(
- ReportWrapper.getSQLBasedFFTColDisplayFormat(colId),
- AppConstants.DEFAULT_DATE_FORMAT) : "";
- } else {
- lTableName = rw.getColumnTableById(dct.getColId()).getTableName(); // should
- // be
- // same
- // as
- // rw.getTableById(dct.getTableId()).getTableName()
- lColumnName = dct.getColName();
- lColumnType = dct.getColType();
- lColFormat = nvl(dct.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT);
- } // else
-
- if (nvl(defaultValue).equals(AppConstants.FILTER_MAX_VALUE)
- || nvl(defaultValue).equals(AppConstants.FILTER_MIN_VALUE))
- try {
- String selectVal = (defaultValue
- .equals(AppConstants.FILTER_MAX_VALUE) ? "MAX" : "MIN")
- + "(" + lColumnName + ")";
- if (lColumnType.equals(AppConstants.CT_DATE))
- selectVal = "TO_CHAR(" + selectVal + ", '"
- + AppConstants.DEFAULT_DATE_FORMAT + "')";
- // DataSet ds = DbUtils.executeQuery("SELECT
- // "+selectVal+" FROM "+lTableName);
- DataSet ds = ConnectionUtils.getDataSet("SELECT " + selectVal
- + " FROM " + lTableName, rw.getDBInfo());
- if (ds.getRowCount() > 0)
- defaultValue = ds.getString(0, 0);
- } catch (Exception e) {
- }
-
- LookupDBInfo lookupDBInfo = DataCache.getLookupTable(lTableName,
- lColumnName);
- String lookupTable = lookupDBInfo.getLookupTable();
- String lookupIdField = lookupDBInfo.getLookupIdField();
- String lookupNameField = lookupDBInfo.getLookupNameField();
- String lookupSortByField = lookupDBInfo.getLookupNameField();
- if (lColumnType.equals(AppConstants.CT_DATE)) {
- // Expects lookup on DATE fields will have both Id and
- // Name fields with DATE format; if not the case will
- // generate an error
- lookupIdField = "TO_CHAR(" + lookupIdField + ", '"
- + AppConstants.DEFAULT_DATE_FORMAT + "')";
- lookupSortByField = " TO_DATE(TO_CHAR("+ lookupNameField +", '" + AppConstants.DEFAULT_DATE_FORMAT+ "'),'" + AppConstants.DEFAULT_DATE_FORMAT+ "') ";
- lookupNameField = "TO_CHAR(" + lookupNameField + ", '" + lColFormat
- + "')";
- lookupSortByField += " DESC";
- } // if
- if (fieldDefaultSQL!=null && fieldDefaultSQL.length()>0 && (fieldDefaultSQL.trim().length()>10) && fieldDefaultSQL.substring(0,10).toLowerCase().startsWith("select")) {
- add(new FormField(fieldName, fieldDisplayName, fieldType, validationType,
- mandatory.equals("Y"), fieldDefaultSQL, helpText, lookupTable,
- lookupIdField, lookupNameField, lookupSortByField,visible.equals("Y"),dependsOn, rangeStartDate, rangeEndDate, rangeStartDateSQL, rangeEndDateSQL, multiSelectListSize));
-
- } else {
- add(new FormField(fieldName, fieldDisplayName, fieldType, validationType,
- mandatory.equals("Y"), defaultValue, helpText, lookupTable,
- lookupIdField, lookupNameField, lookupSortByField,visible.equals("Y"), dependsOn, rangeStartDate, rangeEndDate, rangeStartDateSQL, rangeEndDateSQL, multiSelectListSize));
- }
- } // else
- } // for
-
- List reportCols = rw.getAllColumns();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
-
- if (dct.getColFilterList() != null) {
- int fNo = 0;
- List fList = dct.getColFilterList().getColFilter();
- for (Iterator iterF = fList.iterator(); iterF.hasNext(); fNo++) {
- ColFilterType cft = (ColFilterType) iterF.next();
-
- if (nvl(cft.getArgType()).equals(AppConstants.AT_FORM)
- && rw.getFormFieldByDisplayValue(cft.getArgValue()) == null) {
- String fieldName = rw.getFormFieldName(cft);
- String fieldDisplayName = rw.getFormFieldDisplayName(dct, cft);
-
- LookupDBInfo lookupDBInfo = DataCache.getLookupTable(rw
- .getColumnTableById(dct.getColId()).getTableName(), dct
- .getColName());
- String lookupTable = lookupDBInfo.getLookupTable();
- String lookupIdField = lookupDBInfo.getLookupIdField();
- String lookupNameField = lookupDBInfo.getLookupNameField();
- String lookupSortByField = lookupDBInfo.getLookupNameField();
- Calendar lookupRangeStartDate = rw.getFormFieldRangeStart(cft);
- Calendar lookupRangeEndDate = rw.getFormFieldRangeEnd(cft);
- String lookupRangeStartDateSQL = rw.getFormFieldRangeStartSQL(cft);
- String lookupRangeEndDateSQL = rw.getFormFieldRangeEndSQL(cft);
- if (dct.getColType().equals(AppConstants.CT_DATE)) {
- // Expects lookup on DATE fields will have both Id
- // and Name fields with DATE format; if not the case
- // will generate an error
- lookupIdField = "TO_CHAR("
- + lookupIdField
- + ", '"
- + nvl(dct.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT)
- + "')";
- lookupNameField = "TO_CHAR("
- + lookupNameField
- + ", '"
- + nvl(dct.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT)
- + "')";
- lookupSortByField += " DESC";
- } // if
- add(new FormField(fieldName, fieldDisplayName,
- FormField.FFT_TEXT_W_POPUP, null, false, null, null,
- lookupTable, lookupIdField, lookupNameField, lookupSortByField,null, lookupRangeStartDate, lookupRangeEndDate, lookupRangeStartDateSQL, lookupRangeEndDateSQL, "0"));
- } // if
- } // for
- } // if
- } // for
- } // ReportFormFields
-
- public int getFieldCount() {
- return size();
- } // getFieldCount
-
- public FormField getFormField(int fieldIdx) {
- return (FormField) get(fieldIdx);
- } // getFormField
-
- public FormField getFormField(String fieldName) {
- for (int i = 0; i < getFieldCount(); i++) {
- FormField ff = (FormField) get(i);
- if (ff.getFieldName().equals(fieldName))
- return ff;
- } // for
-
- return null;
- } // getFormField
-
- public void resetNext() {
- resetNext(0);
- } // resetNext
-
- public void resetNext(int toPos) {
- nextElemIdx = toPos;
- } // resetNext
-
- public boolean hasNext() {
- return (nextElemIdx < size());
- } // hasNext
-
- public FormField getNext() {
- return hasNext() ? getFormField(nextElemIdx++) : null;
- } // getNext
-
- /** ************************************************************************************************* */
-
- private String nvl(String s) {
- return (s == null) ? "" : s;
- }
-
- private String nvl(String s, String sDefault) {
- return nvl(s).equals("") ? sDefault : s;
- }
-
-} // ReportFormFields
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportJSONRuntime.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportJSONRuntime.java
deleted file mode 100644
index 7556a310..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportJSONRuntime.java
+++ /dev/null
@@ -1,694 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Map;
-
-import org.openecomp.portalsdk.analytics.model.base.IdNameValue;
-import org.openecomp.portalsdk.analytics.view.ColumnHeader;
-
-/*class MetaColumn {
- private String tableId;
- private String dbColName;
- private String crossTabValue;
- private String colName;
- private String displayName;
- private Integer displayWidth;
- private String displayWidthInPxls;
- private String pdfDisplayWidthInPxls;
- private String displayAlignment;
- private String displayHeaderAlignment;
- private int orderSeq;
- private boolean visible;
- private boolean calculated;
- private String colType;
- private String hyperlinkURL;
- private String hyperlinkType;
- private String actionImg;
- private Integer groupByPos;
- private String subTotalCustomText;
- private Boolean hideRepeatedKey;
- private String colFormat;
- private boolean groupBreak;
- private Integer orderBySeq;
- private String orderByAscDesc;
- private String displayTotal;
- private String colOnChart;
- private Integer chartSeq;
- private String chartColor;
- private String chartLineType;
- private Boolean chartSeries;
- private Boolean isRangeAxisFilled;
- private Boolean createInNewChart;
- private String drillDownType;
- private Boolean drillinPoPUp;
- private String drillDownURL;
- private String drillDownParams;
- private String comment;
- private ColFilterList colFilterList;
- private String semaphoreId;
- private String dbColType;
- private String chartGroup;
- private String yAxis;
- private String dependsOnFormField;
- private String nowrap;
- private Integer indentation;
- private Boolean enhancedPagination;
- private Integer level;
- private Integer start;
- private Integer colspan;
- private String dataMiningCol;
- private String colId;
-
- public String getTableId() {
- return tableId;
- }
- public void setTableId(String tableId) {
- this.tableId = tableId;
- }
- public String getDbColName() {
- return dbColName;
- }
- public void setDbColName(String dbColName) {
- this.dbColName = dbColName;
- }
- public String getCrossTabValue() {
- return crossTabValue;
- }
- public void setCrossTabValue(String crossTabValue) {
- this.crossTabValue = crossTabValue;
- }
- public String getColName() {
- return colName;
- }
- public void setColName(String colName) {
- this.colName = colName;
- }
- public String getDisplayName() {
- return displayName;
- }
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
- public Integer getDisplayWidth() {
- return displayWidth;
- }
- public void setDisplayWidth(Integer displayWidth) {
- this.displayWidth = displayWidth;
- }
- public String getDisplayWidthInPxls() {
- return displayWidthInPxls;
- }
- public void setDisplayWidthInPxls(String displayWidthInPxls) {
- this.displayWidthInPxls = displayWidthInPxls;
- }
- public String getPdfDisplayWidthInPxls() {
- return pdfDisplayWidthInPxls;
- }
- public void setPdfDisplayWidthInPxls(String pdfDisplayWidthInPxls) {
- this.pdfDisplayWidthInPxls = pdfDisplayWidthInPxls;
- }
- public String getDisplayAlignment() {
- return displayAlignment;
- }
- public void setDisplayAlignment(String displayAlignment) {
- this.displayAlignment = displayAlignment;
- }
- public String getDisplayHeaderAlignment() {
- return displayHeaderAlignment;
- }
- public void setDisplayHeaderAlignment(String displayHeaderAlignment) {
- this.displayHeaderAlignment = displayHeaderAlignment;
- }
- public int getOrderSeq() {
- return orderSeq;
- }
- public void setOrderSeq(int orderSeq) {
- this.orderSeq = orderSeq;
- }
- public boolean isVisible() {
- return visible;
- }
- public void setVisible(boolean visible) {
- this.visible = visible;
- }
- public boolean isCalculated() {
- return calculated;
- }
- public void setCalculated(boolean calculated) {
- this.calculated = calculated;
- }
- public String getColType() {
- return colType;
- }
- public void setColType(String colType) {
- this.colType = colType;
- }
- public String getHyperlinkURL() {
- return hyperlinkURL;
- }
- public void setHyperlinkURL(String hyperlinkURL) {
- this.hyperlinkURL = hyperlinkURL;
- }
- public String getHyperlinkType() {
- return hyperlinkType;
- }
- public void setHyperlinkType(String hyperlinkType) {
- this.hyperlinkType = hyperlinkType;
- }
- public String getActionImg() {
- return actionImg;
- }
- public void setActionImg(String actionImg) {
- this.actionImg = actionImg;
- }
- public Integer getGroupByPos() {
- return groupByPos;
- }
- public void setGroupByPos(Integer groupByPos) {
- this.groupByPos = groupByPos;
- }
- public String getSubTotalCustomText() {
- return subTotalCustomText;
- }
- public void setSubTotalCustomText(String subTotalCustomText) {
- this.subTotalCustomText = subTotalCustomText;
- }
- public Boolean getHideRepeatedKey() {
- return hideRepeatedKey;
- }
- public void setHideRepeatedKey(Boolean hideRepeatedKey) {
- this.hideRepeatedKey = hideRepeatedKey;
- }
- public String getColFormat() {
- return colFormat;
- }
- public void setColFormat(String colFormat) {
- this.colFormat = colFormat;
- }
- public boolean isGroupBreak() {
- return groupBreak;
- }
- public void setGroupBreak(boolean groupBreak) {
- this.groupBreak = groupBreak;
- }
- public Integer getOrderBySeq() {
- return orderBySeq;
- }
- public void setOrderBySeq(Integer orderBySeq) {
- this.orderBySeq = orderBySeq;
- }
- public String getOrderByAscDesc() {
- return orderByAscDesc;
- }
- public void setOrderByAscDesc(String orderByAscDesc) {
- this.orderByAscDesc = orderByAscDesc;
- }
- public String getDisplayTotal() {
- return displayTotal;
- }
- public void setDisplayTotal(String displayTotal) {
- this.displayTotal = displayTotal;
- }
- public String getColOnChart() {
- return colOnChart;
- }
- public void setColOnChart(String colOnChart) {
- this.colOnChart = colOnChart;
- }
- public Integer getChartSeq() {
- return chartSeq;
- }
- public void setChartSeq(Integer chartSeq) {
- this.chartSeq = chartSeq;
- }
- public String getChartColor() {
- return chartColor;
- }
- public void setChartColor(String chartColor) {
- this.chartColor = chartColor;
- }
- public String getChartLineType() {
- return chartLineType;
- }
- public void setChartLineType(String chartLineType) {
- this.chartLineType = chartLineType;
- }
- public Boolean getChartSeries() {
- return chartSeries;
- }
- public void setChartSeries(Boolean chartSeries) {
- this.chartSeries = chartSeries;
- }
- public Boolean getIsRangeAxisFilled() {
- return isRangeAxisFilled;
- }
- public void setIsRangeAxisFilled(Boolean isRangeAxisFilled) {
- this.isRangeAxisFilled = isRangeAxisFilled;
- }
- public Boolean getCreateInNewChart() {
- return createInNewChart;
- }
- public void setCreateInNewChart(Boolean createInNewChart) {
- this.createInNewChart = createInNewChart;
- }
- public String getDrillDownType() {
- return drillDownType;
- }
- public void setDrillDownType(String drillDownType) {
- this.drillDownType = drillDownType;
- }
- public Boolean getDrillinPoPUp() {
- return drillinPoPUp;
- }
- public void setDrillinPoPUp(Boolean drillinPoPUp) {
- this.drillinPoPUp = drillinPoPUp;
- }
- public String getDrillDownURL() {
- return drillDownURL;
- }
- public void setDrillDownURL(String drillDownURL) {
- this.drillDownURL = drillDownURL;
- }
- public String getDrillDownParams() {
- return drillDownParams;
- }
- public void setDrillDownParams(String drillDownParams) {
- this.drillDownParams = drillDownParams;
- }
- public String getComment() {
- return comment;
- }
- public void setComment(String comment) {
- this.comment = comment;
- }
- public ColFilterList getColFilterList() {
- return colFilterList;
- }
- public void setColFilterList(ColFilterList colFilterList) {
- this.colFilterList = colFilterList;
- }
- public String getSemaphoreId() {
- return semaphoreId;
- }
- public void setSemaphoreId(String semaphoreId) {
- this.semaphoreId = semaphoreId;
- }
- public String getDbColType() {
- return dbColType;
- }
- public void setDbColType(String dbColType) {
- this.dbColType = dbColType;
- }
- public String getChartGroup() {
- return chartGroup;
- }
- public void setChartGroup(String chartGroup) {
- this.chartGroup = chartGroup;
- }
- public String getyAxis() {
- return yAxis;
- }
- public void setyAxis(String yAxis) {
- this.yAxis = yAxis;
- }
- public String getDependsOnFormField() {
- return dependsOnFormField;
- }
- public void setDependsOnFormField(String dependsOnFormField) {
- this.dependsOnFormField = dependsOnFormField;
- }
- public String getNowrap() {
- return nowrap;
- }
- public void setNowrap(String nowrap) {
- this.nowrap = nowrap;
- }
- public Integer getIndentation() {
- return indentation;
- }
- public void setIndentation(Integer indentation) {
- this.indentation = indentation;
- }
- public Boolean getEnhancedPagination() {
- return enhancedPagination;
- }
- public void setEnhancedPagination(Boolean enhancedPagination) {
- this.enhancedPagination = enhancedPagination;
- }
- public Integer getLevel() {
- return level;
- }
- public void setLevel(Integer level) {
- this.level = level;
- }
- public Integer getStart() {
- return start;
- }
- public void setStart(Integer start) {
- this.start = start;
- }
- public Integer getColspan() {
- return colspan;
- }
- public void setColspan(Integer colspan) {
- this.colspan = colspan;
- }
- public String getDataMiningCol() {
- return dataMiningCol;
- }
- public void setDataMiningCol(String dataMiningCol) {
- this.dataMiningCol = dataMiningCol;
- }
- public String getColId() {
- return colId;
- }
- public void setColId(String colId) {
- this.colId = colId;
- }
-
-}*/
-
-/*class Row {
- private String displayValue;
- private String dataType;
- private String colId;
- private boolean visible;
-
-
- public boolean isVisible() {
- return visible;
- }
- public void setVisible(boolean visible) {
- this.visible = visible;
- }
- public String getDisplayValue() {
- return displayValue;
- }
- public void setDisplayValue(String displayValue) {
- this.displayValue = displayValue;
- }
- public String getDataType() {
- return dataType;
- }
- public void setDataType(String dataType) {
- this.dataType = dataType;
- }
- public String getColId() {
- return colId;
- }
- public void setColId(String colId) {
- this.colId = colId;
- }
-
-
-}*/
-class FormFieldJSON {
- private String fieldId;
- private String fieldDisplayName;
- private String fieldType;
- private String validationType;
- private boolean required;
- //private String defaultValue;
-
- private Calendar rangeStartDate;
- private Calendar rangeEndDate;
- private String multiSelectListSize;
- private String helpText;
- private boolean visible;
- private boolean triggerOtherFormFields;
- private ArrayList<IdNameValue> formFieldValues;
-
- public String getFieldId() {
- return fieldId;
- }
- public void setFieldId(String fieldId) {
- this.fieldId = fieldId;
- }
- public String getFieldDisplayName() {
- return fieldDisplayName;
- }
- public void setFieldDisplayName(String fieldDisplayName) {
- this.fieldDisplayName = fieldDisplayName;
- }
- public String getFieldType() {
- return fieldType;
- }
- public void setFieldType(String fieldType) {
- this.fieldType = fieldType;
- }
- public String getValidationType() {
- return validationType;
- }
- public void setValidationType(String validationType) {
- this.validationType = validationType;
- }
- public boolean isRequired() {
- return required;
- }
- public void setRequired(boolean required) {
- this.required = required;
- }
- public Calendar getRangeStartDate() {
- return rangeStartDate;
- }
- public void setRangeStartDate(Calendar rangeStartDate) {
- this.rangeStartDate = rangeStartDate;
- }
- public Calendar getRangeEndDate() {
- return rangeEndDate;
- }
- public void setRangeEndDate(Calendar rangeEndDate) {
- this.rangeEndDate = rangeEndDate;
- }
- public String getMultiSelectListSize() {
- return multiSelectListSize;
- }
- public void setMultiSelectListSize(String multiSelectListSize) {
- this.multiSelectListSize = multiSelectListSize;
- }
- public String getHelpText() {
- return helpText;
- }
- public void setHelpText(String helpText) {
- this.helpText = helpText;
- }
- public boolean isVisible() {
- return visible;
- }
- public void setVisible(boolean visible) {
- this.visible = visible;
- }
- public boolean isTriggerOtherFormFields() {
- return triggerOtherFormFields;
- }
- public void setTriggerOtherFormFields(boolean triggerOtherFormFields) {
- this.triggerOtherFormFields = triggerOtherFormFields;
- }
- public ArrayList<IdNameValue> getFormFieldValues() {
- return formFieldValues;
- }
- public void setFormFieldValues(ArrayList<IdNameValue> formFieldValues) {
- this.formFieldValues = formFieldValues;
- }
-
-
-}
-public class ReportJSONRuntime {
-
- private String reportID;
- private String reportName;
- private String reportDescr;
- private String reportTitle;
- private String reportSubTitle;
- private boolean allowSchedule;
- private boolean allowEdit;
- private ArrayList <FormFieldJSON> formFieldList;
- private String formfield_comments;
- private ArrayList<ColumnHeader> reportDataColumns;
- private ArrayList<Map<String,Object>> reportDataRows;
- private int totalRows;
- private int pageSize;
- private String sqlWhole;
- private boolean chartAvailable;
- private boolean chartWizardAvailable;
- private boolean displayData;
- private boolean displayForm;
- private boolean displayExcel;
- private boolean displayPDF;
- private String backBtnURL;
- private String colIdxTobeFreezed;
- private int numFormCols;
- private String message;
-
-
- public boolean isChartAvailable() {
- return chartAvailable;
- }
- public void setChartAvailable(boolean chartAvailable) {
- this.chartAvailable = chartAvailable;
- }
- public ArrayList<Map<String,Object>> getReportDataRows() {
- return reportDataRows;
- }
- public void setReportDataRows(ArrayList<Map<String,Object>> reportDataRows) {
- this.reportDataRows = reportDataRows;
- }
- public String getReportID() {
- return reportID;
- }
- public void setReportID(String reportID) {
- this.reportID = reportID;
- }
- public String getReportName() {
- return reportName;
- }
- public void setReportName(String reportName) {
- this.reportName = reportName;
- }
- public String getReportDescr() {
- return reportDescr;
- }
- public void setReportDescr(String reportDescr) {
- this.reportDescr = reportDescr;
- }
- public String getReportTitle() {
- return reportTitle;
- }
- public void setReportTitle(String reportTitle) {
- this.reportTitle = reportTitle;
- }
- public String getReportSubTitle() {
- return reportSubTitle;
- }
- public void setReportSubTitle(String reportSubTitle) {
- this.reportSubTitle = reportSubTitle;
- }
- public boolean isAllowSchedule() {
- return allowSchedule;
- }
- public void setAllowSchedule(boolean allowSchedule) {
- this.allowSchedule = allowSchedule;
- }
- public ArrayList getFormFieldList() {
- return formFieldList;
- }
- public void setFormFieldList(ArrayList formFieldList) {
- this.formFieldList = formFieldList;
- }
- public String getFormfield_comments() {
- return formfield_comments;
- }
- public void setFormfield_comments(String formfield_comments) {
- this.formfield_comments = formfield_comments;
- }
- public ArrayList<ColumnHeader> getReportDataColumns() {
- return reportDataColumns;
- }
- public void setReportDataColumns(ArrayList<ColumnHeader> reportDataColumns) {
- this.reportDataColumns = reportDataColumns;
- }
-
- public int getTotalRows() {
- return totalRows;
- }
- public void setTotalRows(int totalRows) {
- this.totalRows = totalRows;
- }
- public int getPageSize() {
- return pageSize;
- }
- public void setPageSize(int pageSize) {
- this.pageSize = pageSize;
- }
- public String getSqlWhole() {
- return sqlWhole;
- }
- public void setSqlWhole(String sqlWhole) {
- this.sqlWhole = sqlWhole;
- }
-
- public boolean isAllowEdit() {
- return allowEdit;
- }
- public void setAllowEdit(boolean allowEdit) {
- this.allowEdit = allowEdit;
- }
- public String getBackBtnURL() {
- return backBtnURL;
- }
- public void setBackBtnURL(String backBtnURL) {
- this.backBtnURL = backBtnURL;
- }
- public String getColIdxTobeFreezed() {
- return colIdxTobeFreezed;
- }
- public void setColIdxTobeFreezed(String colIdxTobeFreezed) {
- this.colIdxTobeFreezed = colIdxTobeFreezed;
- }
- public int getNumFormCols() {
- return numFormCols;
- }
- public void setNumFormCols(int numFormCols) {
- this.numFormCols = numFormCols;
- }
- public boolean isDisplayData() {
- return displayData;
- }
- public void setDisplayData(boolean displayData) {
- this.displayData = displayData;
- }
- public boolean isDisplayForm() {
- return displayForm;
- }
- public void setDisplayForm(boolean displayForm) {
- this.displayForm = displayForm;
- }
- public boolean isDisplayExcel() {
- return displayExcel;
- }
- public void setDisplayExcel(boolean displayExcel) {
- this.displayExcel = displayExcel;
- }
- public boolean isDisplayPDF() {
- return displayPDF;
- }
- public void setDisplayPDF(boolean displayPDF) {
- this.displayPDF = displayPDF;
- }
- public String getMessage() {
- return message;
- }
- public void setMessage(String message) {
- this.message = message;
- }
- public boolean isChartWizardAvailable() {
- return chartWizardAvailable;
- }
- public void setChartWizardAvailable(boolean chartWizardAvilable) {
- this.chartWizardAvailable = chartWizardAvilable;
- }
-
-
-
-
-}
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamDateValueParser.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamDateValueParser.java
deleted file mode 100644
index e3bbe4d0..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamDateValueParser.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import org.openecomp.portalsdk.analytics.system.Globals;
-import org.openecomp.portalsdk.analytics.util.AppConstants;
-import org.openecomp.portalsdk.analytics.util.Utils;
-
-public class ReportParamDateValueParser {
-
- /*public static final SimpleDateFormat[] dateFormats;
-
- static {
- dateFormats = new SimpleDateFormat[5];
- (dateFormats[0] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MONTHYYYY))
- .setLenient(true);
- (dateFormats[1] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MONTHDDYYYY))
- .setLenient(true);
- (dateFormats[2] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MMDDYYYY))
- .setLenient(true);
- (dateFormats[3] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MMYYYY))
- .setLenient(true);
- (dateFormats[4] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_DDMONYYYY))
- .setLenient(true);
- }*/
-
- public static boolean isDateHrParam(String param) {
- SimpleDateFormat[] dateFormats = new SimpleDateFormat[2];
- (dateFormats[0] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MMDDYYYY_HR))
- .setLenient(true);
- (dateFormats[1] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_DDMONYYYY_HR))
- .setLenient(true);
- for (int i = 0; i < dateFormats.length; i++) {
- try {
- if (dateFormats[i].parse(param) != null) {
- return true;
- }
- } catch (ParseException pe) {
- // do nothing, continue to check param against other dates
- }
- catch (NumberFormatException pe) {
- // do nothing, continue to check param against other dates
- }
- }
- return false;
- }
- public static boolean isDateParam(String param) {
- SimpleDateFormat[] dateFormats = new SimpleDateFormat[5];
- (dateFormats[0] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MONTHYYYY))
- .setLenient(true);
- (dateFormats[1] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MONTHDDYYYY))
- .setLenient(true);
- (dateFormats[2] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MMDDYYYY))
- .setLenient(true);
- (dateFormats[3] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MMYYYY))
- .setLenient(true);
- (dateFormats[4] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_DDMONYYYY))
- .setLenient(true);
-
- for (int i = 0; i < dateFormats.length; i++) {
- try {
- if (dateFormats[i].parse(param) != null) {
- return true;
- }
- } catch (ParseException pe) {
- // do nothing, continue to check param against other dates
- }
- catch (NumberFormatException pe) {
- // do nothing, continue to check param against other dates
- }
- }
- return false;
- }
-
- public static String formatDateParamValue(String param) {
- return ReportParamDateValueParser.formatDateParamValue(param, null);
- }
-
- public static String formatDateHrParamValue(String param) {
- return ReportParamDateValueParser.formatDateHrParamValue(param, null);
- }
-
- public static String formatDateHrParamValue(String param, String dateHrFormatPattern) {
- String formattedDate = null;
- Date parsedDate = null;
-
- dateHrFormatPattern = (dateHrFormatPattern != null) ? dateHrFormatPattern
- : "HH";
-
- SimpleDateFormat[] dateFormats = new SimpleDateFormat[2];
- (dateFormats[0] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MMDDYYYY_HR))
- .setLenient(true);
- (dateFormats[1] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_DDMONYYYY_HR))
- .setLenient(true);
-
- for (int i = 0; i < dateFormats.length; i++) {
- try {
- if (dateFormats[i].parse(param) != null) {
- SimpleDateFormat newDateFormat = new SimpleDateFormat(dateHrFormatPattern);
- parsedDate = dateFormats[i].parse(param);
- formattedDate = newDateFormat.format(parsedDate);
-
-
- return formattedDate;
- }
- } catch (ParseException pe) {
- // do nothing, continue to check param against other dates and
- // format accordingly
- }
- catch (NumberFormatException pe) {
- // do nothing, continue to check param against other dates
- }
- }
- return param;
- }
-
-
- public static String formatDateParamValue(String param, String dateFormatPattern) {
- String formattedDate = null;
- Date parsedDate = null;
-
- dateFormatPattern = (dateFormatPattern != null) ? dateFormatPattern
- : AppConstants.JAVA_DATE_FORMAT_MMDDYYYY;
-
- SimpleDateFormat[] dateFormats = new SimpleDateFormat[5];
- (dateFormats[0] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MONTHYYYY))
- .setLenient(true);
- (dateFormats[1] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MONTHDDYYYY))
- .setLenient(true);
- (dateFormats[2] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MMDDYYYY))
- .setLenient(true);
- (dateFormats[3] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MMYYYY))
- .setLenient(true);
- (dateFormats[4] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_DDMONYYYY))
- .setLenient(true);
-
- for (int i = 0; i < dateFormats.length; i++) {
- try {
- if (dateFormats[i].parse(param) != null) {
- SimpleDateFormat newDateFormat = new SimpleDateFormat(dateFormatPattern);
- parsedDate = dateFormats[i].parse(param);
- formattedDate = newDateFormat.format(parsedDate);
-
- if (Globals.getMonthFormatUseLastDay()
- && (dateFormats[i].toPattern().equals(
- AppConstants.JAVA_DATE_FORMAT_MMYYYY) || dateFormats[i]
- .toPattern().equals(
- AppConstants.JAVA_DATE_FORMAT_MONTHYYYY))) {
-
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(parsedDate);
- int day = gc.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
- formattedDate = Utils.replaceInString(formattedDate, "/01/", "/"
- + String.valueOf(day) + "/");
-
- }
-
- return formattedDate;
- }
- } catch (ParseException pe) {
- // do nothing, continue to check param against other dates and
- // format accordingly
- }
- catch (NumberFormatException pe) {
- // do nothing, continue to check param against other dates
- }
- }
- return param;
- }
-
-} // ReportParamValues
-
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamValues.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamValues.java
deleted file mode 100644
index 66b5f517..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamValues.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.openecomp.portalsdk.analytics.error.RaptorException;
-import org.openecomp.portalsdk.analytics.system.ConnectionUtils;
-import org.openecomp.portalsdk.analytics.system.DbUtils;
-import org.openecomp.portalsdk.analytics.system.Globals;
-import org.openecomp.portalsdk.analytics.util.AppConstants;
-import org.openecomp.portalsdk.analytics.util.DataSet;
-import org.openecomp.portalsdk.analytics.util.Utils;
-import org.openecomp.portalsdk.analytics.util.XSSFilter;
-import org.openecomp.portalsdk.core.controller.FavoritesController;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-
-public class ReportParamValues extends Hashtable {
- EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FavoritesController.class);
-
- private Hashtable paramIsMultiValue = null;
- private Hashtable paramIsTextAreaValue = null;
- private Hashtable paramIsTextAreaDrilldownValue = null;
- private Hashtable paramIsTextAreaValueModified = null;
- private ReportFormFields rff = null;
-
- private Hashtable multiValueBaseSQL = null;
- private Hashtable textAreaValueBaseSQL = null;
-
- public ReportParamValues() {
- super();
- paramIsMultiValue = new Hashtable();
- multiValueBaseSQL = new Hashtable();
- paramIsTextAreaValue = new Hashtable();
- paramIsTextAreaDrilldownValue = new Hashtable();
- paramIsTextAreaValueModified = new Hashtable();
- } // ReportParamValues
-
- public ReportParamValues(ReportFormFields rff, String reportDefType) {
- this();
- this.rff = rff;
- for (Iterator iter = rff.iterator(); iter.hasNext();) {
- FormField ff = (FormField) iter.next();
- if(ff.getValidationType().equals(FormField.VT_TIMESTAMP_HR) || ff.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || ff.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
- put(ff.getFieldName(), nvl(ff.getDefaultValue()));
- put(ff.getFieldName()+"_Hr", nvl(ff.getDefaultValue()));
- if(ff.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || ff.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
- put(ff.getFieldName()+"_Min", nvl(ff.getDefaultValue()));
- }
- if(ff.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
- put(ff.getFieldName()+"_Sec", nvl(ff.getDefaultValue()));
- }
- } else
- put(ff.getFieldName(), nvl(ff.getDefaultValue()));
-
- boolean isMultiValue = ff.getFieldType().equals(FormField.FFT_CHECK_BOX)
- || ff.getFieldType().equals(FormField.FFT_LIST_MULTI);
- boolean isTextAreaValue = ff.getFieldType().equals(FormField.FFT_TEXTAREA) && reportDefType
- .equals(AppConstants.RD_SQL_BASED);
-
- paramIsMultiValue.put(ff.getFieldName(), new Boolean(isMultiValue));
- paramIsTextAreaValue.put(ff.getFieldName(), new Boolean(isTextAreaValue));
-
- if ((isMultiValue || isTextAreaValue) && ff.getBaseSQL() != null)
- multiValueBaseSQL.put(ff.getFieldName(), ff.getBaseSQL());
-
-
- } // for
- } // ReportParamValues
-
- /*
- * public ReportParamValues(ReportFormFields rff, HttpServletRequest
- * request) { this(rff);
- *
- * setParamValues(request); } // ReportParamValues
- */
- public boolean isParameterMultiValue(String fieldName) {
- Boolean b = (Boolean) paramIsMultiValue.get(fieldName);
- return (b != null) ? b.booleanValue() : false;
- } // isParameterMultiValue
-
- public boolean isParameterTextAreaValue(String fieldName) {
- Boolean b = (Boolean) paramIsTextAreaValue.get(fieldName);
- return (b != null) ? b.booleanValue() : false;
- } // isParameterMultiValue
-
- public boolean isParameterTextAreaValueAndModified(String fieldName) {
- Boolean b = (Boolean) paramIsTextAreaValueModified.get(fieldName);
- return (b != null) ? b.booleanValue() : false;
- } // isParameterMultiValue
-
- public boolean setParamValues(HttpServletRequest request, boolean refresh) {
- long currentTime = System.currentTimeMillis();
- //System.out.println("ReportParamValues setParamValues called " + refresh);
- boolean paramUpdated = false;
- if(refresh) clearValues();
- for (Enumeration enKeys = keys(); enKeys.hasMoreElements();) {
- String key = (String) enKeys.nextElement();
- String oldValue = XSSFilter.filterRequestOnlyScript(getParamValue(key));
- String newValue = null;
- if (isParameterMultiValue(key)) {
- String[] values = request.getParameterValues(key);
-
- if (values != null) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < values.length; i++) {
- if (sb.length() > 0)
- sb.append('|');
- sb.append(values[i]);
- } // for
-
- newValue = XSSFilter.filterRequestOnlyScript(sb.toString());
- } // if
- } else if (isParameterTextAreaValue(key)) {
-/* String[] values = request.getParameterValues(key);
-
- if (values != null) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < values.length; i++) {
- if (sb.length() > 0)
- sb.append('|');
- sb.append(values[i]);
- } // for
-*/
- String value = "";
- value = request.getParameter(key);
- value = Utils.oracleSafe(nvl(value));
- paramIsTextAreaDrilldownValue.put(key, value);
- value = value.replaceAll(",", "|");
- value = "('" + Utils.replaceInString(value, "|", "','") + "')";
- //value = Utils.replaceInString(value, "|", ",");
- newValue = XSSFilter.filterRequestOnlyScript(value);
- paramIsTextAreaValueModified.put(key, new Boolean(true));
- //} // if
-
- } else
- // newValue = nvl(request.getParameter(key));
- newValue = XSSFilter.filterRequestOnlyScript(request.getParameter(key));
- //debugLogger.debug("IN REPORTPARAM ^NEW VALUE " + newValue + " OLD VALUE " + oldValue + " KEY " + key + " isParameterMultiValue(key) " + isParameterMultiValue(key));
- if(!isParameterMultiValue(key) && !isParameterTextAreaValue(key)) {
- if(refresh && nvl(newValue).length()<=0) {
- put(key, oldValue);
- } else if ( ((newValue != null && newValue.trim().length()>0) && (oldValue!=null && oldValue.trim().length()>0) && !newValue.equals(oldValue)) ||
- ((newValue != null && newValue.trim().length()>0) && (oldValue == null || oldValue.trim().length() <= 0)) ) {
- paramUpdated = true;
- //System.out.println("paramupdated1 " +paramUpdated+ " " + newValue + " " + oldValue);
- // if(newValue.startsWith("[") && newValue.endsWith("]")) {
- // newValue = getDateAsString(newValue);
- // }
- put(key, newValue);
- } else if (((newValue == null || newValue.trim().length()<=0)) && (oldValue!=null && oldValue.trim().length()>0)) {
- paramUpdated = true;
- put(key, newValue);
- } else if (nvl(newValue).equals(nvl(oldValue)) ) {
- put(key, newValue);
- } else {
- put(key, "");
- }
- } else {
- if (((newValue != null && newValue.trim().length()>0) && (oldValue!=null && oldValue.trim().length()>0) && !newValue.equals(oldValue)) ||
- ((newValue != null && newValue.trim().length()>0) && (oldValue == null || oldValue.trim().length() <= 0)) && (isParameterMultiValue(key)||isParameterTextAreaValue(key))) {
- if(isParameterTextAreaValue(key)) {
- newValue = getParamValueforTextAreaDrilldown(key);
- if(newValue.length() > 0 && !newValue.equals(oldValue)) {
- paramUpdated = true;
- put (key, newValue);
- }
- } else {
- paramUpdated = true;
- put (key, newValue);
- }
-
- } else if (((newValue == null || newValue.trim().length()<=0)) && (oldValue!=null && oldValue.trim().length()>0) && (isParameterMultiValue(key)||isParameterTextAreaValue(key))) {
- paramUpdated = true;
- //System.out.println("paramupdated3 " +paramUpdated+ " N" + newValue + " O" + oldValue);
- put(key, "");
- }
- }
- } // for
- //printValues();
- logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] ------->Time Taken for Adding/Clearing Param Values for Search Field Display " + (System.currentTimeMillis() - currentTime)));
- return paramUpdated;
- } // setParamValues
-
- public String getParamValueforTextAreaDrilldown(String key) {
- return (String) paramIsTextAreaDrilldownValue.get(key);
- }
-
- public String getParamValue(String key) {
- //This logic below is added to avoid BLANK formfield to pass through logic - Sundar
- if (key!=null) {
- if(isParameterTextAreaValueAndModified(key)) {
- String value = "";
- value = (String) get(key);
- value = Utils.oracleSafe(nvl(value));
- value = value.replaceAll(",","|");
- if(nvl(value).length()>0) {
- if(value.indexOf("|")!= -1) { // Need option to support "|"
- value = Utils.replaceInString(value,"\r\n","~");
- }
- value = Utils.replaceInString(value, "~", "' , '");
- value = "('" + Utils.replaceInString(value, "|", "','") + "')"; // changed from "|"
- //value = Utils.replaceInString(value, "|", ",");
- value = XSSFilter.filterRequestOnlyScript(value);
- return value;
- } else return "";
-
-// if(nvl(value).length()>0) {
-// value = Utils.replaceInString(value, ",", "|");
-// value = value.indexOf("('")!=-1? value.substring(2, value.length()-2):value;
-// value = Utils.replaceInString(value, "'|'", ",");
-// }
-// return value;
-
- } else
- return (String) get(key);
- }
- else
- return "";
- } // getParamValue
-
- public String getParamDisplayValue(String key) {
- String value = getParamValue(key);
- if (isParameterMultiValue(key))
- value = "(" + Utils.replaceInString(value, "|", ",") + ")";
- return value;
- } // getParamValue
-
- public String getParamBaseSQL(String key) {
- return (String) multiValueBaseSQL.get(key);
- } // getParamBaseSQL
-
- /** ************************************************************************************************* */
-
- private String nvl(String s) {
- return (s == null) ? "" : s;
- }
-
- private String nvl(String s, String sDefault) {
- return nvl(s).equals("") ? sDefault : s;
- }
-
- private boolean isNull(String a) {
- if ((a == null) || (a.length() == 0) || a.equalsIgnoreCase("null"))
- return true;
- else
- return false;
- }
-
- private void clearValues() {
- FormField ff = null;
- String defaultValue = "";
- String defaultSQL = "";
- String defaultQuery = "";
- DataSet dsDefault = null;
- if (rff!= null) {
- for (Enumeration enKeys = keys(); enKeys.hasMoreElements();) {
- String key = (String) enKeys.nextElement();
- for(rff.resetNext(); rff.hasNext(); ) {
- ff = rff.getNext();
- if(ff.getFieldName().equals(key)) {
- // Add default Value
- defaultValue = ff.getDefaultValue();
- defaultSQL = ff.getFieldDefaultSQL();
- if(nvl(defaultValue).length()>0) {
- put(key,ff.getDefaultValue());
- } else if(nvl(defaultSQL).length() > 0) {
- //defaultSQL = Utils.replaceInString(defaultSQL, "[LOGGED_USERID]", userId);
- if(!(isParameterMultiValue(key) || isParameterTextAreaValue(key))) {
- defaultQuery = "SELECT id, name FROM (SELECT rownum r, id, name FROM (" + defaultSQL
- + ") x "
- + ") xx ";
- try {
- dsDefault = ConnectionUtils.getDataSet(defaultQuery, ff.getDbInfo());
- if(dsDefault!=null && dsDefault.getRowCount()>0) {
- for (int i = 0; i < dsDefault.getRowCount(); i++) {
- put(key, dsDefault.getString(i, 0));
- }
- }
- } catch (RaptorException ex) {}
- } else put(key, "");
-
- } else put(key,"");
- break;
- }
- }
- }
- }
-
-/* for (Enumeration enKeys = keys(); enKeys.hasMoreElements();) {
- String key = (String) enKeys.nextElement();
- put(key,"");
- }
-*/
- }
-
-
- public void printValues() {
- for (Enumeration enKeys = keys(); enKeys.hasMoreElements();) {
- String key = (String) enKeys.nextElement();
- String value = (String) get(key);
- System.out.println("ReportParamValues " + key + " "+ value);
- }
- }
-
- private String getDateAsString (String keyword) {
- String sql = "";
- if (keyword.equals("[PROCESSING_DATE]")) {
- //sql = "select to_char(trunc(sysdate,'dd'), 'mm/dd/yyyy') as dateStr from dual";
- sql = "select to_char(trunc(sysdate,'dd'), 'mm/dd/yyyy') as dateStr" + Globals.getGenerateSqlVisualDual();
- } else if (keyword.equals("[PROCESSING_NEXT_DATE]")) {
- //sql = "select to_char(trunc(sysdate+1,'dd'), 'mm/dd/yyyy') as dateStr from dual";
- sql = "select to_char(trunc(sysdate+1,'dd'), 'mm/dd/yyyy') as dateStr" + Globals.getGenerateSqlVisualDual();
- } else if (keyword.equals("[PROCESSING_DAY_BEFORE_DATE]")) {
- //sql = "select to_char(trunc(sysdate-1,'dd'), 'mm/dd/yyyy') as dateStr from dual";
- sql = "select to_char(trunc(sysdate-1,'dd'), 'mm/dd/yyyy') as dateStr"+ Globals.getGenerateSqlVisualDual();
- } else if (keyword.equals("[PROCESSING_MONTH_START_DATE]")) {
- //sql = "select to_char(trunc(sysdate,'MM'), 'mm/dd/yyyy') as dateStr from dual";
- sql = "select to_char(trunc(sysdate,'MM'), 'mm/dd/yyyy') as dateStr"+ Globals.getGenerateSqlVisualDual();
- } else if (keyword.equals("[PROCESSING_MONTH_END_DATE]")) {
- //sql = "select to_char(last_day(sysdate), 'mm/dd/yyyy') as dateStr from dual";
- sql = "select to_char(last_day(sysdate), 'mm/dd/yyyy') as dateStr" + Globals.getGenerateSqlVisualDual();
- } else if (keyword.equals("[CURRENT_HOUR]")) {
- //sql = "select to_char(trunc(sysdate,'HH24'),'mm/dd/yyyy HH24') as dateStr from dual";
- sql = "select to_char(trunc(sysdate,'HH24'),'mm/dd/yyyy HH24') as dateStr"+ Globals.getGenerateSqlVisualDual();
- } else if (keyword.equals("[PREVIOUS_HOUR]")) {
- //sql = "select to_char(trunc(sysdate-1/24, 'HH24'),'mm/dd/yyyy HH24') as dateStr from dual";
- sql = "select to_char(trunc(sysdate-1/24, 'HH24'),'mm/dd/yyyy HH24') as dateStr" + Globals.getGenerateSqlVisualDual();
- } else if (keyword.equals("[NEXT_HOUR]")) {
- //sql = "select to_char(trunc(sysdate+1/24, 'HH24'),'mm/dd/yyyy HH24') as dateStr from dual";
- sql = "select to_char(trunc(sysdate+1/24, 'HH24'),'mm/dd/yyyy HH24') as dateStr" + Globals.getGenerateSqlVisualDual();
- }
- DataSet ds = null;
-
- try {
- if(sql.length()>0) {
- ds = DbUtils.executeQuery(sql);
- return ds.getString(0,0);
- }
- else
- return "";
- } catch (RaptorException ex) {
- ex.printStackTrace();
- //throw ex;
- }
- return "";
- }
-} // ReportParamValues
-
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcel.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcel.java
deleted file mode 100644
index f4bb9800..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcel.java
+++ /dev/null
@@ -1,419 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.openecomp.portalsdk.analytics.error.RaptorException;
-import org.openecomp.portalsdk.analytics.error.ReportSQLException;
-import org.openecomp.portalsdk.analytics.system.AppUtils;
-import org.openecomp.portalsdk.analytics.system.ConnectionUtils;
-import org.openecomp.portalsdk.analytics.system.Globals;
-import org.openecomp.portalsdk.analytics.util.AppConstants;
-import org.openecomp.portalsdk.analytics.util.DataSet;
-import org.openecomp.portalsdk.analytics.util.Utils;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-
-public class ReportParamValuesForPDFExcel extends Hashtable {
-
- EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportParamValuesForPDFExcel.class);
-
- private Hashtable paramIsMultiValue = null;
- private Hashtable paramIsTextAreaValue = null;
- private ReportFormFields rff = null;
-
- private Hashtable multiValueBaseSQL = null;
-
- public ReportParamValuesForPDFExcel() {
- super();
- paramIsMultiValue = new Hashtable();
- paramIsTextAreaValue = new Hashtable();
- multiValueBaseSQL = new Hashtable();
- } // ReportParamValues
-
- public ReportParamValuesForPDFExcel(ReportFormFields rff, String reportDefType) {
- this();
- this.rff = rff;
- for (Iterator iter = rff.iterator(); iter.hasNext();) {
- FormField ff = (FormField) iter.next();
-
- put(ff.getFieldName(), nvl(ff.getDefaultValue()));
-
- boolean isMultiValue = ff.getFieldType().equals(FormField.FFT_CHECK_BOX)
- || ff.getFieldType().equals(FormField.FFT_LIST_MULTI);
- boolean isTextAreaValue = ff.getFieldType().equals(FormField.FFT_TEXTAREA) && reportDefType
- .equals(AppConstants.RD_SQL_BASED);
- paramIsMultiValue.put(ff.getFieldName(), new Boolean(isMultiValue));
- paramIsTextAreaValue.put(ff.getFieldName(), new Boolean(isTextAreaValue));
- if (isMultiValue && ff.getBaseSQL() != null)
- multiValueBaseSQL.put(ff.getFieldName(), ff.getBaseSQL());
- } // for
- } // ReportParamValues
-
- /*
- * public ReportParamValues(ReportFormFields rff, HttpServletRequest
- * request) { this(rff);
- *
- * setParamValues(request); } // ReportParamValues
- */
- public boolean isParameterMultiValue(String fieldName) {
- Boolean b = (Boolean) paramIsMultiValue.get(fieldName);
- return (b != null) ? b.booleanValue() : false;
- } // isParameterMultiValue
-
- public boolean isParameterTextAreaValue(String fieldName) {
- Boolean b = (Boolean) paramIsTextAreaValue.get(fieldName);
- return (b != null) ? b.booleanValue() : false;
- } // isParameterMultiValue
-
- public boolean setParamValues(HttpServletRequest request, boolean refresh) {
- //debugLogger.debug("ReportParamValues for PDF Excel setParamValues called " + refresh);
- long currentTime = System.currentTimeMillis();
- boolean paramUpdated = false;
- if(refresh) clearValues();
- String name = null;
- String value = null;
- String value1 = "";
- String sql = "";
- FormField ff = null;
- String dbInfo = null;
- ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
- if(rr!=null && rr.getReportType().equals(AppConstants.RT_DASHBOARD)) {
- rr = (ReportRuntime) request.getSession().getAttribute("FirstDashReport");
- if(rr!=null)
- rff = rr.getReportFormFields();
- } else if (rr == null) {
- rr = (ReportRuntime) request.getSession().getAttribute("FirstDashReport");
- if(rr!=null)
- rff = rr.getReportFormFields();
- } else {
- rff = rr.getReportFormFields();
- }
-
- if(rr!=null) {
- dbInfo = rr.getDBInfo();
- if (Utils.isNull(dbInfo)) {
- dbInfo = (String) request.getSession().getAttribute("remoteDB");
- }
- if(!Utils.isNull(dbInfo)){
- for (Iterator iter = rff.iterator(); iter.hasNext();) {
- name=""; //just added
- ff = (FormField) iter.next();
- //debugLogger.debug("ff.getFieldName " + ff.getFieldName() + " " + ff.getFieldDisplayName() + " " + ff.getFieldType()+ " " +ff.getBaseSQLForPDFExcel()+ " "+ rr.getParamValue(ff.getFieldName()));
- if(!ff.getFieldType().equals(FormField.FFT_BLANK)) {
- sql = ff.getBaseSQLForPDFExcel();
- if(sql!=null && sql.trim().length()>0)
- sql = Utils.replaceInString(sql, "[LOGGED_USERID]", AppUtils.getUserID(request));
- if(ff.getFieldType().equals(FormField.FFT_COMBO_BOX) || ff.getFieldType().equals(FormField.FFT_LIST_BOX) || ff.getFieldType().equals(FormField.FFT_TEXT_W_POPUP) || ff.getFieldType().equals(FormField.FFT_HIDDEN)) {
- for (Enumeration enum1 = rr.getParamKeys(); enum1.hasMoreElements();) {
- name = (String) enum1.nextElement();
- value = rr.getParamValue(name);
- value = getParamValueForSQL(name, value);
- if(name.startsWith("ff")) {
- for (Iterator iter1 = rff.iterator(); iter1.hasNext();) {
- FormField ff1 = (FormField) iter1.next();
-
- if(sql!=null && sql.trim().length()>0){
- if(name.equals(ff.getFieldName())){
- sql = Utils.replaceInString(sql, "[VALUE]", value);
- }
- if(name.equals(ff1.getFieldName())){
- sql = Utils.replaceInString(sql, "["+ff1.getFieldDisplayName()+"]", value);
-
- } else continue;
- }
- }
- }
- }
- } else if (ff.getFieldType().equals(ff.FFT_LIST_MULTI)||ff.getFieldType().equals(ff.FFT_CHECK_BOX)) {
- for (Enumeration enum1 = rr.getParamKeys(); enum1.hasMoreElements();) {
- name = (String) enum1.nextElement();
- value = rr.getParamValue(name);
- value = getParamValueForSQL(name, value);
- if(name.startsWith("ff")) {
- for (Iterator iter1 = rff.iterator(); iter1.hasNext();) {
- FormField ff1 = (FormField) iter1.next();
-
- if(sql!=null && sql.trim().length()>0){
- if(name.equals(ff.getFieldName())){
- sql = Utils.replaceInString(sql, "[VALUE]", value);
- }
- if(name.equals(ff1.getFieldName())){
- sql = Utils.replaceInString(sql, "["+ff1.getFieldDisplayName()+"]", value);
-
- } else continue;
- }
- }
- }
- }
- } else {
- if(nvl(ff.getFieldDefaultSQL()).length()<=0)
- sql = "";
- }
- if(sql!=null && sql.trim().length()>0){
- name = "";
- if(name.length()<=0) name = ff.getFieldName();
- value = rr.getParamValue(name);
- //debugLogger.debug("Name "+ name+ " value:" + value);
- String paramValue = getParamValueForSQL(name, value);
- //debugLogger.debug("PDFEXCEL " + name+ " " + ff.getFieldName()+ " " + value + " " + sql +" "+ paramValue);
- if(name!=null && name.equals(ff.getFieldName()))
- sql = Utils.replaceInString(sql, "[VALUE]", paramValue);
- if(paramValue == null) {
- if(sql.lastIndexOf("where id = ''")>0)
- sql = sql.substring(0, sql.lastIndexOf("where id = ''"));
- }
- //debugLogger.debug("SQL Modified " + sql);
- FormField ff2 = null;
- for (Iterator iter1 = rff.iterator(); iter1.hasNext();) {
- ff2 = (FormField)iter1.next();
- sql = Utils.replaceInString(sql, "[" + ff2.getFieldDisplayName() +"]", getParamValue(ff2.getFieldName()));
- }
- //debugLogger.debug("SQL Modified after replacing formfield" + sql);
- try {
- String[] reqParameters = Globals.getRequestParams().split(",");
- String[] sessionParameters = Globals.getSessionParams().split(",");
- String[] scheduleSessionParameters = Globals.getSessionParamsForScheduling().split(",");
- javax.servlet.http.HttpSession session = request.getSession();
- //debugLogger.debug("B4 Session " + sql);
- if(session != null ) {
- for (int i = 0; i < sessionParameters.length; i++) {
- sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) );
- }
- }
- //debugLogger.debug("B4 request " + sql);
- if(request != null ) {
- for (int i = 0; i < scheduleSessionParameters.length; i++) {
- sql = Utils.replaceInString(sql, "[" + scheduleSessionParameters[i].toUpperCase()+"]", request.getParameter(scheduleSessionParameters[i]) );
- }
- for (int i = 0; i < reqParameters.length; i++) {
- if(!reqParameters[i].startsWith("ff")) {
- if (request.getParameter(reqParameters[i])!=null) {
- sql = Utils.replaceInString(sql, "[" + reqParameters[i]+"]", request.getParameter(reqParameters[i]) );
- sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase()+"]", request.getParameter(reqParameters[i]) );
- }
- else {
- sql = Utils.replaceInString(sql, "[" + reqParameters[i]+"]", request.getParameter(reqParameters[i].toUpperCase()) );
- sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase()+"]", request.getParameter(reqParameters[i].toUpperCase()) );
- }
- }
- else
- sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase()+"]", request.getParameter(reqParameters[i]) );
- }
- }
- //debugLogger.debug("After request " + sql);
- DataSet ds = null;
- try {
- ds = ConnectionUtils.getDataSet(sql, dbInfo);
- } catch (ReportSQLException ex) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("sql not complete" + sql));
- }
- if(ff.getFieldType().equals(FormField.FFT_LIST_MULTI) || ff.getFieldType().equals(FormField.FFT_CHECK_BOX)) {
- StringBuffer multiValue = new StringBuffer("");
- if(ds!=null) {
- for(int i = 0; i < ds.getRowCount(); i++) {
- //if(i==0) multiValue.append("(");
- multiValue.append(ds.getString(i,1));
- if(i<ds.getRowCount()-1)
- multiValue.append("|");
- //else multiValue.append(")");
-
- }
- }
- put(ff.getFieldName(), nvl(multiValue.toString()));
- } else {
- if(ff.getValidationType().equals(FormField.VT_TIMESTAMP_HR) || ff.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || ff.getValidationType().equals(FormField.VT_TIMESTAMP_SEC) ) {
- value1 = nvl(rr.getParamValue(ff.getFieldName())) + " "+addZero(Utils.oracleSafe(nvl(rr
- .getParamValue(ff.getFieldName()+"_Hr"))));
- if(ff.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || ff.getValidationType().equals(FormField.VT_TIMESTAMP_SEC) ) {
- value1 = value1 + (nvl(rr
- .getParamValue(ff.getFieldName()+"_Min")).length() > 0 ? ":" + addZero(Utils.oracleSafe(nvl(rr
- .getParamValue(ff.getFieldName()+"_Min")))) : "");
- }
- if(ff.getValidationType().equals(FormField.VT_TIMESTAMP_SEC) ) {
- value1 = value1 + (nvl(rr
- .getParamValue(ff.getFieldName()+"_Sec")).length() > 0 ? ":"+ addZero(Utils.oracleSafe(nvl(rr
- .getParamValue(ff.getFieldName()+"_Sec")))) : "");
- }
- //debugLogger.debug("77777777777777 " + value1);
- put(ff.getFieldName(), nvl(value1));
- } else {
-
- if(ds!=null && ds.getRowCount()>0) put(ff.getFieldName(), nvl(ds.getString(0,1)));
- else put(ff.getFieldName(), nvl(value));
- }
- }
-
- paramUpdated = true;
- } catch (ReportSQLException ex) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("sql not complete" + sql));
- }
- catch (Exception ex) {}
-
- //debugLogger.debug("66666666666666666 " + ff.getValidationType());
-
- //Added for TimeStamp validation
-
- } else {
- if(!ff.getFieldType().equals(FormField.FFT_BLANK)) {
- //Added for TimeStamp validation
- //debugLogger.debug("666666666666 " + ff.getValidationType());
- if(ff.getValidationType().equals(FormField.VT_TIMESTAMP_HR) || ff.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || ff.getValidationType().equals(FormField.VT_TIMESTAMP_SEC) ) {
- value1 = nvl(rr.getParamValue(ff.getFieldName())) + " "+addZero(Utils.oracleSafe(nvl(rr
- .getParamValue(ff.getFieldName()+"_Hr"))));
- if(ff.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || ff.getValidationType().equals(FormField.VT_TIMESTAMP_SEC) ) {
- value1 = value1 + (nvl(rr
- .getParamValue(ff.getFieldName()+"_Min")).length() > 0 ? ":" + addZero(Utils.oracleSafe(nvl(rr
- .getParamValue(ff.getFieldName()+"_Min")))) : "");
- }
- if(ff.getValidationType().equals(FormField.VT_TIMESTAMP_SEC) ) {
- value1 = value1 + (nvl(rr
- .getParamValue(ff.getFieldName()+"_Sec")).length() > 0 ? ":"+ addZero(Utils.oracleSafe(nvl(rr
- .getParamValue(ff.getFieldName()+"_Sec")))) : "");
- }
- //debugLogger.debug("77777777777777 " + value1);
- } else
- value1 = nvl(rr.getParamValue(ff.getFieldName()));
- if(value1.length()<=0) value1 = nvl(ff.getDefaultValue());
- put(ff.getFieldName(), nvl(value1));
-
- }
- paramUpdated = true;
- }
-
- } // BLANK
- } // for
- } // dbInfo
- } // !=null
-
- //printValues();
- logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] ------->Time Taken for Adding/Clearing Param Values for FormField Info Bar " + (System.currentTimeMillis() - currentTime)));
- return paramUpdated;
- } // setParamValues
-
- public String getParamValue(String key) {
- if (key!=null)
- return (String) get(key);
- else
- return "NULL";
- } // getParamValue
-
- public String getParamValueForSQL(String key, String value) {
- value = Utils.oracleSafe(value);
- if (isParameterMultiValue(key))
- value = "('" + Utils.replaceInString(value, "|", "','") + "')";
- return value;
- } // getParamValue
-
- public String getParamDisplayValue(String key) {
- //debugLogger.debug("Key is " + key +" Value is " + getParamValue(key));
- String value = getParamValue(key);
- if (isParameterMultiValue(key))
- value = "(" + Utils.replaceInString(value, "|", ",") + ")";
- return value;
- } // getParamValue
-
- public String getParamBaseSQL(String key) {
- return (String) multiValueBaseSQL.get(key);
- } // getParamBaseSQL
-
- /** ************************************************************************************************* */
-
- private String nvl(String s) {
- return (s == null) ? "" : s;
- }
-
- private String nvl(String s, String sDefault) {
- return nvl(s).equals("") ? sDefault : s;
- }
-
- private boolean isNull(String a) {
- if ((a == null) || (a.length() == 0) || a.equalsIgnoreCase("null"))
- return true;
- else
- return false;
- }
-
- private void clearValues() {
- FormField ff = null;
- String defaultValue = "";
- String defaultSQL = "";
- String defaultQuery = "";
- DataSet dsDefault = null;
- if (rff!= null) {
- for (Enumeration enKeys = keys(); enKeys.hasMoreElements();) {
- String key = (String) enKeys.nextElement();
- for(rff.resetNext(); rff.hasNext(); ) {
- ff = rff.getNext();
- if(ff.getFieldName().equals(key)) {
- // Add default Value
- defaultValue = ff.getDefaultValue();
- defaultSQL = ff.getFieldDefaultSQL();
- if(nvl(defaultValue).length()>0) {
- put(key,ff.getDefaultValue());
- } else if(nvl(defaultSQL).length() > 0) {
- //defaultSQL = Utils.replaceInString(defaultSQL, "[LOGGED_USERID]", userId);
- if(!(isParameterMultiValue(key) || isParameterTextAreaValue(key))) {
- defaultQuery = "SELECT id, name FROM (SELECT rownum r, id, name FROM (" + defaultSQL
- + ") x "
- + ") xx ";
- try {
- dsDefault = ConnectionUtils.getDataSet(defaultQuery, ff.getDbInfo());
- if(dsDefault!=null && dsDefault.getRowCount()>0) {
- for (int i = 0; i < dsDefault.getRowCount(); i++) {
- put(key, dsDefault.getString(i, 1));
- }
- }
- } catch (RaptorException ex) {}
- } else put(key, "");
-
- } else put(key,"");
- break;
- }
- }
- }
- }
-
- }
-
- public void printValues() {
- for (Enumeration enKeys = keys(); enKeys.hasMoreElements();) {
- String key = (String) enKeys.nextElement();
- String value = (String) get(key);
- logger.debug(EELFLoggerDelegate.debugLogger, ("ReportParamValuesForPDFEXCEL " + key + " "+ value));
- }
- }
- public String addZero(String num) {
- int numInt = 0;
- try {
- numInt = Integer.parseInt(num);
- }catch(NumberFormatException ex){
- numInt = 0;
- }
- if(numInt < 10) return "0"+numInt;
- else return ""+numInt;
- }
-
-} // ReportParamValues
-
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportRuntime.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportRuntime.java
deleted file mode 100644
index fd8fadcb..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportRuntime.java
+++ /dev/null
@@ -1,3618 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.Vector;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.openecomp.portalsdk.analytics.error.RaptorException;
-import org.openecomp.portalsdk.analytics.model.DataCache;
-import org.openecomp.portalsdk.analytics.model.ReportHandler;
-import org.openecomp.portalsdk.analytics.model.ReportLoader;
-import org.openecomp.portalsdk.analytics.model.base.IdNameList;
-import org.openecomp.portalsdk.analytics.model.base.IdNameSql;
-import org.openecomp.portalsdk.analytics.model.base.IdNameValue;
-import org.openecomp.portalsdk.analytics.model.base.ReportWrapper;
-import org.openecomp.portalsdk.analytics.model.definition.Marker;
-import org.openecomp.portalsdk.analytics.system.AppUtils;
-import org.openecomp.portalsdk.analytics.system.ConnectionUtils;
-import org.openecomp.portalsdk.analytics.system.DbUtils;
-import org.openecomp.portalsdk.analytics.system.Globals;
-import org.openecomp.portalsdk.analytics.util.AppConstants;
-import org.openecomp.portalsdk.analytics.util.DataSet;
-import org.openecomp.portalsdk.analytics.util.Utils;
-import org.openecomp.portalsdk.analytics.view.ColumnHeader;
-import org.openecomp.portalsdk.analytics.view.ColumnHeaderRow;
-import org.openecomp.portalsdk.analytics.view.CrossTabOrderManager;
-import org.openecomp.portalsdk.analytics.view.CrossTabTotalValue;
-import org.openecomp.portalsdk.analytics.view.DataRow;
-import org.openecomp.portalsdk.analytics.view.DataValue;
-import org.openecomp.portalsdk.analytics.view.ReportData;
-import org.openecomp.portalsdk.analytics.view.RowHeaderCol;
-import org.openecomp.portalsdk.analytics.xmlobj.CustomReportType;
-import org.openecomp.portalsdk.analytics.xmlobj.DataColumnType;
-import org.openecomp.portalsdk.analytics.xmlobj.FormFieldType;
-import org.openecomp.portalsdk.analytics.xmlobj.ObjectFactory;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-
-/**<HR/>
- * This class is part of <B><I>RAPTOR (Rapid Application Programming Tool for OLAP Reporting)</I></B><BR/>
- * <HR/>
- *
- * --------------------------------------------------------------------------------------------------<BR/>
- * <B>ReportRuntime.java</B> - This class involves in running, downloading RAPTOR reports.
- * --------------------------------------------------------------------------------------------------<BR/>
- *
- *
- * <U>Change Log</U><BR/><BR/>
- *
- * 27-Aug-2009 : Version 8.5 (Sundar); <UL><LI>Order by logic is restored for DAYTONA.</LI></UL>
- * 13-Aug-2009 : Version 8.5 (Sundar); <UL><LI>Removing order by logic is rollbacked.</LI></UL>
- * 22-Jun-2009 : Version 8.4 (Sundar); <UL><LI>Bug while parsing SQL for text download is fixed.</LI></UL>
- *
- */
-
-public class ReportRuntime extends ReportWrapper implements Cloneable, Serializable {
-
- static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportRuntime.class);
-
-
- //TODO DELETE IF PARSE SQL is not working
- private int curSQLParsePos = 0;
-
- private String xmlFileURL = null;
-
- private String xmlFileName = null;
-
- private String flatFileName = null;
-
- private String excelPageFileName = null;
-
- private int reportDataSize = -1;
-
- private boolean displayChart = true;
-
- private boolean displayForm = true;
-
- private boolean displayContent = true;
-
- private boolean reportRunLogged = false; // Used to avoid multiple
- // entries in the report log
- // when executing with different
- // params or going to next page
-
- private DataSet chartDataCache = null;
-
- private ReportData pageDataCache = null;
-
- private int cachedPageNo = -1;
-
- private String cachedSQL = null; // For display purposes only
-
- private String wholeSQL = null; // For display purposes only
-
- private String totalSql = null; // For display purposes only
-
- private ReportParamValues reportParamValues = null;
-
- private ReportParamValuesForPDFExcel reportParamValuesFPE = null;
-
- private ReportFormFields reportFormFields = null;
-
- private VisualManager visualManager = null;
-
- private CrossTabOrderManager crossTabOrderManager = null;
-
- private boolean displayColTotals = false;
-
- private boolean displayRowTotals = false;
-
- private DataRow colDataTotalsLinear = null;
-
- private Vector colDataTotalsCrosstab = null;
-
- private Vector rowDataTotalsCrosstab = null;
-
- private String grandTotalCrosstab = null;
-
- public static int DISPLAY_DATA_ONLY = 1;
- public static int DISPLAY_CHART_ONLY = 2;
- public static int DISPLAY_CHART_AND_DATA = 3;
-
- public static final int DATE_OPTION_MONTHLY = 1;
- public static final int DATE_OPTION_YEARLY = 2;
- public static final int DATE_OPTION_DAILY = 3;
-
-
- private int DISPLAY_MODE = 0;
-
- private int DATE_OPTION = -1;
-
- /*
- * private ReportRuntime(CustomReport cr, String reportID,
- * HttpServletRequest request) { super(cr, reportID);
- *
- * reportParamValues = new ReportParamValues(this); reportFormFields = new
- * ReportFormFields(this);
- *
- * if(request!=null) setParamValues(request); } // ReportRuntime
- */
- private ReportRuntime(CustomReportType crType, String reportID, HttpServletRequest request,
- String ownerID, String createID, String createDate, String updateID,
- String updateDate, String menuID, boolean menuApproved) throws RaptorException {
- super(crType, reportID, ownerID, createID, createDate, updateID, updateDate, menuID,
- menuApproved);
- initializeReportRuntime(request);
- } // ReportRuntime
-
- public ReportRuntime(ReportWrapper rw) throws RaptorException {
- this(rw, null);
- } // ReportRuntime
-
- public ReportRuntime(ReportWrapper rw, HttpServletRequest request)throws RaptorException {
- super(rw);
- initializeReportRuntime(request);
- } // ReportRuntime
-
- private void initializeReportRuntime(HttpServletRequest request) throws RaptorException {
- reportFormFields = new ReportFormFields(this, request);
- setParamValues(request, true, true);
-
- visualManager = new VisualManager();
- } // initializeReportRuntime
-
-// public void setReportFormFields(HttpServletRequest request) {
-// reportFormFields = new ReportFormFields(this, request);
-// setParamValues(request, true, true);
-// }
-
- public static ReportRuntime unmarshal(String reportXML, String reportID)
- throws RaptorException {
- return unmarshal(reportXML, reportID, null);
- } // unmarshal
-
- public static ReportRuntime unmarshal(String reportXML, String reportID,
- HttpServletRequest request) throws RaptorException {
- CustomReportType crType = ReportWrapper.unmarshalCR(reportXML);
- ObjectFactory objFactory = new ObjectFactory();
-
- logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] Report [" + reportID + "]: XML unmarshalled"));
-
- return new ReportRuntime(crType, reportID, request, null, null, null, null, null, null,
- false);
-
- } // unmarshal
-
- public String getXmlFileURL() {
- return xmlFileURL;
- }
-
- public String getXmlFileName() {
- return xmlFileName;
- }
-
- public String getFlatFileName() {
- return flatFileName;
- }
-
- public String getExcelPageFileName() {
- return excelPageFileName;
- }
-
- public int getReportDataSize() {
- return reportDataSize;
- }
-
- public boolean getDisplayChart() {
- return displayChart;
- }
-
- public boolean getDisplayForm() {
- return displayForm;
- }
-
- public boolean getDisplayContent() {
- return displayContent;
- }
-
- public int getCachedPageNo() {
- return cachedPageNo;
- }
-
- public String getCachedSQL() {
- return cachedSQL;
- }
-
- public boolean isDashboardType() throws RaptorException {
- return ReportLoader.isDashboardType(getReportID());
- }
-
-
- public void setXmlFileURL(String xmlFileURL) {
- this.xmlFileURL = xmlFileURL;
- }
-
- public void setXmlFileName(String xmlFileName) {
- this.xmlFileName = xmlFileName;
- }
-
- public void setFlatFileName(String flatFileName) {
- this.flatFileName = flatFileName;
- }
-
- public void setExcelPageFileName(String excelPageFileName) {
- this.excelPageFileName = excelPageFileName;
- }
-
- /*private*/ public void setReportDataSize(int reportDataSize) {
- this.reportDataSize = reportDataSize;
- }
-
- private void setDisplayForm(boolean displayForm) {
- this.displayForm = displayForm;
- }
-
- private void setDisplayContent(boolean displayContent) {
- this.displayContent = displayContent;
- }
-
- public void setDisplayFlags(boolean isFirstAccess, boolean forceDisplayContent) {
- if (isFirstAccess) {
- setDisplayForm(true);
-
- if (forceDisplayContent)
- setDisplayContent(true);
- else if (Globals.getDisplayFormBeforeRun())
- if (needFormInput())
- setDisplayContent(false);
- else
- setDisplayContent(true);
- else
- setDisplayContent(true);
- } else {
- setDisplayContent(true);
-
- if (Globals.getIncludeFormWithData())
- setDisplayForm(true);
- else if (Globals.getDisplayFormBeforeRun())
- setDisplayForm(false);
- else
- setDisplayForm(true);
- } // else
- } // setDisplayFlags
-
- public void logReportRun(String userID, String executionTime, String formFields) throws RaptorException {
- if (reportRunLogged)
- return;
-
- ReportLoader.createReportLogEntry(null, reportID, userID, AppConstants.RLA_RUN,executionTime,formFields );
- reportRunLogged = true;
- } // logReportRun
-
- public void logReportExecutionTime(String userId, String executionTime, String action, String formFields) throws RaptorException {
- ReportLoader.createReportLogEntryForExecutionTime(null, reportID, userId,executionTime , action, formFields);
- }
-
- public void logReportExecutionTimeFromLogList (String userId, String executionTime, String formFields) throws RaptorException {
- ReportLoader.createReportLogEntryForExecutionTime(null, reportID, userId,executionTime , AppConstants.RLA_FROM_LOG, formFields);
- }
-
- public void resetVisualSettings() {
- boolean haveToResetCachedData = (visualManager.getSortByColId().length() > 0);
- visualManager = new VisualManager();
-
- if (haveToResetCachedData)
- pageDataCache = null;
-
- if (pageDataCache != null)
- pageDataCache.resetVisualSettings();
- } // resetVisualSettings
-
- /** ************** ReportParamValues processing *************** */
-
- public boolean setParamValues(HttpServletRequest request, boolean resetParams, boolean refresh) throws RaptorException {
- boolean paramsUpdated = false;
- if (resetParams) {
- reportFormFields = new ReportFormFields(this, request);
- reportParamValues = new ReportParamValues(reportFormFields, getReportDefType());
- // This is called even in the wizard page. Hence this condition.
- if((ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)!=null)
- reportParamValuesFPE = new ReportParamValuesForPDFExcel(reportFormFields, getReportDefType());
- paramsUpdated = true;
-
- reportRunLogged = false;
- } else if (request != null) {
- paramsUpdated = reportParamValues.setParamValues(request,refresh);
- }
- // This is called even in the wizard page. Hence this condition.
- if((ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)!=null) {
- if(reportParamValuesFPE!=null) reportParamValuesFPE.setParamValues(request,refresh);
- else {
- reportParamValuesFPE = new ReportParamValuesForPDFExcel(reportFormFields, getReportDefType());
- reportParamValuesFPE.setParamValues(request,refresh);
- }
- } else {
- reportFormFields = new ReportFormFields(this, request);
- //added below two lines for dashboard default value
- reportParamValues = new ReportParamValues(reportFormFields, getReportDefType());
- reportParamValues.setParamValues(request,refresh);
- //End
- reportParamValuesFPE = new ReportParamValuesForPDFExcel(reportFormFields, getReportDefType());
- reportParamValuesFPE.setParamValues(request,refresh);
-
- }
-// }
- if (paramsUpdated) {
- setReportDataSize(-1);
- chartDataCache = null;
- pageDataCache = null;
- cachedPageNo = -1;
-
- crossTabOrderManager = null;
-
- colDataTotalsLinear = null;
- colDataTotalsCrosstab = null;
- rowDataTotalsCrosstab = null;
- grandTotalCrosstab = null;
- if(!refresh)
- resetVisualSettings();
- } // if
-
- displayChart = (request.getParameter(AppConstants.RI_DISPLAY_CHART) == null) ? !isDisplayOptionHideChart() : request.getParameter("display_chart")
- .equals("Y");
-
- return paramsUpdated;
- } // setParamValues
-
- public String getParamValue(String key) {
- //reportParamValues.printValues();
- return reportParamValues.getParamValue(key);
- } // getParamValue
-
- public String getParamDisplayValue(String key) {
- //reportParamValues.printValues();
- return reportParamValues.getParamDisplayValue(key);
- } // getParamValue
-
- public Enumeration getParamKeys() {
- return reportParamValues.keys();
- } // getParamKeys
-
- public Enumeration getParamKeysForPDFExcel() {
- return reportParamValuesFPE.keys();
- } // getParamKeys
-
- public String getParamValueForPDFExcel(String key) {
- return reportParamValuesFPE.getParamValue(key);
- } // getParamValue
-
- public ArrayList getParamNameValuePairs() {
- ArrayList paramList = new ArrayList(getReportFormFields().size());
- for (Iterator iter = getReportFormFields().iterator(); iter.hasNext();) {
- FormField ff = (FormField) iter.next();
- paramList.add(new IdNameValue(ff.getFieldDisplayName(), reportParamValues
- .getParamDisplayValue(ff.getFieldName())));
- } // for
- return paramList;
- } // getParamNameValuePairs
-
- public ArrayList getParamNameValuePairsforPDFExcel(HttpServletRequest request, int type /*excel =1; pdf=2*/) {
- javax.servlet.http.HttpSession session = request.getSession();
- ArrayList paramList = new ArrayList(getReportFormFields().size());
- if(session.getAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO)!=null) {
- paramList = (ArrayList) session.getAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO);
- if(paramList!=null && paramList.size()>0)
- return paramList;
- }
- //System.out.println(" getParamNamePairs type " + type + " " + Globals.customizeFormFieldInfo());
- if ( reportParamValuesFPE == null) {
- reportParamValuesFPE = new ReportParamValuesForPDFExcel(reportFormFields, getReportDefType());
- reportParamValuesFPE.setParamValues(request,true);
- }
-
- String valueString = "";
- for (Iterator iter = getReportFormFields().iterator(); iter.hasNext();) {
- FormField ff = (FormField) iter.next();
- if(ff.isVisible() && /*!ff.getFieldType().equals(FormField.FFT_HIDDEN) &&*/ type == 1){
- valueString = reportParamValuesFPE.getParamDisplayValue(ff.getFieldName());
- } else if(ff.isVisible() && type != 1) {
- valueString = reportParamValuesFPE.getParamDisplayValue(ff.getFieldName());
- }
- if(valueString.equalsIgnoreCase("NULL"))
- valueString="";
- paramList.add(new IdNameValue(ff.getFieldDisplayName(), valueString));
-// }
- } // for
-
- String pdfAttachmentKey = AppUtils.getRequestValue(request, "pdfAttachmentKey");
- boolean isSchedule = false;
- if(pdfAttachmentKey != null)
- isSchedule = true;
- if(Globals.customizeFormFieldInfo() && type == 2) {
- String[] sessionParameters = Globals.getSessionParams().split(",");
-
- if(session != null && !isSchedule ) {
- session.setAttribute("login_id", AppUtils.getUserBackdoorLoginId(request));
- for (int i = 0; i < sessionParameters.length; i++) {
- if(session.getAttribute(sessionParameters[i])!=null)
- paramList.add(new IdNameValue(sessionParameters[i].toUpperCase(), (String)session.getAttribute(sessionParameters[i])));
- }
- }
-
- if(isSchedule) {
- //debugLogger.debug("Globals " + Globals.getSessionParamsForScheduling());
- String[] scheduleSessionParam = Globals.getSessionParamsForScheduling().split(",");
- for (int i = 0; i < scheduleSessionParam.length; i++) {
- //debugLogger.debug(" scheduleSessionParam[i] " + scheduleSessionParam[i] + " " + request.getParameter(scheduleSessionParam[i]) );
- if(request.getParameter(scheduleSessionParam[i])!=null)
- paramList.add(new IdNameValue(scheduleSessionParam[i].toUpperCase(), request.getParameter(scheduleSessionParam[i])));
- }
- }
-
- try {
- SimpleDateFormat oracleDateFormat = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss");
- Date sysdate = oracleDateFormat.parse(ReportLoader.getSystemDateTime());
- SimpleDateFormat dtimestamp = new SimpleDateFormat(Globals.getScheduleDatePattern());
- paramList.add(new IdNameValue("DATE", dtimestamp.format(sysdate)+" "+Globals.getTimeZone()));
- } catch(Exception ex) {}
-
- } else {
- //System.out.println(" In Else getParamNamePairs type " + type);
- String[] sessionDisplayParameters = Globals.getDisplaySessionParamInPDFEXCEL().split(",");
- if(session != null && !isSchedule ) {
- session.setAttribute("login_id", AppUtils.getUserBackdoorLoginId(request));
- for (int i = 0; i < sessionDisplayParameters.length; i++) {
- String sessionDispParam = sessionDisplayParameters[i];
- if(nvl(sessionDispParam).length()>0) {
- String sessionDispParamArr[] = sessionDispParam.split(";");
- //System.out.println("Session " + sessionDispParamArr[1] + " " + (String)session.getAttribute(sessionDispParamArr[0]));
- paramList.add(new IdNameValue(sessionDispParamArr[1], nvl((String)session.getAttribute(sessionDispParamArr[0]),"")));
- }
- }
- }
- if(isSchedule) {
- String[] scheduleSessionParam = Globals.getDisplayScheduleSessionParamInPDFEXCEL().split(",");
- for (int i = 0; i < scheduleSessionParam.length; i++) {
- String scheduleSessionDispParam = scheduleSessionParam[i];
- if(nvl(scheduleSessionDispParam).length()>0) {
- String scheduleSessionDispParamArr[] = scheduleSessionDispParam.split(";");
- paramList.add(new IdNameValue(scheduleSessionDispParamArr[1], nvl(request.getParameter(scheduleSessionDispParamArr[0]),"")));
- }
- }
- }
- try {
- SimpleDateFormat oracleDateFormat = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss");
- Date sysdate = oracleDateFormat.parse(ReportLoader.getSystemDateTime());
- SimpleDateFormat dtimestamp = new SimpleDateFormat(Globals.getScheduleDatePattern());
- paramList.add(new IdNameValue("Report Date/Time", dtimestamp.format(sysdate)+" "+Globals.getTimeZone()));
- } catch(Exception ex) {}
-
- }
-
- for (int i = 0; i < paramList.size(); i++) {
- IdNameValue value = (IdNameValue) paramList.get(i);
- String name = value.getName().replaceAll(",","~");
- value.setName(name);
- }
- //request.getSession().setAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO, paramList);
- return paramList;
- } // getParamNameValuePairs
-
- /** ************** ReportFormFields processing *************** */
-
- public String getFormFieldComments(HttpServletRequest request) {
- String comment = "";
- StringBuffer st = new StringBuffer("");
- if(getFormFieldList()!=null){
- comment = nvl(getFormFieldList().getComment());
- ArrayList al = null;
- if(comment.length()>0) {
- al = getParamNameValuePairsforPDFExcel(request, 2);
- if(al!=null) {
- //st = new StringBuffer(comment);
- for (int i=0; i < al.size(); i++) {
- IdNameValue idNameValue = (IdNameValue)al.get(i);
- if(nvl(idNameValue.getId()).equals("DATE"))
- st.append("<b>Date/Time Report Run:</b>"+ idNameValue.getName() +"<br></br>");
- }
-
- for (int i=0; i < al.size(); i++) {
- IdNameValue idNameValue = (IdNameValue)al.get(i);
- comment = Utils.replaceInString(comment, "["+ idNameValue.getId()+"]", idNameValue.getName());
- }
- st.append(comment);
-
- }
- }
- }
- return st.toString();
- }
-
- public boolean needFormInput() {
- return reportFormFields.getFieldCount() > 0;
- } // needFormInput
-
- public FormField getFormField(String fieldName) {
- return reportFormFields.getFormField(fieldName);
- } // getFormField
-
- public ReportFormFields getReportFormFields() {
- return reportFormFields;
- } // getReportFormFields
-
- /** ************** Report Data processing *************** */
- public DataSet loadChartData(String userId, HttpServletRequest request) throws RaptorException {
- if (nvl(getChartType()).length() == 0)
- return null;
- if (!getDisplayChart())
- return null;
-
- DataSet ds = chartDataCache;
- String sql = null;
- if (ds == null) {
- sql = generateChartSQL(reportParamValues, userId, request);
- String dbInfo = getDBInfo();
- ds = ConnectionUtils.getDataSet(sql, dbInfo);
- if (Globals.getCacheChartData())
- chartDataCache = ds;
- } // if
-
- return ds;
- } // loadChartData
-
- public String getReportDataSQL(String userId, int downloadLimit, HttpServletRequest request) throws RaptorException {
- //String reportSQL = generateSQL(reportParamValues, userId, request);
- String reportSQL = "";
- if(doesReportContainsGroupFormField()) {
- reportSQL = generateSubsetSQL(0, downloadLimit,userId, request, true, reportParamValues);
- } else
- reportSQL = generateSubsetSQL(0, downloadLimit,userId, request, false, reportParamValues);
- return reportSQL;
- }
-
- public ReportData loadReportData(int pageNo, String userId, int downloadLimit, HttpServletRequest request, boolean download) throws RaptorException {
- ReportData rd = null;
- boolean isGoBackAction = AppUtils.getRequestFlag(request, AppConstants.RI_GO_BACK);
- if (pageNo >= 0)
- if (pageNo == cachedPageNo && pageDataCache != null)
- rd = pageDataCache;
-
- if(isGoBackAction && rd!=null) return rd;
- if (rd == null) { // Commented So that Data is refreshed from DB again
- if (getReportDataSize() < 0)
- //if (pageNo > 0)
- //pageNo = 0;
-
- if (getReportType().equals(AppConstants.RT_CROSSTAB))
- rd = loadCrossTabReportData(pageNo, userId, downloadLimit, request, download);
- else if (getReportType().equals(AppConstants.RT_LINEAR))
- rd = loadLinearReportData(pageNo, userId, downloadLimit, request, download);
- else
- throw new RuntimeException(
- "[ReportRuntime.loadReportData] Invalid report type");
-
- if (pageNo >= 0)
- if (Globals.getCacheCurPageData()) {
- pageDataCache = rd;
- cachedPageNo = pageNo;
- }
- } // if // Commented So that Data is refreshed from DB again
-
- return rd;
- } // loadReportData
-
- private ReportData loadCrossTabReportData(int pageNo, String userId, int downloadLimit, HttpServletRequest request, boolean download) throws RaptorException {
- String reportSQL = generateSQL(reportParamValues, userId, request);
- setWholeSQL(reportSQL);
- //if(getReportDefType().equals(AppConstants.RD_SQL_BASED))
- // reportSQL = new SQLCorrector().fixCrosstabSQL(new StringBuffer(reportSQL));
- cachedSQL = reportSQL;
- wholeSQL = reportSQL;
- //if (crossTabOrderManager == null
- ///*&& (!getReportDefType().equals(AppConstants.RD_SQL_BASED))*/)
- //crossTabOrderManager = new CrossTabOrderManager(this, userId,request);
-/* boolean isGoBackAction = AppUtils.getRequestFlag(request, AppConstants.RI_GO_BACK);
- if(isGoBackAction) {
- crossTabOrderManager = null;
- crossTabOrderManager = new CrossTabOrderManager(this, userId,request);
- }
-*/
- List reportCols = getAllColumns();
- // replace the request parameter specified in the drill down
- DataColumnType dataColumnRequest = getCrossTabValueColumn();
- reportSQL = parseReportSQLForDrillDownParams(reportSQL, dataColumnRequest, request);
-
-
- DataSet ds = null;
- // try {
- String dbInfo = getDBInfo();
- StringBuffer colNames = new StringBuffer();
- StringBuffer colExtraIdNames = new StringBuffer();
- StringBuffer colExtraDateNames = new StringBuffer();
-
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- //TODO: commented if (dc.isVisible()) {
- if (colNames.length() > 0)
- colNames.append(", ");
- colNames.append(dc.getColId());
- //TODO uncomment if it's not working} // if
-
- // Checking for extra fields necessary for drill-down
- if (nvl(dc.getDrillDownURL()).length() > 0) {
- System.out.println("Drilldown URL " + dc.getDrillDownURL());
-
- }
- } // for
-
- if (reportSQL.toUpperCase().indexOf("GROUP BY ") < 0)
- colNames.append(colExtraIdNames.toString());
- colNames.append(colExtraDateNames.toString());
- //reportSQL = " SELECT ROWNUM rnum, "
- // + colNames.toString() + " FROM (" + reportSQL + ") ";
-
- String rSQL = Globals.getLoadCrosstabReportData();
- rSQL = rSQL.replace("[colNames.toString()]", colNames.toString());
- rSQL = rSQL.replace("[reportSQL]", reportSQL);
- reportSQL = rSQL;
- setWholeSQL(reportSQL);
- if (crossTabOrderManager == null)
- crossTabOrderManager = new CrossTabOrderManager(this, userId,request);
- ds = ConnectionUtils.getDataSet(reportSQL, dbInfo);
- // if ( (remDbInfo!=null) && (!remDbInfo.equals(AppConstants.DB_LOCAL)))
- // ds = RemDbUtils.executeQuery(reportSQL);
- // else
- // ds = DbUtils.executeQuery(reportSQL);
- /*
- * } catch(SQLException e) { throw new
- * ReportSQLException("[ReportRuntime.loadCrossTabReportData]
- * "+e.getMessage(), reportSQL); }
- */
-
- ReportData rd = new ReportData(pageNo, false);
- ReportFormFields childReportFormFields = null;
- if(doesReportContainsGroupFormField()) {
- List reportCols1 = getAllColumns();
- reportCols = new Vector();
- outer:
- for (Iterator iter = reportCols1.iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
- for (int k=0; k<ds.getColumnCount(); k++) {
- if(dct.getColId().toUpperCase().trim().equals(ds.getColumnName(k).trim())) {
- reportCols.add(dct);
- continue outer;
- }
- }
- }
-
- if (getFormFieldList() != null) {
- String paramValue = "";
- for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) {
- FormFieldType fft = (FormFieldType) iter.next();
- if(fft.isGroupFormField()!=null && fft.isGroupFormField().booleanValue()) {
- paramValue = Utils.oracleSafe(nvl(reportParamValues
- .getParamValue(fft.getFieldId())));
- outer:
- for (Iterator iter1 = reportCols1.iterator(); iter1.hasNext();) {
- DataColumnType dct = (DataColumnType) iter1.next();
- if(("["+fft.getFieldName()+ "]").equals(dct.getColName().trim())) {
- dct.setDisplayName(paramValue);
- continue outer;
- }
- }
-
-
- }
- }
- }
- }
-
- int dataColumnIdx = (rd.reportRowHeaderCols.size() + rd.reportColumnHeaderRows.size())-1;
- DataColumnType dataColumn = getCrossTabValueColumn();
-
- String columnValue = "";
-
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
-
- if (nvl(dct.getDrillDownURL()).length() > 0) {
- childReportFormFields = getChildReportFormFields(request,dct.getDrillDownURL());
- }
-
- if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_ROW)) {
- RowHeaderCol rhc = new RowHeaderCol();
- rhc.setColumnTitle(dct.getDisplayName());
- // rhc.setColumnWidth("10%");
- //rhc.setColumnWidth(dct.getDisplayWidth() + "%");
- if(nvl(dct.getDisplayWidthInPxls()).length()<=0) {
- dct.setDisplayWidthInPxls("100px");
- }
- if(dct.getDisplayWidthInPxls().endsWith("px"))
- rhc.setColumnWidth(dct.getDisplayWidthInPxls());
- else
- rhc.setColumnWidth(dct.getDisplayWidthInPxls()+"px");
-
- rhc.setAlignment(dct.getDisplayAlignment());
- rhc.setDisplayHeaderAlignment(dct.getDisplayHeaderAlignment());
- rhc.setNowrap(nvl(dataColumn.getNowrap(),"null").equals("false")?"null":nvl(dataColumn.getNowrap(),"null"));
- rd.reportRowHeaderCols.addRowHeaderCol(rhc);
- } else if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_COLUMN)) {
- ColumnHeaderRow chr = new ColumnHeaderRow();
- chr.setAlignment(dct.getDisplayHeaderAlignment());
- chr.setRowHeight("15");
- if(nvl(dct.getDisplayWidthInPxls()).length()<=0) {
- dct.setDisplayWidthInPxls("80px");
- }
- if(dct.getDisplayWidthInPxls().endsWith("px"))
- chr.setDisplayWidth(dct.getDisplayWidthInPxls());
- else
- chr.setDisplayWidth(dct.getDisplayWidthInPxls()+"px");
-
- rd.reportColumnHeaderRows.addColumnHeaderRow(chr);
- } else if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_VALUE)) {
- columnValue = dct.getColId();
- } else {
- if(!dct.getColId().toLowerCase().endsWith("_sort")) {
- RowHeaderCol rhc = new RowHeaderCol();
- rhc.setVisible(false);
- rd.reportRowHeaderCols.addRowHeaderCol(rhc);
- }
- }
- } // for
-
- //int dataColumnIdx = getCrossTabValueColumnIndex();
- FormatProcessor formatProcessor = new FormatProcessor(getSemaphoreById(dataColumn
- .getSemaphoreId()),
- getReportDefType().equals(AppConstants.RD_SQL_BASED) ? AppConstants.CT_NUMBER
- : dataColumn.getColType(), dataColumn.getColFormat(), false);
- List dataList = new ArrayList();
- /* //fillup all rows based on rowheaders
- Vector rowHeaders = crossTabOrderManager.getRowHeaderValues();
- CrossTabColumnValues crossTabRowValues;
- int size = 0;
- for (int i = 0; i < rowHeaders.size(); i++) {
- if((i+1)==rowHeaders.size()) {
- crossTabRowValues = (CrossTabColumnValues) rowHeaders.get(i);
- size = crossTabRowValues.getValuesCount();
- }
- }
-
- for (int i = 0; i < size; i++) {
- dataList.add(new DataRow());
- }*/
-
- for (int i = 0; i < ds.getRowCount(); i++) {
- Vector rValues = new Vector();
- Vector cValues = new Vector();
- Vector cValuesSort = new Vector();
-
- int colIdx = 0;
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- try {
- DataColumnType dct = (DataColumnType) iter.next();
- if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_ROW))
- rValues.add(addDataValue(dct, ds.getString(i, dct.getColId())));
- if (nvl(dct.getCrossTabValue()).trim().length()<=0 && !dct.getColId().toLowerCase().endsWith("_sort"))
- rValues.add(addDataValue(dct, ds.getString(i, dct.getColId())));
- if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_COLUMN)) {
- cValues.add(addDataValue(dct, ds.getString(i, dct.getColId())));
- if(getColumnById(dct.getColId().toLowerCase()+"_sort")!=null)
- cValuesSort.add(addDataValue(dct, new Integer(ds.getString(i, dct.getColId()+"_sort")).toString()));
- }
- if (dct.isVisible())
- colIdx++;
- } catch (ArrayIndexOutOfBoundsException ex ) {continue;}
- catch (NumberFormatException ex1) {
- ex1.printStackTrace();
- continue;
- }
- } // for
-
- DataValue dv = new DataValue();
- dv.setDisplayValue(ds.getString(i, columnValue));
- if (nvl(dataColumn.getCrossTabValue()).trim().length()<=0)
- dv.setVisible(false);
- dv.setAlignment(dataColumn.getDisplayAlignment());
- dv.setDisplayTotal(dataColumn.getDisplayTotal());
- dv.setColName(dataColumn.getColName());
- dv.setDisplayName(dataColumn.getDisplayName());
- dv.setColId(dataColumn.getColId());
- dv.setNowrap(nvl(dataColumn.getNowrap(),"null").equals("false")?"null":nvl(dataColumn.getNowrap(),"null"));
- /*StringBuffer indentation = new StringBuffer("");
- if(dataColumn.getIndentation()!=null && dataColumn.getIndentation().intValue()>0) {
- for (int indent=0; indent < dataColumn.getIndentation(); indent++) {
- indentation.append("\t");
- }
- dv.setNowrap("true");
- }
- dv.setIndentation(indentation.toString());*/
-
- if (nvl(dataColumn.getDrillDownURL()).length() > 0) {
- if(dv.getDisplayValue().length() > 0) {
- dv.setDrillDownURL(parseDrillDownURL(i, /* dataColumnIdx, */ds, dataColumn,request, childReportFormFields));
- dv.setDrillDowninPoPUp(dataColumn.isDrillinPoPUp()!=null?dataColumn.isDrillinPoPUp():false);
- }
- if (dv.getDisplayValue().length() == 0) {
- //dv.setDisplayValue("[NULL]");
- dv.setDisplayValue("");
- }
- } // if
-
- rd.setDataValue(rValues, cValues, cValuesSort.size()==0?null:cValuesSort, dv, formatProcessor, crossTabOrderManager, dataList);
- } // for
- rd.setReportDataList(dataList);
- /*if (getReportDataSize() < 0)
- setReportDataSize(rd.getDataRowCount());*/
-
- /*if (pageNo >= 0)
- rd.truncateData(pageNo * getPageSize(), (pageNo + 1) * getPageSize() - 1);
- else {
- if( downloadLimit != -1)
- rd.truncateData(0, downloadLimit - 1);
- else
- rd.truncateData(0, -1);
- }*/
-
- if (colDataTotalsCrosstab == null)
- colDataTotalsCrosstab = generateDataTotalsCrossTab(AppConstants.CV_COLUMN, userId,request);
- if (displayColTotals && colDataTotalsCrosstab != null)
- rd.setColumnDataTotalsCrossTab(colDataTotalsCrosstab, dataColumn
- .getDisplayAlignment(), getCrossTabDisplayTotal(AppConstants.CV_COLUMN),
- crossTabOrderManager, dataList);
-
- if (rowDataTotalsCrosstab == null)
- rowDataTotalsCrosstab = generateDataTotalsCrossTab(AppConstants.CV_ROW, userId, request);
- if (displayRowTotals && rowDataTotalsCrosstab != null)
- rd.setRowDataTotalsCrossTab(rowDataTotalsCrosstab, dataColumn
- .getDisplayAlignment(), getCrossTabDisplayTotal(AppConstants.CV_ROW),
- crossTabOrderManager, dataList);
-
- if (displayColTotals
- && displayRowTotals
- && getCrossTabDisplayTotal(AppConstants.CV_COLUMN).equals(
- getCrossTabDisplayTotal(AppConstants.CV_ROW))) {
- // Display grand total
- if (grandTotalCrosstab == null)
- grandTotalCrosstab = ((CrossTabTotalValue) generateDataTotalsCrossTab("",
- userId,request).get(0)).getTotalValue();
- if (grandTotalCrosstab != null)
- rd.setGrandTotalCrossTab(Utils.truncateTotalDecimals(grandTotalCrosstab),
- dataColumn.getDisplayAlignment(),
- getCrossTabDisplayTotal(AppConstants.CV_COLUMN), dataList);
- } // if
-
- rd.consolidateColumnHeaders(visualManager);
- //if (Globals.getMergeCrosstabRowHeadings())
- // rd.consolidateRowHeaders();
- //rd.addRowNumbers(pageNo, dataList);
-
- if (displayColTotals && colDataTotalsCrosstab != null) {
- String totalLabel = "Total";
- String colDisplayTotal = getCrossTabDisplayTotal(AppConstants.CV_COLUMN);
- if (colDisplayTotal.length() > 0
- && (!colDisplayTotal.equals(AppConstants.TOTAL_SUM_ID)))
- totalLabel = nvl(AppConstants.TOTAL_FUNCTIONS.getNameById(colDisplayTotal));
- if (getReportDataSize() > getPageSize())
- totalLabel += "_nl_(for all pages)";
-
- //rd.setCrossTabColumnTotalLabel(totalLabel);
- } // if
-
- //rd.applyVisibility();
- //Collections.sort((List)dataList, new DataRowComparable());
- DataRow drInFor1 = null;
- Vector<DataValue> v1= null, v2 = null;
- ArrayList<String> temp = new ArrayList<String>();
- if (Globals.getMergeCrosstabRowHeadings()) {
- for (int i = 0; i < dataList.size(); i++) {
- drInFor1 = (DataRow)dataList.get(i);
- drInFor1.setRowNum(i+1);
- v1 = drInFor1.getRowValues();
- if(i<dataList.size()-1) {
- v2 = ((DataRow)dataList.get(i+1)).getRowValues();
- } /*else {
- v2 = ((DataRow)dataList.get(i-1)).getRowValues();
- }*/
- for (int j = 0; j < v1.size(); j++) {
- if(j==0) {
- if(v1.get(j).getDisplayValue().length()>0) { // another ArrayList
- temp = new ArrayList();
- temp.add(v1.get(j).getDisplayValue());
- }
- if(v2!=null && temp.get(j).equals(v2.get(j).getDisplayValue())) {
- v2.get(j).setDisplayValue("");
- }
- }
- }
- }
- }
- rd.setReportDataList(dataList);
- if (getReportDataSize() < 0) {
- //setReportDataSize(rd.getDataRowCount());
- setReportDataSize(rd.getReportDataList().size());
- }
-
- return rd;
- } // loadCrossTabReportData
-
-
- public DataValue addDataValue(DataColumnType dataColumn, String columnValue) {
- DataValue dv = new DataValue();
- dv.setDisplayValue(columnValue);
- if (nvl(dataColumn.getCrossTabValue()).trim().length()<=0)
- dv.setVisible(false);
- dv.setAlignment(dataColumn.getDisplayAlignment());
- dv.setDisplayTotal(dataColumn.getDisplayTotal());
- dv.setColName(dataColumn.getColName());
- dv.setDisplayName(dataColumn.getDisplayName());
- dv.setColId(dataColumn.getColId());
- dv.setNowrap(nvl(dataColumn.getNowrap(),"null").equals("false")?"null":nvl(dataColumn.getNowrap(),"null"));
- return dv;
-
- }
-
- /*private*/ public boolean doesReportContainsGroupFormField() {
- int flag = 0;
- if(getFormFieldList()!=null) {
- for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) {
- FormFieldType fft = (FormFieldType) iter.next();
- if(fft.isGroupFormField()!=null && fft.isGroupFormField().booleanValue()) {
- flag = 1;
- break;
- }
- }
- }
- return (flag ==1);
- }
-
- private ReportData loadLinearReportData(int pageNo, String userId, int downloadLimit, HttpServletRequest request, boolean download) throws RaptorException {
- String action = nvl(request.getParameter(AppConstants.RI_ACTION), request.getParameter("action"));;
-
- String reportSQL = "";
-
- if(action.endsWith("session")) {
- reportSQL = getWholeSQL();
- wholeSQL = reportSQL;
- } else {
- reportSQL = generateSQL(reportParamValues, visualManager.getSortByColId(),
- visualManager.getSortByAscDesc(), userId, request);
- wholeSQL = reportSQL;
- setWholeSQL(wholeSQL);
- }
- DataSet ds = null;
- String dbInfo = getDBInfo();
- ds = ConnectionUtils.getDataSet(wholeSQL, dbInfo);
- setReportDataSize(ds.getRowCount());
- //wholeSQL = reportSQL;
- HttpSession session = request.getSession();
- //debugLogger.debug(" ******** Download Limit ********* " + downloadLimit + " %%%%%%%%%%PAGE " + pageNo );
- List reportCols = null;
- StringBuffer colNames = new StringBuffer();
-
- if(download && action.endsWith("session")) {
- reportCols = getAllColumns();
- colNames = new StringBuffer();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
-
- DataColumnType dc = (DataColumnType) iter.next();
- if (colNames.length() > 0)
- colNames.append(", ");
- colNames.append(dc.getColId());
- }
-
- }
- else {
- String pagedSQL = null; // reportSQL;
- if (pageNo >= 0)
- pagedSQL = generatePagedSQL(pageNo, userId, request, false, null);
- else
- pagedSQL = generateSubsetSQL(0, downloadLimit, userId, request, false, null);
- // replace the request parameter specified in the drill down
- reportCols = getAllColumns();
- colNames = new StringBuffer();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
-
- DataColumnType dc = (DataColumnType) iter.next();
- if (colNames.length() > 0)
- colNames.append(", ");
- colNames.append(dc.getColId());
- if (dc.isVisible()) {
- reportSQL = parseReportSQLForDrillDownParams(reportSQL, dc, request);
- pagedSQL = parseReportSQLForDrillDownParams(pagedSQL, dc, request);
- }
- }
-
- cachedSQL = pagedSQL;
-
-
- // try {
- if(doesReportContainsGroupFormField()) {
- if (pageNo >= 0)
- pagedSQL = generatePagedSQL(pageNo, userId, request, true, reportParamValues);
- else
- pagedSQL = generateSubsetSQL(0, downloadLimit, userId, request, true, reportParamValues);
- }
- //check for Group formfield
- //if groupformfield get columns from sql
-
- ds = ConnectionUtils.getDataSet(pagedSQL, dbInfo);
-
- if(doesReportContainsGroupFormField()) {
- List reportCols1 = getAllColumns();
- reportCols = new Vector();
- outer:
- for (Iterator iter = reportCols1.iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
- for (int k=0; k<ds.getColumnCount(); k++) {
- if(dct.getColId().toUpperCase().trim().equals(ds.getColumnName(k).trim())) {
- reportCols.add(dct);
- continue outer;
- }
- }
- }
-
- if (getFormFieldList() != null) {
- String paramValue = "";
- for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) {
- FormFieldType fft = (FormFieldType) iter.next();
- if(fft.isGroupFormField()!=null && fft.isGroupFormField().booleanValue()) {
- paramValue = Utils.oracleSafe(nvl(reportParamValues
- .getParamValue(fft.getFieldId())));
- outer:
- for (Iterator iter1 = reportCols1.iterator(); iter1.hasNext();) {
- DataColumnType dct = (DataColumnType) iter1.next();
- if(("["+fft.getFieldName()+ "]").equals(dct.getColName().trim())) {
- dct.setDisplayName(paramValue);
- continue outer;
- }
- }
-
-
- }
- }
- }
- }
-
-
- // if ( (remDbInfo!=null) && (!remDbInfo.equals(AppConstants.DB_LOCAL)))
- // {
- // Globals.getRDbUtils().setDBPrefix(remDbInfo);
- // ds = RemDbUtils.executeQuery(pagedSQL);
- // }
- // else
- // ds = DbUtils.executeQuery(pagedSQL);
- /*
- * } catch(SQLException e) { throw new
- * ReportSQLException("[ReportRuntime.loadLinearReportData]
- * "+e.getMessage(), pagedSQL); }
- */
-
- if (getReportDataSize() < 0)
- if (pageNo < 0)
- setReportDataSize(ds.getRowCount());
- else if (ds.getRowCount() <= getPageSize())
- setReportDataSize(ds.getRowCount());
- else {
-
- /*Pattern re1 = Pattern.compile("[Oo][Rr][Dd][Ee][Rr](.*?[^\r\n]*)[Bb][Yy]", Pattern.DOTALL);
- Pattern re2 = Pattern.compile("[Oo][Rr][Dd][Ee][Rr](.*?[^\r\n]*)[Bb][Yy]((.*?[^\r\n]*)|[\\s]|[^0-9a-zA-Z])\\)", Pattern.DOTALL);
- Matcher matcher = re1.matcher(reportSQL);
- Matcher matcher2 = null;
- int startPoint = reportSQL.length()-30;
- String startReportSQL = "";
- String endReportSQL = "";
- while(reportSQL.indexOf("xid", startPoint)!=-1)startPoint++;
- if (matcher.find(startPoint)) {
- startReportSQL = reportSQL.substring(0, reportSQL.indexOf(matcher.group()));
- endReportSQL = reportSQL.substring(reportSQL.indexOf(matcher.group()));
- matcher2 = re2.matcher(endReportSQL);
- if(matcher2.find())
- endReportSQL = endReportSQL.substring(matcher.group().length()-1);
- else
- endReportSQL = "";
- reportSQL = startReportSQL + endReportSQL;
- }*/
- String countSQL = "SELECT count(*) FROM (" + reportSQL + ")"+ (Globals.isPostgreSQL() || Globals.isMySQL()?" AS ":"") +" x ";
- String dbType = "";
-
- if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) {
- try {
- org.openecomp.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.openecomp.portalsdk.analytics.util.RemDbInfo();
- dbType = remDbInfo.getDBType(dbInfo);
- if (dbType.equals("DAYTONA") && reportSQL.trim().toUpperCase().startsWith("SELECT")) {
- Pattern re1 = Pattern.compile("order(.*?[^\r\n]*)by", Pattern.DOTALL);
- Matcher matcher = re1.matcher(reportSQL);
- int startPoint = reportSQL.length()-30;
- while(reportSQL.indexOf("xid", startPoint)!=-1)startPoint++;
- if (matcher.find(startPoint)) {
- reportSQL = reportSQL.substring(0, reportSQL.indexOf(matcher.group()));
- }
- countSQL = "SELECT count(*) FROM (" + reportSQL + ")"+ (Globals.isPostgreSQL() || Globals.isMySQL()?" AS ":"") +" x";
- countSQL = countSQL + " ("+ colNames+ ")";
- } else if (dbType.equals("DAYTONA")) {
- setReportDataSize(50);
- }
- } catch (Exception ex) {
- throw new RaptorException(ex);
- }
- }
-
- DataSet ds2 = null;
- // try {
- if(reportSQL.trim().toUpperCase().startsWith("SELECT")) {
- ds2 = ConnectionUtils.getDataSet(countSQL, dbInfo);
- if (ds2.getRowCount() > 0)
- setReportDataSize(ds2.getInt(0, 0));
- else
- throw new RuntimeException(
- "[ReportRuntime.loadLinearReportData] Unable to load report data size");
- } else
- setReportDataSize(50);
- // if ( (remDbInfo!=null) &&
- // (!remDbInfo.equals(AppConstants.DB_LOCAL))){
- // Globals.getRDbUtils().setDBPrefix(remDbInfo);
- // ds2 = RemDbUtils.executeQuery(countSQL);
- // }
- // else
- // ds2 = DbUtils.executeQuery(countSQL);
- /*
- * } catch(SQLException e) { throw new
- * ReportSQLException("[ReportRuntime.loadLinearReportData size]
- * "+e.getMessage(), countSQL); }
- */
-
-
- } // else
- }
- ReportData rd = new ReportData(pageNo, true);
-
- // Already defined changed for modifying request parameters
- //List reportCols = getAllColumns();
- Vector visibleCols = new Vector(reportCols.size());
- Vector formatProcessors = new Vector(reportCols.size());
-
- // ColumnHeaderRow chr = new ColumnHeaderRow();
- // rd.reportColumnHeaderRows.addColumnHeaderRow(chr);
- // chr.setRowHeight("30");
- int count =0 ;
-
- /* ADDED */
- ReportFormFields rff = getReportFormFields();
- ReportFormFields childReportFormFields = null;
- String fieldDisplayName = "";
- String fieldValue = "";
-
- for (int c = 0; c < reportCols.size(); c++) {
- if(reportCols.get(c)!=null) {
- DataColumnType dct = (DataColumnType) reportCols.get(c);
- if(nvl(dct.getDependsOnFormField()).length()>0 && nvl(dct.getDependsOnFormField()).indexOf("[")!=-1) {
- for(int i = 0 ; i < rff.size(); i++) {
- fieldDisplayName = "["+((FormField)rff.getFormField(i)).getFieldDisplayName()+"]";
- fieldValue = "";
- //if(dct.getOriginalDisplayName()==null) dct.setOriginalDisplayName(dct.getDisplayName());
- if (dct.getDependsOnFormField().equals(fieldDisplayName)) {
- fieldValue = nvl(request.getParameter(((FormField)rff.getFormField(i)).getFieldName()));
-
- if (fieldValue.length()>0) {
- if(!fieldValue.toUpperCase().equals("Y"))
- dct.setDisplayName(fieldValue);
- if(!dct.isVisible())
- dct.setVisible(true);
- } else {
- dct.setVisible(false);
- }
- }
- }
- }
- }
- }
-
- /* ADDED */
- String displayName = "";
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
-
- DataColumnType dc = (DataColumnType) iter.next();
-
- formatProcessors.add(count,new FormatProcessor(
- getSemaphoreById(dc.getSemaphoreId()), dc.getColType(), dc
- .getColFormat(), getReportDefType().equals(
- AppConstants.RD_SQL_BASED)));
-
- if (nvl(dc.getDrillDownURL()).length() > 0) {
- childReportFormFields = getChildReportFormFields(request,AppUtils.getDrillActionURL()+""+dc.getDrillDownURL());
- }
- if (dc.isVisible()) {
- visibleCols.add(count,dc);
- //if(dc.getColId().startsWith("group")) {
- for (int d = 0; d < reportCols.size(); d++) {
- if(reportCols.get(d)!=null) {
- DataColumnType dct1 = (DataColumnType) reportCols.get(d);
- if(dct1.getColId().equals(dc.getColId()+"_name") && ds.getRowCount()>0) {
- displayName = ds.getString(0,dct1.getColId());
- dc.setDisplayName(displayName);
- }
- }
- }
- //}
-
- String widthInPxls = dc.getDisplayWidthInPxls();
-
- if(nvl(widthInPxls).endsWith("px"))
- dc.setDisplayWidthInPxls(widthInPxls);
- else {
- widthInPxls = widthInPxls+"px";
- dc.setDisplayWidthInPxls(widthInPxls+"px");
- }
-
- rd.createColumn(dc.getColId(), dc.getDisplayName(), dc.getDisplayWidthInPxls(), dc.getDisplayHeaderAlignment(),
- visualManager.isColumnVisible(dc.getColId()), visualManager
- .getSortByColId().equals(dc.getColId()) ? visualManager
- .getSortByAscDesc() : null, isRuntimeColSortDisabled(), dc.getLevel()!=null?dc.getLevel():0, dc.getStart()!=null?dc.getStart():0, dc.getColspan()!=null?dc.getColspan():0, dc.isIsSortable()!=null?dc.isIsSortable():false);
- // chr.addColumnHeader(new ColumnHeader(dc.getDisplayName(),
- // (dc.getDisplayWidth()>100)?"10%":(""+dc.getDisplayWidth()+"%")));
- } // if
- else {
- visibleCols.add(count,null);
- rd.createColumn(dc.getColId(), AppConstants.HIDDEN, dc.getDisplayWidthInPxls(), dc.getDisplayHeaderAlignment(),
- false, null,false, dc.getLevel()!=null?dc.getLevel():0, dc.getStart()!=null?dc.getStart():0, dc.getColspan()!=null?dc.getColspan():0, dc.isIsSortable()!=null?dc.isIsSortable():false);
-// formatProcessors.add(count,null);
- }
- count++;
- } // for
-
- if(getReportDefType().equals(AppConstants.RD_SQL_BASED_DATAMIN) && pageNo ==0) {
- /*Vector v = null;
- try {
- v = addForecastData(reportSQL);
- } catch (Exception ex) {
- ex.printStackTrace();
- throw new RaptorException (ex);
- }
- session.setAttribute("FORECASTED_DATA", v);
- DataSet dsWhole = ConnectionUtils.getDataSet(wholeSQL, dbInfo);
- dsWhole.addAll(v);
- session.setAttribute(AppConstants.RI_CHART_FORECAST_DATA, dsWhole);
- }
-
- if(getReportDefType().equals(AppConstants.RD_SQL_BASED_DATAMIN) && session.getAttribute("FORECASTED_DATA")!=null) {
- Vector vForecastedData = (Vector)session.getAttribute("FORECASTED_DATA");
- if(vForecastedData.size() > 0)
- ds.addAll(vForecastedData);*/
- }
-
-
- // Utils._assert(chr.size()==ds.getColumnCount(),
- // "[ReportRuntime.loadLinearReportData] The number of visible columns
- // does not match the number of data columns");
- //TODO: This should be optimized to accept -1 for flat file download
- for (int r = 0; r < Math.min(ds.getRowCount(), ((pageNo < 0) ? (downloadLimit == -1?Globals.getFlatFileUpperLimit():Globals.getDownloadLimit() ) : getPageSize())); r++) {
- DataRow dr = new DataRow();
- rd.reportDataRows.addDataRow(dr);
-
- for (int c = 0; c < reportCols.size(); c++) {
- if(reportCols.get(c)!=null) {
- DataColumnType dct = (DataColumnType) reportCols.get(c);
- DataValue dv = new DataValue();
- dr.addDataValue(dv);
- dv.setDisplayValue(ds.getString(r, c));
- dv.setColName(dct.getColName());
- dv.setColId(dct.getColId());
- dv.setNowrap(nvl(dct.getNowrap(),"null").equals("false")?"null":nvl(dct.getNowrap(),"null"));
- StringBuffer indentation = new StringBuffer("");
- if(dct.getIndentation()!=null && dct.getIndentation()>0) {
- for (int indent=0; indent< dct.getIndentation(); indent++) {
- indentation.append("\t");
- }
- dv.setNowrap("true");
- }
- dv.setIndentation(indentation.toString());
- if(dct.isVisible()) {
-
- dv.setVisible(true);
- dv.setAlignment(dct.getDisplayAlignment());
- dv.setDisplayTotal(dct.getDisplayTotal());
- dv.setDisplayName(dct.getDisplayName());
-
- if (nvl(dct.getDrillDownURL()).length() > 0) {
-
- if(dv.getDisplayValue().length() > 0) {
- dv.setDrillDownURL(parseDrillDownURL(r, /* c, */ds, dct,request, childReportFormFields));
- dv.setDrillDowninPoPUp(dct.isDrillinPoPUp()!=null?dct.isDrillinPoPUp():false);
- }
-
- if (dv.getDisplayValue().length() == 0) {
- //dv.setDisplayValue("[NULL]");
- dv.setDisplayValue("");
- }
- } // if
-
- } else {
- dv.setVisible(false);
- dv.setHidden(true);
- }
- //System.out.println("in Linear report b4" + dr.getFormatId() + dr.getBgColorHtml() + dv.getDisplayValue());
-
- if(dr.getFormatId()!=null)
- ((FormatProcessor) formatProcessors.get(c)).setHtmlFormatters(dv, dr, true);
- else
- ((FormatProcessor) formatProcessors.get(c)).setHtmlFormatters(dv, dr, false);
-
- //System.out.println("in Linear report After" + dr.getFormatId() + dr.getBgColorHtml() + dv.getDisplayValue());
- } // if reportCols
- } // for
- } // for
-
- //Only if rownumber options is needed
- //rd.addRowNumbers(pageNo, getPageSize());
-
- if (colDataTotalsLinear == null) {
- if(!download && !action.endsWith("session"))
- colDataTotalsLinear = generateColumnDataTotalsLinear(new ArrayList(reportCols), userId,
- getDbInfo(),request);
- if(download && action.endsWith("session"))
- colDataTotalsLinear = generateColumnDataTotalsLinear(new ArrayList(reportCols), userId,
- getDbInfo(), getTotalSql());
- }
- if (displayColTotals && colDataTotalsLinear != null) {
- String totalLabel = "Total";
- if (getReportDataSize() > getPageSize())
- totalLabel += "<br><font size=1>(for all pages)</font>";
-
- rd.setColumnDataTotalsLinear(colDataTotalsLinear, totalLabel);
- } // if
- // Please note the below function doesn't set the visibility for dv since this is set in this function. - Sundar
- rd.applyVisibility();
-
- return rd;
- } // loadLinearReportData
-
-
-
- public DataRow generateColumnDataTotalsLinear(ArrayList reportCols, String userId,
- String dbInfo, String reportSQL) throws RaptorException {
- DataRow dr = null;
-
- boolean displayColTotals = false;
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
-
- DataColumnType dct = (DataColumnType) iter.next();
- if( dct != null ) {
- if (nvl(dct.getDisplayTotal()).length() > 0) {
- displayColTotals = true;
- break;
- } // if
- } // if checking dct
- } // for
-
- DataSet ds = null;
- if (displayColTotals) {
- dr = new DataRow();
- // ds =
- // DbUtils.executeQuery(generateTotalSQLLinear(reportParamValues,
- // userId));
- ds = ConnectionUtils.getDataSet(reportSQL,
- dbInfo);
-
- for (int c = 0; c < reportCols.size(); c++) {
- DataColumnType dct = (DataColumnType) reportCols.get(c);
- if ( dct != null ) {
- DataValue dv = new DataValue();
-
- String totalValue = "";
- if (ds != null)
- totalValue = ds.getString(0, c);
- if (nvl(dct.getDisplayTotal()).length() > 0
- && (!dct.getDisplayTotal().equals(AppConstants.TOTAL_SUM_ID)))
- totalValue = nvl(AppConstants.TOTAL_FUNCTIONS.getNameById(dct
- .getDisplayTotal()))
- + ": " + totalValue;
- dv.setDisplayValue(Utils.truncateTotalDecimals(totalValue));
-
- dv.setAlignment(dct.getDisplayAlignment());
- dv.setColName(dct.getColName());
- dv.setDisplayName(dct.getDisplayName());
- dv.setColId(dct.getColId());
- dv.setNowrap(nvl(dct.getNowrap(),"null").equals("false")?"null":nvl(dct.getNowrap(),"null"));
- StringBuffer indentation = new StringBuffer("");
- if(dct.getIndentation()!=null && dct.getIndentation()>0) {
- for (int indent=0; indent< dct.getIndentation(); indent++) {
- indentation.append("\t");
- }
- dv.setNowrap("true");
- }
- dv.setIndentation(indentation.toString());
- dv.setDisplayTotal(dct.getDisplayTotal());
- dv.setBold(true);
- dv.setVisible(dct.isVisible());
- if(dv.isVisible())
- dr.addDataValue(dv);
- } // dct check
- } // for
- }
-
- return dr;
- } // generateColumnDataTotalsLinear
-
-
- public ReportData loadHiveLinearReportData(String reportSQL, String userId, int downloadLimit, HttpServletRequest request) throws RaptorException {
- wholeSQL = reportSQL;
- int countRows = getHiveReportCount(wholeSQL);
- setReportDataSize(countRows);
- if(countRows < 1001)
- wholeSQL += " limit "+ countRows;
- else
- wholeSQL += " limit "+ downloadLimit;
- HttpSession session = request.getSession();
-
- DataSet ds = null;
- // try {
- String dbInfo = getDBInfo();
-
- List reportCols = getAllColumns();
- StringBuffer colNames = new StringBuffer();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
-
- DataColumnType dc = (DataColumnType) iter.next();
- if (colNames.length() > 0)
- colNames.append(", ");
- colNames.append(dc.getColId());
- }
-
- ds = ConnectionUtils.getDataSet(wholeSQL, dbInfo);
-
- ReportData rd = new ReportData(0, true);
-
- // Already defined changed for modifying request parameters
- //List reportCols = getAllColumns();
- Vector visibleCols = new Vector(reportCols.size());
- Vector formatProcessors = new Vector(reportCols.size());
-
- // ColumnHeaderRow chr = new ColumnHeaderRow();
- // rd.reportColumnHeaderRows.addColumnHeaderRow(chr);
- // chr.setRowHeight("30");
- int count =0 ;
-
- /* ADDED */
- ReportFormFields rff = getReportFormFields();
- ReportFormFields childReportFormFields = null;
- String fieldDisplayName = "";
- String fieldValue = "";
-
- for (int c = 0; c < reportCols.size(); c++) {
- if(reportCols.get(c)!=null) {
- DataColumnType dct = (DataColumnType) reportCols.get(c);
- if(nvl(dct.getDependsOnFormField()).length()>0 && nvl(dct.getDependsOnFormField()).indexOf("[")!=-1) {
- for(int i = 0 ; i < rff.size(); i++) {
- fieldDisplayName = "["+((FormField)rff.getFormField(i)).getFieldDisplayName()+"]";
- fieldValue = "";
- //if(dct.getOriginalDisplayName()==null) dct.setOriginalDisplayName(dct.getDisplayName());
- if (dct.getDependsOnFormField().equals(fieldDisplayName)) {
- fieldValue = nvl(request.getParameter(((FormField)rff.getFormField(i)).getFieldName()));
-
- if (fieldValue.length()>0) {
- if(!fieldValue.toUpperCase().equals("Y"))
- dct.setDisplayName(fieldValue);
- if(!dct.isVisible())
- dct.setVisible(true);
- } else {
- dct.setVisible(false);
- }
- }
- }
- }
- }
- }
-
- /* ADDED */
- String displayName = "";
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
-
- DataColumnType dc = (DataColumnType) iter.next();
-
- formatProcessors.add(count,new FormatProcessor(
- getSemaphoreById(dc.getSemaphoreId()), dc.getColType(), dc
- .getColFormat(), getReportDefType().equals(
- AppConstants.RD_SQL_BASED)));
-
- if (nvl(dc.getDrillDownURL()).length() > 0) {
- childReportFormFields = getChildReportFormFields(request,dc.getDrillDownURL());
- }
- if (dc.isVisible()) {
- visibleCols.add(count,dc);
- //if(dc.getColId().startsWith("group")) {
- for (int d = 0; d < reportCols.size(); d++) {
- if(reportCols.get(d)!=null) {
- DataColumnType dct1 = (DataColumnType) reportCols.get(d);
- if(dct1.getColId().equals(dc.getColId()+"_name") && ds.getRowCount()>0) {
- displayName = ds.getString(0,dct1.getColId());
- dc.setDisplayName(displayName);
- }
- }
- }
- //}
-
- String widthInPxls = dc.getDisplayWidthInPxls();
-
- if(nvl(widthInPxls).endsWith("px"))
- dc.setDisplayWidthInPxls(widthInPxls);
- else {
- widthInPxls = widthInPxls+"px";
- dc.setDisplayWidthInPxls(widthInPxls+"px");
- }
-
- rd.createColumn(dc.getColId(), dc.getDisplayName(), dc.getDisplayWidthInPxls(), dc.getDisplayHeaderAlignment(),
- visualManager.isColumnVisible(dc.getColId()), visualManager
- .getSortByColId().equals(dc.getColId()) ? visualManager
- .getSortByAscDesc() : null, isRuntimeColSortDisabled(), dc.getLevel()!=null?dc.getLevel():0, dc.getStart()!=null?dc.getStart():0, dc.getColspan()!=null?dc.getColspan():0, dc.isIsSortable()!=null?dc.isIsSortable():false);
- // chr.addColumnHeader(new ColumnHeader(dc.getDisplayName(),
- // (dc.getDisplayWidth()>100)?"10%":(""+dc.getDisplayWidth()+"%")));
- } // if
- else {
- visibleCols.add(count,null);
- rd.createColumn(dc.getColId(), AppConstants.HIDDEN, dc.getDisplayWidthInPxls(), dc.getDisplayHeaderAlignment(),
- false, null,false, dc.getLevel()!=null?dc.getLevel():0, dc.getStart()!=null?dc.getStart():0, dc.getColspan()!=null?dc.getColspan():0, dc.isIsSortable()!=null?dc.isIsSortable():false);
-// formatProcessors.add(count,null);
- }
- count++;
- } // for
-
- ArrayList reportDataList = new ArrayList();
- for (int r = 0; r < ds.getRowCount(); r++) {
- DataRow dr = new DataRow();
- rd.reportDataRows.addDataRow(dr);
-
- for (int c = 0; c < reportCols.size(); c++) {
- if(reportCols.get(c)!=null) {
- DataColumnType dct = (DataColumnType) reportCols.get(c);
- DataValue dv = new DataValue();
- dr.addDataValue(dv);
- dv.setDisplayValue(ds.getString(r, c));
- dv.setColName(dct.getColName());
- dv.setColId(dct.getColId());
- dv.setNowrap(nvl(dct.getNowrap(),"null").equals("false")?"null":nvl(dct.getNowrap(),"null"));
- StringBuffer indentation = new StringBuffer("");
- if(dct.getIndentation()!=null && dct.getIndentation()>0) {
- for (int indent=0; indent< dct.getIndentation(); indent++) {
- indentation.append("\t");
- }
- dv.setNowrap("true");
- }
- dv.setIndentation(indentation.toString());
- if(dct.isVisible()) {
-
- dv.setVisible(true);
- dv.setAlignment(dct.getDisplayAlignment());
- dv.setDisplayTotal(dct.getDisplayTotal());
- dv.setDisplayName(dct.getDisplayName());
-
- if (nvl(dct.getDrillDownURL()).length() > 0) {
-
- if(dv.getDisplayValue().length() > 0) {
- dv.setDrillDownURL(parseDrillDownURL(r, /* c, */ds, dct,request, childReportFormFields));
- dv.setDrillDowninPoPUp(dct.isDrillinPoPUp()!=null?dct.isDrillinPoPUp():false);
- }
-
- if (dv.getDisplayValue().length() == 0) {
- //dv.setDisplayValue("[NULL]");
- dv.setDisplayValue("");
- }
- } // if
-
- } else {
- dv.setVisible(false);
- dv.setHidden(true);
- }
- //System.out.println("in Linear report b4" + dr.getFormatId() + dr.getBgColorHtml() + dv.getDisplayValue());
-
- if(dr.getFormatId()!=null)
- ((FormatProcessor) formatProcessors.get(c)).setHtmlFormatters(dv, dr, true);
- else
- ((FormatProcessor) formatProcessors.get(c)).setHtmlFormatters(dv, dr, false);
-
- //System.out.println("in Linear report After" + dr.getFormatId() + dr.getBgColorHtml() + dv.getDisplayValue());
- } // if reportCols
- } // for
- reportDataList.add(dr);
- } // for
- rd.setReportDataList(reportDataList);
- //Only if rownumber options is needed
- //rd.addRowNumbers(pageNo, getPageSize());
-
- if (colDataTotalsLinear == null)
- colDataTotalsLinear = generateColumnDataTotalsLinear(new ArrayList(reportCols), userId,
- getDbInfo(),request);
- if (displayColTotals && colDataTotalsLinear != null) {
- String totalLabel = "Total";
- if (getReportDataSize() > getPageSize())
- totalLabel += "<br><font size=1>(for all pages)</font>";
-
- rd.setColumnDataTotalsLinear(colDataTotalsLinear, totalLabel);
- } // if
- // Please note the below function doesn't set the visibility for dv since this is set in this function. - Sundar
- rd.applyVisibility();
-
- return rd;
- } // loadHiveLinearReportData
-
- //For Hive reports
- public int getHiveReportCount(String sql) throws RaptorException {
- //select t from (select count(*) t from (select * from program)x)x1;
- int count = 0;
- String countSql = "select t from (select count(*) t from ("+ sql + ")" + (Globals.isPostgreSQL() || Globals.isMySQL() ?" AS ":"") + " x) AS x1";
-
- DataSet ds = null;
- // try {
- String dbInfo = getDBInfo();
- System.out.println("SQL getReportCount()- " + countSql);
- try {
- ds = ConnectionUtils.getDataSet(countSql, dbInfo);
- int totalRows = 0;
- String dbType = "";
- if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) {
- try {
- org.openecomp.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.openecomp.portalsdk.analytics.util.RemDbInfo();
- dbType = remDbInfo.getDBType(dbInfo);
- } catch (Exception ex) {
- throw new RaptorException(ex);
- }
- }
- if( ds.getRowCount()>0) {
- count = Integer.parseInt(ds.getString(0,0));
- }
- } catch (NumberFormatException ex) {}
- return count;
-
- } // getReportCount
-
-
- /*private*/ public ReportFormFields getChildReportFormFields( HttpServletRequest request, String URL ) throws RaptorException {
- String childReportID = getReportID(URL);
-
- ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, childReportID,
- false, 1);
-
- ReportFormFields ddReportFormFields = ddRr.getReportFormFields();
- return ddReportFormFields;
- }
-
- private String getReportID(String URL) {
- URL = nvl(URL);
- int pos = URL.toLowerCase().indexOf("c_master=")+9;
- String reportID = "";
- if(URL.toLowerCase().indexOf("&", pos)!=-1)
- reportID = URL.substring(pos, URL.toLowerCase().indexOf("&", pos));
- else
- reportID = URL.substring(pos);
- return reportID;
-
- }
- /*private*/ public String parseDrillDownURL(int rowIdx, /* int colIdx, */DataSet ds, DataColumnType dct, HttpServletRequest request, ReportFormFields ddReportFormFields)
- throws RaptorException {
- Vector viewActions = DataCache.getDataViewActions();
- javax.servlet.http.HttpSession session = request.getSession();
-
- StringBuffer dUrl = new StringBuffer();
-
- //String childReportID = getReportID(dct.getDrillDownURL());
-
- //ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, childReportID,
- // false, 1);
-
- //ReportFormFields ddReportFormFields = ddRr.getReportFormFields();
-
- boolean isViewAction = false;
- int flag = 0;
- String requestParam ="";
- for (int k = 0; k < viewActions.size(); k++)
- if (dct.getDrillDownURL().equals(
- AppUtils.getBaseActionURL() + ((String) viewActions.get(k))))
- isViewAction = true;
- if (isViewAction) {
- // Drill-down to record details
- String param = nvl(dct.getDrillDownParams()); // i.e.
- // "c_master=[bo1.RECID$]"
- param = param.substring(AppUtils.getBaseActionParam().length() + 1,
- param.length() - 1); // i.e. "bo1.RECID$"
- param = param.replace('.', '_'); // i.e. "bo1.RECID$"
-
- dUrl.append(AppUtils.getBaseActionParam());
- dUrl.append(java.net.URLEncoder.encode(ds.getString(rowIdx, param.toLowerCase())));
- } else {
- // Drill-down to another report
- // Replacing col ids with values
- String param = nvl(dct.getDrillDownParams());
- while (param.indexOf('[') >= 0) {
- int startIdx = param.indexOf('[');
- int endIdx = param.indexOf(']');
- StringBuffer sb = new StringBuffer();
- if(startIdx>endIdx) {
- if (endIdx < param.length() - 1)
- sb.append(param.substring(endIdx + 1));
- param = sb.toString();
- continue;
- }
- if (startIdx > 0)
- sb.append(param.substring(0, startIdx));
-
- if (param.charAt(startIdx + 1) == '!') {
- // Parameter is a form field value
- String fieldId = param.substring(startIdx + 2, endIdx);
- String fieldValue = (String) reportParamValues.get(fieldId);
-
- sb.append(java.net.URLEncoder.encode(nvl(fieldValue)));
- //TODO Add a else if condition to check whether the param is from request Param
- //TODO make a unique symbol like #
- }else if (param.charAt(startIdx + 1) == '#') {
- flag = 1;
- String fieldId = param.substring(startIdx + 2, endIdx);
- String fieldValue = request.getParameter(fieldId);
- sb.append(java.net.URLEncoder.encode(nvl(fieldValue)));
-
- }else {
- // Parameter is a column value
- String fieldValue = "";
- String colValue = null;
- String colId = null;
- if (param.indexOf('!') < 0 || param.indexOf('!') > endIdx)
- colId = param.substring(startIdx + 1, endIdx);
- else {
- // Need to use NVL(column, form field)
- colId = param.substring(startIdx + 1, param.indexOf('!'));
-
- String fieldId = param.substring(param.indexOf('!') + 1, endIdx);
- FormField ff = getFormField(fieldId);
- if (ff.getFieldType().equals(FormField.FFT_TEXTAREA)) {
- fieldValue = reportParamValues.getParamValueforTextAreaDrilldown(fieldId);
- } else
- fieldValue = (String) reportParamValues.get(fieldId);
- } // else
-
- DataColumnType column = getColumnById(colId);
- String columnName = "";
- int groupColumn = 0;
- int groupMatch = 0;
- if(column.getColName().startsWith("[")) {
- groupColumn = 1;
- columnName = column.getDisplayName();
- for(ddReportFormFields.resetNext(); ddReportFormFields.hasNext(); ) {
- FormField ff = ddReportFormFields.getNext();
- if(ff.getFieldDisplayName().toLowerCase().equals(columnName.toLowerCase())) {
- groupMatch = 1;
- sb.delete(sb.lastIndexOf("&")+1, sb.length());
- sb.append(ff.getFieldName()+"=");
- }
- }
- }
- if (groupColumn == 0 || (groupColumn == 1 && groupMatch == 1)) {
- String dependsOn = column.getDependsOnFormField();
- if(nvl(dependsOn).length()>0)
- System.out.println("DependsOn " + dependsOn);
- if (column != null) {
- // if (column.getColType().equals(AppConstants.CT_DATE))
- //if (!nvl(column.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT)
- // .equals(AppConstants.DEFAULT_DATE_FORMAT))
- // Use extra column instead
- //commented out below line usually for Visual
- //colId += AppConstants.DD_COL_EXTENSION;
- colValue = ds.getString(rowIdx, colId.toLowerCase());
- // if SQL-Based and drill-down param is a date, decode
- // it to the expected Oracle format **/
- if (getReportDefType().equals(AppConstants.RD_SQL_BASED))
- if (!getColumnNoParseDateFlag(column))
- if (ReportParamDateValueParser.isDateParam(colValue))
- colValue = ReportParamDateValueParser
- .formatDateParamValue(colValue);
- } // if
-
- String suppressValues = "|" + nvl(dct.getDrillDownType()) + "|";
- if (suppressValues.length() > 2
- && suppressValues.indexOf("|" + colValue + "|") >= 0)
- // Parameter value is suppressed and not passed to the
- // drill-down report
- colValue = null;
-
- sb.append(java.net.URLEncoder.encode(nvl(colValue, fieldValue)));
- } else {
- sb.delete(sb.lastIndexOf("&")+1, sb.length());
- }
- } // else
-
- if (endIdx < param.length() - 1)
- sb.append(param.substring(endIdx + 1));
- param = sb.toString();
- } // while
- if(Globals.getPassRequestParamInDrilldown()) {
- if(param.indexOf('#') < 0) {
- String[] reqParameters = Globals.getRequestParams().split(",");
- String[] sessionParameters = Globals.getSessionParams().split(",");
- for (int i = 0; i < reqParameters.length; i++) {
- if(request.getParameter(reqParameters[i])!=null) {
- if(!reqParameters[i].toUpperCase().startsWith("FF")){
- if(param.length()>0) {
- param += "&" + reqParameters[i]+"="
- + request.getParameter(reqParameters[i]);
- } else {
- param += "&" + reqParameters[i]+"="
- + request.getParameter(reqParameters[i]);
-
- }
- }
- }
- }
- for (int i = 0; i < sessionParameters.length; i++) {
- if(session.getAttribute(sessionParameters[i].toUpperCase())!=null) {
- if(!sessionParameters[i].toUpperCase().startsWith("FF")){
- if(param.length()>0) {
- param += "&" + sessionParameters[i].toUpperCase()+"="
- + (String)session.getAttribute(sessionParameters[i].toUpperCase());
- } else {
- param += "&" + sessionParameters[i].toUpperCase()+"="
- + (String)session.getAttribute(sessionParameters[i].toUpperCase());
-
- }
- }
- } else {
- param += "&" + sessionParameters[i].toUpperCase()+"="
- + (String)session.getAttribute(sessionParameters[i]);
-
- }
- }
-
- }
- }
-
- dUrl.append(param.toString());
- dUrl.append("&");
- dUrl.append(AppConstants.RI_DISPLAY_CONTENT);
- dUrl.append("=Y");
- dUrl.append("&");
- if(dct.isDrillinPoPUp()==null || (!dct.isDrillinPoPUp().booleanValue())) {
- dUrl.append(AppConstants.RI_SHOW_BACK_BTN);
- dUrl.append("=Y");
- dUrl.append("&");
- }
- dUrl.append(AppConstants.DRILLDOWN_INDEX);
- int index = Integer.parseInt(nvl(AppUtils.getRequestValue(request, AppConstants.DRILLDOWN_INDEX), "0"));
- /*
- int form_index = Integer.parseInt(nvl(AppUtils.getRequestValue(request, AppConstants.FORM_DRILLDOWN_INDEX), "0"));
- index = index>0 ? --index : 0;
- form_index = form_index>0 ? --form_index : 0;*/
- request.setAttribute(AppConstants.DRILLDOWN_INDEX, Integer.toString(index));
- /*session.setAttribute(AppConstants.DRILLDOWN_INDEX, Integer.toString(index));
- request.setAttribute(AppConstants.FORM_DRILLDOWN_INDEX, Integer.toString(form_index));
- session.setAttribute(AppConstants.FORM_DRILLDOWN_INDEX, Integer.toString(form_index));*/
-
- dUrl.append("=" + AppUtils.getRequestNvlValue(request, AppConstants.DRILLDOWN_INDEX));
-
- //TODO Add a if condition to check whether the param is request Param
- } // if
-
- if (dUrl.length() > 0)
- dUrl.insert(0, ((dct.getDrillDownURL()).indexOf('&') > 0) ? '&' : '&');
- dUrl.insert(0, AppUtils.getDrillActionURL()+dct.getDrillDownURL());
-
- //debugLogger.debug(" [[[[[[[[[[[[[[[[ " + dUrl);
-
- return dUrl.toString();
- } // parseDrillDownURL
-
- /** *********************************************************************************** */
-
- public DataRow generateColumnDataTotalsLinear(ArrayList reportCols, String userId,
- String dbInfo, HttpServletRequest request) throws RaptorException {
- DataRow dr = null;
-
- displayColTotals = false;
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
-
- DataColumnType dct = (DataColumnType) iter.next();
- if( dct != null ) {
- if (nvl(dct.getDisplayTotal()).length() > 0) {
- displayColTotals = true;
- break;
- } // if
- } // if checking dct
- } // for
-
- DataSet ds = null;
- if (displayColTotals) {
- dr = new DataRow();
- // ds =
- // DbUtils.executeQuery(generateTotalSQLLinear(reportParamValues,
- // userId));
- ds = ConnectionUtils.getDataSet(generateTotalSQLLinear(reportParamValues, userId,request),
- dbInfo);
-
- for (int c = 0; c < reportCols.size(); c++) {
- DataColumnType dct = (DataColumnType) reportCols.get(c);
- if ( dct != null ) {
- DataValue dv = new DataValue();
- if(dv.isVisible())
- dr.addDataValue(dv);
-
- String totalValue = "";
- if (ds != null)
- totalValue = ds.getString(0, c);
- if (nvl(dct.getDisplayTotal()).length() > 0
- && (!dct.getDisplayTotal().equals(AppConstants.TOTAL_SUM_ID)))
- totalValue = nvl(AppConstants.TOTAL_FUNCTIONS.getNameById(dct
- .getDisplayTotal()))
- + ": " + totalValue;
- dv.setDisplayValue(Utils.truncateTotalDecimals(totalValue));
-
- dv.setAlignment(dct.getDisplayAlignment());
- dv.setColName(dct.getColName());
- dv.setDisplayName(dct.getDisplayName());
- dv.setColId(dct.getColId());
- dv.setNowrap(nvl(dct.getNowrap(),"null").equals("false")?"null":nvl(dct.getNowrap(),"null"));
- StringBuffer indentation = new StringBuffer("");
- if(dct.getIndentation()!=null && dct.getIndentation()>0) {
- for (int indent=0; indent< dct.getIndentation(); indent++) {
- indentation.append("\t");
- }
- dv.setNowrap("true");
- }
- dv.setIndentation(indentation.toString());
- dv.setDisplayTotal(dct.getDisplayTotal());
- dv.setBold(true);
- } // dct check
- } // for
- }
-
- return dr;
- } // generateColumnDataTotalsLinear
-
- private Vector generateDataTotalsCrossTab(String rowColPos, String userId, HttpServletRequest request)
- throws RaptorException {
- String sql = getWholeSQL();
- Vector dataTotals = new Vector();
-
- boolean displayTotals = ((rowColPos.length() == 0) || (getCrossTabDisplayTotal(
- rowColPos).length() > 0));
- if (rowColPos.equals(AppConstants.CV_COLUMN))
- displayColTotals = displayTotals;
- else if (rowColPos.equals(AppConstants.CV_ROW))
- displayRowTotals = displayTotals;
-
- if (displayTotals) {
- // DataSet ds =
- // DbUtils.executeQuery(generateTotalSQLCrossTab(reportParamValues,
- // rowColPos, userId));
- String executeSql = generateTotalSQLCrossTab(
- sql, rowColPos, userId, request, reportParamValues);
- DataSet ds = ConnectionUtils.getDataSet(executeSql, getDbInfo());
-
- for (int i = 0; i < ds.getRowCount(); i++) {
- Vector headerValues = new Vector();
- String totalValue = null;
-
- int cPos = 0;
- for (Iterator iter = getAllColumns().iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
-
- if (rowColPos.length() > 0
- && nvl(dct.getCrossTabValue()).equals(rowColPos)) {
- DataValue dataValue = new DataValue();
- dataValue.setBold(true);
- dataValue.setAlignment("center");
- dataValue.setDisplayValue(ds.getString(i, cPos++));
- headerValues.add(dataValue);
-
- //headerValues.add(ds.getString(i, cPos++));
- }
- else if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_VALUE))
- totalValue = ds.getString(i, cPos++);
- } // for
-
- dataTotals.add(new CrossTabTotalValue(headerValues, Utils
- .truncateTotalDecimals(totalValue)));
- } // for
- } // if
-
- return dataTotals;
- } // generateDataTotalsCrossTab
-
- /** *********************************************************************************** */
-
- public void hideColVisual(String colId) {
- visualManager.hideColumn(colId);
- if (pageDataCache != null)
- pageDataCache.columnVisualShowHide(colId, false);
- } // hideColVisual
-
- public void showColVisual(String colId) {
- visualManager.showColumn(colId);
- if (pageDataCache != null)
- pageDataCache.columnVisualShowHide(colId, true);
- } // showColVisual
-
- public void sortColVisual(String colId) {
- visualManager.setSortByColumn(colId);
- resetCache(true);
-
- pageDataCache = null;
- cachedPageNo = -1;
- } // sortColVisual
-
- /** *********************************************************************************** */
-
- public String generateDistinctValuesSQL(DataColumnType dct, String userId, HttpServletRequest request) throws RaptorException {
- return super.generateDistinctValuesSQL(reportParamValues, dct, userId, request);
- } // generateDistinctValuesSQL
-
- public String getDbInfo() {
- return this.cr.getDbInfo();
- }
-
- private String fixSQL(StringBuffer sql) {
- int pos = 0;
- int pos_f_format = 0;
- int pos_t_format = 0;
- int pos_alias = 0;
- String format = "";
- String alias = null;
- if(sql.indexOf("SELECT", 7)!= -1) {
- pos = sql.indexOf("SELECT", 7);
- if(sql.indexOf("TO_CHAR", pos)!= -1){
- pos = sql.indexOf("TO_CHAR", pos);
- if(sql.indexOf("999",pos)!= -1) {
- pos = sql.indexOf("999",pos);
- pos_f_format = sql.lastIndexOf(", '", pos);
- if(pos_f_format == -1 || (pos - pos_f_format > 10)) {
- pos_f_format = sql.lastIndexOf(",'", pos);
- pos_f_format -= 1;
- }
- pos = pos_f_format;
- if(sql.indexOf("')", pos)!= -1) {
- pos_t_format = sql.indexOf("')", pos);
- //debugLogger.debug("pos_t - " + pos_t_format + " " + pos);
- if(pos_t_format == -1 || (pos_t_format - pos > 20)) {
- pos_t_format = sql.indexOf("' )", pos);
- pos_t_format += 3;
- }
- else if (pos_t_format != -1)
- pos_t_format += 2;
- format = sql.substring(pos_f_format+3, pos_t_format);
- //alias = sql.substring(pos_t_format+3, pos_t_format+6);
- pos_alias = sql.indexOf(" ", pos_t_format);
- alias = sql.substring(pos_alias+1, pos_alias+4);
- }
- }
- }
-
- if(sql.indexOf(alias)!=-1) {
- pos = sql.indexOf(alias);
- //debugLogger.debug(pos + " " + alias.length()+1 + "\n" + sql);
- sql.delete(pos,pos+4);
- sql.insert(pos, "TO_NUMBER("+alias+", '"+format+"')),'"+ format + "')");
- pos = sql.lastIndexOf("SUM", pos);
- if(pos==-1)
- pos = sql.lastIndexOf("AVG", pos);
- else if (pos==-1)
- pos = sql.lastIndexOf("COUNT", pos);
- else if (pos == -1)
- pos = sql.lastIndexOf("STDDEV", pos);
- else if (pos == -1)
- pos = sql.lastIndexOf("VARIANCE", pos);
- sql.insert(pos, "TO_CHAR (");
- }
-
- }
-
- //debugLogger.debug("Alias|" + alias + "| Format " + format);
- //debugLogger.debug(sql.toString());
- return sql.toString();
- } // FixSQL
-
- public String parseReportSQL(String sql) throws RaptorException {
- StringBuffer parsedSQL = new StringBuffer();
-
- Vector updatedReportCols = new Vector();
-
- curSQLParsePos = 0;
- int lastParsePos = curSQLParsePos;
- String lastToken = null;
- logger.debug(EELFLoggerDelegate.debugLogger, ("Flat File parseReportSQL ******* SQL " + sql));
- sql = sql.replaceAll("([\\s]*\\() (?!FROM)", "(");
- sql = sql.replaceAll("[\\s]*\\)", ")");
- //sql = sql.replaceAll("[dD][eE][cC][oO][dD][eE] ", "decode");
- //sql = sql.replaceAll("[\\s]*\\(", "(");
- //sql = replaceNewLine(sql, "decode ", "decode");
- //sql = replaceNewLine(sql, "DECODE ", "decode");
- //sql = replaceNewLine(sql, "Decode ", "decode");
-
- String nextToken = getNextSQLParseToken(sql, true);
- String dbInfo = getDbInfo();
- boolean isCYMBALScript = false;
- if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) {
- try {
- org.openecomp.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.openecomp.portalsdk.analytics.util.RemDbInfo();
- String dbType = remDbInfo.getDBType(dbInfo);
- if (dbType.equals("DAYTONA") && !(nextToken.toUpperCase().equals("SELECT"))) {
- isCYMBALScript = true;
- }
- } catch (Exception ex) {
- throw new RaptorException(ex);
- }
- }
- if ( isCYMBALScript == false ) {
- while (nextToken.length() > 0) {
- //System.out.println("LastToken " + lastToken + " NextToken " + nextToken);
-
-
- if (parsedSQL.length() == 0) {
- if (nextToken.toUpperCase().equals("SELECT"))
- parsedSQL.append("SELECT ");
- else
- throw new org.openecomp.portalsdk.analytics.error.ValidationException(
- "The SQL must start with the SELECT keyword.");
- } else if (nextToken.toUpperCase().equals("DISTINCT")
- && parsedSQL.toString().equals("SELECT ")) {
- parsedSQL.append("DISTINCT ");
- } else if (nextToken.equals("*")
- && (parsedSQL.toString().equals("SELECT ") || parsedSQL.toString().equals(
- "SELECT DISTINCT "))) {
- throw new org.openecomp.portalsdk.analytics.error.ValidationException(
- "You cannot use \"SELECT *\". Please specify select columns/expressions.");
- } else if (nextToken.toUpperCase().equals("FROM")) {
- if (lastToken != null) {
- updatedReportCols.add(getParseSQLDataColumn(lastToken, null, parsedSQL,
- updatedReportCols, false));
- lastToken = null;
- }
-
- parsedSQL.append(" \n");
- while (lastParsePos < sql.length()
- && Character.isWhitespace(sql.charAt(lastParsePos)))
- lastParsePos++;
- parsedSQL.append(sql.substring(lastParsePos));
- break;
- } else {
- //System.out.println("Next Token " + nextToken);
- if (nextToken.charAt(nextToken.length() - 1) == ',') {
- // The token ends with ,
- nextToken = nextToken.substring(0, nextToken.length() - 1);
-
- if (nextToken.length() == 0) {
- if (lastToken != null) {
- updatedReportCols.add(getParseSQLDataColumn(lastToken, null,
- parsedSQL, updatedReportCols, false));
- lastToken = null;
- } // else just comma => ignore it
- } else {
- //System.out.println("Next Token " + nextToken + " is Here" + " Last Token " + lastToken);
- if (lastToken != null) {
- updatedReportCols.add(getParseSQLDataColumn(lastToken, nextToken,
- parsedSQL, updatedReportCols, false));
- lastToken = null;
- } else
- updatedReportCols.add(getParseSQLDataColumn(nextToken, null,
- parsedSQL, updatedReportCols, false));
- }
- } else {
- // The token doesn't end with ,
- if (lastToken == null)
- lastToken = nextToken;
- else {
- String token = getNextSQLParseToken(sql, false);
- //System.out.println(" ********** " + token + " " + lastToken);
- if (!token.toUpperCase().equals("FROM"))
- throw new org.openecomp.portalsdk.analytics.error.ValidationException(
- "|FROM keyword or a comma expected after [" + nextToken
- + "].");
- //System.out.println("Next Token " + nextToken);
- updatedReportCols.add(getParseSQLDataColumn(lastToken, nextToken,
- parsedSQL, updatedReportCols, false));
- lastToken = null;
- } // else
- } // else
- } // else
-
- lastParsePos = curSQLParsePos;
- nextToken = getNextSQLParseToken(sql, true);
- } // while
- } else { // if CYMBAL Script
- nextToken = getNextCYMBALSQLParseToken(sql, true);
- Pattern re = null;
- Matcher matcher = null;
- String extracted = null;
- while (nextToken.length() > 0) {
- if (lastToken == null) lastToken = nextToken;
-
- if( lastToken.toUpperCase().equals("DO DISPLAY")) {
- re = Pattern.compile("each(.*)\\[.(.*?)\\]"); //\\[(.*?)\\]
- matcher = re.matcher(nextToken);
- if (matcher.find()) {
- extracted = matcher.group();
- re = Pattern.compile("\\[(.*?)\\]");
- matcher = re.matcher(nextToken);
- if(matcher.find()) {
- extracted = matcher.group();
- extracted = extracted.substring(1,extracted.length()-2);
- StringTokenizer sToken = new StringTokenizer(extracted);
- while(sToken.hasMoreTokens()) {
- updatedReportCols.add(getParseSQLDataColumn("", sToken.nextToken(),
- new StringBuffer(""), updatedReportCols, true));
- }
- }
-
- }
-
- }
- lastToken = nextToken;
- nextToken = getNextCYMBALSQLParseToken(sql, true);
- }
- }
-
- if (updatedReportCols.size() == 0)
- throw new org.openecomp.portalsdk.analytics.error.ValidationException(
- "The SQL statement must have at least one column in the SELECT clause.");
-
-
- return parsedSQL.toString();
-
- } // parseReportSQL
-
- private String getNextCYMBALSQLParseToken(String sql, boolean updateParsePos) {
- int braketCount = 0;
- boolean isInsideQuote = false;
- StringBuffer nextToken = new StringBuffer();
- for (int idxNext = curSQLParsePos; idxNext < sql.length(); idxNext++) {
- char ch = sql.charAt(idxNext);
-
- if (ch!='\n')
- nextToken.append(ch);
- else break;
- } // for
-
- return nextToken.toString();
- } // getNextSQLParseToken
-
- private String getNextSQLParseToken(String sql, boolean updateParsePos) {
- int braketCount = 0;
- boolean isInsideQuote = false;
- StringBuffer nextToken = new StringBuffer();
- for (int idxNext = curSQLParsePos; idxNext < sql.length(); idxNext++) {
- char ch = sql.charAt(idxNext);
-
- if (Character.isWhitespace(ch) || ch == ',') {
- if (ch == ',')
- nextToken.append(ch);
-
- if (nextToken.length() == 0)
- continue;
- else if (braketCount == 0 && (!isInsideQuote)) {
- if (updateParsePos)
- curSQLParsePos = idxNext + ((ch == ',') ? 1 : 0);
- break;
- } else if (ch != ',' && nextToken.charAt(nextToken.length() - 1) != ' ')
- nextToken.append(' ');
- } else {
- nextToken.append(ch);
-
- if (ch == '(' || ch == '[')
- braketCount++;
- else if (ch == ')' || ch == ']')
- braketCount--;
- else if (ch == '\''/* ||ch=='\"' */)
- isInsideQuote = (!isInsideQuote);
- } // else
- } // for
-
- return nextToken.toString();
- } // getNextSQLParseToken
-
- private DataColumnType getParseSQLDataColumn(String sqlExpression, String colId,
- StringBuffer parsedSQL, Vector updatedReportCols, boolean isCYMBALScript) throws RaptorException {
- DataColumnType dct = null;
-
- if (colId != null) {
- if (!isParseSQLColID(colId))
- throw new org.openecomp.portalsdk.analytics.error.ValidationException(
- "["
- + colId
- + "] must either be a valid column id consisting only of letters, numbers, and underscores, or there must be a comma in front of it.");
-
- dct = getColumnById(colId);
- } else {
- // Getting unique column id
- colId = "";
- int colIdN = 0;
- for (int i = 0; (i < sqlExpression.length()) && (colIdN < 2); i++)
- if (Character.isLetter(sqlExpression.charAt(i))) {
- colId += sqlExpression.toLowerCase().charAt(i);
- colIdN++;
- } // if
-
- colIdN = getAllColumns().size() + updatedReportCols.size();
- for (boolean idAlreadyUsed = true; idAlreadyUsed; colIdN++) {
- String newColId = colId + colIdN;
- idAlreadyUsed = false;
-
- for (Iterator iter = getAllColumns().iterator(); iter.hasNext();)
- if (newColId.equals(((DataColumnType) iter.next()).getColId())) {
- idAlreadyUsed = true;
- break;
- }
-
- if (!idAlreadyUsed)
- for (Iterator iter = updatedReportCols.iterator(); iter.hasNext();)
- if (newColId.equals(((DataColumnType) iter.next()).getColId())) {
- idAlreadyUsed = true;
- break;
- }
- } // for
-
- colId += (colIdN - 1);
- } // else
-
- if (dct == null) {
- dct = (new ObjectFactory()).createDataColumnType();
- dct.setColId(colId);
- dct.setDisplayWidth(10);
- dct.setDisplayAlignment("Left");
- dct.setVisible(true);
- dct.setGroupBreak(false); // ???
-
- boolean isValidIdentifier = Character.isLetterOrDigit(sqlExpression.charAt(0));
- for (int i = 0; i < sqlExpression.length(); i++)
- if (!(Character.isLetterOrDigit(sqlExpression.charAt(i))
- || (sqlExpression.charAt(i) == '_') || (sqlExpression.charAt(i) == '$'))) {
- isValidIdentifier = false;
- break;
- } // if
-
- if (isValidIdentifier) {
- dct.setDisplayName(sqlExpression);
- } else {
- dct.setDisplayName(colId);
- } // else
- } // if
- if(!isCYMBALScript)
- sqlExpression = sqlExpression.replaceAll(", '", ",'");
- dct.setDbColName(sqlExpression);
- dct.setColName(sqlExpression);
- dct.setCalculated(true);
- dct.setColType(AppConstants.CT_CHAR);
- dct.setDbColType(AppConstants.CT_CHAR);
- adjustColumnType(dct); // ???
-
- if(!isCYMBALScript) {
- if (parsedSQL.toString().equals("SELECT ")
- || parsedSQL.toString().equals("SELECT DISTINCT "))
- parsedSQL.append("\n\t");
- else
- parsedSQL.append(", \n\t");
- parsedSQL.append(sqlExpression);
- parsedSQL.append(" ");
- parsedSQL.append(colId);
- }
-
- return dct;
- } // getParseSQLDataColumn
-
- private boolean isParseSQLColID(String token) {
- if (nvl(token).length() == 0)
- return false;
-
- for (int i = 0; i < token.length(); i++) {
- char ch = token.charAt(i);
-
- if (i == 0 && ch == '_')
- return false;
-
- if (!(Character.isLetterOrDigit(ch) || ch == '_'))
- return false;
- } // for
-
- return true;
- } // isParseSQLColID
-
- /*private*/ public String parseReportSQLForDrillDownParams(String reportSQL, DataColumnType dataColumnRequest, HttpServletRequest request){
- String param = nvl(dataColumnRequest.getDrillDownParams());
- String sql = reportSQL;
- int pos = 0;
- while (param.indexOf('[', pos) >= 0) {
- int startIdx = param.indexOf('[',pos);
- int endIdx = param.indexOf(']',startIdx+1);
- pos = startIdx+1;
- StringBuffer sb = new StringBuffer();
- if (startIdx > 0)
- sb.append(param.substring(0, startIdx));
- else break;
-
- if (param.charAt(startIdx + 1) == '#') {
- // Parameter is a form field value
- String fieldId = param.substring(startIdx + 2, endIdx);
- String fieldValue = request.getParameter(fieldId);
- sql = Utils.replaceInString(sql, "[" + fieldId.toUpperCase()+"]", fieldValue );
- }
- }
- return sql;
- }
-
-public List getMapMarkers(ReportData rd, org.openecomp.portalsdk.analytics.xmlobj.ReportMap xmlmap){
-
- ArrayList markers = new ArrayList();
- int rNum = 0;
- HashMap colHash = new HashMap();
-
- for(rd.reportDataRows.resetNext(); rd.reportDataRows.hasNext(); rNum++) {
- DataRow dr = rd.reportDataRows.getNext();
- for(dr.resetNext(); dr.hasNext(); ) {
- DataValue dv = dr.getNext();
- colHash.put(dv.getColId(), dv.getDisplayValueLinkHtml());
- }
-
- for (int i = 0; i < xmlmap.getMarkers().size(); i ++){
- Marker marker = new Marker("", "", "");
- org.openecomp.portalsdk.analytics.xmlobj.Marker m = (org.openecomp.portalsdk.analytics.xmlobj.Marker) xmlmap.getMarkers().get(i);
- String address = (String) colHash.get(m.getAddressColumn());
- String data = (String) colHash.get(m.getDataColumn());
- marker.setAddress(address);
- if (xmlmap.getAddAddressInDataYN() != null && xmlmap.getAddAddressInDataYN().equals("Y")){
- marker.setData(address + "<br/>" + data);
- }
- else{
- marker.setData(data);
- }
- marker.setColor(m.getMarkerColor());
- markers.add(marker);
- System.out.println("%%%%%%%%%%%% marker is : " + address + data);
- }
-
- }
-
- return markers;
- }
-
-
-
- public ReportParamValues getReportParamValues() {
- return reportParamValues;
- }
-
- public String getFormFieldFilled(String title) {
- if( getFormFieldList()!=null && reportParamValues!=null && nvl(title).length()>0) {
- for (Iterator iter1 = getFormFieldList().getFormField().iterator(); iter1.hasNext();) {
- FormFieldType fft = (FormFieldType) iter1.next();
- String fieldDisplay = getFormFieldDisplayName(fft);
- String fieldId = fft.getFieldId();
- if(!fft.getFieldType().equals(FormField.FFT_BLANK) && !fft.getFieldType().equals(FormField.FFT_LIST_MULTI) && !fft.getFieldType().equals(FormField.FFT_TEXTAREA)) {
- String paramValue = Utils.oracleSafe(nvl(reportParamValues.getParamValue(fieldId)));
- title = Utils.replaceInString(title, fieldDisplay, nvl(
- paramValue, ""));
- }
- }
- }
- return title;
- }
-// public static void main (String args[])throws Exception {
-// ReportRuntime rr = new ReportRuntime();
-// String sql= " SELECT NULL TOTAL_AC20, NULL TOTAL_AC21, NULL TOTAL_AC22, NULL TOTAL_CO1, NULL TOTAL_BR2, NULL TOTAL_CO3, NULL TOTAL_CO4, NULL TOTAL_HO20, NULL TOTAL_DU9, NULL TOTAL_HO19, NULL TOTAL_CU10, NULL TOTAL_AC11,TO_CHAR (SUM(TO_NUMBER (SE29,'$9,999,999,990.99')),'$9,999,999,990.99') TOTAL_SE29,TO_CHAR (SUM(TO_NUMBER (BR6,'$9,999,999,990.99')),'$9,999,999,990.99') TOTAL_BR6,TO_CHAR (SUM(TO_NUMBER (TR7,'$9,999,999,990.99')),'$9,999,999,990.99') TOTAL_TR7,TO_CHAR (SUM(TO_NUMBER (FE8,'$9,999,999,990.99')),'$9,999,999,990.99') TOTAL_FE8,TO_CHAR (SUM(TO_NUMBER (TA12,'$9,999,999,990.99')),'$9,999,999,990.99') TOTAL_TA12,TO_CHAR (SUM(TO_NUMBER (UN13,'$9,999,999,990.99')),'$9,999,999,990.99') TOTAL_UN13,TO_CHAR (SUM(TO_NUMBER (TA27,'$9,999,999,990.99')),'$9,999,999,990.99') TOTAL_TA27,TO_CHAR (SUM(TO_NUMBER (TA28,'$9,999,999,990.99')),'$9,999,999,990.99') TOTAL_TA28, NULL TOTAL_CU20, NULL TOTAL_MG23, NULL TOTAL_CU27, NULL TOTAL_CU24, NULL TOTAL_CU28, NULL TOTAL_AC24, NULL TOTAL_CU21, NULL TOTAL_RE25, NULL TOTAL_BI29 FROM (SELECT substr(ACCT_ID,1,3) ac20, substr(ACCT_ID,5,5) ac21, substr(ACCT_ID,11,25) ac22, ci1.CONF_ID co1, ci1.BRIDGE_ID br2, ci1.CONF_RESERVE_DATE co3, ci1.CONF_RESERVE_TIME co4, ci1.HOST_PARTICIPANT_NUMBER ho20, to_number(duration_in_minutes) du9, ci1.HOST_PARTICIPANT_NAME ho19, ci1.CUSTOMER_CONF_ID cu10, ci1.ACCESS_METHOD ac11, TO_CHAR(ci1.SETUP_CHARGES,'$9,999,999,990.99') se29, TO_CHAR(ci1.BRIDGE_CHARGES,'$9,999,999,990.99') br6, TO_CHAR(ci1.TRANSPORT_CHARGES,'$9,999,999,990.99') tr7, TO_CHAR(ci1.FEATURES_CHARGES,'$9,999,999,990.99') fe8, TO_CHAR(ci1.TAXES,'$9,999,999,990.99') ta12, TO_CHAR(Univ_connect_charges+admin_exp_fee+nvl(property_tax_allotment,0)+nvl(federal_regulatory_fee,0),'$9,999,999,990.99') un13, TO_CHAR(setup_charges+Bridge_charges + transport_charges + features_charges-discount,'$9,999,999,990.99') ta27, TO_CHAR(setup_charges + bridge_charges + transport_charges + features_charges + taxes + univ_connect_charges+admin_exp_fee+nvl(property_tax_allotment,0)+nvl(federal_regulatory_fee,0)-discount,'$9,999,999,990.99') ta28, ci1.CUST_ID cu20, ci2.MGD_SVC_FEE mg23, NULL cu27, to_char( DURATION_IN_MINUTES * mgd_svc_fee ,'$9,990.99') cu24, NULL cu28, ci2.ACCESS_DESCRIPTION ac24, decode ( cust_id , '0011681500002' , '00002' , decode ( cust_id , '0011681500092' , '00092' , decode ( cust_id , '0011681500093' , '00093' , substr(cust_id,9,5) ))) cu21, ci1.RECORD_TYPE re25, ci1.BILL_MONTH bi29 FROM CIS_AUDIO ci1, CIS_MGD_SVC_FEE ci2 WHERE ci2.ACCESS_METHOD (+)=ci1.ACCESS_METHOD AND substr(ACCT_ID,1,3) = '215' AND decode ( cust_id , '0011681500002' , '00002' , decode ( cust_id , '0011681500092' , '00092' , decode ( cust_id , '0011681500093' , '00093' , substr(cust_id,9,5) ))) IN ('00002') AND ci1.BILL_MONTH = 'NOV 2006' ORDER BY ci1.ACCESS_METHOD ASC) totalSQL";
-// rr.parseReportSQL(sql);
-// }
-
- public synchronized Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- // this shouldn't happen, since we are Cloneable
- throw new InternalError("Cloning throws error.");
- }
- }
-
- /* private Vector addForecastData(String sql) throws Exception {
- InstanceQuery instTrainQuery = new InstanceQuery();
- //instTrainQuery.setDatabaseURL("jdbc:idb:=experiments.prp");
- instTrainQuery.setUsername("fusionapp");
- instTrainQuery.setPassword("i64eq4aunp");
- Instances data = instTrainQuery.retrieveInstances(sql);
-
- ArrayList<String> forecastArray = new ArrayList<String>();
-
- List reportCols = getAllColumns();
- DataColumnType dct = null;
- Iterator iter = null;
-
- String dateAttribute = "";
-
- for(iter=reportCols.iterator(); iter.hasNext(); ) {
- dct = (DataColumnType) iter.next();
- if(nvl(dct.getDataMiningCol()).equals(AppConstants.DM_FORECASTING_ATTR))
- forecastArray.add(dct.getColId().toUpperCase());
- }
-
- for(iter=reportCols.iterator(); iter.hasNext(); ) {
- dct = (DataColumnType) iter.next();
- if(nvl(dct.getDataMiningCol()).equals(AppConstants.DM_DATE_ATTR))
- dateAttribute = dct.getColId().toUpperCase();
- }
-
-
- int forecastUnits = getForecastingPeriod();
- // new forecaster
- WekaForecaster forecaster = new WekaForecaster();
-
- // set the targets we want to forecast. This method calls
- // setFieldsToLag() on the lag maker object for us
- StringBuffer forecastAttribute = new StringBuffer("");
- for (int i=0; i < forecastArray.size(); i++) {
- forecastAttribute.append(forecastArray.get(i));
- if(i<forecastArray.size()-1) forecastAttribute.append(",");
- }
- forecaster.setFieldsToForecast(forecastAttribute.toString());
-
- // default underlying classifier is SMOreg (SVM) - we'll use
- // gaussian processes for regression instead
- if(getClassifier().equals(AppConstants.DM_GAUSSIAN_CLASSIFIER))
- forecaster.setBaseForecaster(new GaussianProcesses());
- else if (getClassifier().equals(AppConstants.DM_SVM_CLASSIFIER))
- forecaster.setBaseForecaster(new weka.classifiers.functions.SMOreg());
-
- forecaster.getTSLagMaker().setTimeStampField(dateAttribute); // date time stamp
- forecaster.getTSLagMaker().setMinLag(1);
- forecaster.getTSLagMaker().setMaxLag(12); // monthly data
-
- // add a month of the year indicator field
- forecaster.getTSLagMaker().setAddMonthOfYear(true);
-
- // add a quarter of the year indicator field
- forecaster.getTSLagMaker().setAddQuarterOfYear(true);
-
- // build the model
- forecaster.buildForecaster(data, System.out);
-
- // prime the forecaster with enough recent historical data
- // to cover up to the maximum lag. In our case, we could just supply
- // the 12 most recent historical instances, as this covers our maximum
- // lag period
- forecaster.primeForecaster(data);
-
- // forecast for 12 units (months) beyond the end of the
- // training data
- List<List<NumericPrediction>> forecast = forecaster.forecast(getForecastingPeriod(), System.out);
-
- String dateFormat = "";
- if(nvl(getForecastingTimeFormat()).length()>0)
- dateFormat = getForecastingTimeFormat();
- java.text.SimpleDateFormat sdf = null;
- java.text.SimpleDateFormat sdf1 = null;
- java.text.SimpleDateFormat sdf2 = null;
- if(dateFormat.equals("Default")) {
- sdf = new SimpleDateFormat("yyyy-MM-dd\'T\'HH:mm:ss");
- sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- } else {
- sdf = new SimpleDateFormat("yyyy-MM-dd\'T\'HH:mm:ss");
- sdf1 = new SimpleDateFormat(dateFormat);
- sdf2 = new SimpleDateFormat("MM/yyyy");
- }
- // output the predictions. Outer list is over the steps; inner list is over
- // the targets
- int k = 0;
- int flag = 0;
- Enumeration<Attribute> enum1 = data.lastInstance().enumerateAttributes();
- Attribute attrib = null;
-
- HashMap<String, Object> predictedHashMap = new HashMap<String, Object>();
-
- while(enum1.hasMoreElements()) {
- attrib = enum1.nextElement();
- System.out.println(attrib.name() + " " + attrib.index());
- }
- Vector<Vector> forecastedDataSet = new Vector<Vector>();
- Vector forecastedData = new Vector();
- Date d = null;
- Date forecastedDate = null;
- Calendar c1 = Calendar.getInstance();
- for (int i = 0; i < forecastUnits; i++) {
- TSLagMaker ts = forecaster.getTSLagMaker();
- //java.sql.Timestamp ts1 = new java.sql.Timestamp(new Long(ts.getCurrentTimeStampValue()).longValue());
- //System.out.println(data.lastInstance().dataset().attribute(0).getDateFormat());//parseDate("yyyy-MM-dd\'T\'HH:mm:ss")
- //System.out.println(data.lastInstance().dataset().lastInstance().stringValue(0) + " " + sdf.parse(data.lastInstance().dataset().lastInstance().stringValue(0)));
- d = sdf.parse(data.lastInstance().dataset().lastInstance().stringValue(0));
- c1.setTime(d);
- c1.add(Calendar.MONTH, i+1);
- forecastedDate = c1.getTime();
- List<NumericPrediction> predsAtStep = forecast.get(i);
- predictedHashMap.put(dateAttribute, sdf1.format(forecastedDate));
- predictedHashMap.put(dateAttribute+"_FORMAT", sdf2.format(forecastedDate));
-
- for (int j = 0; j < forecastArray.size(); j++) {
- NumericPrediction predForTarget = predsAtStep.get(j);
- predictedHashMap.put(forecastArray.get(j), new Integer(new Double(predForTarget.predicted()).intValue()).toString());
- //System.out.print(forecastArray.get(j)+" " + predForTarget.predicted());
- }
-
- enum1 = data.lastInstance().enumerateAttributes();
- while(enum1.hasMoreElements()) {
- attrib = enum1.nextElement();
- if((!attrib.name().equals(dateAttribute)) && (!attrib.name().equals(dateAttribute+"_FORMAT"))){
- for (int h=0; h < forecastArray.size(); h++) {
- if(attrib.name().equals(forecastArray.get(h))) {
- forecastedData.add(predictedHashMap.get(attrib.name()));
- flag = 1;
- }
-
- }
- } else if(attrib.name().equals(dateAttribute+"_FORMAT")) {
- forecastedData.add(predictedHashMap.get(dateAttribute+"_FORMAT"));
- flag = 1;
- } else if(attrib.name().equals(dateAttribute)) {
- forecastedData.add(predictedHashMap.get(dateAttribute));
- flag = 1;
- }
- if(flag == 0) {
- forecastedData.add("");
- } / *else {
- forecastedData.add(predictedHashMap.get(dateAttribute));
- forecastedData.add(predictedHashMap.get(dateAttribute+"_format"));
- }* /
- //System.out.println(attrib.name() + " " + attrib.index());
-
-
-
-
-
- flag = 0;
-
- }
- forecastedDataSet.add(forecastedData);
- predictedHashMap = new HashMap<String, Object>();
- forecastedData = new Vector();
- enum1 = data.lastInstance().enumerateAttributes();
- }
- setReportDataSize(getReportDataSize()+getForecastingPeriod());
- return forecastedDataSet;
- } */
-
- public VisualManager getVisualManager() {
- return visualManager;
- }
-
- public String getReportSQLWithRowNum(String _orderBy, boolean asc) {
- String sql = getWholeSQL();
- int closeBracketPos = 0;
- /*if (nvl(_orderBy).length() > 0) {
- if(sql.lastIndexOf(")")!= -1) closeBracketPos = sql.lastIndexOf(")");
- int idxOrderBy = (closeBracketPos>0)?sql.toUpperCase().indexOf("ORDER BY", closeBracketPos):sql.toUpperCase().lastIndexOf("ORDER BY");
- DataColumnType dct = getColumnById(_orderBy+"_sort");
- if(dct!=null && dct.getColName().length()>0) {
- _orderBy = _orderBy+"_sort";
- }
- if (idxOrderBy < 0)
- sql += " ORDER BY " + _orderBy + " " + (asc ? "ASC" : "DESC");
- else {
- int braketCount = 0;
- int idxOrderByClauseEnd = 0;
- for (idxOrderByClauseEnd = idxOrderBy; idxOrderByClauseEnd < sql.length(); idxOrderByClauseEnd++) {
- char ch = sql.charAt(idxOrderByClauseEnd);
-
- if (ch == '(')
- braketCount++;
- else if (ch == ')') {
- if (braketCount == 0)
- break;
- braketCount--;
- }
- } // for
-
- sql = sql.substring(0, idxOrderBy) + " ORDER BY " + _orderBy + " "
- + (asc ? "ASC" : "DESC") + sql.substring(idxOrderByClauseEnd);
- } // else
- } // if*/
-
- // Added reportSQLOnlyFirstPart which has Column information with Rownum
- return nvl(getReportSQLOnlyFirstPart()) + " " + sql + ") x ";
-
- }
-
- public int getDisplayMode() {
- return DISPLAY_MODE;
- }
-
- public void setDisplayMode(int mode) {
- DISPLAY_MODE = mode;
- }
-
- public int getDateOption() {
- return DATE_OPTION;
- }
-
- public void setDateOption(int dateOption) {
- DATE_OPTION = dateOption;
- }
-
- public boolean isDisplayColTotals() {
- return displayColTotals;
- }
-
- public void setDisplayColTotals(boolean displayColTotals) {
- this.displayColTotals = displayColTotals;
- }
-
- public boolean isDisplayRowTotals() {
- return displayRowTotals;
- }
-
- public void setDisplayRowTotals(boolean displayRowTotals) {
- this.displayRowTotals = displayRowTotals;
- }
-
-
- private boolean canPersistLinearReport() {
- boolean visibleColExist = false;
-
- if (getDataSourceList().getDataSource().size() > 0) {
- for (Iterator iter = getAllColumns().iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
-
- if (dct.isVisible()) {
- visibleColExist = true;
- break;
- }
- } // for
- } // if
-
- return visibleColExist;
- } // canPersistLinearReport
-
- public void persistLinearReport(HttpServletRequest request)
- throws RaptorException {
- if (!canPersistLinearReport())
- return;
-
- Connection connection = null;
- try {
- String userID = AppUtils.getUserID(request);
- String reportXML = marshal();
- logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] Report " + reportID
- + " XML marshalled succesfully"));
-
- // Update report
- verifySQLBasedReportAccess(request);
- reportSecurity.reportUpdate(request);
- connection = DbUtils.startTransaction();
- ReportLoader.updateCustomReportRec(connection, this, reportXML);
- ReportLoader.createReportLogEntry(connection, reportID, userID,
- AppConstants.RLA_UPDATE, "", "");
- logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] DB update report "
- + reportID + " succesfull"));
- DbUtils.commitTransaction(connection);
- } catch (RaptorException e) {
- e.printStackTrace();
- DbUtils.rollbackTransaction(connection);
- throw e;
- } finally {
- DbUtils.clearConnection(connection);
- }
- } // persistLinearReport
-
- public void persistDashboardReport(HttpServletRequest request)
- throws RaptorException {
-
- Connection connection = null;
- try {
- String userID = AppUtils.getUserID(request);
- String reportXML = marshal();
- logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] Report " + reportID
- + " XML marshalled succesfully"));
-
- // Update report
- verifySQLBasedReportAccess(request);
- reportSecurity.reportUpdate(request);
- connection = DbUtils.startTransaction();
- ReportLoader.updateCustomReportRec(connection, this, reportXML);
- ReportLoader.createReportLogEntry(connection, reportID, userID,
- AppConstants.RLA_UPDATE, "", "");
- logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] DB update report "
- + reportID + " succesfull"));
- DbUtils.commitTransaction(connection);
- } catch (RaptorException e) {
- e.printStackTrace();
- DbUtils.rollbackTransaction(connection);
- throw e;
- } finally {
- DbUtils.clearConnection(connection);
- }
- } // persistDashboardReport
- public String getTotalSql() {
- return totalSql;
- }
-
- public void setTotalSql(String totalSql) {
- this.totalSql = totalSql;
- }
-
- public void setTriggerFormFieldCheck( ReportFormFields FormFieldList, FormField selectedFormField) {
-
- for (Iterator iter = getReportFormFields().iterator(); iter.hasNext();) {
- FormField ff = (FormField) iter.next();
- if(!ff.getFieldName().equals(selectedFormField.getFieldName())) {
- if(nvl(ff.getBaseSQL()).length()>0 && ff.getBaseSQL().indexOf("["+selectedFormField.getFieldDisplayName() +"]")!= -1) {
- selectedFormField.setTriggerOtherFormFields(true);
- }
-
- }
- }
-
- }
-
- public void setTriggerThisFormFieldCheck( ReportFormFields FormFieldList, FormField selectedFormField) {
-
- String sql = nvl(selectedFormField.getBaseSQL()).length()>0 ? selectedFormField.getBaseSQL():"";
- for (Iterator iter = getReportFormFields().iterator(); iter.hasNext();) {
- FormField ff = (FormField) iter.next();
- if(!ff.getFieldName().equals(selectedFormField.getFieldName())) {
- if(sql.indexOf("["+ff.getFieldDisplayName() +"]")!= -1) {
- selectedFormField.setTriggerThisFormfield(true);
- break;
- }
-
- }
- }
-
- }
-
- private boolean isAllowEdit(HttpServletRequest request) {
- boolean allowEdit = false;
- try {
- if( AppUtils.isAdminUser(request) || AppUtils.isSuperUser(request) ) {
- allowEdit = true;
- }
- } catch (RaptorException ex) {
- allowEdit = false;
- }
- return allowEdit;
- }
- public ReportJSONRuntime createReportJSONRuntime(HttpServletRequest request, ReportData rd) {
- String userId = AppUtils.getUserID(request);
- ObjectMapper mapper = new ObjectMapper();
- ReportJSONRuntime reportJSONRuntime = new ReportJSONRuntime();
- reportJSONRuntime.setReportTitle(getReportTitle());
- reportJSONRuntime.setReportID(getReportID());
- reportJSONRuntime.setReportDescr(getReportDescr());
- reportJSONRuntime.setReportName(getReportName());
- reportJSONRuntime.setReportSubTitle(getReportSubTitle());
- reportJSONRuntime.setAllowSchedule(isAllowSchedule());
- reportJSONRuntime.setAllowEdit(isAllowEdit(request));
- reportJSONRuntime.setColIdxTobeFreezed(getFrozenColumnId());
- reportJSONRuntime.setNumFormCols(getNumFormColsAsInt());
- //back button url
- reportJSONRuntime.setBackBtnURL("");
- String chartType = getChartType();
- boolean displayChart = (nvl(chartType).length()>0)&&getDisplayChart();
- boolean displayChartWizard = getDisplayChart();
- reportJSONRuntime.setChartAvailable(displayChart);
- reportJSONRuntime.setChartWizardAvailable(displayChartWizard);
- reportJSONRuntime.setDisplayData(!isDisplayOptionHideData());
- reportJSONRuntime.setDisplayForm(!isDisplayOptionHideForm());
- reportJSONRuntime.setDisplayExcel(!isDisplayOptionHideExcelIcons());
- reportJSONRuntime.setDisplayPDF(!isDisplayOptionHidePDFIcons());
- ArrayList<IdNameValue> formFieldValues = new ArrayList<IdNameValue>();
- ArrayList<FormFieldJSON> formFieldJSONList = new ArrayList<FormFieldJSON>();
- if(getReportFormFields()!=null) {
- formFieldJSONList = new ArrayList<FormFieldJSON>(getReportFormFields().size());
- for (Iterator iter = getReportFormFields().iterator(); iter.hasNext();) {
- formFieldValues = new ArrayList<IdNameValue>();
- FormField ff = (FormField) iter.next();
- ff.setDbInfo(getDbInfo());
- FormFieldJSON ffJSON = new FormFieldJSON();
- ffJSON.setFieldId(ff.getFieldName());
- ffJSON.setFieldType(ff.getFieldType());
- ffJSON.setFieldDisplayName(ff.getFieldDisplayName());
- ffJSON.setHelpText(ff.getHelpText());
- ffJSON.setValidationType(ff.getValidationType());
- ffJSON.setVisible(ff.isVisible());
- //ffJSON.setTriggerOtherFormFields(ff.getDependsOn());
- IdNameList lookup = null;
- lookup = ff.getLookupList();
- String selectedValue = "";
- String oldSQL = "";
- IdNameList lookupList = null;
- boolean readOnly = false;
- if(lookup!=null) {
- if(!ff.hasPredefinedList) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = lu.getSql();
- oldSQL = lu.getSql();
- setTriggerFormFieldCheck( getReportFormFields(), ff);
- ffJSON.setTriggerOtherFormFields(ff.isTriggerOtherFormFields());
- SQL = parseAndFillReq_Session_UserValues(request, SQL, userId);
- SQL = parseAndFillWithCurrentValues(request, SQL, ff);
- String defaultSQL = lu.getDefaultSQL();
- defaultSQL = parseAndFillReq_Session_UserValues(request, defaultSQL, userId);
- defaultSQL = parseAndFillWithCurrentValues(request, defaultSQL, ff);
- lookup = new IdNameSql(-1,SQL,defaultSQL);
-
- lookupList = lookup;
- try {
- lookup.loadUserData(0, "", ff.getDbInfo(), ff.getUserId());
- } catch (Exception e ){ e.printStackTrace(); //throw new RaptorRuntimeException(e);
- }
- }
- lookup.trimToSize();
-
- String[] requestValue = request.getParameterValues(ff.getFieldName());
-
- if(lookup != null && lookup.size() > 0) {
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- readOnly = value.isReadOnly();
- if(requestValue != null && Arrays.asList(requestValue).contains(value.getId())) {
- //if(value.getId().equals(requestValue))
- value.setDefaultValue(true);
- } else if (AppUtils.nvl(ff.getDefaultValue()).length()>0) {
- if(ff.getDefaultValue().equals(value.getId())) {
- value.setDefaultValue(true);
- }
- }
- if(!(ff.getFieldType().equals(FormField.FFT_CHECK_BOX) || ff.getFieldType().equals(FormField.FFT_COMBO_BOX) || ff.getFieldType().equals(FormField.FFT_LIST_BOX)
- || ff.getFieldType().equals(FormField.FFT_LIST_MULTI)) && value.isDefaultValue())
- formFieldValues.add(value);
- else if(ff.getFieldType().equals(FormField.FFT_CHECK_BOX) || ff.getFieldType().equals(FormField.FFT_COMBO_BOX) || ff.getFieldType().equals(FormField.FFT_LIST_BOX)
- || ff.getFieldType().equals(FormField.FFT_LIST_MULTI)) {
- formFieldValues.add(value);
- }
- //break;
- }
- } else {
- if(requestValue!=null && requestValue.length>0) {
- IdNameValue value = new IdNameValue(requestValue[0], requestValue[0], true, false);
- formFieldValues.add(value);
- }
- }
-
- } else {
- setTriggerFormFieldCheck( getReportFormFields(), ff);
- ffJSON.setTriggerOtherFormFields(ff.isTriggerOtherFormFields());
- String[] requestValue = request.getParameterValues(ff.getFieldName());
- if(requestValue!=null && requestValue.length>0) {
- IdNameValue value = new IdNameValue(requestValue[0], requestValue[0], true, false);
- formFieldValues.add(value);
- } else if (AppUtils.nvl(ff.getDefaultValue()).length()>0) {
- IdNameValue value = new IdNameValue(ff.getDefaultValue(), ff.getDefaultValue(), true, false);
- formFieldValues.add(value);
- }
- }
- if(!ff.hasPredefinedList) {
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- }
-
-
-
- ffJSON.setFormFieldValues(formFieldValues);
- formFieldJSONList.add(ffJSON);
- } // for
- }
- reportJSONRuntime.setFormFieldList(formFieldJSONList);
- //reportJSONRuntime.setReportDataColumns(get);
- int count = 0;
- Map<String,Object> dvJSON = null;
- if(rd!=null) {
- count = 0;
- reportJSONRuntime.setTotalRows(getReportDataSize());
- ArrayList<ColumnHeader> colList = new ArrayList<ColumnHeader>();
- ArrayList<Map<String,Object>> reportDataRows = new ArrayList<Map<String,Object>>();
- for(rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext(); ) {
- count++;
- ColumnHeaderRow chr = rd.reportColumnHeaderRows.getNext();
- for(chr.resetNext(); chr.hasNext(); ) {
- colList.add(chr.getNext());
- }
- }
- if(getReportDataSize() > 0) {
- count = 0;
- for(rd.reportDataRows.resetNext(); rd.reportDataRows.hasNext(); count++) {
- dvJSON = new HashMap<String,Object>();
- DataRow dr = rd.reportDataRows.getNext();
- for(dr.resetNext(); dr.hasNext(); ) {
- DataValue dv = dr.getNext();
- try {
- dvJSON.put(dv.getColId(), dv);
- } catch (Exception ex) {
- ex.printStackTrace();
-
- }
- }
- reportDataRows.add(dvJSON);
- }
- }
- reportJSONRuntime.setReportDataColumns(colList);
- reportJSONRuntime.setReportDataRows(reportDataRows);
- //reportJSONRuntime.setSqlWhole(getWholeSQL());
- reportJSONRuntime.setPageSize(getPageSize());
-
- }
-
- if(getReportDataSize() <= 0) {
- reportJSONRuntime.setMessage(getEmptyMessage());
- }
- reportJSONRuntime.setSqlWhole(getWholeSQL());
- return reportJSONRuntime;
-
- }
-
- public ReportJSONRuntime createFormFieldJSONRuntime(HttpServletRequest request) {
- String userId = AppUtils.getUserID(request);
- ObjectMapper mapper = new ObjectMapper();
- ReportJSONRuntime reportJSONRuntime = new ReportJSONRuntime();
- reportJSONRuntime.setReportTitle(getReportTitle());
- reportJSONRuntime.setReportID(getReportID());
- reportJSONRuntime.setReportName(getReportName());
- reportJSONRuntime.setReportSubTitle(getReportSubTitle());
- reportJSONRuntime.setNumFormCols(getNumFormColsAsInt());
- ArrayList<IdNameValue> formFieldValues = new ArrayList<IdNameValue>();
- ArrayList<FormFieldJSON> formFieldJSONList = new ArrayList<FormFieldJSON>();
- if(reportFormFields!=null) {
- formFieldJSONList = new ArrayList<FormFieldJSON>(reportFormFields.size());
- for (Iterator iter = reportFormFields.iterator(); iter.hasNext();) {
- formFieldValues = new ArrayList<IdNameValue>();
- FormField ff = (FormField) iter.next();
- FormFieldJSON ffJSON = new FormFieldJSON();
- ffJSON.setFieldId(ff.getFieldName());
- ffJSON.setFieldType(ff.getFieldType());
- ffJSON.setFieldDisplayName(ff.getFieldDisplayName());
- ffJSON.setHelpText(ff.getHelpText());
- ffJSON.setValidationType(ff.getValidationType());
- ffJSON.setFormFieldValues(formFieldValues);
- ffJSON.setVisible(ff.isVisible());
- formFieldJSONList.add(ffJSON);
- }
- for (Iterator iter = reportFormFields.iterator(); iter.hasNext();) {
- formFieldValues = new ArrayList<IdNameValue>();
- FormField ff = (FormField) iter.next();
- ff.setDbInfo(getDbInfo());
- for (Iterator iter1 = formFieldJSONList.iterator(); iter1.hasNext();) {
- FormFieldJSON ffJSON = (FormFieldJSON) iter1.next();
- if(ffJSON.getFieldId().equals(ff.getFieldName())) {
- IdNameList lookup = null;
- lookup = ff.getLookupList();
- String selectedValue = "";
- String oldSQL = "";
- IdNameList lookupList = null;
- boolean readOnly = false;
- if(lookup!=null) {
- if(!ff.hasPredefinedList) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = lu.getSql();
- oldSQL = lu.getSql();
- setTriggerFormFieldCheck( getReportFormFields(), ff);
- ffJSON.setTriggerOtherFormFields(ff.isTriggerOtherFormFields());
- setTriggerThisFormFieldCheck(getReportFormFields(), ff);
- SQL = parseAndFillReq_Session_UserValues(request, SQL, userId);
- SQL = parseAndFillOtherFormfieldValues(request, SQL, userId, formFieldJSONList);
- //SQL = parseAndFillWithCurrentValues(formGrid,SQL, ff);
- String defaultSQL = lu.getDefaultSQL();
- defaultSQL = parseAndFillReq_Session_UserValues(request, defaultSQL, userId);
- //defaultSQL = parseAndFillWithCurrentValues(formGrid,defaultSQL, ff);
- lookup = new IdNameSql(-1,SQL,defaultSQL);
-
- lookupList = lookup;
- try {
- lookup.loadUserData(0, "", ff.getDbInfo(), ff.getUserId());
- } catch (Exception e ){ e.printStackTrace(); //throw new RaptorRuntimeException(e);
- }
- }
- lookup.trimToSize();
-
- String requestValue = request.getParameter(ff.getFieldName());
- ArrayList<String> requestValueList = new ArrayList<String>();
- requestValueList.add(requestValue);
-
- /*if(ff.isTriggerThisFormfield()) {
- refreshFormFieldsWithLatestValue(request, userId, ff, formFieldJSONList);
- }*/
-
-
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- readOnly = value.isReadOnly();
- if(nvl(requestValue).length()>0) {
- if(value.getId().equals(requestValue))
- value.setDefaultValue(true);
- }
- formFieldValues.add(value);
- //break;
- }
-
- } else {
- setTriggerFormFieldCheck( getReportFormFields(), ff);
- ffJSON.setTriggerOtherFormFields(ff.isTriggerOtherFormFields());
- String[] requestValue = request.getParameterValues(ff.getFieldName());
- if(requestValue!=null && requestValue.length>0) {
- IdNameValue value = new IdNameValue(requestValue[0], requestValue[0], true, false);
- formFieldValues.add(value);
- } else if (AppUtils.nvl(ff.getDefaultValue()).length()>0) {
- IdNameValue value = new IdNameValue(ff.getDefaultValue(), ff.getDefaultValue(), true, false);
- formFieldValues.add(value);
- }
- }
- if(!ff.hasPredefinedList) {
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- }
-
-
- //if(!ff.isTriggerThisFormfield()) {
- ffJSON.setFormFieldValues(formFieldValues);
- //}
-
- break;
-
- } //if
- } //for
- }//for
- }//if
-
- reportJSONRuntime.setFormFieldList(formFieldJSONList);
- //reportJSONRuntime.setReportDataColumns(get);
-
- return reportJSONRuntime;
-
- }
-
-
- private String parseAndFillOtherFormfieldValues(HttpServletRequest request, String SQL, String userId, ArrayList<FormFieldJSON> formFieldJSONList) {
- ArrayList<IdNameValue> formFieldValues = new ArrayList<IdNameValue>();
- String selectedValue = "";
- String displayName = "";
- for (Iterator iter1 = formFieldJSONList.iterator(); iter1.hasNext();) {
- FormFieldJSON ffJSON = (FormFieldJSON) iter1.next();
- displayName = ffJSON.getFieldDisplayName();
- ArrayList<IdNameValue> formfieldvalues = ffJSON.getFormFieldValues();
- for (int i = 0; i< formfieldvalues.size(); i++) {
- IdNameValue formfieldItem = formfieldvalues.get(i);
- if(formfieldItem.isDefaultValue()) {
- selectedValue = formfieldItem.getId();
- }
- }
- SQL = Utils.replaceInString(SQL, "["+displayName+"]", selectedValue);
- }
- return SQL;
-
- }
-
- private void refreshFormFieldsWithLatestValue(HttpServletRequest request, String userId, FormField ff_src, ArrayList<FormFieldJSON> formFieldJSONList) {
- ArrayList<IdNameValue> formFieldValues = new ArrayList<IdNameValue>();
- //ArrayList<FormFieldJSON> formFieldJSONList = new ArrayList<FormFieldJSON>();
- List<String> requestValueList = null;
- IdNameList lookup = null;
- lookup = ff_src.getLookupList();
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = "" ;
- String oldSQL = "";
- String oldDefaultSQL = "";
- String defaultSQL = "";
- IdNameList lookupList = null;
- if(lu != null) {
- SQL = lu.getSql();
- oldSQL = lu.getSql();
- oldDefaultSQL = lu.getDefaultSQL();
- defaultSQL = lu.getDefaultSQL();
- }
- boolean readOnly = false;
- for (Iterator iter1 = formFieldJSONList.iterator(); iter1.hasNext();) {
- FormFieldJSON ffJSON = (FormFieldJSON) iter1.next();
- if((ffJSON.getFieldId().equals(ff_src.getFieldName())) && ffJSON.isVisible()) {
- for (Iterator iter = reportFormFields.iterator(); iter.hasNext();) {
- formFieldValues = new ArrayList<IdNameValue>();
- FormField ff = (FormField) iter.next();
- if(!ff.getFieldName().equals(ff_src.getFieldName())) {
- //IdNameList lookup = null;
- //lookup = ff.getLookupList();
- String selectedValue = "";
-
-
-
- String [] requestParam = request.getParameterValues(ff.getFieldName());
- if(requestParam != null) {
- requestValueList = Arrays.asList(request.getParameterValues(ff.getFieldName()));
-
- } else {
- requestValueList = new ArrayList<String>();
- }
-
-
- if(nvl(ff_src.getBaseSQL()).length()>0 && ff_src.getBaseSQL().indexOf("["+ff.getFieldDisplayName() +"]")!= -1) {
- if(lookup!=null) {
- try {
- if(!ff_src.hasPredefinedList) {
- String formatSelected = null;
- if(ff_src.getFieldType().equals(FormField.FFT_LIST_MULTI) || ff_src.getFieldType().equals(FormField.FFT_CHECK_BOX)) {
- formatSelected = formatSelectedItems(requestValueList, ff_src.getFieldType());
- } else
- formatSelected = requestValueList.size()>0?requestValueList.get(0):"";
- SQL = Utils.replaceInString(SQL, "["+ff_src.getFieldDisplayName()+"]", formatSelected);
- defaultSQL = Utils.replaceInString(defaultSQL, "["+ff_src.getFieldDisplayName()+"]", formatSelected);
- defaultSQL = parseAndFillWithCurrentValues(request, defaultSQL, ff_src);
- defaultSQL = parseAndFillReq_Session_UserValues(request, defaultSQL, userId);
- SQL = parseAndFillReq_Session_UserValues(request, SQL, userId);
- SQL = parseAndFillWithCurrentValues(request, SQL, ff_src);
-
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
-
- }
-
- }
- }
- }
-
- if(nvl(ff_src.getBaseSQL()).length()>0) {
- lookup = new IdNameSql(-1,SQL,defaultSQL);
- lookupList = lookup;
- try {
- lookup.loadUserData(0, "", ff_src.getDbInfo(), ff_src.getUserId());
- } catch (Exception e ){
- e.printStackTrace(); //throw new RaptorRuntimeException(e);
- }
- if(!ff_src.hasPredefinedList) {
- lookup.trimToSize();
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- readOnly = value.isReadOnly();
- formFieldValues.add(value);
- }
- }
- ffJSON.setFormFieldValues(formFieldValues);
- }
- if(!ff_src.hasPredefinedList) {
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- if(oldDefaultSQL != null && !oldDefaultSQL.equals("")) {
- ((IdNameSql)lookup).setDefaultSQL(oldDefaultSQL);
- }
- }
-
- }
- }
-
- }
-
-
- private void triggerOtherFormFieldsWithThisValue(HttpServletRequest request, String userId, FormField ff_src, ArrayList<String> requestValueList, ArrayList<FormFieldJSON> formFieldJSONList) {
- ArrayList<IdNameValue> formFieldValues = new ArrayList<IdNameValue>();
- //ArrayList<FormFieldJSON> formFieldJSONList = new ArrayList<FormFieldJSON>();
- for (Iterator iter = reportFormFields.iterator(); iter.hasNext();) {
- formFieldValues = new ArrayList<IdNameValue>();
- FormField ff = (FormField) iter.next();
- if(!ff_src.getFieldName().equals(ff.getFieldName())) {
- for (Iterator iter1 = formFieldJSONList.iterator(); iter1.hasNext();) {
- FormFieldJSON ffJSON = (FormFieldJSON) iter1.next();
- if(ffJSON.getFieldId().equals(ff.getFieldName()) && ffJSON.isVisible()) {
- if(nvl(ff.getBaseSQL()).length()>0 && ff.getBaseSQL().indexOf("["+ff_src.getFieldDisplayName() +"]")!= -1) {
- IdNameList lookup = null;
- lookup = ff.getLookupList();
- String selectedValue = "";
- String oldSQL = "";
- String oldDefaultSQL = "";
- IdNameList lookupList = null;
- boolean readOnly = false;
- if(lookup!=null) {
- try {
- if(!ff.hasPredefinedList) {
- IdNameSql lu = (IdNameSql) lookup;
- String SQL = lu.getSql();
- oldSQL = lu.getSql();
- oldDefaultSQL = lu.getDefaultSQL();
- String defaultSQL = lu.getDefaultSQL();
- String formatSelected = null;
- if(ff_src.getFieldType().equals(FormField.FFT_LIST_MULTI) || ff_src.getFieldType().equals(FormField.FFT_CHECK_BOX)) {
- formatSelected = formatSelectedItems(requestValueList, ff.getFieldType());
- }
- else
- formatSelected = requestValueList.size()>0?requestValueList.get(0):"";
- SQL = Utils.replaceInString(SQL, "["+ff_src.getFieldDisplayName()+"]", formatSelected);
- defaultSQL = Utils.replaceInString(defaultSQL, "["+ff_src.getFieldDisplayName()+"]", formatSelected);
- defaultSQL = parseAndFillWithCurrentValues(request, defaultSQL, ff_src);
- defaultSQL = parseAndFillReq_Session_UserValues(request, defaultSQL, userId);
- SQL = parseAndFillReq_Session_UserValues(request, SQL, userId);
- SQL = parseAndFillWithCurrentValues(request, SQL, ff_src);
- lookup = new IdNameSql(-1,SQL,defaultSQL);
- lookupList = lookup;
- try {
- lookup.loadUserData(0, "", ff.getDbInfo(), ff.getUserId());
- } catch (Exception e ){
- e.printStackTrace(); //throw new RaptorRuntimeException(e);
- }
- }
- lookup.trimToSize();
-
-
-
- for (lookup.resetNext(); lookup.hasNext();) {
- IdNameValue value = lookup.getNext();
- readOnly = value.isReadOnly();
-// if(nvl(requestValue).length()>0) {
-// if(value.getId().equals(requestValue))
-// value.setDefaultValue(true);
-// }
- formFieldValues.add(value);
- //break;
- }
-
- ffJSON.setFormFieldValues(formFieldValues);
-
- if(!ff.hasPredefinedList) {
- if(oldSQL != null && !oldSQL.equals("")) {
- ((IdNameSql)lookup).setSQL(oldSQL);
- }
- if(oldDefaultSQL != null && !oldDefaultSQL.equals("")) {
- ((IdNameSql)lookup).setDefaultSQL(oldDefaultSQL);
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- } //ff baseSQL
- }
- }
- }
- }
-
- }
-
- public String formatSelectedItems(List selectedItems, String type) {
- StringBuffer value = new StringBuffer("");
- int count = 0;
- boolean multiple = false;
- if(type.equals("LIST_MULTI_SELECT"))
- multiple = true;
- //multiple = (selectedItems.size()>1);
- for(Iterator iter = selectedItems.iterator(); iter.hasNext(); ) {
- count++;
- String entry = (String) iter.next();
- if(count == 1 && multiple)
- value.append("(");
- //if(type.equals(FormField.FFT_CHECK_BOX))
- /*if(type.equals(FormField.FFT_CHECK_BOX))
- value.append("'"+Utils.oracleSafe(entry)+"'");
- else*/ if (type.equals(FormField.FFT_LIST_MULTI))
- value.append("'"+Utils.oracleSafe(entry)+"'");
- else if(type.equals(FormField.FFT_LIST_BOX))
- value.append(Utils.oracleSafe(entry));
- else
- value.append("'"+Utils.oracleSafe(entry)+"'");
- if((count < selectedItems.size()) && multiple)
- value.append(",");
- if((count == selectedItems.size()) && multiple)
- value.append(")");
- }
-
- if(value.length()>0)
- return value.toString();
- else
- return null;
- }
-
-public String parseAndFillWithCurrentValues(HttpServletRequest request, String sql, FormField source_Formfield) {
-
- if (getFormFieldList() != null) {
- for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) {
- FormFieldType fft = (FormFieldType) iter.next();
- String fieldId = fft.getFieldId();
- String fieldDisplay = getFormFieldDisplayName(fft);
- String formfield_value = "";
- List<String> selectedItems = new ArrayList<String>();
- //Added so that Combo Box in old RAPTOR definition is translated to List box
- if(fft.getFieldType().equals(FormField.FFT_COMBO_BOX)) {
- fft.setFieldType(FormField.FFT_LIST_BOX);
- }
- if(!fft.getFieldType().equals(FormField.FFT_BLANK)) {
- //if(source_Formfield==null || (source_Formfield!=null && !fft.getFieldId().equals(source_Formfield.getFieldName()))) {
- // Add oracle safe
- // Add param base sql
- if(fft.getFieldType().equals(FormField.FFT_LIST_MULTI) || fft.getFieldType().equals(FormField.FFT_CHECK_BOX)) {
- if(request.getParameterValues(fieldId)!=null && request.getParameterValues(fieldId).length > 0) {
-
- selectedItems = Arrays.asList(request.getParameterValues(fieldId));
- formfield_value = formatSelectedItems(selectedItems, fft.getFieldType());
- } else {
- formfield_value = "";
- }
- } else if(fft.getFieldType().equals(FormField.FFT_RADIO_BTN)) {
- if(request.getParameter(fieldId)!=null) {
- formfield_value = request.getParameter(fieldId);
- } else {
- formfield_value = "";
- }
- } else if (fft.getFieldType().equals(FormField.FFT_HIDDEN)) {
- if(request.getParameter(fieldId)!=null) {
- formfield_value = request.getParameter(fieldId);
- } else {
- formfield_value = "";
- }
- } else if((fft.getFieldType().equals(FormField.FFT_TEXT) || fft.getFieldType().equals(FormField.FFT_TEXTAREA)) &&
- (!fft.getValidationType().equals(FormField.VT_DATE) && !fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)&&
- !fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) && !fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) ) {
- if(request.getParameter(fieldId)!=null) {
- formfield_value = request.getParameter(fieldId);
- } else {
- formfield_value = "";
- }
- } else if (fft.getValidationType().equals(FormField.VT_DATE) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)||
- fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
- /*if(formGrid.hasFellow(fieldId, true)) {
- Datebox tb = (Datebox) formGrid.getFellowIfAny(fieldId, true);
- try {
- formfield_value = tb.getText();
- } catch (WrongValueException ex) {
- formfield_value = "";
- }
- if(AppUtils.nvl(formfield_value).length() > 0) {
- if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)) {
- if(formGrid.hasFellow(fieldId+"_Hr", true)) {
- Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true);
- formfield_value = formfield_value + " " + hiddenLbHr.getValue();
- }
- } else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)) {
- if(formGrid.hasFellow(fieldId+"_Min", true)) {
- Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true);
- //formfield_value = formfield_value + " " + hiddenLbHr.getValue();
- Label hiddenLbMin = (Label) formGrid.getFellowIfAny(fieldId+"_Min", true);
- formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue();
-
- }
- } else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
- if(formGrid.hasFellow(fieldId+"_Sec", true)) {
- Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true);
- //formfield_value = formfield_value + " " + hiddenLbHr.getValue();
- Label hiddenLbMin = (Label) formGrid.getFellowIfAny(fieldId+"_Min", true);
- //formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue();
- Label hiddenLbSec = (Label) formGrid.getFellowIfAny(fieldId+"_Sec", true);
- formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue()+ ":" +hiddenLbSec.getValue();
-
- }
- }
- }
-
- } else {
- formfield_value = "";
- }*/
- } else if ((fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)||
- fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC))) {
- /*if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)||
- fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
- if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)) {
- if(formGrid.hasFellow(fieldId+"_Hr", true)) {
- Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true);
- formfield_value = formfield_value + " " + hiddenLbHr.getValue();
- }
- } else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)) {
- if(formGrid.hasFellow(fieldId+"_Min", true)) {
- Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true);
- //formfield_value = formfield_value + " " + hiddenLbHr.getValue();
- Label hiddenLbMin = (Label) formGrid.getFellowIfAny(fieldId+"_Min", true);
- formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue();
-
- }
- } else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
- if(formGrid.hasFellow(fieldId+"_Sec", true)) {
- Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true);
- //formfield_value = formfield_value + " " + hiddenLbHr.getValue();
- Label hiddenLbMin = (Label) formGrid.getFellowIfAny(fieldId+"_Min", true);
- //formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue();
- Label hiddenLbSec = (Label) formGrid.getFellowIfAny(fieldId+"_Sec", true);
- formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue()+ ":" +hiddenLbSec.getValue();
-
- }
- }
-
- } */
- } else if (fft.getFieldType().equals(FormField.FFT_TEXT_W_POPUP)) {
- if(request.getParameter(fieldId)!=null) {
- formfield_value = request.getParameter(fieldId);
- } else {
- formfield_value = "";
- }
- } else if (fft.getFieldType().equals(FormField.FFT_LIST_BOX)) {
- if(request.getParameter(fieldId)!=null) {
- formfield_value = request.getParameter(fieldId);
- } else {
- formfield_value = "";
- }
- //}
- }
- if(nvl(formfield_value).length()>0) {
- sql = Utils.replaceInString(sql, fieldDisplay, formfield_value);
- } else {
- sql = Utils.replaceInString(sql, "'"+fieldDisplay+"'", "null");
- sql = Utils.replaceInString(sql, fieldDisplay, "null");
- //sql = Utils.replaceInString(sql, fieldDisplay, "''");
- }
- } // for
- }
- }
- return sql;
- }
- public String parseAndFillReq_Session_UserValues(HttpServletRequest request, String sql, String user_id) {
- HttpSession session = request.getSession();
-
- String[] reqParameters = Globals.getRequestParams().split(",");
- String[] sessionParameters = Globals.getSessionParams().split(",");
- String[] scheduleSessionParameters = Globals.getSessionParamsForScheduling().split(",");
-
-
- if(AppUtils.nvl(sql).length()>0) {
- for (int i = 0; i < reqParameters.length; i++) {
- if(!reqParameters[i].startsWith("ff") && (request.getParameter(reqParameters[i].toUpperCase())!=null && request.getParameter(reqParameters[i].toUpperCase()).length() > 0))
- sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase()+"]", request.getParameter(reqParameters[i].toUpperCase()) );
- else if (request.getParameter(reqParameters[i])!=null && request.getParameter(reqParameters[i]).length() > 0)
- sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase()+"]", request.getParameter(reqParameters[i]) );
- }
-
- for (int i = 0; i < scheduleSessionParameters.length; i++) {
- //debugLogger.debug(" Session " + " scheduleSessionParameters[i] " + scheduleSessionParameters[i].toUpperCase() + " " + request.getParameter(scheduleSessionParameters[i]));
- if(request.getParameter(scheduleSessionParameters[i])!=null && request.getParameter(scheduleSessionParameters[i]).trim().length()>0 )
- sql = Utils.replaceInString(sql, "[" + scheduleSessionParameters[i].toUpperCase()+"]", request.getParameter(scheduleSessionParameters[i]) );
- if(request.getAttribute(scheduleSessionParameters[i])!=null && ((String)request.getAttribute(scheduleSessionParameters[i])).trim().length()>0 )
- sql = Utils.replaceInString(sql, "[" + scheduleSessionParameters[i].toUpperCase()+"]", (String) request.getAttribute(scheduleSessionParameters[i]) );
-
- }
-
- for (int i = 0; i < sessionParameters.length; i++) {
- //if(!sessionParameters[i].startsWith("ff"))
- //fieldSQL = Utils.replaceInString(fieldSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i].toUpperCase()) );
- //else {
- if (session.getAttribute(sessionParameters[i])!=null && ((String)session.getAttribute(sessionParameters[i])).length() > 0) {
- //debugLogger.debug(" Session " + " sessionParameters[i] " + sessionParameters[i] + " " + (String)session.getAttribute(sessionParameters[i]));
- sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) );
- }
- // }
- }
- sql = Utils.replaceInString(sql, "[USERID]", user_id);
- sql = Utils.replaceInString(sql, "[USER_ID]", user_id);
- sql = Utils.replaceInString(sql, "[LOGGED_USERID]", user_id);
-
- }
- return sql;
- }
-
-} // ReportRuntime
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/TimeSeriesChartOptions.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/TimeSeriesChartOptions.java
deleted file mode 100644
index 9e6f657f..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/TimeSeriesChartOptions.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-public class TimeSeriesChartOptions {
- private String lineChartRenderer;
- private boolean multiSeries;
- private boolean nonTimeAxis;
- private boolean showXAxisLabel;
- private boolean addXAxisTicker;
-
- public String getLineChartRenderer() {
- return lineChartRenderer;
- }
- public void setLineChartRenderer(String lineChartRenderer) {
- this.lineChartRenderer = lineChartRenderer;
- }
- public boolean isMultiSeries() {
- return multiSeries;
- }
- public void setMultiSeries(boolean multiSeries) {
- this.multiSeries = multiSeries;
- }
- public boolean isNonTimeAxis() {
- return nonTimeAxis;
- }
- public void setNonTimeAxis(boolean nonTimeAxis) {
- this.nonTimeAxis = nonTimeAxis;
- }
- public boolean isShowXAxisLabel() {
- return showXAxisLabel;
- }
- public void setShowXAxisLabel(boolean showXAxisLabel) {
- this.showXAxisLabel = showXAxisLabel;
- }
- public boolean isAddXAxisTicker() {
- return addXAxisTicker;
- }
- public void setAddXAxisTicker(boolean addXAxisTicker) {
- this.addXAxisTicker = addXAxisTicker;
- }
-
-
-
-}
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/VisualManager.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/VisualManager.java
deleted file mode 100644
index 9587de53..00000000
--- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/VisualManager.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ================================================================================
- * eCOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-package org.openecomp.portalsdk.analytics.model.runtime;
-
-import java.util.HashMap;
-
-import org.openecomp.portalsdk.analytics.RaptorObject;
-import org.openecomp.portalsdk.analytics.util.AppConstants;
-
-public class VisualManager extends RaptorObject {
- private HashMap hiddenCols = new HashMap();
-
- private String sortByColId = "";
-
- private String sortByAscDesc = AppConstants.SO_ASC;
-
- public VisualManager() {
- super();
- }
-
- public void hideColumn(String colId) {
- hiddenCols.put(colId, "Y");
- } // hideColumn
-
- public void showColumn(String colId) {
- hiddenCols.put(colId, "N");
- } // showColumn
-
- public boolean isColumnVisible(String colId) {
- return nvl((String) hiddenCols.get(colId), "N").equals("N");
- } // isColumnVisible
-
- public void setSortByColumn(String colId) {
- if (sortByColId.equals(colId))
- sortByAscDesc = sortByAscDesc.equals(AppConstants.SO_ASC) ? AppConstants.SO_DESC
- : AppConstants.SO_ASC;
- else {
- sortByColId = colId;
- sortByAscDesc = AppConstants.SO_ASC;
- }
- } // setSortByColumn
-
- public String getSortByColId() {
- return sortByColId;
- }
-
- public String getSortByAscDesc() {
- return sortByAscDesc;
- }
-
-} // VisualManager