From 6beb446925c967aca92f5513adf36c5db77c00d6 Mon Sep 17 00:00:00 2001 From: TATTAVARADA Date: Thu, 27 Apr 2017 07:53:18 -0400 Subject: [PORTAL-7] Rebase This rebasing includes common libraries and common overlays projects abstraction of components Change-Id: Ia1efa4deacdc5701e6205104ac021a6c80ed60ba Signed-off-by: st782s --- .../analytics/model/runtime/BarChartOptions.java | 75 - .../analytics/model/runtime/CategoryAxisJSON.java | 24 - .../analytics/model/runtime/ChartD3Helper.java | 4064 -------------------- .../analytics/model/runtime/ChartGen.java | 73 - .../analytics/model/runtime/ChartJSON.java | 448 --- .../analytics/model/runtime/ChartJSONHelper.java | 1550 -------- .../analytics/model/runtime/ChartWebRuntime.java | 420 -- .../model/runtime/CommonChartOptions.java | 81 - .../analytics/model/runtime/ErrorJSONRuntime.java | 43 - .../model/runtime/FlexTimeSeriesChartOptions.java | 38 - .../analytics/model/runtime/FormField.java | 2111 ---------- .../analytics/model/runtime/FormatProcessor.java | 375 -- .../portalsdk/analytics/model/runtime/Item.java | 54 - .../analytics/model/runtime/LookupDBInfo.java | 89 - .../analytics/model/runtime/RangeAxisJSON.java | 93 - .../analytics/model/runtime/ReportFormFields.java | 366 -- .../analytics/model/runtime/ReportJSONRuntime.java | 694 ---- .../model/runtime/ReportParamDateValueParser.java | 194 - .../analytics/model/runtime/ReportParamValues.java | 370 -- .../runtime/ReportParamValuesForPDFExcel.java | 419 -- .../analytics/model/runtime/ReportRuntime.java | 3618 ----------------- .../model/runtime/TimeSeriesChartOptions.java | 62 - .../analytics/model/runtime/VisualManager.java | 68 - 23 files changed, 15329 deletions(-) delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/BarChartOptions.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/CategoryAxisJSON.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartD3Helper.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartGen.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSON.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartJSONHelper.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ChartWebRuntime.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/CommonChartOptions.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ErrorJSONRuntime.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FlexTimeSeriesChartOptions.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FormField.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/FormatProcessor.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/Item.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/LookupDBInfo.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/RangeAxisJSON.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportFormFields.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportJSONRuntime.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamDateValueParser.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamValues.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcel.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/ReportRuntime.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/TimeSeriesChartOptions.java delete mode 100644 ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime/VisualManager.java (limited to 'ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/model/runtime') 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 chartOptionsMap = new HashMap(); - 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 chartOptionsMap = new HashMap(); - 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 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 ts1 = new HashSet(); - ArrayList ts1 = new ArrayList(); - HashMap 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("\n"); - wholeScript.append("\n"); - wholeScript.append("\n"); - wholeScript.append("\n"); - wholeScript.append("\n"); - //wholeScript.append("") - wholeScript.append(" \n" ); - wholeScript.append(" \n"); - if(showTitle) - wholeScript.append("

" + title +"

"); - - wholeScript.append("
\n"); - //js files - wholeScript.append(""); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - //wholeScript.append(" \n"); - //wholeScript.append(" \n"); - wholeScript.append(" \n"); - //json - wholeScript.append(" \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(); - HashMap 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 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 colorList = new TreeSet(); - 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 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("\n"); - wholeScript.append("\n"); - wholeScript.append("\n"); - wholeScript.append("\n"); - wholeScript.append("\n"); - wholeScript.append(" \n" ); - - wholeScript.append(" \n"); - - if(showTitle) - wholeScript.append("

" + title +"

"); - - - wholeScript.append("
\n"); - //js files - wholeScript.append("\n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - //wholeScript.append(" \n"); - //if(multipleSeries) - //wholeScript.append(" \n"); - - //json - wholeScript.append(" \n"); - - } else if (chartType.equals(AppConstants.GT_PIE) || chartType.equals(AppConstants.GT_PIE_3D)) { - wholeScript.append("\n"); - wholeScript.append("\n"); - wholeScript.append("\n"); - wholeScript.append("\n"); - wholeScript.append("\n"); - wholeScript.append(" \n" ); - wholeScript.append(" \n"); - - if(showTitle) - wholeScript.append("

" + title +"

"); - - wholeScript.append("
"); - //"\n"); - //js files - wholeScript.append("\n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \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 dateStrList = new TreeSet(); - // added to store all date elements - SortedSet sortSet = new TreeSet(); - 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=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("\n"); - wholeScript.append("\n"); - wholeScript.append(" \n"); - //wholeScript.append("\n"); - wholeScript.append("\n"); - wholeScript.append("\n"); - wholeScript.append("\n"); - wholeScript.append("\n"); - - wholeScript.append("\n "); - wholeScript.append("\n"); - wholeScript.append("\n"); - wholeScript.append(" \n"); - -/* if(showTitle) - wholeScript.append("

" + (AppUtils.nvl(reportRuntime.getReportTitle()).length()>0?reportRuntime.getReportTitle():reportRuntime.getReportName()) + "

\n"); -*/ - wholeScript.append(" \n"); - if(showTitle) { - wholeScript.append(" \n "); - wholeScript.append(" \n "); - } - - wholeScript.append(" \n "); - - wholeScript.append(" \n "); - wholeScript.append(" \n "); - - wholeScript.append(" \n "); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - if(AppUtils.nvl(reportRuntime.getLegendPosition()).length()>=0 && reportRuntime.getLegendPosition().equals("right")) { - wholeScript.append(" \n"); - } - wholeScript.append(" \n"); - if(anomalyRec > 0) { - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - } - wholeScript.append("
\n "); - wholeScript.append("
"+title+"
\n"); - wholeScript.append("
\n "); - if(AppUtils.nvl(reportRuntime.getLegendPosition()).length()<=0 || reportRuntime.getLegendPosition().equals("top")) { - wholeScript.append("
\n"); - } - wholeScript.append("
\n"); - wholeScript.append("
\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("
\n"); - wholeScript.append("
\n"); - wholeScript.append("
\n"); - wholeScript.append("
\n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n" ); - wholeScript.append(" \n"); - wholeScript.append("
Anomaly Description
\n"); - wholeScript.append("
\n"); - - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(""); - - - } else if (chartType.equals(AppConstants.GT_SCATTER)) { - - wholeScript.append("\n"); - wholeScript.append(" \n" ); - wholeScript.append(" \n"); - wholeScript.append("
"); - //js files - wholeScript.append("\n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append(" \n"); - wholeScript.append("\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)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) 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 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 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 formFieldList; - private ArrayList 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 rangeAxisList; - private ArrayList > 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 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 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 getRangeAxisList() { - return rangeAxisList; - } - public void setRangeAxisList(ArrayList 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 getRowList() { - return rowList; - } - public void setRowList(ArrayList rowList) { - this.rowList = rowList; - }*/ - - public ArrayList> getWholeList() { - return wholeList; - } - public void setWholeList(ArrayList> wholeList) { - this.wholeList = wholeList; - } - //private ArrayList reportDataColumns; - //private ArrayList> reportDataRows; - public ArrayList getChartColumnJSONList() { - return chartColumnJSONList; - } - public void setChartColumnJSONList(ArrayList 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 chartOptionsMap = new HashMap(); - 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 chartOptionsMap = new HashMap(); - 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 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 dcList = reportRuntime.getOnlyVisibleColumns(); - int countIndex = 0; - ArrayList chartColumnJSONList = new ArrayList(); - 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 formFieldValues = new ArrayList(); - ArrayList formFieldJSONList = new ArrayList(); - if(reportRuntime.getReportFormFields()!=null) { - formFieldJSONList = new ArrayList(reportRuntime.getReportFormFields().size()); - for (Iterator iter = reportRuntime.getReportFormFields().iterator(); iter.hasNext();) { - formFieldValues = new ArrayList(); - 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 reportCols = reportRuntime.getAllColumns(); - boolean hasSeriesColumn = false; - //ArrayList - for (Iterator 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 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 rangeAxisJSONList = new ArrayList(); - 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> wholeList = new ArrayList>(); - - ArrayList rowList = new ArrayList(); - if(showData) { - for (int i = 0; i < ds.getRowCount(); i++) { - rowList = new ArrayList(); - for (int j = 0; j0) { - /*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) 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 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 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 params = new HashMap(); - - //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 params = new HashMap(); - 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 chartOptionsMap = new HashMap(); - - String rotateLabelsStr = ""; - rotateLabelsStr = AppUtils.nvl(reportRuntime.getLegendLabelAngle()); - if(rotateLabelsStr.toLowerCase().equals("standard")) { - rotateLabelsStr = "0"; - } else if (rotateLabelsStr.toLowerCase().equals("up45")) { - rotateLabelsStr = "45"; - } else if (rotateLabelsStr.toLowerCase().equals("down45")) { - rotateLabelsStr = "-45"; - } else if (rotateLabelsStr.toLowerCase().equals("up90")) { - rotateLabelsStr = "90"; - } else if (rotateLabelsStr.toLowerCase().equals("down90")) { - rotateLabelsStr = "-90"; - } else - rotateLabelsStr = "0"; - - String width = (AppUtils.getRequestNvlValue(request, "width").length()>0?AppUtils.getRequestNvlValue(request, "width"):(AppUtils.nvl(reportRuntime.getChartWidth()).length()>0?reportRuntime.getChartWidth():"700")); - String height = (AppUtils.getRequestNvlValue(request, "height").length()>0?AppUtils.getRequestNvlValue(request, "height"):(AppUtils.nvl(reportRuntime.getChartHeight()).length()>0?reportRuntime.getChartHeight():"300")); - String animationStr = (AppUtils.getRequestNvlValue(request, "animation").length()>0?AppUtils.getRequestNvlValue(request, "animation"):new Boolean(reportRuntime.isAnimateAnimatedChart()).toString()); - - String rotateLabels = (AppUtils.getRequestNvlValue(request, "rotateLabels").length()>0?AppUtils.getRequestNvlValue(request, "rotateLabels"):(rotateLabelsStr.length()>0?rotateLabelsStr:"0")); - String staggerLabelsStr = (AppUtils.getRequestNvlValue(request, "staggerLabels").length()>0?AppUtils.getRequestNvlValue(request, "staggerLabels"):"false"); - String showMaxMinStr = (AppUtils.getRequestNvlValue(request, "showMaxMin").length()>0?AppUtils.getRequestNvlValue(request, "showMaxMin"):"false"); - String showControlsStr = (AppUtils.getRequestNvlValue(request, "showControls").length()>0?AppUtils.getRequestNvlValue(request, "showControls"):new Boolean(reportRuntime.displayBarControls()).toString()); - String showLegendStr = (AppUtils.getRequestNvlValue(request, "showLegend").length()>0?AppUtils.getRequestNvlValue(request, "showLegend"):new Boolean(!new Boolean(reportRuntime.hideChartLegend())).toString()); - String topMarginStr = AppUtils.getRequestNvlValue(request, "topMargin"); - String topMargin = (AppUtils.nvl(topMarginStr).length()<=0)?(reportRuntime.getTopMargin()!=null?reportRuntime.getTopMargin().toString():"30"):topMarginStr; - String bottomMarginStr = AppUtils.getRequestNvlValue(request, "bottomMargin"); - String bottomMargin = (AppUtils.nvl(bottomMarginStr).length()<=0)?(reportRuntime.getBottomMargin()!=null?reportRuntime.getBottomMargin().toString():"50"):bottomMarginStr; - String leftMarginStr = AppUtils.getRequestNvlValue(request, "leftMargin"); - String leftMargin = (AppUtils.nvl(leftMarginStr).length()<=0)?(reportRuntime.getLeftMargin()!=null?reportRuntime.getLeftMargin().toString():"100"):leftMarginStr; - String rightMarginStr = AppUtils.getRequestNvlValue(request, "rightMargin"); - String rightMargin = (AppUtils.nvl(rightMarginStr).length()<=0)?(reportRuntime.getRightMargin()!=null?reportRuntime.getRightMargin().toString():"160"):rightMarginStr; - String showTitleStr = (AppUtils.getRequestNvlValue(request, "showTitle").length()>0?AppUtils.getRequestNvlValue(request, "showTitle"):new Boolean(reportRuntime.displayChartTitle()).toString()); - String subType = AppUtils.getRequestNvlValue(request, "subType").length()>0?AppUtils.getRequestNvlValue(request, "subType"):(AppUtils.nvl(reportRuntime.getTimeSeriesRender()).equals("area")?reportRuntime.getTimeSeriesRender():""); - String stackedStr = AppUtils.getRequestNvlValue(request, "stacked").length()>0?AppUtils.getRequestNvlValue(request, "stacked"):new Boolean(reportRuntime.isChartStacked()).toString(); - String horizontalBar = AppUtils.getRequestNvlValue(request, "horizontalBar").length()>0?AppUtils.getRequestNvlValue(request, "horizontalBar"):new Boolean(reportRuntime.isHorizontalOrientation()).toString(); - String barRealTimeAxis = AppUtils.getRequestNvlValue(request, "barRealTimeAxis"); - String barReduceXAxisLabels = AppUtils.getRequestNvlValue(request, "barReduceXAxisLabels").length()>0?AppUtils.getRequestNvlValue(request, "barReduceXAxisLabels"):new Boolean(reportRuntime.isLessXaxisTickers()).toString();; - String timeAxis = AppUtils.getRequestNvlValue(request, "timeAxis").length()>0?AppUtils.getRequestNvlValue(request, "timeAxis"):new Boolean(reportRuntime.isTimeAxis()).toString(); - String logScale = AppUtils.getRequestNvlValue(request, "logScale").length()>0?AppUtils.getRequestNvlValue(request, "logScale"):new Boolean(reportRuntime.isLogScale()).toString(); - String precision = AppUtils.getRequestNvlValue(request, "precision").length()>0?AppUtils.getRequestNvlValue(request, "precision"):"2"; - - /* boolean animation = AppUtils.getRequestFlag(request, "animation"); - boolean staggerLabels = AppUtils.getRequestFlag(request, "staggerLabels"); - boolean showMaxMin = (showMaxMinStr.length()<=0)?false:Boolean.parseBoolean(showMaxMinStr); - boolean showControls = (showControlsStr.length()<=0)?true:Boolean.parseBoolean(showControlsStr); - boolean showLegend = (showLegendStr.length()<=0)?true:Boolean.parseBoolean(showLegendStr); - boolean showTitle = (showTitleStr.length()<=0)?true:Boolean.parseBoolean(showTitleStr); - boolean stacked = (stackedStr.length()<=0)?true:Boolean.parseBoolean(stackedStr); - */ - // Add all options to Map - chartOptionsMap.put("width", width); - chartOptionsMap.put("height", height); - chartOptionsMap.put("animation", animationStr); - chartOptionsMap.put("rotateLabels", rotateLabels); - chartOptionsMap.put("staggerLabels", staggerLabelsStr); - chartOptionsMap.put("showMaxMin", showMaxMinStr); - chartOptionsMap.put("showControls", showControlsStr); - chartOptionsMap.put("showLegend", showLegendStr); - chartOptionsMap.put("topMargin", topMargin); - chartOptionsMap.put("bottomMargin", bottomMargin); - chartOptionsMap.put("leftMargin", leftMargin); - chartOptionsMap.put("rightMargin", rightMargin); - chartOptionsMap.put("showTitle", showTitleStr); - chartOptionsMap.put("subType", subType); - chartOptionsMap.put("stacked", stackedStr); - chartOptionsMap.put("horizontalBar", horizontalBar); - chartOptionsMap.put("timeAxis", timeAxis); - chartOptionsMap.put("barRealTimeAxis", barRealTimeAxis); - chartOptionsMap.put("barReduceXAxisLabels", barReduceXAxisLabels); - - chartOptionsMap.put("logScale", logScale); - chartOptionsMap.put("precision", precision); - - - - if(reportRuntime!=null) { - 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 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 chartOptionsMap) { - drawD3Charts(chartOptionsMap); - - } - */ - - public String drawD3Charts(HashMap 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 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 RAPTOR (Rapid Application Programming Tool for OLAP Reporting) - * 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 "" + fieldDisplayName + ""; - 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 "\"\""; - return ((getHelpText()!=null && getHelpText().length()>0)? "tooltipText=\""+ getHelpText()+"\">": ">"); - //return ((getHelpText()!=null && getHelpText().length()>0)? "": ""); - } - - - 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 "\n" + "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 "\n" + " \"Loading, "; - - return progress+" \n  \n" - + " 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 = "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" - + "\n\t\t\t\t" - : ""); */ - - 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" - : ""); - if(validationType.equals(VT_TIMESTAMP_HR) || validationType.equals(VT_TIMESTAMP_MIN) || validationType.equals(VT_TIMESTAMP_SEC) ) { - //Add Hours/Minutes and Seconds. - timeStampStr = " Hour "; - } - //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 += " Min "; - } - //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 += " Sec "; - } - - 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 +" "+ */ ""; - } else { - checkboxStr = /*checkboxStr +" "+ */""; - } - /*if(validationType.equals(VT_TIMESTAMP_HR) || validationType.equals(VT_TIMESTAMP_MIN) || validationType.equals(VT_TIMESTAMP_SEC)) { - checkboxStr = checkboxStr +" "+ ""; - } - if(validationType.equals(VT_TIMESTAMP_MIN) || validationType.equals(VT_TIMESTAMP_SEC)) { - checkboxStr = checkboxStr +" "+ ""; - } - if(validationType.equals(VT_TIMESTAMP_SEC)) { - checkboxStr = checkboxStr +" "+ ""; - }*/ - } - 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 "