summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk')
-rw-r--r--ecomp-sdk/epsdk-analytics/pom.xml4
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java67
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportHandler.java10835
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java10614
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResultJSON.java34
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendNotifications.java721
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java257
7 files changed, 11407 insertions, 11125 deletions
diff --git a/ecomp-sdk/epsdk-analytics/pom.xml b/ecomp-sdk/epsdk-analytics/pom.xml
index 26821ded..39ca61d7 100644
--- a/ecomp-sdk/epsdk-analytics/pom.xml
+++ b/ecomp-sdk/epsdk-analytics/pom.xml
@@ -116,7 +116,7 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
- <version>3.14</version>
+ <version>3.17</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
@@ -131,7 +131,7 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
- <version>3.14</version>
+ <version>3.17</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java
index 3eca7c68..0b3cf05a 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java
@@ -148,6 +148,9 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
private static final String REPORT_DOWNLOAD_PAGE = ";report.download.page";
private static final String FALSE = "false";
private static final String COLNAME = "[colName]";
+ private static final String FORM_FIELDS = "formFields";
+ private static final String USER_ID = "user_id";
+ private static final String MESSAGE = "message";
private void preserveReportRuntimeAsBackup(HttpServletRequest request) {
HttpSession session = request.getSession();
ArrayList repAl = null;
@@ -312,19 +315,17 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
if(reportID !=null)
rr1 = rh1.loadReportRuntime(request, reportID, true, 1);
if(rr1!=null && rr1.getReportType().equals(AppConstants.RT_DASHBOARD)) {
- int DASH=7;
- int requestFlag = DASH;
+ int dash=7;
+ int requestFlag = dash;
ReportHandler rh = new ReportHandler();
// Added below statement to add parent dashboard report id in session.
request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REP_ID, reportID);
- //rr = null;
- // get dashboard HTML from report runtime. getListOfReportsFromDashBoardHTML
+
String strHTML = rr1.getDashboardLayoutHTML();
TreeMap treeMap = getListOfReportsFromDashBoardHTML(strHTML);
Set set = treeMap.entrySet();
- String value = "";
HashMap reportsRuntimeMap = new HashMap();
HashMap reportDataMap = new HashMap();
@@ -336,9 +337,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
userId = AppUtils.getUserID(request);
int pageNo = -1;
int downloadLimit = 0;
- int rep_idx = 0;
- int widthFlag = 0;
- int heightFlag = 0;
ReportRuntime rrDashboardReports = null;
Integer intObj = null;
ReportRuntime similiarReportRuntime = null;
@@ -367,9 +365,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
}
downloadLimit = (rrDashboardReports.getMaxRowsInExcelDownload()>0)?rrDashboardReports.getMaxRowsInExcelDownload():Globals.getDownloadLimit();
- if (new Integer(nvl(rrDashboardReports.getDataContainerWidth(),"100")).intValue() >100) widthFlag = 1;
- if (new Integer(nvl(rrDashboardReports.getDataContainerHeight(),"100")).intValue() >100) heightFlag = 1;
-
+
if(record == 1) {
if(rrDashboardReports.getReportFormFields()!=null && rrDashboardReports.getReportFormFields().size()>0) {
buildReportdata = false;
@@ -392,7 +388,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
long totalTime = System.currentTimeMillis() - currentTime;
- formFields = AppUtils.getRequestNvlValue(request, "formFields");
+ formFields = AppUtils.getRequestNvlValue(request, FORM_FIELDS);
if(buildReportdata) {
rrDashboardReports.logReportRun(userId, String.valueOf(totalTime),formFields);
rrDashboardReports.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_EXECUTION_TIME, formFields);
@@ -423,7 +419,8 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
return "raptor/report_dashboard_run_container.jsp";
} else {
fromDashboard = AppUtils.getRequestFlag(request,"fromDashboard");
- if(isDashboardInDrillDownList(request)) fromDashboard= true;
+ if(isDashboardInDrillDownList(request))
+ fromDashboard= true;
if(!fromDashboard) {
request.getSession().removeAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP);
@@ -435,31 +432,29 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
request.getSession().removeAttribute(AppConstants.EMBEDDED_REPORTRUNTIME_MAP);
request.getSession().removeAttribute(AppConstants.EMBEDDED_REPORTDATA_MAP);
}
- //String pdfAttachmentKey = AppUtils.getRequestValue(request, "pdfAttachmentKey");
- String report_email_sent_log_id = ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),AppUtils.getRequestValue(request, "log_id"));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Email PDF" + pdfAttachmentKey+" "+ report_email_sent_log_id));
+
+ String reportEmailSentLogId = ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),AppUtils.getRequestValue(request, "log_id"));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Email PDF" + pdfAttachmentKey+" "+ reportEmailSentLogId));
//email pdf attachment specific
- if(nvl(pdfAttachmentKey).length()>0 && report_email_sent_log_id !=null)
+ if(nvl(pdfAttachmentKey).length()>0 && reportEmailSentLogId !=null)
isEmailAttachment = true;
if(isEmailAttachment) {
String query = Globals.getDownloadAllEmailSent();
query = query.replace("[pdfAttachmentKey.trim()]", pdfAttachmentKey.trim());
- query = query.replace("[report_email_sent_log_id.trim()]", report_email_sent_log_id.trim());
+ query = query.replace("[report_email_sent_log_id.trim()]", reportEmailSentLogId.trim());
DataSet ds = DbUtils.executeQuery(query, 1);
if(!ds.isEmpty()) {
- userId = ds.getString(0,"user_id");
+ userId = ds.getString(0,USER_ID);
reportID = ds.getString(0, "rep_id");
request.setAttribute("schedule_email_userId", userId);
} else {
- request.setAttribute("message", "This link has expired, please <a href=''>login</a> and regenerate the report");
+ request.setAttribute(MESSAGE, "This link has expired, please <a href=''>login</a> and regenerate the report");
return "raptor/message.jsp";
}
- } else userId = AppUtils.getUserID(request);
-// debugLogger.debug("Report ID b4 showbutton in ActionHandler "
-// + ( request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)!=null?((ReportRuntime)request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).getReportID():"Not in session"));
-// debugLogger.debug("Report ID " + reportID + " " + reportIDFromSession);
+ } else
+ userId = AppUtils.getUserID(request);
// Scheduling Dashoard report
if(reportID !=null && nvl(pdfAttachmentKey).length()>0)
@@ -540,7 +535,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
long totalTime = System.currentTimeMillis() - currentTime;
- formFields = AppUtils.getRequestNvlValue(request, "formFields");
+ formFields = AppUtils.getRequestNvlValue(request, FORM_FIELDS);
rrDashboardReports.logReportRun(userId, String.valueOf(totalTime),formFields);
rrDashboardReports.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_EXECUTION_TIME, formFields);
@@ -703,7 +698,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
request.getSession().setAttribute(AppConstants.RI_REPORT_DATA, rd);
} // else
long totalTime = System.currentTimeMillis() - currentTime;
- formFields = AppUtils.getRequestNvlValue(request, "formFields");
+ formFields = AppUtils.getRequestNvlValue(request, FORM_FIELDS);
request.setAttribute(AppConstants.RLA_EXECUTION_TIME, "" + totalTime);
@@ -1046,7 +1041,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
String toListUpdated = nvl(request.getParameter("toListUpdated"), FALSE);
reportUpdated = wp.processAdhocSchedule(request, action);
if(reportUpdated && toListUpdated.equals(FALSE)) {
- request.setAttribute("message", "Report has been scheduled successfully");
+ request.setAttribute(MESSAGE, "Report has been scheduled successfully");
reportSchedule = (ReportSchedule) request.getSession().getAttribute(AppConstants.SI_REPORT_SCHEDULE);
reportSchedule.persistScheduleData(connection, request);
DbUtils.commitTransaction(connection);
@@ -1208,7 +1203,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
removeVariablesFromSession(request);
DataCache.refreshAll();
Globals.getAppUtils().resetUserCache();
- request.setAttribute("message", "Cache Refreshed");
+ request.setAttribute(MESSAGE, "Cache Refreshed");
return nextPage;
}
public String reportCreate(HttpServletRequest request, String nextPage) {
@@ -1739,7 +1734,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
if(!isFromSchedule)
userId = AppUtils.getUserID(request);
else
- userId = AppUtils.getRequestValue(request, "user_id");
+ userId = AppUtils.getRequestValue(request, USER_ID);
Runtime runtime = Runtime.getRuntime();
ReportRuntime rr = null;
if(!isFromSchedule) {
@@ -1763,11 +1758,11 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
DataSet ds = DbUtils.executeQuery(query, 1);
if(!ds.isEmpty()) {
- userId = ds.getString(0,"user_id");
+ userId = ds.getString(0,USER_ID);
reportID = ds.getString(0, "rep_id");
request.setAttribute("schedule_email_userId", userId);
} else {
- request.setAttribute("message", "This link has expired, please <a href=''>login</a> and regenerate the report");
+ request.setAttribute(MESSAGE, "This link has expired, please <a href=''>login</a> and regenerate the report");
return "raptor/message.jsp";
}
@@ -1803,7 +1798,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
messageBuffer.append("Download data file using the following link<BR>");
messageBuffer.append("<a href=\"" + request.getContextPath() + "/raptor/dwnld/data/" +
strFileName + "\">click here</a>.</p>");
- request.setAttribute("message", messageBuffer.toString());
+ request.setAttribute(MESSAGE, messageBuffer.toString());
}
else if(!flag) {
String whole_fileName = FilenameUtils.normalize (Globals.getShellScriptDir() +AppConstants.SHELL_QUERY_DIR+ fileName+AppConstants.FT_SQL);
@@ -1932,8 +1927,8 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
}
//DbUtils.commitTransaction(connection);
//DbUtils.clearConnection(connection);
-
-
+
+
// debugLogger.debug("|"+downloadProcess.toString() + "|");
// if (downloadProcess == null)
@@ -1944,7 +1939,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
// retCode= downloadProcess.waitFor();
// } catch (InterruptedException e){
// e.printStackTrace();
-// }
+// }
// debugLogger.debug("retCode " + retCode);
// Process child = rtime.exec("/bin/bash");
// BufferedWriter outCommand = new BufferedWriter(new
@@ -1953,7 +1948,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
// outCommand.flush();
// int retCode = child.waitFor();
// debugLogger.debug("RetCode " + retCode);
- //request.setAttribute("message", "Shell Script is running in the background. You'll get an email once it is done");
+ //request.setAttribute(MESSAGE, "Shell Script is running in the background. You'll get an email once it is done");
}
return nextPage;
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportHandler.java
index e22d2e23..38f6497c 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportHandler.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportHandler.java
@@ -33,36 +33,31 @@
*
* ============LICENSE_END============================================
*
- *
+ *
*/
/* ===========================================================================================
- * This class is part of <I>RAPTOR (Rapid Application Programming Tool for OLAP Reporting)</I>
+ * This class is part of <I>RAPTOR (Rapid Application Programming Tool for OLAP Reporting)</I>
* Raptor : This tool is used to generate different kinds of reports with lot of utilities
* ===========================================================================================
*
* -------------------------------------------------------------------------------------------
- * ReportHandler.java - This class is used to generate reports in Excel using POI and also to
+ * ReportHandler.java - This class is used to generate reports in Excel using POI and also to
* create ReportRuntime and ReportDefinition object using report id.
* -------------------------------------------------------------------------------------------
*
*
* Changes
* -------
- * 18-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> request Object is passed to prevent caching user/roles - Datamining/Hosting. </LI></UL>
+ * 18-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> request Object is passed to prevent caching user/roles - Datamining/Hosting. </LI></UL>
* 14-Jul-2009 : Version 8.4 (Sundar); <UL><LI> Signature for generating excel method has been changed to add the report name as sheet name. </LI>
* <LI> Dashboard reports can be downloaded with each report as a separate sheet. </LI>
- * </UL>
- * 08-Jun-2009 : Version 8.3 (Sundar); <UL><LI> Short datatype is replaced with default integer datatype to create
- * row as short is not expoting more than 32768 rows. </LI></UL>
+ * </UL>
+ * 08-Jun-2009 : Version 8.3 (Sundar); <UL><LI> Short datatype is replaced with default integer datatype to create
+ * row as short is not expoting more than 32768 rows. </LI></UL>
*
*/
package org.onap.portalsdk.analytics.model;
-import com.lowagie.text.Document;
-import com.lowagie.text.Paragraph;
-import com.lowagie.text.html.simpleparser.HTMLWorker;
-import com.lowagie.text.html.simpleparser.StyleSheet;
-import com.lowagie.text.pdf.PdfPTable;
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.File;
@@ -107,10 +102,18 @@ import java.util.concurrent.TimeoutException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
+
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+
+import com.lowagie.text.Document;
+import com.lowagie.text.Paragraph;
+import com.lowagie.text.html.simpleparser.HTMLWorker;
+import com.lowagie.text.html.simpleparser.StyleSheet;
+import com.lowagie.text.pdf.PdfPTable;
+
import org.apache.commons.io.FilenameUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
@@ -123,8 +126,10 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.DateUtil;
+import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Header;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
@@ -173,71 +178,69 @@ import org.owasp.esapi.ESAPI;
public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
- private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportHandler.class);
-
- public ReportHandler() {}
-
- private String sheetName = "";
- private static final String XML_ENCODING = "UTF-8";
- private static final int FONT_SIZE = 10;
- private static final int FONT_HEADER_TITLE_SIZE = 12;
- private static final int FONT_HEADER_DESCR_SIZE = 9;
- private static final int FONT_FOOTER_SIZE = 9;
- private static final String DEFAULT = "default";
- private static final String YELLOW = "yellow";
- private static final String GREEN = "green";
- private static final String RED = "red";
- private static final String RUNTIME_PARAMETERS = "Run-time Parameters";
- private static final String FONT_TAHOMA = "Tahoma";
-
- private HashMap loadStyles(ReportRuntime rr, HSSFWorkbook wb) {
- HSSFCellStyle styleDefault = wb.createCellStyle();
- // Style default will be normal with no background
- HSSFFont fontDefault = wb.createFont();
- // The default will be plain .
- fontDefault.setColor((short) HSSFFont.COLOR_NORMAL);
- fontDefault.setFontHeight((short) (FONT_SIZE / 0.05));
- fontDefault.setFontName(FONT_TAHOMA);
-
- styleDefault.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleDefault.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleDefault.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleDefault.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleDefault.setBorderRight(HSSFCellStyle.BORDER_THIN);
- // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleDefault.setFillPattern(HSSFCellStyle.NO_FILL);
- styleDefault.setFont(fontDefault);
-
- HSSFCellStyle styleRed = wb.createCellStyle();
- styleRed.cloneStyleFrom(styleDefault);
- styleRed.setFillForegroundColor((short) HSSFColor.RED.index);
- styleRed.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
- HSSFFont fontRed = wb.createFont();
- fontRed.setColor((short) HSSFColor.WHITE.index);
- fontRed.setFontHeight((short) (FONT_SIZE / 0.05));
- fontRed.setFontName(FONT_TAHOMA);
- styleRed.setFont(fontRed);
-
- HSSFCellStyle styleYellow = wb.createCellStyle();
- styleYellow.cloneStyleFrom(styleDefault);
- styleYellow.setFillForegroundColor((short) HSSFColor.YELLOW.index);
- styleYellow.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
- HSSFFont fontYellow = wb.createFont();
- fontYellow.setColor((short) HSSFColor.BLACK.index);
- fontYellow.setFontHeight((short) (FONT_SIZE / 0.05));
- fontYellow.setFontName(FONT_TAHOMA);
- styleYellow.setFont(fontYellow);
-
- HSSFCellStyle styleGreen = wb.createCellStyle();
- styleGreen.cloneStyleFrom(styleDefault);
- styleGreen.setFillForegroundColor((short) HSSFColor.GREEN.index);
- styleGreen.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
- HSSFFont fontGreen = wb.createFont();
- fontGreen.setColor((short) HSSFColor.WHITE.index);
- fontGreen.setFontHeight((short) (FONT_SIZE / 0.05));
- fontGreen.setFontName(FONT_TAHOMA);
- styleGreen.setFont(fontGreen);
-
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportHandler.class);
+
+ public ReportHandler() {
+ }
+
+ private String SHEET_NAME = "";
+ private static final String XML_ENCODING = "UTF-8";
+ private static int font_size = 10;
+ private static int font_header_title_size = 12;
+ private static int font_header_descr_size = 9;
+ private static int font_footer_size = 9;
+
+
+ private HashMap loadStyles(ReportRuntime rr, HSSFWorkbook wb) {
+ HSSFCellStyle styleDefault = wb.createCellStyle();
+ //System.out.println("Load Styles");
+ // Style default will be normal with no background
+ HSSFFont fontDefault = wb.createFont();
+ // The default will be plain .
+ fontDefault.setColor((short) HSSFFont.COLOR_NORMAL);
+ fontDefault.setFontHeight((short) (font_size / 0.05));
+ fontDefault.setFontName("Tahoma");
+
+ styleDefault.setAlignment(HorizontalAlignment.CENTER );
+ styleDefault.setBorderBottom(BorderStyle.THIN);
+ styleDefault.setBorderTop(BorderStyle.THIN);
+ styleDefault.setBorderLeft(BorderStyle.THIN);
+ styleDefault.setBorderRight(BorderStyle.THIN);
+ // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
+ styleDefault.setFillPattern(FillPatternType.NO_FILL);
+ styleDefault.setFont(fontDefault);
+
+ HSSFCellStyle styleRed = wb.createCellStyle();
+ styleRed.cloneStyleFrom(styleDefault);
+ styleRed.setFillForegroundColor((short)HSSFColor.RED.index);
+ styleRed.setFillPattern(FillPatternType.SOLID_FOREGROUND );
+ HSSFFont fontRed = wb.createFont();
+ fontRed.setColor((short) HSSFColor.WHITE.index);
+ fontRed.setFontHeight((short) (font_size / 0.05));
+ fontRed.setFontName("Tahoma");
+ styleRed.setFont(fontRed);
+
+ HSSFCellStyle styleYellow = wb.createCellStyle();
+ styleYellow.cloneStyleFrom(styleDefault);
+ styleYellow.setFillForegroundColor((short)HSSFColor.YELLOW.index);
+ styleYellow.setFillPattern(FillPatternType.SOLID_FOREGROUND );
+ HSSFFont fontYellow = wb.createFont();
+ fontYellow.setColor((short) HSSFColor.BLACK.index);
+ fontYellow.setFontHeight((short) (font_size / 0.05));
+ fontYellow.setFontName("Tahoma");
+ styleYellow.setFont(fontYellow);
+
+ HSSFCellStyle styleGreen = wb.createCellStyle();
+ styleGreen.cloneStyleFrom(styleDefault);
+ styleGreen.setFillForegroundColor((short)HSSFColor.GREEN.index);
+ styleGreen.setFillPattern(FillPatternType.SOLID_FOREGROUND );
+ HSSFFont fontGreen = wb.createFont();
+ fontGreen.setColor((short) HSSFColor.WHITE.index);
+ fontGreen.setFontHeight((short) (font_size / 0.05));
+ fontGreen.setFontName("Tahoma");
+ styleGreen.setFont(fontGreen);
+
+
ArrayList semColumnList = new ArrayList();
List dsList = rr.getDataSourceList().getDataSource();
for (Iterator iter = dsList.iterator(); iter.hasNext();) {
@@ -246,2501 +249,2587 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
for (Iterator iterator = dcList.iterator(); iterator.hasNext();) {
DataColumnType element1 = (DataColumnType) iterator.next();
semColumnList.add(element1.getSemaphoreId());
-
- }
- }
- SemaphoreList semList = rr.getSemaphoreList();
- HashMap hashMapStyles = new HashMap();
- HashMap hashMapFonts = new HashMap();
- hashMapFonts.put(DEFAULT, fontDefault);
- hashMapFonts.put(RED, fontRed);
- hashMapFonts.put(YELLOW, fontYellow);
- hashMapFonts.put(GREEN, fontGreen);
- hashMapStyles.put(DEFAULT, styleDefault);
- hashMapStyles.put(RED, styleRed);
- hashMapStyles.put(YELLOW, styleYellow);
- hashMapStyles.put(GREEN, styleGreen);
- HSSFCellStyle cellStyle = null;
- if (semList == null || semList.getSemaphore() == null) {
- return hashMapStyles;
- } else {
- for (Iterator iter = semList.getSemaphore().iterator(); iter.hasNext();) {
- SemaphoreType sem = (SemaphoreType) iter.next();
- if (!semColumnList.contains(sem.getSemaphoreId()))
- continue;
- // System.out.println("SemphoreId ----> " + sem.getSemaphoreId());
- FormatList fList = sem.getFormatList();
- List formatList = fList.getFormat();
- for (Iterator fIter = formatList.iterator(); fIter.hasNext();) {
- FormatType fmt = (FormatType) fIter.next();
- if (fmt != null) {
- // if (fmt.getLessThanValue().length() > 0) {
- cellStyle = wb.createCellStyle();
- HSSFFont cellFont = wb.createFont();
- // System.out.println("Format Id " + fmt.getFormatId());
- if (nvl(fmt.getBgColor()).length() > 0) {
- // System.out.println("Load Styles " +
- // fmt.getFormatId()
- // + " " +fmt.getBgColor() + " " +
- // ExcelColorDef.getExcelColor(fmt.getBgColor()));
- cellStyle.setFillForegroundColor(ExcelColorDef.getExcelColor(fmt
- .getBgColor()));
- cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
- }
- if (nvl(fmt.getFontColor()).length() > 0) {
- cellFont.setColor(ExcelColorDef.getExcelColor(fmt.getFontColor()));
- } else
- cellFont.setColor((short) HSSFFont.COLOR_NORMAL);
- if (fmt.isBold())
- cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
- if (fmt.isItalic())
- cellFont.setItalic(true);
- if (fmt.isUnderline())
- cellFont.setUnderline(HSSFFont.U_SINGLE);
- if (nvl(fmt.getFontFace()).length() > 0)
- cellFont.setFontName(fmt.getFontFace());
- else
- cellFont.setFontName(FONT_TAHOMA);
- // cellFont.setFontHeight((short) (10 / 0.05));
-
- if (nvl(fmt.getFontSize()).length() > 0) {
- try {
- // cellFont.setFontHeight((short) (Integer.parseInt(fmt.getFontSize()) / 0.05));
- cellFont.setFontHeight((short) (FONT_SIZE / 0.05));
- } catch (NumberFormatException e) {
- cellFont.setFontHeight((short) (FONT_SIZE / 0.05));// 10
- }
- } else
- cellFont.setFontHeight((short) (FONT_SIZE / 0.05));
- cellStyle.setFont(cellFont);
- cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
- cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
- hashMapStyles.put(fmt.getFormatId(), cellStyle);
- } else {
- // hashMapStyles.put(fmt.getFormatId(), styleDefault); //fmt is null here
- hashMapStyles.put(DEFAULT, styleDefault);
- }
- }
-
+
}
}
- return hashMapStyles;
- }
-
- private void paintExcelParams(final HSSFWorkbook wb, int rowNum, final int col, final List paramsList,
- final String customizedParamInfo, final HSSFSheet sheet, final String reportTitle, final String reportDescr)
- throws IOException {
- // HSSFSheet sheet = wb.getSheet(getSheetName());
+ SemaphoreList semList = rr.getSemaphoreList();
+ HashMap hashMapStyles = new HashMap();
+ HashMap hashMapFonts = new HashMap();
+ hashMapFonts.put("default", fontDefault);
+ hashMapFonts.put("red", fontRed);
+ hashMapFonts.put("yellow", fontYellow);
+ hashMapFonts.put("green", fontGreen);
+ hashMapStyles.put("default", styleDefault);
+ hashMapStyles.put("red", styleRed);
+ hashMapStyles.put("yellow", styleYellow);
+ hashMapStyles.put("green", styleGreen);
+ HSSFCellStyle cellStyle = null;
+ if (semList == null || semList.getSemaphore() == null) {
+ return hashMapStyles;
+ } else {
+ for (Iterator iter = semList.getSemaphore().iterator(); iter.hasNext();) {
+ SemaphoreType sem = (SemaphoreType) iter.next();
+ if(!semColumnList.contains(sem.getSemaphoreId())) continue;
+ //System.out.println("SemphoreId ----> " + sem.getSemaphoreId());
+ FormatList fList = sem.getFormatList();
+ List formatList = fList.getFormat();
+ for (Iterator fIter = formatList.iterator(); fIter.hasNext();) {
+ FormatType fmt = (FormatType) fIter.next();
+ if(fmt!=null){
+ //if (fmt.getLessThanValue().length() > 0) {
+ cellStyle = wb.createCellStyle();
+ HSSFFont cellFont = wb.createFont();
+ //System.out.println("Format Id " + fmt.getFormatId());
+ if (nvl(fmt.getBgColor()).length() > 0) {
+// System.out.println("Load Styles " +
+// fmt.getFormatId()
+// + " " +fmt.getBgColor() + " " +
+// ExcelColorDef.getExcelColor(fmt.getBgColor()));
+ cellStyle.setFillForegroundColor(ExcelColorDef.getExcelColor(fmt
+ .getBgColor()));
+ cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND );
+ }
+ if (nvl(fmt.getFontColor()).length() > 0) {
+ cellFont.setColor(ExcelColorDef.getExcelColor(fmt.getFontColor()));
+ } else
+ cellFont.setColor((short) HSSFFont.COLOR_NORMAL);
+ if (fmt.isBold())
+ cellFont.setBold(true);
+ if (fmt.isItalic())
+ cellFont.setItalic(true);
+ if (fmt.isUnderline())
+ cellFont.setUnderline(HSSFFont.U_SINGLE);
+ if(nvl(fmt.getFontFace()).length()>0)
+ cellFont.setFontName(fmt.getFontFace());
+ else
+ cellFont.setFontName("Tahoma");
+ //cellFont.setFontHeight((short) (10 / 0.05));
+
+ if(nvl(fmt.getFontSize()).length()>0) {
+ try {
+ //cellFont.setFontHeight((short) (Integer.parseInt(fmt.getFontSize()) / 0.05));
+ cellFont.setFontHeight((short) (font_size/0.05));
+ } catch(NumberFormatException e){
+ cellFont.setFontHeight((short) (font_size / 0.05));//10
+ }
+ }
+ else
+ cellFont.setFontHeight((short) (font_size / 0.05));
+ cellStyle.setFont(cellFont);
+ cellStyle.setAlignment(HorizontalAlignment.CENTER);
+ cellStyle.setBorderBottom(BorderStyle.THIN);
+ cellStyle.setBorderTop(BorderStyle.THIN);
+ cellStyle.setBorderLeft(BorderStyle.THIN);
+ cellStyle.setBorderRight(BorderStyle.THIN);
+ hashMapStyles.put(fmt.getFormatId(), cellStyle);
+ } else {
+ // hashMapStyles.put(fmt.getFormatId(), styleDefault); //fmt is null here
+ hashMapStyles.put("default", styleDefault);
+ }
+ }
+
+ }
+ }
+ return hashMapStyles;
+ }
+
+ private void paintExcelParams(final HSSFWorkbook wb, int rowNum, final int col, final List paramsList,
+ final String customizedParamInfo, final HSSFSheet sheet, final String reportTitle, final String reportDescr)
+ throws IOException {
+ //HSSFSheet sheet = wb.getSheet(getSheetName());
int cellNum = 0;
HSSFRow row = null;
- short s1 = 0;
- short s2 = (short) 1;
+ short s1 = 0, s2 = (short) 1;
+ HtmlStripper strip = new HtmlStripper();
// Name Style
HSSFCellStyle styleName = wb.createCellStyle();
- // styleName.setFillBackgroundColor(HSSFColor.GREY_80_PERCENT.index);
+ //styleName.setFillBackgroundColor(HSSFColor.GREY_80_PERCENT.index);
styleName.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
- // styleName.setFillPattern(HSSFCellStyle.SPARSE_DOTS);
- styleName.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleName.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleName.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleName.setBorderRight(HSSFCellStyle.BORDER_THIN);
- styleName.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleName.setDataFormat((short) 0);
+ //styleName.setFillPattern(HSSFCellStyle.SPARSE_DOTS);
+ styleName.setAlignment(HorizontalAlignment.CENTER);
+ styleName.setBorderBottom(BorderStyle.THIN);
+ styleName.setBorderTop(BorderStyle.THIN);
+ styleName.setBorderRight(BorderStyle.THIN);
+ styleName.setBorderLeft(BorderStyle.THIN);
+ styleName.setDataFormat((short)0);
HSSFFont font = wb.createFont();
- font.setFontHeight((short) (FONT_SIZE / 0.05));
- font.setFontName(FONT_TAHOMA);
+ font.setFontHeight((short) (font_size / 0.05));
+ font.setFontName("Tahoma");
font.setColor(HSSFColor.BLACK.index);
- font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+ font.setBold(true);
styleName.setFont(font);
- // Data Style
-
+ //Data Style
+
// Create some fonts.
HSSFFont fontDefault = wb.createFont();
// Initialize the styles & fonts.
// The default will be plain .
fontDefault.setColor((short) HSSFFont.COLOR_NORMAL);
- fontDefault.setFontHeight((short) (FONT_SIZE / 0.05));
- fontDefault.setFontName(FONT_TAHOMA);
+ fontDefault.setFontHeight((short) (font_size / 0.05));
+ fontDefault.setFontName("Tahoma");
fontDefault.setItalic(true);
// Style default will be normal with no background
HSSFCellStyle styleValue = wb.createCellStyle();
- styleValue.setDataFormat((short) 0);
- styleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleValue.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleValue.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleValue.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleValue.setBorderRight(HSSFCellStyle.BORDER_THIN);
+ styleValue.setDataFormat((short)0);
+ styleValue.setAlignment(HorizontalAlignment.CENTER);
+ styleValue.setBorderBottom(BorderStyle.THIN);
+ styleValue.setBorderTop(BorderStyle.THIN);
+ styleValue.setBorderLeft(BorderStyle.THIN);
+ styleValue.setBorderRight(BorderStyle.THIN);
// styleValue.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleValue.setFillPattern(HSSFCellStyle.NO_FILL);
+ styleValue.setFillPattern(FillPatternType.NO_FILL);
styleValue.setFont(fontDefault);
HSSFCell cell = null;
HSSFCellStyle styleDescription = wb.createCellStyle();
- styleDescription.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- // styleDescription.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- // styleDescription.setBorderTop(HSSFCellStyle.BORDER_THIN);
- // styleDescription.setBorderRight(HSSFCellStyle.BORDER_THIN);
- // styleDescription.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+ styleDescription.setAlignment(HorizontalAlignment.CENTER);
+// styleDescription.setBorderBottom(BorderStyle.THIN);
+// styleDescription.setBorderTop(BorderStyle.THIN);
+// styleDescription.setBorderRight(BorderStyle.THIN);
+// styleDescription.setBorderLeft(BorderStyle.THIN);
HSSFFont fontDescr = wb.createFont();
- fontDescr.setFontHeight((short) (FONT_SIZE / 0.05)); // 14
- fontDescr.setFontName(FONT_TAHOMA);
+ fontDescr.setFontHeight((short) (font_size / 0.05)); //14
+ fontDescr.setFontName("Tahoma");
fontDescr.setColor(HSSFColor.BLACK.index);
- fontDescr.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+ fontDescr.setBold(true);
styleDescription.setFont(font);
HSSFCell cellDescr = null;
int paramSeq = 0;
HSSFHeader header = sheet.getHeader();
- StringBuilder strBuf = new StringBuilder();
- if (!Globals.customizeFormFieldInfo() || customizedParamInfo.length() <= 0) {
- for (Iterator iter = paramsList.iterator(); iter.hasNext();) {
- IdNameValue value = (IdNameValue) iter.next();
- // System.out.println("\"" + value.getId() + " = " + value.getName() + "\"");
- if (nvl(value.getId()).trim().length() > 0 && (!nvl(value.getId()).trim().equals("BLANK"))) {
- paramSeq += 1;
- if (paramSeq <= 1) {
- row = sheet.createRow(++rowNum);
- cell = row.createCell((short) 0);
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
- cellDescr = row.createCell((short) 0);
- cellDescr.setCellValue(RUNTIME_PARAMETERS);
- cellDescr.setCellStyle(styleDescription);
-
- strBuf.append(reportTitle + "\n");
- // strBuf.append("Run-time Parameters\n");
- }
- row = sheet.createRow(++rowNum);
- cellNum = 0;
- // System.out.println("RowNum " + rowNum + " " + value.getId() + " " +value.getName());
- cell = row.createCell((short) cellNum);
- cell.setCellValue(value.getId());
- cell.setCellStyle(styleName);
- cellNum += 1;
- cell = row.createCell((short) cellNum);
- cell.setCellValue(value.getName().replaceAll("~", ","));
- cell.setCellStyle(styleValue);
-
- // strBuf.append(value.getId()+": "+ value.getName()+"\n");
- }
- } // for
+ StringBuffer strBuf = new StringBuffer();
+ if(!Globals.customizeFormFieldInfo() || customizedParamInfo.length()<=0) {
+ for (Iterator iter = paramsList.iterator(); iter.hasNext();) {
+ IdNameValue value = (IdNameValue) iter.next();
+ //System.out.println("\"" + value.getId() + " = " + value.getName() + "\"");
+ if(nvl(value.getId()).trim().length()>0 && (!nvl(value.getId()).trim().equals("BLANK"))) {
+ paramSeq += 1;
+ if(paramSeq <= 1) {
+ row = sheet.createRow(++rowNum);
+ cell = row.createCell((short) 0);
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
+ cellDescr = row.createCell((short) 0);
+ cellDescr.setCellValue("Run-time Parameters");
+ cellDescr.setCellStyle(styleDescription);
+
+
+ strBuf.append(reportTitle+"\n");
+ //strBuf.append("Run-time Parameters\n");
+ }
+ row = sheet.createRow(++rowNum);
+ cellNum = 0;
+ //System.out.println("RowNum " + rowNum + " " + value.getId() + " " +value.getName());
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue(value.getId());
+ cell.setCellStyle(styleName);
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue(value.getName().replaceAll("~",","));
+ cell.setCellStyle(styleValue);
+
+ //strBuf.append(value.getId()+": "+ value.getName()+"\n");
+ }
+ } //for
} else {
- strBuf.append(reportTitle + "\n");
- Document document = new Document();
- document.open();
+ strBuf.append(reportTitle+"\n");
+ Document document = new Document();
+ document.open();
HTMLWorker worker = new HTMLWorker(document);
- StyleSheet style = new StyleSheet();
- style.loadTagStyle("body", "leading", "16,0");
- ArrayList p = HTMLWorker.parseToList(new StringReader(customizedParamInfo), style);
- String name = "";
- String token = "";
- String value = "";
- String s = "";
- PdfPTable pdfTable = null;
- for (int k = 0; k < p.size(); ++k) {
- if (p.get(k) instanceof Paragraph)
- s = ((Paragraph) p.get(k)).toString();
- else { /* if ((p.get(k) instanceof PdfPTable)) */
- pdfTable = ((PdfPTable) p.get(k));
- }
- // todo: Logic for parsing pdfTable should be added after upgrading to iText 5.0.0
- // s = Utils.replaceInString(s, ",", "|");
- s = s.replaceAll(",", "|");
- s = s.replaceAll("~", ",");
- if (s.indexOf(":") != -1) {
- // System.out.println("|"+s+"|");
- row = sheet.createRow(++rowNum);
+ StyleSheet style = new StyleSheet();
+ style.loadTagStyle("body", "leading", "16,0");
+ ArrayList p = HTMLWorker.parseToList(new StringReader(customizedParamInfo), style);
+ String name = "";
+ String token = "";
+ String value = "";
+ String s = "";
+ PdfPTable pdfTable = null;
+ for (int k = 0; k < p.size(); ++k){
+ if(p.get(k) instanceof Paragraph)
+ s = ((Paragraph)p.get(k)).toString();
+ else { /*if ((p.get(k) instanceof PdfPTable))*/
+ pdfTable = ((PdfPTable)p.get(k));
+ }
+ //todo: Logic for parsing pdfTable should be added after upgrading to iText 5.0.0
+ //s = Utils.replaceInString(s, ",", "|");
+ s = s.replaceAll(",", "|");
+ s = s.replaceAll("~", ",");
+ if(s.indexOf(":")!= -1) {
+ //System.out.println("|"+s+"|");
+ row = sheet.createRow(++rowNum);
cell = row.createCell((short) 0);
sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
cellDescr = row.createCell((short) 0);
- cellDescr.setCellValue(RUNTIME_PARAMETERS);
- cellDescr.setCellStyle(styleDescription);
-
- // strBuf.append("Run-time Parameters\n");
- StringTokenizer st = new StringTokenizer(s.trim(), "|");
- while (st.hasMoreTokens()) {
- token = st.nextToken();
- token = token.trim();
- if (!(token.trim().equals("|") || token.trim().equals("]]") || token.trim().equals("]")
- || token.trim().equals("["))) {
- if (token.endsWith(":")) {
- name = token;
- name = name.substring(0, name.length() - 1);
- if (name.startsWith("["))
- name = name.substring(1);
- value = st.nextToken();
- if (nvl(value).endsWith("]"))
- value = nvl(value).substring(0, nvl(value).length() - 1);
- } /*
- * else if(name != null && name.length() > 0) { value = st.nextToken();
- * if(value.endsWith("]]"))value = value.substring(0, value.length()-1); }
- */
- if (name != null && name.trim().length() > 0) {
- row = sheet.createRow((short) ++rowNum);
- cellNum = 0;
- cell = row.createCell((short) cellNum);
- cell.setCellValue(name.trim());
- cell.setCellStyle(styleName);
- cellNum += 1;
- cell = row.createCell((short) cellNum);
- cell.setCellValue(value.trim());
- cell.setCellStyle(styleValue);
- // strBuf.append(name.trim()+": "+ value.trim()+"\n");
- }
- /*
- * if(token.endsWith(":") && (value!=null && value.trim().length()<=0) && (name!=null &&
- * name.trim().length()>0 && name.endsWith(":"))) { name = name.substring(0,
- * name.indexOf(":")+1); //value = token.substring(token.indexOf(":")+1); row =
- * sheet.createRow((short) ++rowNum); cellNum = 0; cell = row.createCell((short) cellNum);
- * cell.setCellValue(name.trim()); cell.setCellStyle(styleName); cellNum += 1; cell =
- * row.createCell((short) cellNum); cell.setCellValue(value.trim());
- * cell.setCellStyle(styleValue);
- *
- * //strBuf.append(name.trim()+": "+ value.trim()+"\n"); value = ""; name = ""; }
- */ }
- // int cw = 0;
- // cw = name.trim().length() + 12;
- // if(i!=cellWidth.size()-1)
- if (name != null && (sheet.getColumnWidth((short) 0) < (short) name.trim().length())) {
- sheet.setColumnWidth((short) 0, (short) name.trim().length());
- }
- if (sheet.getColumnWidth((short) 1) < (short) value.trim().length()) {
- sheet.setColumnWidth((short) 1, (short) value.trim().length());
- }
- name = "";
- value = "";
-
- }
-
- try {
- SimpleDateFormat oracleDateFormat = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss");
- Date sysdate = oracleDateFormat.parse(ReportLoader.getSystemDateTime());
- SimpleDateFormat dtimestamp = new SimpleDateFormat(Globals.getScheduleDatePattern());
-
- row = sheet.createRow((short) ++rowNum);
- cellNum = 0;
- cell = row.createCell((short) cellNum);
- cell.setCellValue("Report Date/Time");
- cell.setCellStyle(styleName);
- cellNum += 1;
- cell = row.createCell((short) cellNum);
-
- cell.setCellValue(dtimestamp.format(sysdate) + " " + Globals.getTimeZone());
- cell.setCellStyle(styleValue);
-
- } catch (Exception ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "Excetion in paintExcelParams", ex);
- }
- }
- }
-
- /*
- * Iterator iter1 = paramsList.iterator(); s1 = 0; s2 = (short)10; if(iter1.hasNext()) { row =
- * sheet.createRow((short) ++rowNum); cellNum = 0; cell = row.createCell((short) cellNum);
- * sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
- * cell.setCellValue(strip.stripHtml(customizedParamInfo)); }
- */
- /*
- * rowNum += 2; row = sheet.createRow(rowNum);
- */
- } // if
+ cellDescr.setCellValue("Run-time Parameters");
+ cellDescr.setCellStyle(styleDescription);
+
+ //strBuf.append("Run-time Parameters\n");
+ StringTokenizer st = new StringTokenizer(s.trim(), "|");
+ while(st.hasMoreTokens()) {
+ token = st.nextToken();
+ token = token.trim();
+ if (!(token.trim().equals("|") || token.trim().equals("]]") || token.trim().equals("]") || token.trim().equals("[") )) {
+ if(token.endsWith(":")) {
+ name = token;
+ name = name.substring(0, name.length()-1);
+ if(name.startsWith("["))
+ name = name.substring(1);
+ value = st.nextToken();
+ if(nvl(value).endsWith("]"))value = nvl(value).substring(0, nvl(value).length()-1);
+ } /*else if(name != null && name.length() > 0) {
+ value = st.nextToken();
+ if(value.endsWith("]]"))value = value.substring(0, value.length()-1);
+ }*/
+ if(name!=null && name.trim().length()>0) {
+ row = sheet.createRow((short) ++rowNum);
+ cellNum = 0;
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue(name.trim());
+ cell.setCellStyle(styleName);
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue(value.trim());
+ cell.setCellStyle(styleValue);
+ //strBuf.append(name.trim()+": "+ value.trim()+"\n");
+ }
+/* if(token.endsWith(":") && (value!=null && value.trim().length()<=0) && (name!=null && name.trim().length()>0 && name.endsWith(":"))) {
+ name = name.substring(0, name.indexOf(":")+1);
+ //value = token.substring(token.indexOf(":")+1);
+ row = sheet.createRow((short) ++rowNum);
+ cellNum = 0;
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue(name.trim());
+ cell.setCellStyle(styleName);
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue(value.trim());
+ cell.setCellStyle(styleValue);
+
+ //strBuf.append(name.trim()+": "+ value.trim()+"\n");
+ value = "";
+ name = "";
+ }
+*/ }
+ //int cw = 0;
+ //cw = name.trim().length() + 12;
+ // if(i!=cellWidth.size()-1)
+ if(name!=null && (sheet.getColumnWidth((short)0)< (short) name.trim().length())){
+ sheet.setColumnWidth((short)0, (short) name.trim().length());
+ }
+ if(sheet.getColumnWidth((short)1)< (short) value.trim().length()){
+ sheet.setColumnWidth((short)1, (short) value.trim().length());
+ }
+ name = "";
+ value = "";
+
+ }
+
+ try {
+ SimpleDateFormat oracleDateFormat = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss");
+ Date sysdate = oracleDateFormat.parse(ReportLoader.getSystemDateTime());
+ SimpleDateFormat dtimestamp = new SimpleDateFormat(Globals.getScheduleDatePattern());
+
+ row = sheet.createRow((short) ++rowNum);
+ cellNum = 0;
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue("Report Date/Time");
+ cell.setCellStyle(styleName);
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+
+ cell.setCellValue(dtimestamp.format(sysdate)+" "+Globals.getTimeZone());
+ cell.setCellStyle(styleValue);
+
+ } catch(Exception ex) {
+ //ex.printStackTrace();
+ }
+
+
+ }
+ }
+
+
+/* Iterator iter1 = paramsList.iterator();
+ s1 = 0; s2 = (short)10;
+ if(iter1.hasNext()) {
+ row = sheet.createRow((short) ++rowNum);
+ cellNum = 0;
+ cell = row.createCell((short) cellNum);
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
+ cell.setCellValue(strip.stripHtml(customizedParamInfo));
+ }
+*/
+/* rowNum += 2;
+ row = sheet.createRow(rowNum);*/
+ } // if
Iterator iterCheck = paramsList.iterator();
- if (iterCheck.hasNext()) {
+ if(iterCheck.hasNext()) {
rowNum += 2;
row = sheet.createRow(rowNum);
}
- header.setCenter(HSSFHeader.font(FONT_TAHOMA, "") + HSSFHeader.fontSize((short) 9) + " " + strBuf.toString());
+ header.setCenter(HSSFHeader.font("Tahoma", "")+ HSSFHeader.fontSize((short) 9)+" " + strBuf.toString());
HSSFFooter footer = sheet.getFooter();
- footer.setLeft(HSSFFooter.font(FONT_TAHOMA, "") + HSSFFooter.fontSize((short) 9) + "Page " + HSSFFooter.page()
- + " of " + HSSFFooter.numPages());
- footer.setCenter(
- HSSFFooter.font(FONT_TAHOMA, "") + HSSFFooter.fontSize((short) 9) + Globals.getFooterFirstLine()
- + "\n" + Globals.getFooterSecondLine());
-
+ footer.setLeft(HSSFFooter.font("Tahoma", "")+ HSSFFooter.fontSize((short) 9)+ "Page " + HSSFFooter.page()
+ + " of " + HSSFFooter.numPages() );
+ footer.setCenter(HSSFFooter.font("Tahoma", "")+ HSSFFooter.fontSize((short) 9)+Globals.getFooterFirstLine()+"\n"+Globals.getFooterSecondLine());
+
}
- private int paintExcelData(final HSSFWorkbook wb, int rowNum, final ReportData rd, final Map styles,
- final ReportRuntime rr, final HSSFSheet sheet, final String sql_whole,
- final HttpServletRequest request) throws RaptorException {
- int mb = 1024 * 1024;
- Runtime runtime = Runtime.getRuntime();
- int returnValue = 0;
- // HSSFSheet sheet = wb.getSheetAt(0);
- HSSFCellStyle styleDefault = wb.createCellStyle();
- HSSFCellStyle styleNumber = wb.createCellStyle();
+ private int paintExcelData(final HSSFWorkbook wb, int rowNum, final ReportData rd, final Map styles,
+ final ReportRuntime rr, final HSSFSheet sheet, final String sql_whole,
+ final HttpServletRequest request) throws RaptorException {
+ int mb = 1024*1024;
+ Runtime runtime = Runtime.getRuntime();
+ int returnValue = 0;
+ // HSSFSheet sheet = wb.getSheetAt(0);
+ HSSFCellStyle styleDefault = wb.createCellStyle();
+ HSSFCellStyle styleNumber = wb.createCellStyle();
HSSFCellStyle styleDecimalNumber = wb.createCellStyle();
- HSSFCellStyle styleCurrencyNumber = wb.createCellStyle();
+ HSSFCellStyle styleCurrencyNumber = wb.createCellStyle();
HSSFCellStyle styleCurrencyDecimalNumber = wb.createCellStyle();
- HSSFCellStyle styleDate = wb.createCellStyle();
+ HSSFCellStyle styleDate = wb.createCellStyle();
HtmlStripper strip = new HtmlStripper();
- // HSSFSheet sheet = wb.getSheet(getSheetName());
- HSSFCellStyle styleDataHeader = wb.createCellStyle();
- // style.setFillBackgroundColor(HSSFColor.AQUA.index);
- styleDataHeader.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index);
- styleDataHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
- styleDataHeader.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleDataHeader.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleDataHeader.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleDataHeader.setBorderRight(HSSFCellStyle.BORDER_THIN);
- styleDataHeader.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- HSSFFont font = wb.createFont();
- font.setFontHeight((short) (FONT_SIZE / 0.05));
- font.setFontName(FONT_TAHOMA);
- font.setColor(HSSFColor.BLACK.index);
- styleDataHeader.setFont(font);
- // Column Header
- boolean firstPass = true;
- ArrayList cellWidth = new ArrayList();
- java.util.HashMap dataTypeMap = new java.util.HashMap();
- int cellNum = 0;
- rowNum += 0;
- ColumnHeaderRow chr = null;
- String title = "";
-
- // System.out.println("***************** Size " + rd.reportColumnHeaderRows.size());
- // for (int i = 0; i < rd.reportColumnHeaderRows.size(); i++) {
- // for (int j = 0; j < rd.reportColumnHeaderRows.getColumnHeaderRow(i).size(); j++) {
- // System.out.println("Column Title " +
- // rd.reportColumnHeaderRows.getColumnHeaderRow(i).getColumnHeader(j).getColumnTitle()
- // + " " + rd.reportColumnHeaderRows.getColumnHeaderRow(i).getColumnHeader(j).isVisible());
- // }
- // }
- /*
- * List dsList = rr.getDataSourceList().getDataSource(); HashMap dataColumnTypeHashMap = new
- * HashMap(); for (Iterator iter = dsList.iterator(); iter.hasNext();) { DataSourceType element =
- * (DataSourceType) iter.next(); List dcList = element.getDataColumnList().getDataColumn(); for
- * (Iterator iterator = dcList.iterator(); iterator.hasNext();) { DataColumnType element1 =
- * (DataColumnType) iterator.next(); dataTypeMap.put(element1.getColId(), element1.getColType());
- * dataColumnTypeHashMap.put(element1.getColName(), element1); } }
- */
- int columnRows = rr.getVisibleColumnCount() - 1;
-
- HttpSession session = request.getSession();
- String drilldown_index = (String) session.getAttribute("drilldown_index");
- int index = 0;
- try {
- index = Integer.parseInt(drilldown_index);
- } catch (NumberFormatException ex) {
- index = 0;
- }
- String header = (String) session.getAttribute("TITLE_" + index);
- String subtitle = (String) session.getAttribute("SUBTITLE_" + index);
- if (nvl(header).length() > 0) {
- header = Utils.replaceInString(header, "<BR/>", " ");
- header = Utils.replaceInString(header, "<br/>", " ");
- header = Utils.replaceInString(header, "<br>", " ");
- header = strip.stripHtml(nvl(header).trim());
- subtitle = Utils.replaceInString(subtitle, "<BR/>", " ");
- subtitle = Utils.replaceInString(subtitle, "<br/>", " ");
- subtitle = Utils.replaceInString(subtitle, "<br>", " ");
- subtitle = strip.stripHtml(nvl(subtitle).trim());
- HSSFRow row = sheet.createRow(rowNum);
- cellNum = 0;
- row.createCell((short) cellNum).setCellValue(header);
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short) (columnRows)));
- rowNum += 1;
- row = sheet.createRow(rowNum);
- cellNum = 0;
- row.createCell((short) cellNum).setCellValue(subtitle);
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short) (columnRows)));
- rowNum += 1;
- }
-
- for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) {
- HSSFRow row = sheet.createRow(rowNum);
- cellNum = -1;
- /*
- * if(rd.reportTotalRowHeaderCols!=null) { cellNum +=1; row.createCell((short)
- * cellNum).setCellValue("Total"); row.createCell((short) cellNum).setCellStyle(styleDataHeader);
- * //row.getCell((short) cellNum).setCellStyle(styleDataHeader); }
- */
- chr = rd.reportColumnHeaderRows.getNext();
-
- if (nvl(sql_whole).length() <= 0 || (!rr.getReportType().equals(AppConstants.RT_LINEAR))) {
- if (rr.getReportType().equals(AppConstants.RT_CROSSTAB))
- rd.reportRowHeaderCols.resetNext(0);
- else
- rd.reportRowHeaderCols.resetNext(1);
-
- for (; rd.reportRowHeaderCols.hasNext();) {
- cellNum += 1;
- RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
-
- if (firstPass) {
- title = rhc.getColumnTitle();
- title = Utils.replaceInString(title, "_nl_", " \n");
- row.createCell((short) cellNum).setCellValue(title);
- // commented after bug reported by EPAT 01/17/2015
- // sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum+columnRows, (short) cellNum,
- // (short) (cellNum)));
- // System.out.println(" **************** Row Header Title " + rhc.getColumnTitle() + " " +
- // cellNum + " " );
- // System.out.println(cellNum + " " + cellWidth.size());
- if (cellWidth.size() > 0 && cellWidth.size() > cellNum) {
- if (((Integer) cellWidth.get(cellNum)).intValue() < rhc
- .getColumnTitle().length())
- cellWidth.set(cellNum, new Integer(title.length()));
- } else
- cellWidth.add(cellNum, new Integer(title.length()));
- row.getCell((short) cellNum).setCellStyle(styleDataHeader);
- }
-
- } // for
-
+ //HSSFSheet sheet = wb.getSheet(getSheetName());
+ HSSFCellStyle styleDataHeader = wb.createCellStyle();
+ // style.setFillBackgroundColor(HSSFColor.AQUA.index);
+ styleDataHeader.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index);
+ styleDataHeader.setFillPattern(FillPatternType.SOLID_FOREGROUND );
+ styleDataHeader.setAlignment(HorizontalAlignment.CENTER);
+ styleDataHeader.setBorderBottom(BorderStyle.THIN);
+ styleDataHeader.setBorderTop(BorderStyle.THIN);
+ styleDataHeader.setBorderRight(BorderStyle.THIN);
+ styleDataHeader.setBorderLeft(BorderStyle.THIN);
+ HSSFFont font = wb.createFont();
+ font.setFontHeight((short) (font_size / 0.05));
+ font.setFontName("Tahoma");
+ font.setColor(HSSFColor.BLACK.index);
+ styleDataHeader.setFont(font);
+ // Column Header
+ boolean firstPass = true;
+ ArrayList cellWidth = new ArrayList();
+ java.util.HashMap dataTypeMap = new java.util.HashMap();
+ int cellNum = 0;
+ rowNum += 0;
+ ColumnHeaderRow chr = null;
+ String title = "";
+
+// System.out.println("***************** Size " + rd.reportColumnHeaderRows.size());
+// for (int i = 0; i < rd.reportColumnHeaderRows.size(); i++) {
+// for (int j = 0; j < rd.reportColumnHeaderRows.getColumnHeaderRow(i).size(); j++) {
+// System.out.println("Column Title " + rd.reportColumnHeaderRows.getColumnHeaderRow(i).getColumnHeader(j).getColumnTitle()
+// + " " + rd.reportColumnHeaderRows.getColumnHeaderRow(i).getColumnHeader(j).isVisible());
+// }
+// }
+/* List dsList = rr.getDataSourceList().getDataSource();
+ HashMap dataColumnTypeHashMap = new HashMap();
+ for (Iterator iter = dsList.iterator(); iter.hasNext();) {
+ DataSourceType element = (DataSourceType) iter.next();
+ List dcList = element.getDataColumnList().getDataColumn();
+ for (Iterator iterator = dcList.iterator(); iterator.hasNext();) {
+ DataColumnType element1 = (DataColumnType) iterator.next();
+ dataTypeMap.put(element1.getColId(), element1.getColType());
+ dataColumnTypeHashMap.put(element1.getColName(), element1);
}
-
- firstPass = false;
-
- /*
- * for(chr.resetNext(); chr.hasNext(); ) { ColumnHeader ch = chr.getNext(); if(ch.isVisible()) {
- * cellNum += 1; row.createCell((short) cellNum).setCellValue(ch.getColumnTitle()); // <td
- * align="center"<%= ch.getColumnWidthHtml() %><%= ch.getColSpanHtml() %><%= ch.getRowSpanHtml() %>>
- * // <b class=rtableheader><%= ch.getColumnTitleHtml() %></b> // </td> } // if } // for
- */
-
- // cellNum = -1;
-
- // Set mapSet = dataTypeMap.entrySet();
- // Map.Entry me;
- // String element, value ;
- // for (Iterator iter = mapSet.iterator(); iter.hasNext();) {
- // me=(Map.Entry)iter.next();
- // element = (String) me.getKey();
- // value = (String) me.getValue();
- // System.out.println("DataTypeMap " + element + " " + value);
- // }
-
- for (chr.resetNext(); chr.hasNext();) {
- ColumnHeader ch = chr.getNext();
- if (ch.isVisible()) {
- cellNum += 1;
-
- int colSpan = ch.getColSpan() - 1;
- title = ch.getColumnTitle();
- title = Utils.replaceInString(title, "_nl_", " \n");
- row.createCell((short) cellNum).setCellValue(title);
- if (colSpan > 0) {
- for (int k = 1; k <= colSpan; k++) {
- row.createCell((short) cellNum + k);
- }
- sheet.addMergedRegion(
- new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short) (cellNum + colSpan)));
- }
-
- /*
- * if (cellWidth.size() > cellNum) { if (((Integer) cellWidth.get(cellNum)).intValue() < ch
- * .getColumnTitle().length()) cellWidth .set((cellNum), new Integer(ch.getColumnTitle().length()));
- * } else cellWidth.add((cellNum), new Integer(ch.getColumnTitle().length()));
- */ row.getCell((short) (cellNum)).setCellStyle(styleDataHeader);
- for (int k = 1; k <= colSpan; k++) {
- row.getCell((short) (cellNum + k)).setCellStyle(styleDataHeader);
- }
-
- if (colSpan > 0)
- cellNum += colSpan;
- }
- } // for
-
- /*
- * int cw = 0; for (int i = 0; i < cellWidth.size(); i++) { cw = ((Integer)
- * cellWidth.get(i)).intValue() + 6; sheet.setColumnWidth((short) (i), (short) ((cw * 8) / ((double)
- * 1 / 20))); }
- */
- rowNum += 1;
- } // for
-
- // Data
- // Create some cell styles.
- // HSSFCellStyle styleDefault = wb.createCellStyle();
- HSSFCellStyle styleCell = null;
-
- HSSFCellStyle styleTotal = wb.createCellStyle();
+ }
+*/
+ int columnRows = rr.getVisibleColumnCount() - 1;
+
+ HttpSession session = request.getSession();
+ String drilldown_index = (String) session.getAttribute("drilldown_index");
+ int index = 0;
+ try {
+ index = Integer.parseInt(drilldown_index);
+ } catch (NumberFormatException ex) {
+ index = 0;
+ }
+ String header = (String) session.getAttribute("TITLE_"+index);
+ String subtitle = (String) session.getAttribute("SUBTITLE_"+index);
+ if(nvl(header).length()>0) {
+ header = Utils.replaceInString(header, "<BR/>", " ");
+ header = Utils.replaceInString(header, "<br/>", " ");
+ header = Utils.replaceInString(header, "<br>", " ");
+ header = strip.stripHtml(nvl(header).trim());
+ subtitle = Utils.replaceInString(subtitle, "<BR/>", " ");
+ subtitle = Utils.replaceInString(subtitle, "<br/>", " ");
+ subtitle = Utils.replaceInString(subtitle, "<br>", " ");
+ subtitle = strip.stripHtml(nvl(subtitle).trim());
+ HSSFRow row = sheet.createRow(rowNum);
+ cellNum = 0;
+ row.createCell((short) cellNum).setCellValue(header);
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short) (columnRows)));
+ rowNum += 1;
+ row = sheet.createRow(rowNum);
+ cellNum = 0;
+ row.createCell((short) cellNum).setCellValue(subtitle);
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short) (columnRows)));
+ rowNum += 1;
+ }
+
+ for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) {
+ HSSFRow row = sheet.createRow(rowNum);
+ cellNum = -1;
+ /*if(rd.reportTotalRowHeaderCols!=null) {
+ cellNum +=1;
+ row.createCell((short) cellNum).setCellValue("Total");
+ row.createCell((short) cellNum).setCellStyle(styleDataHeader);
+ //row.getCell((short) cellNum).setCellStyle(styleDataHeader);
+ }*/
+ chr = rd.reportColumnHeaderRows.getNext();
+
+ if(nvl(sql_whole).length() <= 0 || (!rr.getReportType().equals(AppConstants.RT_LINEAR))) {
+ if(rr.getReportType().equals(AppConstants.RT_CROSSTAB))
+ rd.reportRowHeaderCols.resetNext(0);
+ else
+ rd.reportRowHeaderCols.resetNext(1);
+
+ for (; rd.reportRowHeaderCols.hasNext();) {
+ cellNum += 1;
+ RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
+
+ if (firstPass) {
+ title = rhc.getColumnTitle();
+ title = Utils.replaceInString(title,"_nl_", " \n");
+ row.createCell((short) cellNum).setCellValue(title);
+ //commented after bug reported by EPAT 01/17/2015
+ //sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum+columnRows, (short) cellNum, (short) (cellNum)));
+ //System.out.println(" **************** Row Header Title " + rhc.getColumnTitle() + " " + cellNum + " " );
+ //System.out.println(cellNum + " " + cellWidth.size());
+ if (cellWidth.size() > 0 && cellWidth.size() > cellNum) {
+ if (((Integer) cellWidth.get(cellNum)).intValue() < rhc
+ .getColumnTitle().length())
+ cellWidth.set(cellNum, new Integer(title.length()));
+ } else
+ cellWidth.add(cellNum, new Integer(title.length()));
+ row.getCell((short) cellNum).setCellStyle(styleDataHeader);
+ }
+
+
+ } // for
+
+ }
+
+ firstPass = false;
+
+/* for(chr.resetNext(); chr.hasNext(); ) {
+ ColumnHeader ch = chr.getNext();
+ if(ch.isVisible()) {
+ cellNum += 1;
+ row.createCell((short) cellNum).setCellValue(ch.getColumnTitle());
+// <td align="center"<%= ch.getColumnWidthHtml() %><%= ch.getColSpanHtml() %><%= ch.getRowSpanHtml() %>>
+// <b class=rtableheader><%= ch.getColumnTitleHtml() %></b>
+// </td>
+ } // if
+ } // for
+*/
+
+ //cellNum = -1;
+
+
+// Set mapSet = dataTypeMap.entrySet();
+// Map.Entry me;
+// String element, value ;
+// for (Iterator iter = mapSet.iterator(); iter.hasNext();) {
+// me=(Map.Entry)iter.next();
+// element = (String) me.getKey();
+// value = (String) me.getValue();
+// System.out.println("DataTypeMap " + element + " " + value);
+// }
+
+ for (chr.resetNext(); chr.hasNext();) {
+ ColumnHeader ch = chr.getNext();
+ if(ch.isVisible()) {
+ cellNum += 1;
+
+ int colSpan = ch.getColSpan()-1;
+ title = ch.getColumnTitle();
+ title = Utils.replaceInString(title,"_nl_", " \n");
+ row.createCell((short) cellNum).setCellValue(title);
+ if(colSpan > 0) {
+ for ( int k = 1; k <= colSpan; k++ ) {
+ row.createCell((short) cellNum+k);
+ }
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short) (cellNum+colSpan)));
+ }
+
+
+
+/* if (cellWidth.size() > cellNum) {
+ if (((Integer) cellWidth.get(cellNum)).intValue() < ch
+ .getColumnTitle().length())
+ cellWidth
+ .set((cellNum), new Integer(ch.getColumnTitle().length()));
+ } else
+ cellWidth.add((cellNum), new Integer(ch.getColumnTitle().length()));
+*/ row.getCell((short) (cellNum)).setCellStyle(styleDataHeader);
+ for ( int k = 1; k <= colSpan; k++ ) {
+ row.getCell((short) (cellNum+k)).setCellStyle(styleDataHeader);
+ }
+
+ if(colSpan > 0)
+ cellNum += colSpan;
+ }
+ } // for
+
+/* int cw = 0;
+ for (int i = 0; i < cellWidth.size(); i++) {
+ cw = ((Integer) cellWidth.get(i)).intValue() + 6;
+ sheet.setColumnWidth((short) (i), (short) ((cw * 8) / ((double) 1 / 20)));
+ }
+*/
+ rowNum += 1;
+ } // for
+
+
+ // Data
+ // Create some cell styles.
+ //HSSFCellStyle styleDefault = wb.createCellStyle();
+ HSSFCellStyle styleCell = null;
+
+ HSSFCellStyle styleTotal = wb.createCellStyle();
HSSFCellStyle styleCurrencyTotal = wb.createCellStyle();
HSSFCellStyle styleDefaultTotal = wb.createCellStyle();
HSSFCellStyle styleCurrencyDecimalNumberTotal = wb.createCellStyle();
HSSFCellStyle styleDecimalNumberTotal = wb.createCellStyle();
HSSFCellStyle styleCurrencyNumberTotal = wb.createCellStyle();
-
- // Create some fonts.
- HSSFFont fontDefault = wb.createFont();
- HSSFFont fontBold = wb.createFont();
- // Initialize the styles & fonts.
- // The default will be plain .
- fontDefault.setColor((short) HSSFFont.COLOR_NORMAL);
- fontDefault.setFontHeight((short) (FONT_SIZE / 0.05));
- fontDefault.setFontName(FONT_TAHOMA);
-
- // The default will be bold black tachoma 10pt text.
- fontBold.setColor((short) HSSFFont.COLOR_NORMAL);
- fontBold.setFontHeight((short) (FONT_SIZE / 0.05));
- fontBold.setFontName(FONT_TAHOMA);
- fontBold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
- // Style default will be normal with no background
- styleDefault.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleDefault.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleDefault.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleDefault.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleDefault.setBorderRight(HSSFCellStyle.BORDER_THIN);
- // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleDefault.setFillPattern(HSSFCellStyle.NO_FILL);
- styleDefault.setFont(fontDefault);
- styleDefault.setWrapText(true);
- // Number
- styleNumber.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleNumber.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleNumber.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleNumber.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleNumber.setBorderRight(HSSFCellStyle.BORDER_THIN);
- // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleNumber.setFillPattern(HSSFCellStyle.NO_FILL);
- styleNumber.setFont(fontDefault);
- try {
- styleNumber.setDataFormat((short) 0x26);// HSSFDataFormat.getBuiltinFormat("(#,##0_);[Red](#,##0)"));
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "Excetion in setDataFormat", e);
- }
- // Decimal Number
- styleDecimalNumber.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleDecimalNumber.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleDecimalNumber.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleDecimalNumber.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleDecimalNumber.setBorderRight(HSSFCellStyle.BORDER_THIN);
+
+
+ // Create some fonts.
+ HSSFFont fontDefault = wb.createFont();
+ HSSFFont fontBold = wb.createFont();
+ // Initialize the styles & fonts.
+ // The default will be plain .
+ fontDefault.setColor((short) HSSFFont.COLOR_NORMAL);
+ fontDefault.setFontHeight((short) (font_size / 0.05));
+ fontDefault.setFontName("Tahoma");
+
+ // The default will be bold black tachoma 10pt text.
+ fontBold.setColor((short) HSSFFont.COLOR_NORMAL);
+ fontBold.setFontHeight((short) (font_size / 0.05));
+ fontBold.setFontName("Tahoma");
+ fontBold.setBold(true);
+ // Style default will be normal with no background
+ styleDefault.setAlignment(HorizontalAlignment.CENTER);
+ styleDefault.setBorderBottom(BorderStyle.THIN);
+ styleDefault.setBorderTop(BorderStyle.THIN);
+ styleDefault.setBorderLeft(BorderStyle.THIN);
+ styleDefault.setBorderRight(BorderStyle.THIN);
+ // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
+ styleDefault.setFillPattern(FillPatternType.NO_FILL);
+ styleDefault.setFont(fontDefault);
+ styleDefault.setWrapText(true);
+ //Number
+ styleNumber.setAlignment(HorizontalAlignment.CENTER);
+ styleNumber.setBorderBottom(BorderStyle.THIN);
+ styleNumber.setBorderTop(BorderStyle.THIN);
+ styleNumber.setBorderLeft(BorderStyle.THIN);
+ styleNumber.setBorderRight(BorderStyle.THIN);
+ // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
+ styleNumber.setFillPattern(FillPatternType.NO_FILL);
+ styleNumber.setFont(fontDefault);
+ try {
+ styleNumber.setDataFormat((short)0x26);//HSSFDataFormat.getBuiltinFormat("(#,##0_);[Red](#,##0)"));
+ } catch (Exception e) {
+
+ }
+ //Decimal Number
+ styleDecimalNumber.setAlignment(HorizontalAlignment.CENTER);
+ styleDecimalNumber.setBorderBottom(BorderStyle.THIN);
+ styleDecimalNumber.setBorderTop(BorderStyle.THIN);
+ styleDecimalNumber.setBorderLeft(BorderStyle.THIN);
+ styleDecimalNumber.setBorderRight(BorderStyle.THIN);
// styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleDecimalNumber.setFillPattern(HSSFCellStyle.NO_FILL);
+ styleDecimalNumber.setFillPattern(FillPatternType.NO_FILL);
styleDecimalNumber.setFont(fontDefault);
- styleDecimalNumber.setDataFormat((short) 0x27);// HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
-
- // Decimal Number
- styleDecimalNumberTotal.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleDecimalNumberTotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleDecimalNumberTotal.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleDecimalNumberTotal.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleDecimalNumberTotal.setBorderRight(HSSFCellStyle.BORDER_THIN);
+ styleDecimalNumber.setDataFormat((short)0x27);//HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
+
+ //Decimal Number
+ styleDecimalNumberTotal.setAlignment(HorizontalAlignment.CENTER);
+ styleDecimalNumberTotal.setBorderBottom(BorderStyle.THIN);
+ styleDecimalNumberTotal.setBorderTop(BorderStyle.THIN);
+ styleDecimalNumberTotal.setBorderLeft(BorderStyle.THIN);
+ styleDecimalNumberTotal.setBorderRight(BorderStyle.THIN);
// styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleDecimalNumberTotal.setFillPattern(HSSFCellStyle.NO_FILL);
+ styleDecimalNumberTotal.setFillPattern(FillPatternType.NO_FILL);
styleDecimalNumberTotal.setFont(fontBold);
- styleDecimalNumberTotal.setDataFormat((short) 0x27);// HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
-
- // CurrencyNumber
- styleCurrencyDecimalNumber.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleCurrencyDecimalNumber.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleCurrencyDecimalNumber.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleCurrencyDecimalNumber.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleCurrencyDecimalNumber.setBorderRight(HSSFCellStyle.BORDER_THIN);
+ styleDecimalNumberTotal.setDataFormat((short)0x27);//HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
+
+ //CurrencyNumber
+ styleCurrencyDecimalNumber.setAlignment(HorizontalAlignment.CENTER);
+ styleCurrencyDecimalNumber.setBorderBottom(BorderStyle.THIN);
+ styleCurrencyDecimalNumber.setBorderTop(BorderStyle.THIN);
+ styleCurrencyDecimalNumber.setBorderLeft(BorderStyle.THIN);
+ styleCurrencyDecimalNumber.setBorderRight(BorderStyle.THIN);
+ // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
+ styleCurrencyDecimalNumber.setFillPattern(FillPatternType.NO_FILL);
+ styleCurrencyDecimalNumber.setFont(fontDefault);
+ styleCurrencyDecimalNumber.setDataFormat((short)8);//HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
+
+ //currency number bold
+ styleCurrencyDecimalNumberTotal.setAlignment(HorizontalAlignment.CENTER);
+ styleCurrencyDecimalNumberTotal.setBorderBottom(BorderStyle.THIN);
+ styleCurrencyDecimalNumberTotal.setBorderTop(BorderStyle.THIN);
+ styleCurrencyDecimalNumberTotal.setBorderLeft(BorderStyle.THIN);
+ styleCurrencyDecimalNumberTotal.setBorderRight(BorderStyle.THIN);
+ // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
+ styleCurrencyDecimalNumberTotal.setFillPattern(FillPatternType.NO_FILL);
+ styleCurrencyDecimalNumberTotal.setFont(fontBold);
+ styleCurrencyDecimalNumberTotal.setDataFormat((short)8);//HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
+
+
+ //CurrencyNumber
+ styleCurrencyNumber.setAlignment(HorizontalAlignment.CENTER);
+ styleCurrencyNumber.setBorderBottom(BorderStyle.THIN);
+ styleCurrencyNumber.setBorderTop(BorderStyle.THIN);
+ styleCurrencyNumber.setBorderLeft(BorderStyle.THIN);
+ styleCurrencyNumber.setBorderRight(BorderStyle.THIN);
// styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleCurrencyDecimalNumber.setFillPattern(HSSFCellStyle.NO_FILL);
- styleCurrencyDecimalNumber.setFont(fontDefault);
- styleCurrencyDecimalNumber.setDataFormat((short) 8);// HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
-
- // currency number bold
- styleCurrencyDecimalNumberTotal.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleCurrencyDecimalNumberTotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleCurrencyDecimalNumberTotal.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleCurrencyDecimalNumberTotal.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleCurrencyDecimalNumberTotal.setBorderRight(HSSFCellStyle.BORDER_THIN);
- // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleCurrencyDecimalNumberTotal.setFillPattern(HSSFCellStyle.NO_FILL);
- styleCurrencyDecimalNumberTotal.setFont(fontBold);
- styleCurrencyDecimalNumberTotal.setDataFormat((short) 8);// HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
-
- // CurrencyNumber
- styleCurrencyNumber.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleCurrencyNumber.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleCurrencyNumber.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleCurrencyNumber.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleCurrencyNumber.setBorderRight(HSSFCellStyle.BORDER_THIN);
- // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleCurrencyNumber.setFillPattern(HSSFCellStyle.NO_FILL);
+ styleCurrencyNumber.setFillPattern(FillPatternType.NO_FILL);
styleCurrencyNumber.setFont(fontDefault);
- styleCurrencyNumber.setDataFormat((short) 6);// HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
-
- // CurrencyNumber
- styleCurrencyNumberTotal.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleCurrencyNumberTotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleCurrencyNumberTotal.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleCurrencyNumberTotal.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleCurrencyNumberTotal.setBorderRight(HSSFCellStyle.BORDER_THIN);
+ styleCurrencyNumber.setDataFormat((short) 6);//HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
+
+
+ //CurrencyNumber
+ styleCurrencyNumberTotal.setAlignment(HorizontalAlignment.CENTER);
+ styleCurrencyNumberTotal.setBorderBottom(BorderStyle.THIN);
+ styleCurrencyNumberTotal.setBorderTop(BorderStyle.THIN);
+ styleCurrencyNumberTotal.setBorderLeft(BorderStyle.THIN);
+ styleCurrencyNumberTotal.setBorderRight(BorderStyle.THIN);
// styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleCurrencyNumberTotal.setFillPattern(HSSFCellStyle.NO_FILL);
+ styleCurrencyNumberTotal.setFillPattern(FillPatternType.NO_FILL);
styleCurrencyNumberTotal.setFont(fontBold);
- styleCurrencyNumberTotal.setDataFormat((short) 6);// HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
-
- // Date
- styleDate.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleDate.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleDate.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleDate.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleDate.setBorderRight(HSSFCellStyle.BORDER_THIN);
- // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleDate.setFillPattern(HSSFCellStyle.NO_FILL);
- styleDate.setFont(fontDefault);
- styleDate.setDataFormat((short) 0xe);// HSSFDataFormat.getBuiltinFormat("m/d/yy"));
-
- // Style for Total will be Bold with normal font with no background
- styleTotal.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleTotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleTotal.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleTotal.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleTotal.setBorderRight(HSSFCellStyle.BORDER_THIN);
- // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleTotal.setFillPattern(HSSFCellStyle.NO_FILL);
- styleTotal.setDataFormat((short) 0x28);// HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
- styleTotal.setFont(fontBold);
-
- styleCurrencyTotal.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleCurrencyTotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleCurrencyTotal.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleCurrencyTotal.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleCurrencyTotal.setBorderRight(HSSFCellStyle.BORDER_THIN);
+ styleCurrencyNumberTotal.setDataFormat((short) 6);//HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
+
+ //Date
+ styleDate.setAlignment(HorizontalAlignment.CENTER);
+ styleDate.setBorderBottom(BorderStyle.THIN);
+ styleDate.setBorderTop(BorderStyle.THIN);
+ styleDate.setBorderLeft(BorderStyle.THIN);
+ styleDate.setBorderRight(BorderStyle.THIN);
+ // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
+ styleDate.setFillPattern(FillPatternType.NO_FILL);
+ styleDate.setFont(fontDefault);
+ styleDate.setDataFormat((short)0xe);//HSSFDataFormat.getBuiltinFormat("m/d/yy"));
+
+ // Style for Total will be Bold with normal font with no background
+ styleTotal.setAlignment(HorizontalAlignment.CENTER);
+ styleTotal.setBorderBottom(BorderStyle.THIN);
+ styleTotal.setBorderTop(BorderStyle.THIN);
+ styleTotal.setBorderLeft(BorderStyle.THIN);
+ styleTotal.setBorderRight(BorderStyle.THIN);
+ // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
+ styleTotal.setFillPattern(FillPatternType.NO_FILL);
+ styleTotal.setDataFormat((short)0x28);//HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
+ styleTotal.setFont(fontBold);
+
+ styleCurrencyTotal.setAlignment(HorizontalAlignment.CENTER);
+ styleCurrencyTotal.setBorderBottom(BorderStyle.THIN);
+ styleCurrencyTotal.setBorderTop(BorderStyle.THIN);
+ styleCurrencyTotal.setBorderLeft(BorderStyle.THIN);
+ styleCurrencyTotal.setBorderRight(BorderStyle.THIN);
// styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleCurrencyTotal.setFillPattern(HSSFCellStyle.NO_FILL);
- styleCurrencyTotal.setDataFormat((short) 8);// HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
- styleCurrencyTotal.setFont(fontBold);
-
- styleDefaultTotal.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleDefaultTotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleDefaultTotal.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleDefaultTotal.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleDefaultTotal.setBorderRight(HSSFCellStyle.BORDER_THIN);
+ styleCurrencyTotal.setFillPattern(FillPatternType.NO_FILL);
+ styleCurrencyTotal.setDataFormat((short)8);//HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
+ styleCurrencyTotal.setFont(fontBold);
+
+ styleDefaultTotal.setAlignment(HorizontalAlignment.CENTER);
+ styleDefaultTotal.setBorderBottom(BorderStyle.THIN);
+ styleDefaultTotal.setBorderTop(BorderStyle.THIN);
+ styleDefaultTotal.setBorderLeft(BorderStyle.THIN);
+ styleDefaultTotal.setBorderRight(BorderStyle.THIN);
// styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleDefaultTotal.setFillPattern(HSSFCellStyle.NO_FILL);
- styleDefaultTotal.setDataFormat((short) 0x28);
- //// styleDefaultTotal.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
- styleDefaultTotal.setFont(fontBold);
-
- firstPass = true;
- // Declare a row object reference.
- HSSFRow row = null;
- // Declare a cell object reference.
- HSSFCell cell = null;
- // HSSFCell cellNumber = null;
- // HSSFCell cellCurrencyNumber = null;
- // HSSFCell cellDate = null;
-
- // All the possible combinations of date format
- SimpleDateFormat MMDDYYYYFormat = new SimpleDateFormat("MM/dd/yyyy");
- SimpleDateFormat YYYYMMDDFormat = new SimpleDateFormat("yyyy/MM/dd");
- SimpleDateFormat MONYYYYFormat = new SimpleDateFormat("MMM yyyy");
- SimpleDateFormat MMYYYYFormat = new SimpleDateFormat("MM/yyyy");
+ styleDefaultTotal.setFillPattern(FillPatternType.NO_FILL);
+ styleDefaultTotal.setDataFormat((short)0x28);
+ ////styleDefaultTotal.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
+ styleDefaultTotal.setFont(fontBold);
+
+ firstPass = true;
+ // Declare a row object reference.
+ HSSFRow row = null;
+ // Declare a cell object reference.
+ HSSFCell cell = null;
+ //HSSFCell cellNumber = null;
+ //HSSFCell cellCurrencyNumber = null;
+ //HSSFCell cellDate = null;
+
+ //All the possible combinations of date format
+ SimpleDateFormat MMDDYYYYFormat = new SimpleDateFormat("MM/dd/yyyy");
+ 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 YYYYMMDDDASHFormat = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- SimpleDateFormat DDMONYYYYFormat = new SimpleDateFormat("dd-MMM-yyyy");
- SimpleDateFormat MONTHYYYYFormat = new SimpleDateFormat("MMMMM, yyyy");
- 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 DDMONYYHHMMFormat = new SimpleDateFormat("dd-MMM-yy 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 MMDDYYYYHHMMZFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm z");
- SimpleDateFormat MMMMMDDYYYYHHMMSS = new SimpleDateFormat("MMMMM-dd-yyyy HH:mm:ss");
-
+ SimpleDateFormat YYYYMMDDDASHFormat = new SimpleDateFormat("yyyy-MM-dd");
+ SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ SimpleDateFormat DDMONYYYYFormat = new SimpleDateFormat("dd-MMM-yyyy");
+ SimpleDateFormat MONTHYYYYFormat = new SimpleDateFormat("MMMMM, yyyy");
+ 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 DDMONYYHHMMFormat = new SimpleDateFormat("dd-MMM-yy 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 MMDDYYYYHHMMZFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm z");
+ SimpleDateFormat MMMMMDDYYYYHHMMSS = new SimpleDateFormat("MMMMM-dd-yyyy HH:mm:ss");
+
+
ResultSetMetaData rsmd = null;
CreationHelper createHelper = wb.getCreationHelper();
- if (nvl(sql_whole).length() > 0 && rr.getReportType().equals(AppConstants.RT_LINEAR)) {
- try (Connection conn = ConnectionUtils.getConnection(rr.getDbInfo());
- Statement st = conn.createStatement();
- ResultSet rs = st.executeQuery(sql_whole)) {
- System.out.println("************* Map Whole SQL *************");
- System.out.println(sql_whole);
- System.out.println("*****************************************");
- rsmd = rs.getMetaData();
- int numberOfColumns = rsmd.getColumnCount();
- HashMap colHash = new HashMap();
- DataRow dr = null;
- int j = 0;
- int rowCount = 0;
- while (rs.next()) {
- rowCount++;
- row = sheet.createRow(rowNum);
- cellNum = -1;
- colHash = new HashMap();
- for (int i = 1; i <= numberOfColumns; i++) {
- colHash.put(rsmd.getColumnLabel(i).toUpperCase(), strip.stripHtml(rs.getString(i)));
- }
- rd.reportDataRows.resetNext();
- dr = rd.reportDataRows.getNext();
- j = 0;
- // if(rowCount%1000 == 0) wb.write(sos);
-
- /*
- * if(rd.reportTotalRowHeaderCols!=null) { //cellNum = -1; //for
- * (rd.reportRowHeaderCols.resetNext(); rd.reportRowHeaderCols.hasNext();) { cellNum += 1;
- * //RowHeaderCol rhc = rd.reportRowHeaderCols.getRowHeaderCol(0); //if (firstPass) //
- * rhc.resetNext(); //RowHeader rh = rhc.getRowHeader(rowCount-1); row.createCell((short)
- * cellNum).setCellValue(rowCount); row.getCell((short) cellNum).setCellStyle(styleDefault); if
- * (firstPass) cellWidth.add(cellNum, new Integer((rowCount+"").length())); else
- * cellWidth.set(cellNum, new Integer((rowCount+"").length()));
- *
- * //} // for }
- */
- firstPass = false;
- // cellNum = -1;
- for (dr.resetNext(); dr.hasNext(); j++) {
- // for (chr.resetNext(); chr.hasNext();) {
- // ColumnHeader ch = chr.getNext();
- styleCell = null;
- DataValue dv = dr.getNext();
- HtmlFormatter htmlFormat = dv.getCellFormatter();
- if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null)
- styleCell = (HSSFCellStyle) styles.get(nvl(dr.getFormatId(), DEFAULT));
- if (htmlFormat != null && dv.getFormatId() != null && styles != null)
- styleCell = (HSSFCellStyle) styles.get(nvl(dv.getFormatId(), DEFAULT));
- String value = nvl((String) colHash.get(dv.getColId().toUpperCase()));
-
- boolean bold = false;
-
- if (dv.isVisible()) {
- cellNum += 1;
- cell = row.createCell((short) cellNum);
- // System.out.println("Stripping HTML 1");
- // cell.setCellValue(strip.stripHtml(dv.getDisplayValue()));
- String dataType = (String) (dataTypeMap.get(dv.getColId()));
- // System.out.println("Value " + value + " " + (( dataType !=null &&
- // dataType.equals("DATE")) || (dv.getColName()!=null &&
- // dv.getColName().toLowerCase().endsWith("date"))) );
- if (dataType != null && dataType.equals("NUMBER")) {
- // cellNumber = row.createCell((short) cellNum);
- // cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
- // cellNumber.setCellValue(dv.getDisplayValue());
- // cellCurrencyNumber = row.createCell((short) cellNum);
- int zInt = 0;
- if (value.equals("null")) {
- cell.setCellValue(zInt);
- } else {
-
- if ((value.indexOf(".")) != -1) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
-
- // if (dv.getDisplayValue().startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempDollar = dv.getDisplayValue().trim();
- tempDollar = tempDollar.replaceAll(" ", "").substring(0);
- tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempDollar);
- // System.out.println("Before copy Value |" + tempDollar);
- // tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1,
- // tempDollar.length()-1);
- // System.out.println("After copy Value |" + tempDollar);
- if ((tempDollar.indexOf(",")) != -1) {
- tempDollar = tempDollar.replaceAll(",", "");
- }
- // System.out.println("The final string 1 is "+tempDollar);
- double tempDoubleDollar = 0.0;
- try {
- tempDoubleDollar = Double.parseDouble(tempDollar);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 8);// HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleCurrencyDecimalNumber);
- cell.setCellValue(tempDoubleDollar);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- // cell.setCellStyle(styleDefault);
- cell.setCellValue(tempDollar);
- }
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- double tempDouble = 0.0;
- try {
- tempDouble = Double.parseDouble(value);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 0x28);// HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDecimalNumber);
- cell.setCellValue(tempDouble);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(value);
- }
-
- }
- } else {
- if (!(value.equals(""))) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
- // if (dv.getDisplayValue().startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempInt = value.trim();
- tempInt = tempInt.replaceAll(" ", "").substring(0);
- tempInt = tempInt.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempInt);
- // System.out.println("Before copy Value |" + tempInt);
- // tempInt = String.copyValueOf(tempInt.toCharArray(), 1,
- // tempInt.length()-1);
- // System.out.println("After copy Value |" + tempInt);
- if ((tempInt.indexOf(",")) != -1) {
- tempInt = tempInt.replaceAll(",", "");
- }
- // System.out.println("The final string INT is "+tempInt);
- Long tempIntDollar = 0L;
- try {
- tempIntDollar = Long.parseLong(tempInt);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 6);// HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleCurrencyNumber);
- cell.setCellValue(tempIntDollar);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(tempInt);
- }
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- String tempStr = value.trim();
- if ((tempStr.indexOf(",")) != -1) {
- tempStr = tempStr.replaceAll(",", "");
- }
- Long temp = 0L;
-
- try {
- temp = Long.parseLong(tempStr);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 0x26);// HSSFDataFormat.getBuiltinFormat("(#,##0_);[Red](#,##0)"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleNumber);
- cell.setCellValue(temp);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(tempStr);
- }
-
- }
- // int temp = Integer.parseInt(value.trim());
- // cell.setCellValue(temp);
- // }else{
- // cell.setCellValue(strip.stripHtml(value));
- // }
- }
- }
- }
-
- } else if ((dataType != null && dataType.equals("DATE"))
- || (dv.getDisplayName() != null
- && dv.getDisplayName().toLowerCase().endsWith("date"))
- ||
- (dv.getColId() != null && dv.getColId().toLowerCase().endsWith("date")) ||
- (dv.getColName() != null && dv.getColName().toLowerCase().endsWith("date"))) {
- // cellDate = row.createCell((short) cellNum);
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("mm/dd/yy"));
-
- if (styleCell != null) {
- styleCell.setDataFormat((short) 0xe);// HSSFDataFormat.getBuiltinFormat("m/d/yy"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDate);
- // String MY_DATE_FORMAT = "yyyy-MM-dd";
- // value = nvl(value).length()<=0?nvl(dv.getDisplayValue()):value;
- Date date = null;
- int flag = 0;
- date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy h:mm:ss"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yyyy h:mm:ss"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yyyy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yyyy"));
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("yyyy/m/d"));
- flag = 1;
- }
- if (date == null)
- date = timestampFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("yyyy-m-d h:mm:ss")); // yyyy-MM-dd
- // HH:mm:ss
- flag = 1;
- }
- if (date == null)
- date = MONYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("mmm yyyy"));
- flag = 1;
- }
- if (date == null)
- date = MMYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/yyyy"));
- flag = 1;
- }
- if (date == null)
- date = MMMMMDDYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("mmm/d/yyyy"));
- flag = 1;
- }
- if (date == null)
- date = MONTHYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("mmm/yyyy"));
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("yyyy/m/d h:mm:ss"));
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDDASHFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("yyyy-m-d"));
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("yyyy/m/d h:mm"));
- flag = 1;
- }
- if (date == null)
- date = DDMONYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("d-mmm-yyyy h:mm:ss"));
- flag = 1;
- }
- if (date == null)
- date = DDMONYYYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("d-mmm-yyyy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = DDMONYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("d-mmm-yy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = DDMONYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("d-mmm-yyyy"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy h:mm:ss"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy h:mm:ss"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYHHMMZFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yyyy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = MMMMMDDYYYYHHMMSS.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yyyy h:mm"));
- flag = 1;
- }
-
- if (date != null) {
- // System.out.println("ExcelDate " + HSSFDateUtil.getExcelDate(date));
- cell.setCellValue(HSSFDateUtil.getExcelDate(date));
- try {
- String str = cell.getStringCellValue();
- } catch (IllegalStateException ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "IllegalStateException occured",
- ex);
- /* cell.getCellStyle().setDataFormat((short)0); */
- cell.setCellValue(value);
- }
- } else {
- /* cell.getCellStyle().setDataFormat((short)0); */
- cell.setCellValue(value);
- }
- // cellDate.setCellValue(date);
- // cellDate.setCellValue(value); //cellDate.setCellValue(date);
- // cellDate.setCellValue(dv.getDisplayValue());
-
- } else if ((dv.getDisplayTotal() != null && dv.getDisplayTotal().equals("SUM("))
- || (dv.getColName() != null && dv.getColName().indexOf("999") != -1)) {
- // cellNumber = row.createCell((short) cellNum);
- // cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
- // cellNumber.setCellValue(dv.getDisplayValue());
- cell = row.createCell((short) cellNum);
- int zInt = 0;
- if (value.equals("null")) {
- cell.setCellValue(zInt);
- } else {
-
- if ((value.indexOf(".")) != -1) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
-
- // if (value.startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempDollar = value.trim();
- tempDollar = tempDollar.replaceAll(" ", "").substring(0);
- tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempDollar);
- // System.out.println("Before copy Value |" + tempDollar);
- // tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1,
- // tempDollar.length()-1);
- // System.out.println("After copy Value |" + tempDollar);
- if ((tempDollar.indexOf(",")) != -1) {
- tempDollar = tempDollar.replaceAll(",", "");
- }
- // System.out.println("The final string 2IF is "+tempDollar);
- double tempDoubleDollar = 0.0;
- try {
- tempDoubleDollar = Double.parseDouble(tempDollar);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 8);// HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleCurrencyDecimalNumber);
- cell.setCellValue(tempDoubleDollar);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(tempDollar);
- }
-
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- String tempDoubleStr = value.trim();
- tempDoubleStr = tempDoubleStr.replaceAll(" ", "").substring(0);
- if ((tempDoubleStr.indexOf(",")) != -1) {
- tempDoubleStr = tempDoubleStr.replaceAll(",", "");
- }
- double tempDouble = 0.0;
- try {
- tempDouble = Double.parseDouble(tempDoubleStr);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 0x28);// HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDecimalNumber);
- cell.setCellValue(tempDouble);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(tempDoubleStr);
- }
- }
-
- } else {
- if (!(value.equals(""))) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
- // if (value.startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempInt = value.trim();
- tempInt = tempInt.replaceAll(" ", "").substring(0);
- tempInt = tempInt.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempInt);
- // System.out.println("Before copy Value |" + tempInt);
- // tempInt = String.copyValueOf(tempInt.toCharArray(), 1,
- // tempInt.length()-1);
- // System.out.println("After copy Value |" + tempInt);
- if ((tempInt.indexOf(",")) != -1) {
- tempInt = tempInt.replaceAll(",", "");
- }
- // System.out.println("The final string INT 2 is "+tempInt);
-
- Long tempIntDollar = 0L;
-
- try {
- tempIntDollar = Long.parseLong(tempInt);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 6);// HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleCurrencyNumber);
- cell.setCellValue(tempIntDollar);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(tempInt);
- }
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- String tempStr = value.trim();
- if ((tempStr.indexOf(",")) != -1) {
- tempStr = tempStr.replaceAll(",", "");
- }
- Long temp = 0L;
-
- try {
- temp = Long.parseLong(tempStr);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 0x26);// HSSFDataFormat.getBuiltinFormat("(#,##0_);[Red](#,##0)"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleNumber);
- cell.setCellValue(temp);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(tempStr);
- }
- }
- // int temp = Integer.parseInt(dv.getDisplayValue().trim());
- // cell.setCellValue(temp);
- // }else{
- // cell.setCellValue(strip.stripHtml(dv.getDisplayValue()));
- // }
- } else {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- }
- }
- }
-
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("General"));
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
+ if(nvl(sql_whole).length() >0 && rr.getReportType().equals(AppConstants.RT_LINEAR)) {
+ try(Connection conn = ConnectionUtils.getConnection(rr.getDbInfo());
+ Statement st = conn.createStatement();
+ ResultSet rs = st.executeQuery(sql_whole)) {
+ System.out.println("************* Map Whole SQL *************");
+ System.out.println(sql_whole);
+ System.out.println("*****************************************");
+ rsmd = rs.getMetaData();
+ int numberOfColumns = rsmd.getColumnCount();
+ HashMap colHash = new HashMap();
+ DataRow dr = null;
+ int j = 0;
+ int rowCount = 0;
+ while(rs.next()) {
+ rowCount++;
+ row = sheet.createRow(rowNum);
+ cellNum = -1;
+ colHash = new HashMap();
+ for (int i = 1; i <= numberOfColumns; i++) {
+ colHash.put(rsmd.getColumnLabel(i).toUpperCase(), strip.stripHtml(rs.getString(i)));
+ }
+ rd.reportDataRows.resetNext();
+ dr = rd.reportDataRows.getNext();
+ j = 0;
+ //if(rowCount%1000 == 0) wb.write(sos);
+
+ /*if(rd.reportTotalRowHeaderCols!=null) {
+ //cellNum = -1;
+ //for (rd.reportRowHeaderCols.resetNext(); rd.reportRowHeaderCols.hasNext();) {
+ cellNum += 1;
+ //RowHeaderCol rhc = rd.reportRowHeaderCols.getRowHeaderCol(0);
+ //if (firstPass)
+ // rhc.resetNext();
+ //RowHeader rh = rhc.getRowHeader(rowCount-1);
+ row.createCell((short) cellNum).setCellValue(rowCount);
+ row.getCell((short) cellNum).setCellStyle(styleDefault);
+ if (firstPass)
+ cellWidth.add(cellNum, new Integer((rowCount+"").length()));
+ else
+ cellWidth.set(cellNum, new Integer((rowCount+"").length()));
+
+ //} // for
+ }*/
+ firstPass = false;
+ //cellNum = -1;
+ for (dr.resetNext(); dr.hasNext();j++) {
+ //for (chr.resetNext(); chr.hasNext();) {
+ //ColumnHeader ch = chr.getNext();
+ styleCell = null;
+ DataValue dv = dr.getNext();
+ HtmlFormatter htmlFormat = dv.getCellFormatter();
+ if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null)
+ styleCell = (HSSFCellStyle) styles.get(nvl(dr.getFormatId(),"default"));
+ if (htmlFormat != null && dv.getFormatId() != null && styles != null)
+ styleCell = (HSSFCellStyle) styles.get(nvl(dv.getFormatId(),"default"));
+ String value = nvl((String)colHash.get(dv.getColId().toUpperCase()));
+
+ boolean bold = false;
+
+ if(dv.isVisible()) {
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+ //System.out.println("Stripping HTML 1");
+ //cell.setCellValue(strip.stripHtml(dv.getDisplayValue()));
+ String dataType = (String) (dataTypeMap.get(dv.getColId()));
+ //System.out.println("Value " + value + " " + (( dataType !=null && dataType.equals("DATE")) || (dv.getColName()!=null && dv.getColName().toLowerCase().endsWith("date"))) );
+ if (dataType!=null && dataType.equals("NUMBER")){
+ //cellNumber = row.createCell((short) cellNum);
+ //cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
+ //cellNumber.setCellValue(dv.getDisplayValue());
+ //cellCurrencyNumber = row.createCell((short) cellNum);
+ int zInt = 0;
+ if (value.equals("null")){
+ cell.setCellValue(zInt);
+ }else{
+
+ if ((value.indexOf("."))!= -1){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+
+ //if (dv.getDisplayValue().startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempDollar = dv.getDisplayValue().trim();
+ tempDollar = tempDollar.replaceAll(" ", "").substring(0);
+ tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempDollar);
+ //System.out.println("Before copy Value |" + tempDollar);
+ //tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1, tempDollar.length()-1);
+ //System.out.println("After copy Value |" + tempDollar);
+ if ((tempDollar.indexOf(","))!= -1){
+ tempDollar = tempDollar.replaceAll(",", "");
+ }
+ //System.out.println("The final string 1 is "+tempDollar);
+ double tempDoubleDollar = 0.0;
+ try {
+ tempDoubleDollar = Double.parseDouble(tempDollar);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short) 8);//HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleCurrencyDecimalNumber);
+ cell.setCellValue(tempDoubleDollar);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ //cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempDollar);
+ }
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ double tempDouble = 0.0;
+ try {
+ tempDouble = Double.parseDouble(value);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short)0x28);//HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDecimalNumber);
+ cell.setCellValue(tempDouble);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(value);
+ }
+
+ }
+ }else {
+ if (!(value.equals(""))){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ //if (dv.getDisplayValue().startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempInt = value.trim();
+ tempInt = tempInt.replaceAll(" ", "").substring(0);
+ tempInt = tempInt.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempInt);
+ //System.out.println("Before copy Value |" + tempInt);
+ //tempInt = String.copyValueOf(tempInt.toCharArray(), 1, tempInt.length()-1);
+ //System.out.println("After copy Value |" + tempInt);
+ if ((tempInt.indexOf(","))!= -1){
+ tempInt = tempInt.replaceAll(",", "");
+ }
+ //System.out.println("The final string INT is "+tempInt);
+ Long tempIntDollar = 0L;
+ try {
+ tempIntDollar = Long.parseLong(tempInt);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short) 6);//HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleCurrencyNumber);
+ cell.setCellValue(tempIntDollar);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempInt);
+ }
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempStr = value.trim();
+ if ((tempStr.indexOf(","))!= -1){
+ tempStr = tempStr.replaceAll(",", "");
+ }
+ Long temp = 0L;
+
+ try {
+ temp = Long.parseLong(tempStr);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short) 0x26);//HSSFDataFormat.getBuiltinFormat("(#,##0_);[Red](#,##0)"));
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleNumber);
+ cell.setCellValue(temp);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempStr);
+ }
+
+
+ }
+ //int temp = Integer.parseInt(value.trim());
+ // cell.setCellValue(temp);
+ //}else{
+ // cell.setCellValue(strip.stripHtml(value));
+ //}
+ }
+ }
+ }
+
+ }else if ( ( dataType !=null && dataType.equals("DATE")) || (dv.getDisplayName()!=null && dv.getDisplayName().toLowerCase().endsWith("date")) ||
+ (dv.getColId()!=null && dv.getColId().toLowerCase().endsWith("date")) ||
+ (dv.getColName()!=null && dv.getColName().toLowerCase().endsWith("date")) ) {
+ //cellDate = row.createCell((short) cellNum);
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("mm/dd/yy"));
+
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short) 0xe);//HSSFDataFormat.getBuiltinFormat("m/d/yy"));
+ cell.setCellStyle(styleCell);
} else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(strip.stripHtml(value));
- }
-
- // if (!(value.equals(""))){
- // int temp = Integer.parseInt(value.trim());
- // cell.setCellValue(temp);
- // }else{
- // cell.setCellValue(strip.stripHtml(value));
- // }
- // HSSFCellStyle styleFormat = null;
- // HSSFCellStyle numberStyle = null;
- // HSSFFont formatFont = null;
- // short fgcolor = 0;
- // short fillpattern = 0;
- if (cellWidth.size() > cellNum) {
- if (((Integer) cellWidth.get(cellNum)).intValue() < dv
- .getDisplayValue().length())
- cellWidth.set((cellNum),
- (value.length() <= Globals.getMaxCellWidthInExcel())
- ? new Integer(value.length())
- : new Integer(Globals.getMaxCellWidthInExcel()));
- } else
- cellWidth.add((cellNum),
- (value.length() <= Globals.getMaxCellWidthInExcel())
- ? new Integer(value.length())
- : new Integer(Globals.getMaxCellWidthInExcel()));
- // System.out.println("1IF "+ (dv.isBold()) + " "+ value + " " + dv.getDisplayTotal() + " "
- // + dv.getColName() );
- if (dv.isBold()) {
- if ((dv.getDisplayTotal() != null && dv.getDisplayTotal().equals("SUM("))
- || (dv.getColName() != null && dv.getColName().indexOf("999") != -1)) {
- if (value != null && (value.trim().startsWith("$"))
- || (value.trim().startsWith("-$"))) {
- cell.setCellStyle(styleCurrencyTotal);
- } else {
- cell.setCellStyle(styleTotal);
- }
- } else {
- cell.setCellStyle(styleDefaultTotal);
- }
- bold = true;
- }
- // System.out.println("2IF "+ (dr.isRowFormat()) + " " + (dv.isCellFormat()) + " " +
- // (styles!=null));
- if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null) {
- // cell.setCellStyle((HSSFCellStyle) styles.get(nvl(dr.getFormatId(),DEFAULT)));
- continue;
- }
- // System.out.println("3IF "+ (htmlFormat != null) + " " + (dv.getFormatId() != null) + " "
- // + (bold == false) + " "+ (styles != null));
- if (htmlFormat != null && dv.getFormatId() != null && bold == false
- && styles != null) {
- // cell.setCellStyle((HSSFCellStyle) styles.get(nvl(dv.getFormatId(),DEFAULT)));
- } // else if (bold == false)
- // cell.setCellStyle(styleDefault);
- } // dv.isVisible
- }
- rowNum += 1;
-
- }
-
- int cw = 0;
- for (int i = 0; i < cellWidth.size(); i++) {
- cw = ((Integer) cellWidth.get(i)).intValue() + 12;
- // if(i!=cellWidth.size()-1)
- sheet.setColumnWidth((short) (i), (short) ((cw * 8) / ((double) 1 / 20)));
- // else
- // sheet.setColumnWidth((short) (i + 1), (short) ((cw * 10) /
- // ((double) 1 / 20)));
- }
-
- // To Display Total Values for Linear report
- if (rd.reportDataTotalRow != null) {
- row = sheet.createRow(rowNum);
- cellNum = -1;
- rd.reportTotalRowHeaderCols.resetNext();
- // for (rd.reportTotalRowHeaderCols.resetNext(); rd.reportTotalRowHeaderCols.hasNext();) {
- cellNum += 1;
- RowHeaderCol rhc = rd.reportTotalRowHeaderCols.getNext();
- RowHeader rh = rhc.getRowHeader(0);
- row.createCell((short) cellNum).setCellValue(strip.stripHtml(rh.getRowTitle()));
- row.getCell((short) cellNum).setCellStyle(styleDefaultTotal);
- // }
-
- rd.reportDataTotalRow.resetNext();
- DataRow drTotal = rd.reportDataTotalRow.getNext();
- // cellNum = -1;
-
- drTotal.resetNext();
- drTotal.getNext();
- for (; drTotal.hasNext();) {
- cellNum += 1;
- cell = row.createCell((short) cellNum);
- DataValue dv = drTotal.getNext();
- String value = dv.getDisplayValue();
- cell.setCellValue(value);
- boolean bold = false;
- if (dv.isBold()) {
- if ((dv.getDisplayTotal() != null && dv.getDisplayTotal().equals("SUM("))
- || (dv.getColName() != null && dv.getColName().indexOf("999") != -1)) {
- if (value != null && (value.trim().startsWith("$"))
- || (value.trim().startsWith("-$"))) {
- cell.setCellStyle(styleCurrencyTotal);
- } else {
- cell.setCellStyle(styleTotal);
- }
- } else {
- cell.setCellStyle(styleDefaultTotal);
- }
- bold = true;
- }
- }
- }
-
- } catch (SQLException ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "SQLException occured ", ex);
- throw new RaptorException(ex);
- } catch (ReportSQLException ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "ReportSQLException occured ", ex);
- throw new RaptorException(ex);
- } catch (Exception ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "Exception occured ", ex);
- if (!(ex.getCause() instanceof java.net.SocketException))
- throw new RaptorException(ex);
- }
-
- /*
- * if(Globals.getShowDisclaimer() && !Globals.disclaimerPositionedTopInCSVExcel()) { rowNum += 1;
- * row = sheet.createRow(rowNum); cellNum = 0; String disclaimer = Globals.getFooterFirstLine() +
- * " " + Globals.getFooterSecondLine(); row.createCell((short) cellNum).setCellValue(disclaimer);
- * sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short)
- * (columnRows))); rowNum += 1; }
- */
- } else {
- if (rr.getReportType().equals(AppConstants.RT_LINEAR)) {
- int rowCount = 0;
- for (rd.reportDataRows.resetNext(); rd.reportDataRows.hasNext();) {
- DataRow dr = rd.reportDataRows.getNext();
- // List l = rd.getReportDataList();
- // for (int dataRow = 0; dataRow < l.size(); dataRow++) {
- rowCount++;
-
- // DataRow dr = (DataRow) l.get(dataRow);
- row = sheet.createRow(rowNum);
-
- cellNum = -1;
-
- if (rr.getReportType().equals(AppConstants.RT_LINEAR) && rd.reportTotalRowHeaderCols != null) {
- rd.reportRowHeaderCols.resetNext(0);
- if (rd.reportTotalRowHeaderCols != null) {
- // cellNum = -1;
- // for (rd.reportRowHeaderCols.resetNext(); rd.reportRowHeaderCols.hasNext();) {
- // cellNum += 1;
- // RowHeaderCol rhc = rd.reportRowHeaderCols.getRowHeaderCol(0);
- // if (firstPass)
- // rhc.resetNext();
- // RowHeader rh = rhc.getRowHeader(rowCount-1);
- // row.createCell((short) cellNum).setCellValue(rowCount);
- // row.getCell((short) cellNum).setCellStyle(styleDefault);
- // if (firstPass)
- // cellWidth.add(cellNum, new Integer((rowCount+"").length()));
- // else
- // cellWidth.set(cellNum, new Integer((rowCount+"").length()));
-
- // } // for
- }
-
- } else {
- rd.reportRowHeaderCols.resetNext(0);
- }
- for (; rd.reportRowHeaderCols.hasNext();) {
- cellNum += 1;
- RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
- if (firstPass)
- rhc.resetNext();
- RowHeader rh = rhc.getNext();
- row.createCell((short) cellNum).setCellValue(strip.stripHtml(rh.getRowTitle()));
- row.getCell((short) cellNum).setCellStyle(styleDefault);
- if (cellWidth.size() > 0) {
- if (((Integer) cellWidth.get(cellNum)).intValue() < rh.getRowTitle()
- .length())
- cellWidth.set(cellNum, new Integer(rh.getRowTitle().length()));
- } else
- cellWidth.add(cellNum, new Integer(rh.getRowTitle().length()));
-
- } // for
- firstPass = false;
- // cellNum = -1;
- int j = 0;
-
- for (dr.resetNext(); dr.hasNext(); j++) {
- DataValue dv = dr.getNext();
- styleCell = null;
- boolean bold = false;
- String value = nvl(dv.getDisplayValue());
- value = strip.stripHtml(value);
- HtmlFormatter htmlFormat = dv.getCellFormatter();
- if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null)
- styleCell = (HSSFCellStyle) styles.get(nvl(dr.getFormatId(), DEFAULT));
- if (htmlFormat != null && dv.getFormatId() != null && styles != null)
- styleCell = (HSSFCellStyle) styles.get(nvl(dv.getFormatId(), DEFAULT));
-
- if (dv.isVisible()) {
- cellNum += 1;
- cell = row.createCell((short) cellNum);
- // System.out.println("Stripping HTML 1");
- // cell.setCellValue(strip.stripHtml(value));
- String dataType = (String) (dataTypeMap.get(dv.getColId()));
- // System.out.println(" The Display Value is ********"+value + " " + dv.getDisplayTotal() +
- // " " + dv.getColName());
-
- if (dataType != null && dataType.equals("NUMBER")) {
- // cellNumber = row.createCell((short) cellNum);
- // cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
- // cellNumber.setCellValue(value);
- // cellCurrencyNumber = row.createCell((short) cellNum);
- int zInt = 0;
- if (value.equals("null")) {
- cell.setCellValue(zInt);
- } else {
-
- if ((value.indexOf(".")) != -1) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
-
- // if (value.startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempDollar = value.trim();
- tempDollar = tempDollar.replaceAll(" ", "").substring(0);
- tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempDollar);
- // System.out.println("Before copy Value |" + tempDollar);
- // tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1,
- // tempDollar.length()-1);
- // System.out.println("After copy Value |" + tempDollar);
- if ((tempDollar.indexOf(",")) != -1) {
- tempDollar = tempDollar.replaceAll(",", "");
- }
- // System.out.println("The final string 1 is "+tempDollar);
- double tempDoubleDollar = 0.0;
- try {
- tempDoubleDollar = Double.parseDouble(tempDollar);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 8);// HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleCurrencyDecimalNumber);
- cell.setCellValue(tempDoubleDollar);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(tempDollar);
- }
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- double tempDouble = 0.0;
- try {
- tempDouble = Double.parseDouble(value);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 0x28);// HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDecimalNumber);
- cell.setCellValue(tempDouble);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(value);
- }
-
- }
- } else {
- if (!(value.equals(""))) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
- // if (value.startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempInt = value.trim();
- tempInt = tempInt.replaceAll(" ", "").substring(0);
- tempInt = tempInt.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempInt);
- // System.out.println("Before copy Value |" + tempInt);
- // tempInt = String.copyValueOf(tempInt.toCharArray(), 1,
- // tempInt.length()-1);
- // System.out.println("After copy Value |" + tempInt);
- if ((tempInt.indexOf(",")) != -1) {
- tempInt = tempInt.replaceAll(",", "");
- }
- // System.out.println("The final string INT is "+tempInt);
- Long tempIntDollar = 0L;
- try {
- tempIntDollar = Long.parseLong(tempInt);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 6);// HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleCurrencyNumber);
- cell.setCellValue(tempIntDollar);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(tempInt);
- }
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- String tempStr = value.trim();
- if ((tempStr.indexOf(",")) != -1) {
- tempStr = tempStr.replaceAll(",", "");
- }
- Long temp = 0L;
-
- try {
- temp = Long.parseLong(tempStr);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 0x26);// HSSFDataFormat.getBuiltinFormat("(#,##0_);[Red](#,##0)"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleNumber);
- cell.setCellValue(temp);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(tempStr);
- }
-
- }
- // int temp = Integer.parseInt(value.trim());
- // cell.setCellValue(temp);
- // }else{
- // cell.setCellValue(strip.stripHtml(value));
- // }
- }
- }
- }
-
- } else if ((dataType != null && dataType.equals("DATE"))
- || (dv.getDisplayName() != null
- && dv.getDisplayName().toLowerCase().endsWith("date"))
- ||
- (dv.getColId() != null && dv.getColId().toLowerCase().endsWith("date")) ||
- (dv.getColName() != null && dv.getColName().toLowerCase().endsWith("date"))) {
- // cellDate = row.createCell((short) cellNum);
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("mm/dd/yy"));
-
- if (styleCell != null) {
- styleCell.setDataFormat((short) 0xe); // HSSFDataFormat.getBuiltinFormat("m/d/yy"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDate);
- // String MY_DATE_FORMAT = "yyyy-MM-dd";
- Date date = null;
- int flag = 0;
- date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy h:mm:ss"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yyyy"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yyyy h:mm:ss"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yyyy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy"));
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("yyyy/m/d"));
- flag = 1;
- }
- if (date == null)
- date = timestampFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("yyyy-m-d h:mm:ss")); // yyyy-MM-dd
- // HH:mm:ss
- flag = 1;
- }
- if (date == null)
- date = MONYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("mmm yyyy"));
- flag = 1;
- }
- if (date == null)
- date = MMYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/yyyy"));
- flag = 1;
- }
- if (date == null)
- date = MMMMMDDYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("mmm/d/yyyy"));
- flag = 1;
- }
- if (date == null)
- date = MONTHYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("mmm/yyyy"));
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("yyyy/m/d h:mm:ss"));
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDDASHFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("yyyy-m-d"));
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("yyyy/m/d h:mm"));
- flag = 1;
- }
- if (date == null)
- date = DDMONYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("d-mmm-yyyy h:mm:ss"));
- flag = 1;
- }
- if (date == null)
- date = DDMONYYYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("d-mmm-yyyy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = DDMONYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("d-mmm-yy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = DDMONYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("d-mmm-yyyy"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy h:mm:ss"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yy h:mm:ss"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYHHMMZFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yyyy h:mm"));
- flag = 1;
- }
- if (date == null)
- date = MMMMMDDYYYYHHMMSS.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cell.getCellStyle().setDataFormat(
- createHelper.createDataFormat().getFormat("m/d/yyyy h:mm"));
- flag = 1;
- }
-
- if (date != null) {
- // System.out.println("ExcelDate " + HSSFDateUtil.getExcelDate(date));
- cell.setCellValue(HSSFDateUtil.getExcelDate(date));
- try {
- String str = cell.getStringCellValue();
- } catch (IllegalStateException ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "IllegalStateException occured",
- ex);
- /* cell.getCellStyle().setDataFormat((short)0); */
- cell.setCellValue(value);
- }
- } else {
- /* cell.getCellStyle().setDataFormat((short)0); */
- cell.setCellValue(value);
- }
- // cellDate.setCellValue(date);
- // cellDate.setCellValue(value);
-
- } else if ((dv.getDisplayTotal() != null && dv.getDisplayTotal().equals("SUM("))
- || (dv.getColName() != null && dv.getColName().indexOf("999") != -1)) {
- // cellNumber = row.createCell((short) cellNum);
- // cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
- // cellNumber.setCellValue(value);
- cell = row.createCell((short) cellNum);
- int zInt = 0;
- if (value.equals("null")) {
- cell.setCellValue(zInt);
- } else {
-
- if ((value.indexOf(".")) != -1) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
-
- // if (value.startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempDollar = value.trim();
- tempDollar = tempDollar.replaceAll(" ", "").substring(0);
- tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempDollar);
- // System.out.println("Before copy Value |" + tempDollar);
- // tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1,
- // tempDollar.length()-1);
- // System.out.println("After copy Value |" + tempDollar);
- if ((tempDollar.indexOf(",")) != -1) {
- tempDollar = tempDollar.replaceAll(",", "");
- }
- // System.out.println("The final string 2IF is "+tempDollar);
- double tempDoubleDollar = 0.0;
- try {
- tempDoubleDollar = Double.parseDouble(tempDollar);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 8);// HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleCurrencyDecimalNumber);
- cell.setCellValue(tempDoubleDollar);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(tempDollar);
- }
-
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- String tempDoubleStr = value.trim();
- tempDoubleStr = tempDoubleStr.replaceAll(" ", "").substring(0);
- if ((tempDoubleStr.indexOf(",")) != -1) {
- tempDoubleStr = tempDoubleStr.replaceAll(",", "");
- }
- double tempDouble = 0.0;
- try {
- tempDouble = Double.parseDouble(tempDoubleStr);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 0x28); // for decimal
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDecimalNumber);
- cell.setCellValue(tempDouble);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(tempDoubleStr);
- }
- }
-
- } else {
- if (!(value.equals(""))) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
- // if (value.startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempInt = value.trim();
- tempInt = tempInt.replaceAll(" ", "").substring(0);
- tempInt = tempInt.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempInt);
- // System.out.println("Before copy Value |" + tempInt);
- // tempInt = String.copyValueOf(tempInt.toCharArray(), 1,
- // tempInt.length()-1);
- // System.out.println("After copy Value |" + tempInt);
- if ((tempInt.indexOf(",")) != -1) {
- tempInt = tempInt.replaceAll(",", "");
- }
- // System.out.println("The final string INT 2 is "+tempInt);
-
- Long tempIntDollar = 0L;
-
- try {
- tempIntDollar = Long.parseLong(tempInt);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 6);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleCurrencyNumber);
- cell.setCellValue(tempIntDollar);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(tempInt);
- }
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- String tempStr = value.trim();
- if ((tempStr.indexOf(",")) != -1) {
- tempStr = tempStr.replaceAll(",", "");
- }
- Long temp = 0L;
-
- try {
- temp = Long.parseLong(tempStr);
- if (styleCell != null) {
- styleCell.setDataFormat((short) 0x26);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleNumber);
- cell.setCellValue(temp);
- } catch (NumberFormatException ne) {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(tempStr);
- }
- }
- // int temp = Integer.parseInt(value.trim());
- // cell.setCellValue(temp);
- // }else{
- // cell.setCellValue(strip.stripHtml(value));
- // }
- } else {
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
- } else
- cell.setCellStyle(styleDefault);
- }
- }
- }
-
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("General"));
- if (styleCell != null) {
- styleCell.setWrapText(true);
- cell.setCellStyle(styleCell);
+ cell.setCellStyle(styleDate);
+ //String MY_DATE_FORMAT = "yyyy-MM-dd";
+ //value = nvl(value).length()<=0?nvl(dv.getDisplayValue()):value;
+ Date date = null;
+ int flag = 0;
+ date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy h:mm:ss"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yyyy h:mm:ss"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yyyy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yyyy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("yyyy/m/d"));
+ flag = 1;
+ }
+ if(date==null)
+ date = timestampFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("yyyy-m-d h:mm:ss")); //yyyy-MM-dd HH:mm:ss
+ flag = 1;
+ }
+ if(date==null)
+ date = MONYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("mmm yyyy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/yyyy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMMMMDDYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("mmm/d/yyyy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MONTHYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("mmm/yyyy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("yyyy/m/d h:mm:ss"));
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDDASHFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("yyyy-m-d"));
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("yyyy/m/d h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("d-mmm-yyyy h:mm:ss"));
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("d-mmm-yyyy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("d-mmm-yy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("d-mmm-yyyy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy h:mm:ss"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy h:mm:ss"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYHHMMZFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yyyy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMMMMDDYYYYHHMMSS.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yyyy h:mm"));
+ flag = 1;
+ }
+
+ if(date!=null) {
+ //System.out.println("ExcelDate " + HSSFDateUtil.getExcelDate(date));
+ cell.setCellValue(HSSFDateUtil.getExcelDate(date));
+ try {
+ String str = cell.getStringCellValue();
+ } catch (IllegalStateException ex) { /*cell.getCellStyle().setDataFormat((short)0);*/cell.setCellValue(value);}
+ } else {
+ /*cell.getCellStyle().setDataFormat((short)0);*/
+ cell.setCellValue(value);
+ }
+ //cellDate.setCellValue(date);
+ //cellDate.setCellValue(value); //cellDate.setCellValue(date);
+ //cellDate.setCellValue(dv.getDisplayValue());
+
+ }else if((dv.getDisplayTotal()!=null && dv.getDisplayTotal().equals("SUM(")) || (dv.getColName()!=null && dv.getColName().indexOf("999")!=-1)){
+ //cellNumber = row.createCell((short) cellNum);
+ //cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
+ //cellNumber.setCellValue(dv.getDisplayValue());
+ cell = row.createCell((short) cellNum);
+ int zInt = 0;
+ if (value.equals("null")){
+ cell.setCellValue(zInt);
+ }else{
+
+ if ((value.indexOf("."))!= -1){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempDollar = value.trim();
+ tempDollar = tempDollar.replaceAll(" ", "").substring(0);
+ tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempDollar);
+ //System.out.println("Before copy Value |" + tempDollar);
+ //tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1, tempDollar.length()-1);
+ //System.out.println("After copy Value |" + tempDollar);
+ if ((tempDollar.indexOf(","))!= -1){
+ tempDollar = tempDollar.replaceAll(",", "");
+ }
+ //System.out.println("The final string 2IF is "+tempDollar);
+ double tempDoubleDollar = 0.0;
+ try {
+ tempDoubleDollar = Double.parseDouble(tempDollar);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short) 8);//HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleCurrencyDecimalNumber);
+ cell.setCellValue(tempDoubleDollar);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempDollar);
+ }
+
+
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempDoubleStr = value.trim();
+ tempDoubleStr = tempDoubleStr.replaceAll(" ", "").substring(0);
+ if ((tempDoubleStr.indexOf(","))!= -1){
+ tempDoubleStr = tempDoubleStr.replaceAll(",", "");
+ }
+ double tempDouble = 0.0;
+ try {
+ tempDouble = Double.parseDouble(tempDoubleStr);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short)0x28 );//HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDecimalNumber);
+ cell.setCellValue(tempDouble);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempDoubleStr);
+ }
+ }
+
+ }else {
+ if (!(value.equals(""))){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempInt = value.trim();
+ tempInt = tempInt.replaceAll(" ", "").substring(0);
+ tempInt = tempInt.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempInt);
+ //System.out.println("Before copy Value |" + tempInt);
+ //tempInt = String.copyValueOf(tempInt.toCharArray(), 1, tempInt.length()-1);
+ //System.out.println("After copy Value |" + tempInt);
+ if ((tempInt.indexOf(","))!= -1){
+ tempInt = tempInt.replaceAll(",", "");
+ }
+ //System.out.println("The final string INT 2 is "+tempInt);
+
+ Long tempIntDollar = 0L;
+
+ try {
+ tempIntDollar = Long.parseLong(tempInt);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short) 6);//HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleCurrencyNumber);
+ cell.setCellValue(tempIntDollar);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempInt);
+ }
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempStr = value.trim();
+ if ((tempStr.indexOf(","))!= -1){
+ tempStr = tempStr.replaceAll(",", "");
+ }
+ Long temp = 0L;
+
+ try {
+ temp = Long.parseLong(tempStr);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short) 0x26);//HSSFDataFormat.getBuiltinFormat("(#,##0_);[Red](#,##0)"));
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleNumber);
+ cell.setCellValue(temp);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempStr);
+ }
+ }
+ //int temp = Integer.parseInt(dv.getDisplayValue().trim());
+ // cell.setCellValue(temp);
+ //}else{
+ // cell.setCellValue(strip.stripHtml(dv.getDisplayValue()));
+ //}
+ } else {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ }
+ }
+ }
+
+
+ }
+ else {
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("General"));
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(strip.stripHtml(value));
+ }
+
+ //if (!(value.equals(""))){
+ //int temp = Integer.parseInt(value.trim());
+ //cell.setCellValue(temp);
+ //}else{
+ // cell.setCellValue(strip.stripHtml(value));
+ //}
+ //HSSFCellStyle styleFormat = null;
+ //HSSFCellStyle numberStyle = null;
+ //HSSFFont formatFont = null;
+ //short fgcolor = 0;
+ //short fillpattern = 0;
+ if (cellWidth.size() > cellNum) {
+ if (((Integer) cellWidth.get(cellNum)).intValue() < dv
+ .getDisplayValue().length())
+ cellWidth.set((cellNum),
+ (value.length()<=Globals.getMaxCellWidthInExcel())?new Integer(value.length()):new Integer(Globals.getMaxCellWidthInExcel()));
+ } else
+ cellWidth.add((cellNum), (value.length()<=Globals.getMaxCellWidthInExcel())?new Integer(value.length()):new Integer(Globals.getMaxCellWidthInExcel()));
+ //System.out.println("1IF "+ (dv.isBold()) + " "+ value + " " + dv.getDisplayTotal() + " " + dv.getColName() );
+ if (dv.isBold()) {
+ if((dv.getDisplayTotal()!=null && dv.getDisplayTotal().equals("SUM(")) || (dv.getColName()!=null && dv.getColName().indexOf("999")!=-1)){
+ if (value!=null && (value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ cell.setCellStyle(styleCurrencyTotal);
+ }
+ else {
+ cell.setCellStyle(styleTotal);
+ }
+ } else {
+ cell.setCellStyle(styleDefaultTotal);
+ }
+ bold = true;
+ }
+ //System.out.println("2IF "+ (dr.isRowFormat()) + " " + (dv.isCellFormat()) + " " + (styles!=null));
+ if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null) {
+ //cell.setCellStyle((HSSFCellStyle) styles.get(nvl(dr.getFormatId(),"default")));
+ continue;
+ }
+ //System.out.println("3IF "+ (htmlFormat != null) + " " + (dv.getFormatId() != null) + " " + (bold == false) + " "+ (styles != null));
+ if (htmlFormat != null && dv.getFormatId() != null && bold == false
+ && styles != null) {
+ //cell.setCellStyle((HSSFCellStyle) styles.get(nvl(dv.getFormatId(),"default")));
+ } //else if (bold == false)
+ //cell.setCellStyle(styleDefault);
+ } // dv.isVisible
+ }
+ rowNum += 1;
+
+ }
+
+ int cw = 0;
+ for (int i = 0; i < cellWidth.size(); i++) {
+ cw = ((Integer) cellWidth.get(i)).intValue() + 12;
+ // if(i!=cellWidth.size()-1)
+ sheet.setColumnWidth((short) (i), (short) ((cw * 8) / ((double) 1 / 20)));
+ // else
+ // sheet.setColumnWidth((short) (i + 1), (short) ((cw * 10) /
+ // ((double) 1 / 20)));
+ }
+
+ // To Display Total Values for Linear report
+ if(rd.reportDataTotalRow!=null) {
+ row = sheet.createRow(rowNum);
+ cellNum = -1;
+ rd.reportTotalRowHeaderCols.resetNext();
+ //for (rd.reportTotalRowHeaderCols.resetNext(); rd.reportTotalRowHeaderCols.hasNext();) {
+ cellNum += 1;
+ RowHeaderCol rhc = rd.reportTotalRowHeaderCols.getNext();
+ RowHeader rh = rhc.getRowHeader(0);
+ row.createCell((short) cellNum).setCellValue(strip.stripHtml(rh.getRowTitle()));
+ row.getCell((short) cellNum).setCellStyle(styleDefaultTotal);
+ //}
+
+ rd.reportDataTotalRow.resetNext();
+ DataRow drTotal = rd.reportDataTotalRow.getNext();
+ //cellNum = -1;
+
+ drTotal.resetNext();
+ drTotal.getNext();
+ for (; drTotal.hasNext();) {
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+ DataValue dv = drTotal.getNext();
+ String value = dv.getDisplayValue();
+ cell.setCellValue(value);
+ boolean bold = false;
+ if (dv.isBold()) {
+ if((dv.getDisplayTotal()!=null && dv.getDisplayTotal().equals("SUM(")) || (dv.getColName()!=null && dv.getColName().indexOf("999")!=-1)){
+ if (value!=null && (value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ cell.setCellStyle(styleCurrencyTotal);
+ } else {
+ cell.setCellStyle(styleTotal);
+ }
+ } else {
+ cell.setCellStyle(styleDefaultTotal);
+ }
+ bold = true;
+ }
+ }
+ }
+
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ throw new RaptorException(ex);
+ } catch (ReportSQLException ex) {
+ throw new RaptorException(ex);
+ } catch (Exception ex) {
+ if(!(ex.getCause() instanceof java.net.SocketException) )
+ throw new RaptorException (ex);
+ }
+
+ /*if(Globals.getShowDisclaimer() && !Globals.disclaimerPositionedTopInCSVExcel()) {
+ rowNum += 1;
+ row = sheet.createRow(rowNum);
+ cellNum = 0;
+ String disclaimer = Globals.getFooterFirstLine() + " " + Globals.getFooterSecondLine();
+ row.createCell((short) cellNum).setCellValue(disclaimer);
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short) (columnRows)));
+ rowNum += 1;
+ }*/
+ } else {
+ if(rr.getReportType().equals(AppConstants.RT_LINEAR)) {
+ int rowCount = 0;
+ for (rd.reportDataRows.resetNext(); rd.reportDataRows.hasNext();) {
+ DataRow dr = rd.reportDataRows.getNext();
+ //List l = rd.getReportDataList();
+ //for (int dataRow = 0; dataRow < l.size(); dataRow++) {
+ rowCount++;
+
+
+ //DataRow dr = (DataRow) l.get(dataRow);
+ row = sheet.createRow(rowNum);
+
+ cellNum = -1;
+
+ if (rr.getReportType().equals(AppConstants.RT_LINEAR) && rd.reportTotalRowHeaderCols!=null) {
+ rd.reportRowHeaderCols.resetNext(0);
+ if(rd.reportTotalRowHeaderCols!=null) {
+ //cellNum = -1;
+ //for (rd.reportRowHeaderCols.resetNext(); rd.reportRowHeaderCols.hasNext();) {
+ //cellNum += 1;
+ //RowHeaderCol rhc = rd.reportRowHeaderCols.getRowHeaderCol(0);
+ //if (firstPass)
+ // rhc.resetNext();
+ //RowHeader rh = rhc.getRowHeader(rowCount-1);
+ //row.createCell((short) cellNum).setCellValue(rowCount);
+ //row.getCell((short) cellNum).setCellStyle(styleDefault);
+ //if (firstPass)
+ //cellWidth.add(cellNum, new Integer((rowCount+"").length()));
+ //else
+ //cellWidth.set(cellNum, new Integer((rowCount+"").length()));
+
+ //} // for
+ }
+
+ } else {
+ rd.reportRowHeaderCols.resetNext(0);
+ }
+ for (; rd.reportRowHeaderCols.hasNext();) {
+ cellNum += 1;
+ RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
+ if (firstPass)
+ rhc.resetNext();
+ RowHeader rh = rhc.getNext();
+ row.createCell((short) cellNum).setCellValue(strip.stripHtml(rh.getRowTitle()));
+ row.getCell((short) cellNum).setCellStyle(styleDefault);
+ if (cellWidth.size() > 0) {
+ if (((Integer) cellWidth.get(cellNum)).intValue() < rh.getRowTitle()
+ .length())
+ cellWidth.set(cellNum, new Integer(rh.getRowTitle().length()));
+ } else
+ cellWidth.add(cellNum, new Integer(rh.getRowTitle().length()));
+
+ } // for
+ firstPass = false;
+ //cellNum = -1;
+ int j = 0;
+
+ for (dr.resetNext(); dr.hasNext();j++) {
+ DataValue dv = dr.getNext();
+ styleCell = null;
+ boolean bold = false;
+ String value = nvl(dv.getDisplayValue());
+ value = strip.stripHtml(value);
+ HtmlFormatter htmlFormat = dv.getCellFormatter();
+ if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null)
+ styleCell = (HSSFCellStyle) styles.get(nvl(dr.getFormatId(),"default"));
+ if (htmlFormat != null && dv.getFormatId() != null && styles != null)
+ styleCell = (HSSFCellStyle) styles.get(nvl(dv.getFormatId(),"default"));
+
+ if(dv.isVisible()) {
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+ //System.out.println("Stripping HTML 1");
+ //cell.setCellValue(strip.stripHtml(value));
+ String dataType = (String) (dataTypeMap.get(dv.getColId()));
+ //System.out.println(" The Display Value is ********"+value + " " + dv.getDisplayTotal() + " " + dv.getColName());
+
+ if (dataType!=null && dataType.equals("NUMBER")){
+ //cellNumber = row.createCell((short) cellNum);
+ //cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
+ //cellNumber.setCellValue(value);
+ //cellCurrencyNumber = row.createCell((short) cellNum);
+ int zInt = 0;
+ if (value.equals("null")){
+ cell.setCellValue(zInt);
+ }else{
+
+ if ((value.indexOf("."))!= -1){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempDollar = value.trim();
+ tempDollar = tempDollar.replaceAll(" ", "").substring(0);
+ tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempDollar);
+ //System.out.println("Before copy Value |" + tempDollar);
+ //tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1, tempDollar.length()-1);
+ //System.out.println("After copy Value |" + tempDollar);
+ if ((tempDollar.indexOf(","))!= -1){
+ tempDollar = tempDollar.replaceAll(",", "");
+ }
+ //System.out.println("The final string 1 is "+tempDollar);
+ double tempDoubleDollar = 0.0;
+ try {
+ tempDoubleDollar = Double.parseDouble(tempDollar);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short) 8);//HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleCurrencyDecimalNumber);
+ cell.setCellValue(tempDoubleDollar);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempDollar);
+ }
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ double tempDouble = 0.0;
+ try {
+ tempDouble = Double.parseDouble(value);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short) 0x28);//HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDecimalNumber);
+ cell.setCellValue(tempDouble);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(value);
+ }
+
+ }
+ }else {
+ if (!(value.equals(""))){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempInt = value.trim();
+ tempInt = tempInt.replaceAll(" ", "").substring(0);
+ tempInt = tempInt.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempInt);
+ //System.out.println("Before copy Value |" + tempInt);
+ //tempInt = String.copyValueOf(tempInt.toCharArray(), 1, tempInt.length()-1);
+ //System.out.println("After copy Value |" + tempInt);
+ if ((tempInt.indexOf(","))!= -1){
+ tempInt = tempInt.replaceAll(",", "");
+ }
+ //System.out.println("The final string INT is "+tempInt);
+ Long tempIntDollar = 0L;
+ try {
+ tempIntDollar = Long.parseLong(tempInt);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short)6);//HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleCurrencyNumber);
+ cell.setCellValue(tempIntDollar);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempInt);
+ }
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempStr = value.trim();
+ if ((tempStr.indexOf(","))!= -1){
+ tempStr = tempStr.replaceAll(",", "");
+ }
+ Long temp = 0L;
+
+ try {
+ temp = Long.parseLong(tempStr);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short)0x26);//HSSFDataFormat.getBuiltinFormat("(#,##0_);[Red](#,##0)"));
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleNumber);
+ cell.setCellValue(temp);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempStr);
+ }
+
+
+ }
+ //int temp = Integer.parseInt(value.trim());
+ // cell.setCellValue(temp);
+ //}else{
+ // cell.setCellValue(strip.stripHtml(value));
+ //}
+ }
+ }
+ }
+
+ }else if ( ( dataType !=null && dataType.equals("DATE")) || (dv.getDisplayName()!=null && dv.getDisplayName().toLowerCase().endsWith("date")) ||
+ (dv.getColId()!=null && dv.getColId().toLowerCase().endsWith("date")) ||
+ (dv.getColName()!=null && dv.getColName().toLowerCase().endsWith("date")) ) {
+ //cellDate = row.createCell((short) cellNum);
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("mm/dd/yy"));
+
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short)0xe); //HSSFDataFormat.getBuiltinFormat("m/d/yy"));
+ cell.setCellStyle(styleCell);
} else
- cell.setCellStyle(styleDefault);
- cell.setCellValue(strip.stripHtml(value));
- }
-
- // if (!(value.equals(""))){
- // int temp = Integer.parseInt(value.trim());
- // cell.setCellValue(temp);
- // }else{
- // cell.setCellValue(strip.stripHtml(value));
- // }
- // HSSFCellStyle styleFormat = null;
- // HSSFCellStyle numberStyle = null;
- // HSSFFont formatFont = null;
- // short fgcolor = 0;
- // short fillpattern = 0;
- if (cellWidth.size() > cellNum) {
- if (((Integer) cellWidth.get(cellNum)).intValue() < dv
- .getDisplayValue().length())
- cellWidth.set((cellNum),
- (value.length() <= Globals.getMaxCellWidthInExcel())
- ? new Integer(value.length())
- : new Integer(Globals.getMaxCellWidthInExcel()));
- } else
- cellWidth.add((cellNum),
- (value.length() <= Globals.getMaxCellWidthInExcel())
- ? new Integer(value.length())
- : new Integer(Globals.getMaxCellWidthInExcel()));
- // System.out.println("1IF "+ (dv.isBold()) + " "+ value + " " + dv.getDisplayTotal() + " "
- // + dv.getColName() );
- if (dv.isBold()) {
- if ((dv.getDisplayTotal() != null && dv.getDisplayTotal().equals("SUM("))
- || (dv.getColName() != null && dv.getColName().indexOf("999") != -1)) {
- if (value != null && (value.trim().startsWith("$"))
- || (value.trim().startsWith("-$"))) {
- cell.setCellStyle(styleCurrencyTotal);
- } else {
- cell.setCellStyle(styleTotal);
- }
- } else {
- cell.setCellStyle(styleDefaultTotal);
- }
- bold = true;
- }
- // System.out.println("2IF "+ (dr.isRowFormat()) + " " + (dv.isCellFormat()) + " " +
- // (styles!=null));
- if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null) {
- // cell.setCellStyle((HSSFCellStyle) styles.get(nvl(dr.getFormatId(),DEFAULT)));
- continue;
- }
- // System.out.println("3IF "+ (htmlFormat != null) + " " + (dv.getFormatId() != null) + " "
- // + (bold == false) + " "+ (styles != null));
- if (htmlFormat != null && dv.getFormatId() != null && bold == false
- && styles != null) {
- // cell.setCellStyle((HSSFCellStyle) styles.get(nvl(dv.getFormatId(),DEFAULT)));
- } // else if (bold == false)
- // cell.setCellStyle(styleDefault);
- } // if (dv.isVisible)
- } // for
-
- /*
- * for (int tmp=0; tmp<dataTypeMap.size(); tmp++){ String dataTypeStr =
- * (String)(dataTypeMap.get(tmp)); if(dataTypeStr.equals("NUMBER")){ cell.setCellStyle(styleNumber);
- * }else if (dataTypeStr.equals("VARCHAR2")){ cell.setCellStyle(styleDefault);
- *
- * }else if (dataTypeStr.equals("DATE")){ cell.setCellStyle(styleDate); }else{
- *
- * }
- *
- * }
- */
- rowNum += 1;
- int cw = 0;
- for (int i = 0; i < cellWidth.size(); i++) {
- cw = ((Integer) cellWidth.get(i)).intValue() + 12;
- // if(i!=cellWidth.size()-1)
- sheet.setColumnWidth((short) (i), (short) ((cw * 8) / ((double) 1 / 20)));
- // else
- // sheet.setColumnWidth((short) (i + 1), (short) ((cw * 10) /
- // ((double) 1 / 20)));
- }
-
- } // for
-
- // To Display Total Values for Linear report
- if (rd.reportDataTotalRow != null) {
- row = sheet.createRow(rowNum);
- cellNum = -1;
- rd.reportTotalRowHeaderCols.resetNext();
- // for (rd.reportTotalRowHeaderCols.resetNext(); rd.reportTotalRowHeaderCols.hasNext();) {
- cellNum += 1;
- RowHeaderCol rhc = rd.reportTotalRowHeaderCols.getNext();
- RowHeader rh = rhc.getRowHeader(0);
- row.createCell((short) cellNum).setCellValue(strip.stripHtml(rh.getRowTitle()));
- row.getCell((short) cellNum).setCellStyle(styleDefaultTotal);
- // }
-
- rd.reportDataTotalRow.resetNext();
- DataRow drTotal = rd.reportDataTotalRow.getNext();
- // cellNum = -1;
-
- drTotal.resetNext();
- drTotal.getNext();
- for (; drTotal.hasNext();) {
- cellNum += 1;
- cell = row.createCell((short) cellNum);
- DataValue dv = drTotal.getNext();
- String value = dv.getDisplayValue();
- cell.setCellValue(value);
- boolean bold = false;
- if (dv.isBold()) {
- if ((dv.getDisplayTotal() != null && dv.getDisplayTotal().equals("SUM("))
- || (dv.getColName() != null && dv.getColName().indexOf("999") != -1)) {
- if (value != null && (value.trim().startsWith("$"))
- || (value.trim().startsWith("-$"))) {
- cell.setCellStyle(styleCurrencyTotal);
- } else {
- cell.setCellStyle(styleTotal);
- }
- } else {
- cell.setCellStyle(styleDefaultTotal);
- }
- bold = true;
- }
- }
- }
-
- /*
- * if (rr.getReportType().equals(AppConstants.RT_LINEAR) && rd.reportTotalRowHeaderCols!=null) {
- *
- * for (rd.reportDataTotalRow.resetNext(); rd.reportDataTotalRow.hasNext();) { rowCount++;
- *
- *
- * DataRow dr = rd.reportDataTotalRow.getNext(); row = sheet.createRow(rowNum); cellNum = -1; int j
- * = 0; cellNum += 1; cell = row.createCell((short) cellNum); cell.setCellValue("Total");
- * cell.setCellStyle(styleTotal);
- *
- * for (dr.resetNext(); dr.hasNext();j++) { DataValue dv = dr.getNext(); if(j==0 || !dv.isVisible())
- * continue; cellNum += 1; styleCell = null; boolean bold = true; String value =
- * nvl(dv.getDisplayValue()); //cellNumber = row.createCell((short) cellNum);
- * //cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
- * //cellNumber.setCellValue(dv.getDisplayValue()); cell = row.createCell((short) cellNum); int zInt
- * = 0; if (value.equals("null")){ cell.setCellValue(zInt); }else{
- *
- * if ((value.indexOf("."))!= -1){ if ((value.trim().startsWith("$")) ||
- * (value.trim().startsWith("-$") )) {
- *
- * //if (value.startsWith("$")){
- * //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)")); String
- * tempDollar = value.trim(); tempDollar = tempDollar.replaceAll(" ", "").substring(0); tempDollar =
- * tempDollar.replaceAll("\\$", "").substring(0); //System.out.println("SUBSTRING |" + tempDollar);
- * //System.out.println("Before copy Value |" + tempDollar); //tempDollar =
- * String.copyValueOf(tempDollar.toCharArray(), 1, tempDollar.length()-1);
- * //System.out.println("After copy Value |" + tempDollar); if ((tempDollar.indexOf(","))!= -1){
- * tempDollar = tempDollar.replaceAll(",", ""); }
- * //System.out.println("The final string 2IF is "+tempDollar); double tempDoubleDollar = 0.0; try {
- * tempDoubleDollar = Double.parseDouble(tempDollar); if(styleTotal!=null) {
- * styleTotal.setDataFormat((short)
- * 8);//HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
- * cell.setCellStyle(styleTotal); } else cell.setCellStyle(styleCurrencyDecimalNumberTotal);
- * cell.setCellValue(tempDoubleDollar); } catch (NumberFormatException ne) { if(styleTotal!=null) {
- * styleTotal.setWrapText(true); cell.setCellStyle(styleTotal); } else
- * cell.setCellStyle(styleDefault); cell.setCellValue(tempDollar); }
- *
- *
- * }else{ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00")); String
- * tempDoubleStr = value.trim(); tempDoubleStr = tempDoubleStr.replaceAll(" ", "").substring(0); if
- * ((tempDoubleStr.indexOf(","))!= -1){ tempDoubleStr = tempDoubleStr.replaceAll(",", ""); } double
- * tempDouble = 0.0; try { tempDouble = Double.parseDouble(tempDoubleStr); if(styleTotal!=null) {
- * styleTotal.setDataFormat((short)0x28
- * );//HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
- * cell.setCellStyle(styleTotal); } else cell.setCellStyle(styleDecimalNumberTotal);
- * cell.setCellValue(tempDouble); } catch (NumberFormatException ne) { if(styleTotal!=null) {
- * styleTotal.setWrapText(true); cell.setCellStyle(styleTotal); } else
- * cell.setCellStyle(styleDefault); cell.setCellValue(tempDoubleStr); } }
- *
- * }else { if (!(value.equals(""))){ if ((value.trim().startsWith("$")) ||
- * (value.trim().startsWith("-$") )) { //if (value.startsWith("$")){
- * //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)")); String
- * tempInt = value.trim(); tempInt = tempInt.replaceAll(" ", "").substring(0); tempInt =
- * tempInt.replaceAll("\\$", "").substring(0); //System.out.println("SUBSTRING |" + tempInt);
- * //System.out.println("Before copy Value |" + tempInt); //tempInt =
- * String.copyValueOf(tempInt.toCharArray(), 1, tempInt.length()-1);
- * //System.out.println("After copy Value |" + tempInt); if ((tempInt.indexOf(","))!= -1){ tempInt =
- * tempInt.replaceAll(",", ""); } //System.out.println("The final string INT 2 is "+tempInt);
- *
- * Long tempIntDollar = 0L;
- *
- * try { tempIntDollar = Long.parseLong(tempInt); if(styleTotal!=null) {
- * styleTotal.setDataFormat((short)
- * 6);//HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)")); cell.setCellStyle(styleTotal);
- * } else cell.setCellStyle(styleCurrencyNumberTotal); cell.setCellValue(tempIntDollar); } catch
- * (NumberFormatException ne) { if(styleTotal!=null) { styleTotal.setWrapText(true);
- * cell.setCellStyle(styleTotal); } else cell.setCellStyle(styleDefault);
- * cell.setCellValue(tempInt); } }else{
- * //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00")); String tempStr =
- * value.trim(); if ((tempStr.indexOf(","))!= -1){ tempStr = tempStr.replaceAll(",", ""); } Long
- * temp = 0L;
- *
- * try { temp = Long.parseLong(tempStr); if(styleTotal!=null) { styleTotal.setDataFormat((short)
- * 0x26);//HSSFDataFormat.getBuiltinFormat("(#,##0_);[Red](#,##0)")); cell.setCellStyle(styleTotal);
- * } else cell.setCellStyle(styleNumber); cell.setCellValue(temp); } catch (NumberFormatException
- * ne) { if(styleTotal!=null) { styleTotal.setWrapText(true); cell.setCellStyle(styleTotal); } else
- * cell.setCellStyle(styleDefault); cell.setCellValue(tempStr); } } //int temp =
- * Integer.parseInt(dv.getDisplayValue().trim()); // cell.setCellValue(temp); //}else{ //
- * cell.setCellValue(strip.stripHtml(dv.getDisplayValue())); //} } else { if(styleTotal!=null) {
- * styleTotal.setWrapText(true); cell.setCellStyle(styleTotal); } else
- * cell.setCellStyle(styleDefault); } } }
- *
- *
- *
- *
- * } } }
- */
-
- } else if (rr.getReportType().equals(AppConstants.RT_CROSSTAB)) { // Linear
- int rowCount = 0;
- List l = rd.getReportDataList();
- boolean first = true;
- for (int dataRow = 0; dataRow < l.size(); dataRow++) {
-
- DataRow dr = (DataRow) l.get(dataRow);
- row = sheet.createRow(rowNum);
-
- cellNum = -1;
- first = true;
- Vector<DataValue> rowNames = dr.getRowValues();
- for (dr.resetNext(); dr.hasNext(); rowCount++) {
- if (first) {
- if (rowNames != null) {
- for (int i = 0; i < rowNames.size(); i++) {
- DataValue dv = rowNames.get(i);
- cellNum += 1;
- row.createCell((short) cellNum).setCellValue(strip.stripHtml(dv.getDisplayValue()));
- row.getCell((short) cellNum).setCellStyle(styleDefault);
- }
- }
- }
- first = false;
-
- DataValue dv = dr.getNext();
- if (dv.isVisible()) {
- String value = dv.getDisplayValue();
- if (value.indexOf("|#") != -1)
- value = value.substring(0, value.indexOf("|"));
-
- if (dr.isRowFormat() || nvl(dv.getFormatId()).length() > 0) {
- cellNum += 1;
- row.createCell((short) cellNum).setCellValue(strip.stripHtml(dv.getDisplayValue()));
- // row.getCell((short) cellNum).setCellStyle(styleDefault);
- if (nvl(dv.getFormatId()).length() > 0)
- row.getCell((short) cellNum)
- .setCellStyle((HSSFCellStyle) styles.get(nvl(dv.getFormatId(), DEFAULT)));
- else
- row.setRowStyle((HSSFCellStyle) styles.get(nvl(dr.getFormatId(), DEFAULT)));
- } else {
- cellNum += 1;
- row.createCell((short) cellNum).setCellValue(strip.stripHtml(value));
- row.getCell((short) cellNum).setCellStyle(styleDefault);
- } // end
- value = dv.getDisplayValue();
- if (value.indexOf("|#") != -1) {
- String color = value.substring(value.indexOf("|") + 1);
- if (color.equals("#FF0000"))
- row.getCell((short) cellNum).setCellStyle((HSSFCellStyle) styles.get(RED));
- else if (color.equals("#008000"))
- row.getCell((short) cellNum).setCellStyle((HSSFCellStyle) styles.get(GREEN));
- else if (color.equals("#FFFF00"))
- row.getCell((short) cellNum).setCellStyle((HSSFCellStyle) styles.get(YELLOW));
- else {
- row.getCell((short) cellNum).setCellStyle((HSSFCellStyle) styles.get(DEFAULT));
- }
-
- }
- }
- }
- rowNum += 1;
- int cw = 0;
- for (int i = 0; i < cellWidth.size(); i++) {
- cw = ((Integer) cellWidth.get(i)).intValue() + 12;
- // if(i!=cellWidth.size()-1)
- sheet.setColumnWidth((short) (i), (short) ((cw * 8) / ((double) 1 / 20)));
- // else
- // sheet.setColumnWidth((short) (i + 1), (short) ((cw * 10) /
- // ((double) 1 / 20)));
- }
-
- } // for
-
- }
-
- }
-
- String footer = (String) session.getAttribute("FOOTER_" + index);
- if (nvl(footer).length() > 0) {
- footer = Utils.replaceInString(footer, "<BR/>", " ");
- footer = Utils.replaceInString(footer, "<br/>", " ");
- footer = Utils.replaceInString(footer, "<br>", " ");
- footer = strip.stripHtml(nvl(footer).trim());
- row = sheet.createRow(rowNum);
- cellNum = 0;
- row.createCell((short) cellNum).setCellValue(footer);
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short) (columnRows)));
- rowNum += 1;
- }
-
- if (Globals.getShowDisclaimer() && !Globals.disclaimerPositionedTopInCSVExcel()) {
-
- rowNum += 1;
- row = sheet.createRow(rowNum);
- cellNum = 0;
- String disclaimer = Globals.getFooterFirstLine() + " " + Globals.getFooterSecondLine();
- row.createCell((short) cellNum).setCellValue(disclaimer);
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short) (columnRows)));
- rowNum += 1;
- }
-
- logger.debug(EELFLoggerDelegate.debugLogger, ("##### Heap utilization statistics [MB] #####"));
+ cell.setCellStyle(styleDate);
+ //String MY_DATE_FORMAT = "yyyy-MM-dd";
+ Date date = null;
+ int flag = 0;
+ date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy h:mm:ss"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yyyy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yyyy h:mm:ss"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yyyy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("yyyy/m/d"));
+ flag = 1;
+ }
+ if(date==null)
+ date = timestampFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("yyyy-m-d h:mm:ss")); //yyyy-MM-dd HH:mm:ss
+ flag = 1;
+ }
+ if(date==null)
+ date = MONYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("mmm yyyy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/yyyy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMMMMDDYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("mmm/d/yyyy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MONTHYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("mmm/yyyy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("yyyy/m/d h:mm:ss"));
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDDASHFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("yyyy-m-d"));
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("yyyy/m/d h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("d-mmm-yyyy h:mm:ss"));
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("d-mmm-yyyy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("d-mmm-yy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("d-mmm-yyyy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy h:mm:ss"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yy h:mm:ss"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYHHMMZFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yyyy h:mm"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMMMMDDYYYYHHMMSS.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cell.getCellStyle().setDataFormat(
+ createHelper.createDataFormat().getFormat("m/d/yyyy h:mm"));
+ flag = 1;
+ }
+
+ if(date!=null) {
+ //System.out.println("ExcelDate " + HSSFDateUtil.getExcelDate(date));
+ cell.setCellValue(HSSFDateUtil.getExcelDate(date));
+ try {
+ String str = cell.getStringCellValue();
+ } catch (IllegalStateException ex) { /*cell.getCellStyle().setDataFormat((short)0);*/cell.setCellValue(value);}
+ } else {
+ /*cell.getCellStyle().setDataFormat((short)0);*/
+ cell.setCellValue(value);
+ }
+ //cellDate.setCellValue(date);
+ //cellDate.setCellValue(value);
+
+ }else if((dv.getDisplayTotal()!=null && dv.getDisplayTotal().equals("SUM(")) || (dv.getColName()!=null && dv.getColName().indexOf("999")!=-1)){
+ //cellNumber = row.createCell((short) cellNum);
+ //cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
+ //cellNumber.setCellValue(value);
+ cell = row.createCell((short) cellNum);
+ int zInt = 0;
+ if (value.equals("null")){
+ cell.setCellValue(zInt);
+ }else{
+
+ if ((value.indexOf("."))!= -1){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempDollar = value.trim();
+ tempDollar = tempDollar.replaceAll(" ", "").substring(0);
+ tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempDollar);
+ //System.out.println("Before copy Value |" + tempDollar);
+ //tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1, tempDollar.length()-1);
+ //System.out.println("After copy Value |" + tempDollar);
+ if ((tempDollar.indexOf(","))!= -1){
+ tempDollar = tempDollar.replaceAll(",", "");
+ }
+ //System.out.println("The final string 2IF is "+tempDollar);
+ double tempDoubleDollar = 0.0;
+ try {
+ tempDoubleDollar = Double.parseDouble(tempDollar);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short)8);//HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleCurrencyDecimalNumber);
+ cell.setCellValue(tempDoubleDollar);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempDollar);
+ }
+
+
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempDoubleStr = value.trim();
+ tempDoubleStr = tempDoubleStr.replaceAll(" ", "").substring(0);
+ if ((tempDoubleStr.indexOf(","))!= -1){
+ tempDoubleStr = tempDoubleStr.replaceAll(",", "");
+ }
+ double tempDouble = 0.0;
+ try {
+ tempDouble = Double.parseDouble(tempDoubleStr);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short) 0x28); // for decimal
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDecimalNumber);
+ cell.setCellValue(tempDouble);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempDoubleStr);
+ }
+ }
+
+ }else {
+ if (!(value.equals(""))){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempInt = value.trim();
+ tempInt = tempInt.replaceAll(" ", "").substring(0);
+ tempInt = tempInt.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempInt);
+ //System.out.println("Before copy Value |" + tempInt);
+ //tempInt = String.copyValueOf(tempInt.toCharArray(), 1, tempInt.length()-1);
+ //System.out.println("After copy Value |" + tempInt);
+ if ((tempInt.indexOf(","))!= -1){
+ tempInt = tempInt.replaceAll(",", "");
+ }
+ //System.out.println("The final string INT 2 is "+tempInt);
+
+ Long tempIntDollar = 0L;
+
+ try {
+ tempIntDollar = Long.parseLong(tempInt);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short) 6);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleCurrencyNumber);
+ cell.setCellValue(tempIntDollar);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempInt);
+ }
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempStr = value.trim();
+ if ((tempStr.indexOf(","))!= -1){
+ tempStr = tempStr.replaceAll(",", "");
+ }
+ Long temp = 0L;
+
+ try {
+ temp = Long.parseLong(tempStr);
+ if(styleCell!=null) {
+ styleCell.setDataFormat((short) 0x26);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleNumber);
+ cell.setCellValue(temp);
+ } catch (NumberFormatException ne) {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempStr);
+ }
+ }
+ //int temp = Integer.parseInt(value.trim());
+ // cell.setCellValue(temp);
+ //}else{
+ // cell.setCellValue(strip.stripHtml(value));
+ //}
+ } else {
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ }
+ }
+ }
+
+
+ }
+ else {
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("General"));
+ if(styleCell!=null) {
+ styleCell.setWrapText(true);
+ cell.setCellStyle(styleCell);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(strip.stripHtml(value));
+ }
+
+ //if (!(value.equals(""))){
+ //int temp = Integer.parseInt(value.trim());
+ //cell.setCellValue(temp);
+ //}else{
+ // cell.setCellValue(strip.stripHtml(value));
+ //}
+ //HSSFCellStyle styleFormat = null;
+ //HSSFCellStyle numberStyle = null;
+ //HSSFFont formatFont = null;
+ //short fgcolor = 0;
+ //short fillpattern = 0;
+ if (cellWidth.size() > cellNum) {
+ if (((Integer) cellWidth.get(cellNum)).intValue() < dv
+ .getDisplayValue().length())
+ cellWidth.set((cellNum),
+ (value.length()<=Globals.getMaxCellWidthInExcel())?new Integer(value.length()):new Integer(Globals.getMaxCellWidthInExcel()));
+ } else
+ cellWidth.add((cellNum), (value.length()<=Globals.getMaxCellWidthInExcel())?new Integer(value.length()):new Integer(Globals.getMaxCellWidthInExcel()));
+ //System.out.println("1IF "+ (dv.isBold()) + " "+ value + " " + dv.getDisplayTotal() + " " + dv.getColName() );
+ if (dv.isBold()) {
+ if((dv.getDisplayTotal()!=null && dv.getDisplayTotal().equals("SUM(")) || (dv.getColName()!=null && dv.getColName().indexOf("999")!=-1)){
+ if (value!=null && (value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ cell.setCellStyle(styleCurrencyTotal);
+ }
+ else {
+ cell.setCellStyle(styleTotal);
+ }
+ } else {
+ cell.setCellStyle(styleDefaultTotal);
+ }
+ bold = true;
+ }
+ //System.out.println("2IF "+ (dr.isRowFormat()) + " " + (dv.isCellFormat()) + " " + (styles!=null));
+ if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null) {
+ //cell.setCellStyle((HSSFCellStyle) styles.get(nvl(dr.getFormatId(),"default")));
+ continue;
+ }
+ //System.out.println("3IF "+ (htmlFormat != null) + " " + (dv.getFormatId() != null) + " " + (bold == false) + " "+ (styles != null));
+ if (htmlFormat != null && dv.getFormatId() != null && bold == false
+ && styles != null) {
+ // cell.setCellStyle((HSSFCellStyle) styles.get(nvl(dv.getFormatId(),"default")));
+ } //else if (bold == false)
+ //cell.setCellStyle(styleDefault);
+ } // if (dv.isVisible)
+ } // for
+
+ /*for (int tmp=0; tmp<dataTypeMap.size(); tmp++){
+ String dataTypeStr = (String)(dataTypeMap.get(tmp));
+ if(dataTypeStr.equals("NUMBER")){
+ cell.setCellStyle(styleNumber);
+ }else if (dataTypeStr.equals("VARCHAR2")){
+ cell.setCellStyle(styleDefault);
+
+ }else if (dataTypeStr.equals("DATE")){
+ cell.setCellStyle(styleDate);
+ }else{
+
+ }
+
+ }*/
+ rowNum += 1;
+ int cw = 0;
+ for (int i = 0; i < cellWidth.size(); i++) {
+ cw = ((Integer) cellWidth.get(i)).intValue() + 12;
+ // if(i!=cellWidth.size()-1)
+ sheet.setColumnWidth((short) (i), (short) ((cw * 8) / ((double) 1 / 20)));
+ // else
+ // sheet.setColumnWidth((short) (i + 1), (short) ((cw * 10) /
+ // ((double) 1 / 20)));
+ }
+
+ } // for
+
+ // To Display Total Values for Linear report
+ if(rd.reportDataTotalRow!=null) {
+ row = sheet.createRow(rowNum);
+ cellNum = -1;
+ rd.reportTotalRowHeaderCols.resetNext();
+ //for (rd.reportTotalRowHeaderCols.resetNext(); rd.reportTotalRowHeaderCols.hasNext();) {
+ cellNum += 1;
+ RowHeaderCol rhc = rd.reportTotalRowHeaderCols.getNext();
+ RowHeader rh = rhc.getRowHeader(0);
+ row.createCell((short) cellNum).setCellValue(strip.stripHtml(rh.getRowTitle()));
+ row.getCell((short) cellNum).setCellStyle(styleDefaultTotal);
+ //}
+
+ rd.reportDataTotalRow.resetNext();
+ DataRow drTotal = rd.reportDataTotalRow.getNext();
+ //cellNum = -1;
+
+ drTotal.resetNext();
+ drTotal.getNext();
+ for (; drTotal.hasNext();) {
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+ DataValue dv = drTotal.getNext();
+ String value = dv.getDisplayValue();
+ cell.setCellValue(value);
+ boolean bold = false;
+ if (dv.isBold()) {
+ if((dv.getDisplayTotal()!=null && dv.getDisplayTotal().equals("SUM(")) || (dv.getColName()!=null && dv.getColName().indexOf("999")!=-1)){
+ if (value!=null && (value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ cell.setCellStyle(styleCurrencyTotal);
+ } else {
+ cell.setCellStyle(styleTotal);
+ }
+ } else {
+ cell.setCellStyle(styleDefaultTotal);
+ }
+ bold = true;
+ }
+ }
+ }
+
+ /*
+ if (rr.getReportType().equals(AppConstants.RT_LINEAR) && rd.reportTotalRowHeaderCols!=null) {
+
+ for (rd.reportDataTotalRow.resetNext(); rd.reportDataTotalRow.hasNext();) {
+ rowCount++;
+
+
+ DataRow dr = rd.reportDataTotalRow.getNext();
+ row = sheet.createRow(rowNum);
+ cellNum = -1;
+ int j = 0;
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue("Total");
+ cell.setCellStyle(styleTotal);
+
+ for (dr.resetNext(); dr.hasNext();j++) {
+ DataValue dv = dr.getNext();
+ if(j==0 || !dv.isVisible()) continue;
+ cellNum += 1;
+ styleCell = null;
+ boolean bold = true;
+ String value = nvl(dv.getDisplayValue());
+ //cellNumber = row.createCell((short) cellNum);
+ //cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
+ //cellNumber.setCellValue(dv.getDisplayValue());
+ cell = row.createCell((short) cellNum);
+ int zInt = 0;
+ if (value.equals("null")){
+ cell.setCellValue(zInt);
+ }else{
+
+ if ((value.indexOf("."))!= -1){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempDollar = value.trim();
+ tempDollar = tempDollar.replaceAll(" ", "").substring(0);
+ tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempDollar);
+ //System.out.println("Before copy Value |" + tempDollar);
+ //tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1, tempDollar.length()-1);
+ //System.out.println("After copy Value |" + tempDollar);
+ if ((tempDollar.indexOf(","))!= -1){
+ tempDollar = tempDollar.replaceAll(",", "");
+ }
+ //System.out.println("The final string 2IF is "+tempDollar);
+ double tempDoubleDollar = 0.0;
+ try {
+ tempDoubleDollar = Double.parseDouble(tempDollar);
+ if(styleTotal!=null) {
+ styleTotal.setDataFormat((short) 8);//HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)"));
+ cell.setCellStyle(styleTotal);
+ } else
+ cell.setCellStyle(styleCurrencyDecimalNumberTotal);
+ cell.setCellValue(tempDoubleDollar);
+ } catch (NumberFormatException ne) {
+ if(styleTotal!=null) {
+ styleTotal.setWrapText(true);
+ cell.setCellStyle(styleTotal);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempDollar);
+ }
+
+
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempDoubleStr = value.trim();
+ tempDoubleStr = tempDoubleStr.replaceAll(" ", "").substring(0);
+ if ((tempDoubleStr.indexOf(","))!= -1){
+ tempDoubleStr = tempDoubleStr.replaceAll(",", "");
+ }
+ double tempDouble = 0.0;
+ try {
+ tempDouble = Double.parseDouble(tempDoubleStr);
+ if(styleTotal!=null) {
+ styleTotal.setDataFormat((short)0x28 );//HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
+ cell.setCellStyle(styleTotal);
+ } else
+ cell.setCellStyle(styleDecimalNumberTotal);
+ cell.setCellValue(tempDouble);
+ } catch (NumberFormatException ne) {
+ if(styleTotal!=null) {
+ styleTotal.setWrapText(true);
+ cell.setCellStyle(styleTotal);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempDoubleStr);
+ }
+ }
+
+ }else {
+ if (!(value.equals(""))){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempInt = value.trim();
+ tempInt = tempInt.replaceAll(" ", "").substring(0);
+ tempInt = tempInt.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempInt);
+ //System.out.println("Before copy Value |" + tempInt);
+ //tempInt = String.copyValueOf(tempInt.toCharArray(), 1, tempInt.length()-1);
+ //System.out.println("After copy Value |" + tempInt);
+ if ((tempInt.indexOf(","))!= -1){
+ tempInt = tempInt.replaceAll(",", "");
+ }
+ //System.out.println("The final string INT 2 is "+tempInt);
+
+ Long tempIntDollar = 0L;
+
+ try {
+ tempIntDollar = Long.parseLong(tempInt);
+ if(styleTotal!=null) {
+ styleTotal.setDataFormat((short) 6);//HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
+ cell.setCellStyle(styleTotal);
+ } else
+ cell.setCellStyle(styleCurrencyNumberTotal);
+ cell.setCellValue(tempIntDollar);
+ } catch (NumberFormatException ne) {
+ if(styleTotal!=null) {
+ styleTotal.setWrapText(true);
+ cell.setCellStyle(styleTotal);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempInt);
+ }
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempStr = value.trim();
+ if ((tempStr.indexOf(","))!= -1){
+ tempStr = tempStr.replaceAll(",", "");
+ }
+ Long temp = 0L;
+
+ try {
+ temp = Long.parseLong(tempStr);
+ if(styleTotal!=null) {
+ styleTotal.setDataFormat((short) 0x26);//HSSFDataFormat.getBuiltinFormat("(#,##0_);[Red](#,##0)"));
+ cell.setCellStyle(styleTotal);
+ } else
+ cell.setCellStyle(styleNumber);
+ cell.setCellValue(temp);
+ } catch (NumberFormatException ne) {
+ if(styleTotal!=null) {
+ styleTotal.setWrapText(true);
+ cell.setCellStyle(styleTotal);
+ } else
+ cell.setCellStyle(styleDefault);
+ cell.setCellValue(tempStr);
+ }
+ }
+ //int temp = Integer.parseInt(dv.getDisplayValue().trim());
+ // cell.setCellValue(temp);
+ //}else{
+ // cell.setCellValue(strip.stripHtml(dv.getDisplayValue()));
+ //}
+ } else {
+ if(styleTotal!=null) {
+ styleTotal.setWrapText(true);
+ cell.setCellStyle(styleTotal);
+ } else
+ cell.setCellStyle(styleDefault);
+ }
+ }
+ }
+
+
+
+
+ }
+ }
+ }
+ */
+
+
+
+ } else if (rr.getReportType().equals(AppConstants.RT_CROSSTAB)) { // Linear
+ int rowCount = 0;
+ List l = rd.getReportDataList();
+ boolean first = true;
+ for (int dataRow = 0; dataRow < l.size(); dataRow++) {
+
+
+ DataRow dr = (DataRow) l.get(dataRow);
+ row = sheet.createRow(rowNum);
+
+ cellNum = -1;
+ first = true;
+ Vector<DataValue> rowNames = dr.getRowValues();
+ for(dr.resetNext(); dr.hasNext(); rowCount++ ) {
+ if(first) {
+ if(rowNames!=null) {
+ for(int i=0; i<rowNames.size(); i++) {
+ DataValue dv = rowNames.get(i);
+ cellNum += 1;
+ row.createCell((short) cellNum).setCellValue(strip.stripHtml(dv.getDisplayValue()));
+ row.getCell((short) cellNum).setCellStyle(styleDefault);
+ }
+ }
+ }
+ first = false;
+
+ DataValue dv = dr.getNext();
+ if(dv.isVisible()) {
+ String value = dv.getDisplayValue();
+ if(value.indexOf("|#")!=-1)
+ value = value.substring(0,value.indexOf("|"));
+
+ if(dr.isRowFormat() || nvl(dv.getFormatId()).length()>0) {
+ cellNum += 1;
+ row.createCell((short) cellNum).setCellValue(strip.stripHtml(dv.getDisplayValue()));
+ //row.getCell((short) cellNum).setCellStyle(styleDefault);
+ if(nvl(dv.getFormatId()).length()>0)
+ row.getCell((short) cellNum).setCellStyle((HSSFCellStyle) styles.get(nvl(dv.getFormatId(),"default")));
+ else
+ row.setRowStyle((HSSFCellStyle) styles.get(nvl(dr.getFormatId(),"default")));
+ } else {
+ cellNum += 1;
+ row.createCell((short) cellNum).setCellValue(strip.stripHtml(value));
+ row.getCell((short) cellNum).setCellStyle(styleDefault);
+ } // end
+ value = dv.getDisplayValue();
+ if(value.indexOf("|#")!=-1) {
+ String color = value.substring(value.indexOf("|")+1);
+ if(color.equals("#FF0000"))
+ row.getCell((short) cellNum).setCellStyle((HSSFCellStyle) styles.get("red"));
+ else if (color.equals("#008000"))
+ row.getCell((short) cellNum).setCellStyle((HSSFCellStyle) styles.get("green"));
+ else if (color.equals("#FFFF00"))
+ row.getCell((short) cellNum).setCellStyle((HSSFCellStyle) styles.get("yellow"));
+ else {
+ row.getCell((short) cellNum).setCellStyle((HSSFCellStyle) styles.get("default"));
+ }
+
+ }
+ }
+ }
+ rowNum += 1;
+ int cw = 0;
+ for (int i = 0; i < cellWidth.size(); i++) {
+ cw = ((Integer) cellWidth.get(i)).intValue() + 12;
+ // if(i!=cellWidth.size()-1)
+ sheet.setColumnWidth((short) (i), (short) ((cw * 8) / ((double) 1 / 20)));
+ // else
+ // sheet.setColumnWidth((short) (i + 1), (short) ((cw * 10) /
+ // ((double) 1 / 20)));
+ }
+
+
+ } // for
+
+ }
+
+
+ }
+
+ String footer = (String) session.getAttribute("FOOTER_"+index);
+ if(nvl(footer).length()>0) {
+ footer = Utils.replaceInString(footer, "<BR/>", " ");
+ footer = Utils.replaceInString(footer, "<br/>", " ");
+ footer = Utils.replaceInString(footer, "<br>", " ");
+ footer = strip.stripHtml(nvl(footer).trim());
+ row = sheet.createRow(rowNum);
+ cellNum = 0;
+ row.createCell((short) cellNum).setCellValue(footer);
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short) (columnRows)));
+ rowNum += 1;
+ }
+
+ if(Globals.getShowDisclaimer() && !Globals.disclaimerPositionedTopInCSVExcel()) {
+
+ rowNum += 1;
+ row = sheet.createRow(rowNum);
+ cellNum = 0;
+ String disclaimer = Globals.getFooterFirstLine() + " " + Globals.getFooterSecondLine();
+ row.createCell((short) cellNum).setCellValue(disclaimer);
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short) (columnRows)));
+ rowNum += 1;
+ }
+
+ logger.debug(EELFLoggerDelegate.debugLogger, ("##### Heap utilization statistics [MB] #####"));
logger.debug(EELFLoggerDelegate.debugLogger, ("Used Memory:"
- + (runtime.maxMemory() - runtime.freeMemory()) / mb));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Free Memory:"
- + runtime.freeMemory() / mb));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Total Memory:" + runtime.totalMemory() / mb));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Max Memory:" + runtime.maxMemory() / mb));
- return returnValue;
+ + (runtime.maxMemory() - runtime.freeMemory()) / mb));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Free Memory:"
+ + runtime.freeMemory() / mb));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Total Memory:" + runtime.totalMemory() / mb));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Max Memory:" + runtime.maxMemory() / mb));
+ return returnValue;
+
+ }
+
+ private void paintExcelHeader(HSSFWorkbook wb, int rowNum, int col, String reportTitle,
+ String reportDescr, HSSFSheet sheet) {
+ short s1 = 0, s2 = (short) (col-1);
+ rowNum += 1;
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
+ HSSFRow row = null, row1 = null;
+
+ row = sheet.createRow(rowNum);
+ // Header Style
+ HSSFCellStyle styleHeader = wb.createCellStyle();
+ styleHeader.setAlignment(HorizontalAlignment.CENTER);
+ HSSFFont font = wb.createFont();
+ font.setFontHeight((short) (font_header_title_size / 0.05)); //14
+ font.setFontName("Tahoma");
+ font.setColor(HSSFColor.BLACK.index);
+ styleHeader.setFont(font);
+
+ HSSFCell cell = row.createCell((short) 0);
+ cell.setCellValue(reportTitle);
+ cell.setCellStyle(styleHeader);
+ HSSFHeader header = sheet.getHeader();
+ header.setCenter(HSSFHeader.font("Tahoma", "")+ HSSFHeader.fontSize((short) 9)+" " + reportTitle);
+
+ //header.setCenter(HSSFHeader.font("Tahoma", "")+ HSSFHeader.fontSize((short) 9)+reportTitle+"\n"+((Globals.getShowDescrAtRuntime() && nvl(reportDescr).length() > 0)?reportDescr:""));
+
+ // Report Description
+ if (Globals.getShowDescrAtRuntime() && nvl(reportDescr).length() > 0) {
+ rowNum += 1;
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
+ HSSFCellStyle styleDescription = wb.createCellStyle();
+ styleDescription.setAlignment(HorizontalAlignment.CENTER);
+ HSSFFont fontDescr = wb.createFont();
+ fontDescr.setFontHeight((short) font_header_descr_size);
+ fontDescr.setFontName("Tahoma");
+ fontDescr.setColor(HSSFColor.BLACK.index);
+ styleDescription.setFont(fontDescr);
+ HSSFCell cellDescr = row.createCell((short) 0);
+ cellDescr.setCellValue(reportDescr);
+ cellDescr.setCellStyle(styleHeader);
+ }
+
+ if(Globals.disclaimerPositionedTopInCSVExcel()) {
+ rowNum += 1;
+ row = sheet.createRow(rowNum);
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
+ HSSFCellStyle styleDescription = wb.createCellStyle();
+ styleDescription.setAlignment(HorizontalAlignment.CENTER);
+ HSSFFont fontDescr = wb.createFont();
+ fontDescr.setFontHeight((short) (font_size / 0.05)); //14
+ fontDescr.setFontName("Tahoma");
+ fontDescr.setColor(HSSFColor.BLACK.index);
+ fontDescr.setBold(true);
+ styleDescription.setFont(fontDescr);
+ HSSFCell cellDescr = row.createCell((short) 0);
+ String disclaimer = Globals.getFooterFirstLine() + " " + Globals.getFooterSecondLine();
+ cellDescr.setCellValue(disclaimer);
+ cellDescr.setCellStyle(styleDescription);
+ }
- }
+ rowNum += 1;
+ row = sheet.createRow(rowNum);
+ // System.out.println(" Last Row " + wb.getSheetAt(0).getLastRowNum());
+ }
- private void paintExcelHeader(HSSFWorkbook wb, int rowNum, int col, String reportTitle,
- String reportDescr, HSSFSheet sheet) {
- short s1 = 0, s2 = (short) (col - 1);
+ private void paintExcelFooter(HSSFWorkbook wb, int rowNum, int col, HSSFSheet sheet) {
+ logger.debug(EELFLoggerDelegate.debugLogger, ("excel footer"));
+ //HSSFSheet sheet = wb.getSheet(getSheetName());
+ HSSFFooter footer = sheet.getFooter();
+ footer.setLeft(HSSFFooter.font("Tahoma", "")+ HSSFFooter.fontSize((short) font_footer_size)+ "Page " + HSSFFooter.page()
+ + " of " + HSSFFooter.numPages() );
+ footer.setCenter(HSSFFooter.font("Tahoma", "")+ HSSFFooter.fontSize((short) font_footer_size)+Globals.getFooterFirstLine()+"\n"+Globals.getFooterSecondLine());
+ //footer.setCenter(HSSFFooter.font("Tahoma", "Italic")+ HSSFFooter.fontSize((short) 16))+Globals.getFooterSecondLine());
+/* footer.font("Tahoma");
+ short s1 = 0, s2 = (short) (col-1);
rowNum += 1;
sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
HSSFRow row = null, row1 = null;
-
+
row = sheet.createRow(rowNum);
// Header Style
- HSSFCellStyle styleHeader = wb.createCellStyle();
- styleHeader.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+ HSSFCellStyle styleFooter = wb.createCellStyle();
+ styleFooter.setAlignment(HorizontalAlignment.CENTER);
HSSFFont font = wb.createFont();
- font.setFontHeight((short) (FONT_HEADER_TITLE_SIZE / 0.05)); // 14
- font.setFontName(FONT_TAHOMA);
+ font.setFontHeight((short) (10 / 0.05));
+ font.setFontName("Tahoma");
font.setColor(HSSFColor.BLACK.index);
- styleHeader.setFont(font);
+ font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+ styleFooter.setFont(font);
HSSFCell cell = row.createCell((short) 0);
- cell.setCellValue(reportTitle);
- cell.setCellStyle(styleHeader);
- HSSFHeader header = sheet.getHeader();
- header.setCenter(HSSFHeader.font(FONT_TAHOMA, "") + HSSFHeader.fontSize((short) 9) + " " + reportTitle);
-
- // header.setCenter(HSSFHeader.font(FONT_TAHOMA, "")+ HSSFHeader.fontSize((short)
- // 9)+reportTitle+"\n"+((Globals.getShowDescrAtRuntime() && nvl(reportDescr).length() >
- // 0)?reportDescr:""));
-
- // Report Description
- if (Globals.getShowDescrAtRuntime() && nvl(reportDescr).length() > 0) {
- rowNum += 1;
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
- HSSFCellStyle styleDescription = wb.createCellStyle();
- styleDescription.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- HSSFFont fontDescr = wb.createFont();
- fontDescr.setFontHeight((short) FONT_HEADER_DESCR_SIZE);
- fontDescr.setFontName(FONT_TAHOMA);
- fontDescr.setColor(HSSFColor.BLACK.index);
- styleDescription.setFont(fontDescr);
- HSSFCell cellDescr = row.createCell((short) 0);
- cellDescr.setCellValue(reportDescr);
- cellDescr.setCellStyle(styleHeader);
- }
-
- if (Globals.disclaimerPositionedTopInCSVExcel()) {
- rowNum += 1;
- row = sheet.createRow(rowNum);
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
- HSSFCellStyle styleDescription = wb.createCellStyle();
- styleDescription.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- HSSFFont fontDescr = wb.createFont();
- fontDescr.setFontHeight((short) (FONT_SIZE / 0.05)); // 14
- fontDescr.setFontName(FONT_TAHOMA);
- fontDescr.setColor(HSSFColor.BLACK.index);
- fontDescr.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
- styleDescription.setFont(fontDescr);
- HSSFCell cellDescr = row.createCell((short) 0);
- String disclaimer = Globals.getFooterFirstLine() + " " + Globals.getFooterSecondLine();
- cellDescr.setCellValue(disclaimer);
- cellDescr.setCellStyle(styleDescription);
- }
-
- rowNum += 1;
+ debugLogger.debug(Globals.getFooterFirstLine());
+ cell.setCellValue(Globals.getFooterFirstLine());
+ cell.setCellStyle(styleFooter);
+
+ rowNum += 1;
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
row = sheet.createRow(rowNum);
- // System.out.println(" Last Row " + wb.getSheetAt(0).getLastRowNum());
- }
-
- private void paintExcelFooter(HSSFWorkbook wb, int rowNum, int col, HSSFSheet sheet) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("excel footer"));
- // HSSFSheet sheet = wb.getSheet(getSheetName());
- HSSFFooter footer = sheet.getFooter();
- footer.setLeft(HSSFFooter.font(FONT_TAHOMA, "") + HSSFFooter.fontSize((short) FONT_FOOTER_SIZE) + "Page "
- + HSSFFooter.page()
- + " of " + HSSFFooter.numPages());
- footer.setCenter(HSSFFooter.font(FONT_TAHOMA, "") + HSSFFooter.fontSize((short) FONT_FOOTER_SIZE)
- + Globals.getFooterFirstLine() + "\n" + Globals.getFooterSecondLine());
- // footer.setCenter(HSSFFooter.font(FONT_TAHOMA, "Italic")+ HSSFFooter.fontSize((short)
- // 16))+Globals.getFooterSecondLine());
- /*
- * footer.font(FONT_TAHOMA); short s1 = 0, s2 = (short) (col-1); rowNum += 1;
- * sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2)); HSSFRow row = null, row1 =
- * null;
- *
- * row = sheet.createRow(rowNum); // Header Style HSSFCellStyle styleFooter = wb.createCellStyle();
- * styleFooter.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFFont font = wb.createFont();
- * font.setFontHeight((short) (10 / 0.05)); font.setFontName(FONT_TAHOMA);
- * font.setColor(HSSFColor.BLACK.index); font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
- * styleFooter.setFont(font);
- *
- * HSSFCell cell = row.createCell((short) 0); debugLogger.debug(Globals.getFooterFirstLine());
- * cell.setCellValue(Globals.getFooterFirstLine()); cell.setCellStyle(styleFooter);
- *
- * rowNum += 1; sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2)); row =
- * sheet.createRow(rowNum); cell = row.createCell((short) 0);
- * debugLogger.debug(Globals.getFooterSecondLine());
- * cell.setCellValue(Globals.getFooterSecondLine()); cell.setCellStyle(styleFooter);
- */
+ cell = row.createCell((short) 0);
+ debugLogger.debug(Globals.getFooterSecondLine());
+ cell.setCellValue(Globals.getFooterSecondLine());
+ cell.setCellStyle(styleFooter);
+*/
logger.debug(EELFLoggerDelegate.debugLogger, ("Done"));
}
- public String saveAsExcelFile(HttpServletRequest request, ReportData rd,
- ArrayList reportParamNameValues, String reportTitle, String reportDescr) {
- return saveAsExcelFile(request, rd, reportParamNameValues, reportTitle, reportDescr, 2); // 2 denotes
- // ReportRuntime object
- // should be taken from
- // session.
- }
-
- public String saveAsExcelFile(HttpServletRequest request, ReportData rd,
- ArrayList reportParamNameValues, String reportTitle, String reportDescr, int requestFlag) {
- setSheetName(Globals.getSheetName());
- try (HSSFWorkbook wb = new HSSFWorkbook()) {
- ReportRuntime rr;
- if (requestFlag == 2)
- rr = (ReportRuntime) request.getSession().getAttribute(
- AppConstants.SI_REPORT_RUNTIME);
- else
- rr = (ReportRuntime) request.getAttribute(
- AppConstants.SI_REPORT_RUNTIME);
-
- HashMap styles = new HashMap();
- String xlsFName = "";
- if (rr != null) {
- styles = loadStyles(rr, wb);
- xlsFName = AppUtils.generateUniqueFileName(request, rr.getReportName(), AppConstants.FT_XLS);
- }
- logger.debug(EELFLoggerDelegate.debugLogger, ("Xls File name " +
- AppUtils.getTempFolderPath()
- + xlsFName));
- try (FileOutputStream xlsOut = new FileOutputStream(FilenameUtils.normalize(AppUtils.getTempFolderPath()
- + xlsFName))) {
- // BufferedWriter xlsOut = new BufferedWriter(new
- // FileWriter(AppUtils
- // .getTempFolderPath()
- // + xlsFName));
-
- int col = 0;
- // System.out.println("Row Header Count " + rd.reportRowHeaderCols.getRowCount());
- // System.out.println("Total Count " + rd.getTotalColumnCount());
-
- if (!rd.reportRowHeaderCols.hasNext())
- col = rd.getTotalColumnCount();
- else
- col = rd.getTotalColumnCount();
- int rowNum = 0;
- HSSFSheet sheet = wb.createSheet(getSheetName());
-
- if (Globals.getPrintTitleInDownload() && reportTitle != null) {
- paintExcelHeader(wb, rowNum, col, reportTitle, reportDescr, sheet);
- rowNum = sheet.getLastRowNum();
- } else
- rowNum = 0;
- if (Globals.getPrintParamsInDownload() && rr != null
- && rr.getParamNameValuePairsforPDFExcel(request, 1) != null) {
- paintExcelParams(wb, rowNum, col, rr.getParamNameValuePairsforPDFExcel(request, 1),
- rr.getFormFieldComments(request), sheet, reportTitle, reportDescr);
- } // if
+ public String saveAsExcelFile(HttpServletRequest request, ReportData rd,
+ ArrayList reportParamNameValues, String reportTitle, String reportDescr) {
+ return saveAsExcelFile(request, rd, reportParamNameValues, reportTitle, reportDescr, 2); //2 denotes ReportRuntime object should be taken from session.
+ }
+ public String saveAsExcelFile(HttpServletRequest request, ReportData rd,
+ ArrayList reportParamNameValues, String reportTitle, String reportDescr, int requestFlag) {
+ setSheetName(Globals.getSheetName());
+ try {
+ ReportRuntime rr;
+ if(requestFlag == 2)
+ rr = (ReportRuntime) request.getSession().getAttribute(
+ AppConstants.SI_REPORT_RUNTIME);
+ else
+ rr = (ReportRuntime) request.getAttribute(
+ AppConstants.SI_REPORT_RUNTIME);
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HashMap styles = new HashMap();
+ String xlsFName="";
+ if (rr != null){
+ styles = loadStyles(rr, wb);
+ xlsFName = AppUtils.generateUniqueFileName(request, rr.getReportName(), AppConstants.FT_XLS);
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Xls File name " +
+ AppUtils.getTempFolderPath()
+ + xlsFName));
+ try(FileOutputStream xlsOut = new FileOutputStream(FilenameUtils.normalize(AppUtils.getTempFolderPath()
+ + xlsFName))){
+ // BufferedWriter xlsOut = new BufferedWriter(new
+ // FileWriter(AppUtils
+ // .getTempFolderPath()
+ // + xlsFName));
+
+ int col = 0;
+ //System.out.println("Row Header Count " + rd.reportRowHeaderCols.getRowCount());
+ //System.out.println("Total Count " + rd.getTotalColumnCount());
+
+ if (!rd.reportRowHeaderCols.hasNext())
+ col = rd.getTotalColumnCount();
+ else
+ col = rd.getTotalColumnCount();
+ int rowNum = 0;
+ HSSFSheet sheet = wb.createSheet(getSheetName());
+
+ if (Globals.getPrintTitleInDownload()&& reportTitle != null ) {
+ paintExcelHeader(wb, rowNum, col, reportTitle, reportDescr, sheet);
rowNum = sheet.getLastRowNum();
- // System.out.println(" rowNum after Params " + rowNum);
- paintExcelData(wb, rowNum, rd, styles, rr, sheet, "", request);
- if (Globals.getPrintFooterInDownload()) {
- rowNum = sheet.getLastRowNum();
- rowNum += 2;
- paintExcelFooter(wb, rowNum, col, sheet);
- }
- // response.setContentType("application/vnd.ms-excel");
- // response.setHeader("Content-disposition", "attachment;filename=download_all_"
- // + user_id + ".xls");
- wb.write(xlsOut);
- xlsOut.flush();
+ } else
+ rowNum = 0;
+ if (Globals.getPrintParamsInDownload() && rr.getParamNameValuePairsforPDFExcel(request, 1) != null) {
+ paintExcelParams(wb,rowNum,col,rr.getParamNameValuePairsforPDFExcel(request, 1), rr.getFormFieldComments(request), sheet, reportTitle, reportDescr);
+ } // if
+ rowNum = sheet.getLastRowNum();
+ //System.out.println(" rowNum after Params " + rowNum);
+ paintExcelData(wb, rowNum, rd, styles,rr, sheet, "", request);
+ if (Globals.getPrintFooterInDownload() ) {
+ rowNum = sheet.getLastRowNum();
+ rowNum += 2;
+ paintExcelFooter(wb, rowNum, col, sheet);
}
- return xlsFName;
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "Excetion in saveAsExcelFile", e);
- (new ErrorHandler()).processError(request, "Exception saving data to EXCEL file: "
- + e.getMessage());
- return null;
- }
- } // saveAsExcelFile
+ //response.setContentType("application/vnd.ms-excel");
+ //response.setHeader("Content-disposition", "attachment;filename=download_all_"
+ // + user_id + ".xls");
+ wb.write(xlsOut);
+ xlsOut.flush();
+ }
+ return xlsFName;
+ } catch (Exception e) {
+ e.printStackTrace();
+ (new ErrorHandler()).processError(request, "Exception saving data to EXCEL file: "
+ + e.getMessage());
+ return null;
+ }
+ } // saveAsExcelFile
public void createExcelFileContent(final Writer out, ReportData rd, final ReportRuntime rr,
- final HttpServletRequest request, final HttpServletResponse response, final String user_id, final int type)
- throws IOException, RaptorException {
+ final HttpServletRequest request, final HttpServletResponse response, final String user_id, final int type)
+ throws IOException, RaptorException {
// Adding utility for downloading Dashboard reports.
Map styles = new HashMap();
@@ -2750,7 +2839,7 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
int returnValue = 0;
final boolean isDashboard = (session.getAttribute(AppConstants.SI_DASHBOARD_REP_ID) != null) &&
- (((String) session.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).equals(rr.getReportID()));
+ (((String) session.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).equals(rr.getReportID()));
if (isDashboard) {
final String formattedDate = new SimpleDateFormat("MMddyyyyHHmm").format(new Date());
@@ -2759,23 +2848,22 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
FileInputStream xlsIn = null;
final Map reportRuntimeMap = (TreeMap) request.getSession()
- .getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP);
+ .getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP);
final Map reportDataMap = (TreeMap) request.getSession()
- .getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP);
+ .getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP);
if (reportRuntimeMap != null) {
final Set setReportRuntime = reportRuntimeMap.entrySet();
final Set setReportDataMap = reportDataMap.entrySet();
final Iterator iter2 = setReportDataMap.iterator();
int count = 0;
- for (Iterator iter = setReportRuntime.iterator(); iter.hasNext();) {
+ for (Iterator iter = setReportRuntime.iterator(); iter.hasNext(); ) {
count++;
try {
xlsIn =
- new FileInputStream(
- FilenameUtils.normalize(AppUtils.getTempFolderPath() + xlsFName));
+ new FileInputStream(FilenameUtils.normalize(AppUtils.getTempFolderPath() + xlsFName));
} catch (final FileNotFoundException e) {
- logger.error(EELFLoggerDelegate.errorLogger, "File not found in the specified path.", e);
+ System.out.println("File not found in the specified path.");
}
if (xlsIn != null) {
final POIFSFileSystem fileSystem = new POIFSFileSystem(xlsIn);
@@ -2790,8 +2878,8 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
final ReportData rdDashRep = (ReportData) entryData.getValue();
int col = 0;
final String reportTitle = (nvl(rrDashRep.getReportTitle()).length() > 0 ? rrDashRep
- .getReportTitle()
- : rrDashRep.getReportName());
+ .getReportTitle()
+ : rrDashRep.getReportName());
final String reportDescr = rrDashRep.getReportDescr();
if (!rdDashRep.reportRowHeaderCols.hasNext()) {
col = rdDashRep.getTotalColumnCount();
@@ -2803,7 +2891,7 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
}
int rowNum = 0;
final String formattedReportName =
- new HtmlStripper().stripSpecialCharacters(rrDashRep.getReportName());
+ new HtmlStripper().stripSpecialCharacters(rrDashRep.getReportName());
HSSFSheet sheet = null;
try {
@@ -2811,9 +2899,8 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
sheet.getPrintSetup().setLandscape(true);
styles = loadStyles(rrDashRep, wb);
} catch (final IllegalArgumentException ex) {
- logger.warn("IllegalArgumentException occured", ex);
try (final FileOutputStream xlsOut = new FileOutputStream(
- FilenameUtils.normalize(AppUtils.getTempFolderPath() + xlsFName))) {
+ FilenameUtils.normalize(AppUtils.getTempFolderPath() + xlsFName))) {
wb.write(xlsOut);
xlsOut.flush();
} catch (final IOException e) {
@@ -2828,23 +2915,23 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
} else {
rowNum = 0;
}
- // getting ReportRuntime object from session
+ //getting ReportRuntime object from session
if (Globals.getPrintParamsInDownload()
- && rrDashRep.getParamNameValuePairsforPDFExcel(request, 1) != null) {
+ && rrDashRep.getParamNameValuePairsforPDFExcel(request, 1) != null) {
if (count > 1 && Globals.showParamsInAllDashboardReports()) {
paintExcelParams(wb, rowNum, col,
- rrDashRep.getParamNameValuePairsforPDFExcel(request, 1),
- rrDashRep.getFormFieldComments(request), sheet, reportTitle, reportDescr);
+ rrDashRep.getParamNameValuePairsforPDFExcel(request, 1),
+ rrDashRep.getFormFieldComments(request), sheet, reportTitle, reportDescr);
} else if (count == 1) {
paintExcelParams(wb, rowNum, col,
- rrDashRep.getParamNameValuePairsforPDFExcel(request, 1),
- rrDashRep.getFormFieldComments(request), sheet, reportTitle, reportDescr);
+ rrDashRep.getParamNameValuePairsforPDFExcel(request, 1),
+ rrDashRep.getFormFieldComments(request), sheet, reportTitle, reportDescr);
}
} // if
rowNum = sheet.getLastRowNum();
final String sql_whole = rrDashRep.getWholeSQL();
returnValue = paintExcelData(wb, rowNum, rdDashRep, styles, rrDashRep, sheet, sql_whole,
- request);
+ request);
if (returnValue == 0) {
if (Globals.getPrintFooterInDownload()) {
rowNum = sheet.getLastRowNum();
@@ -2852,9 +2939,9 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
paintExcelFooter(wb, rowNum, col, sheet);
}
try (final FileOutputStream xlsOut = new FileOutputStream(
- FilenameUtils.normalize(AppUtils.getTempFolderPath() + xlsFName))) {
+ FilenameUtils.normalize(AppUtils.getTempFolderPath() + xlsFName))) {
wb.write(xlsOut);
- // TODO Remove comment
+ //TODO Remove comment
xlsOut.flush();
} catch (final IOException e) {
logger.warn("Failed to open FileOutputStream", e);
@@ -2866,15 +2953,15 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
response.reset();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition",
- "attachment;filename=" + "dashboard" + formattedDate + user_id + ".xls");
+ "attachment;filename=" + "dashboard" + formattedDate + user_id + ".xls");
xlsIn = new FileInputStream(AppUtils.getTempFolderPath() + xlsFName);
int readBytes = 0;
final byte[] bOut = new byte[4096];
try (final BufferedInputStream buf = new BufferedInputStream(xlsIn);
- final ServletOutputStream sos = response.getOutputStream();) {
- // read from the file; write to the ServletOutputStream
+ final ServletOutputStream sos = response.getOutputStream();) {
+ //read from the file; write to the ServletOutputStream
while ((readBytes = buf.read(bOut, 0, 4096)) > 0) {
buf.available();
sos.write(bOut, 0, readBytes);
@@ -2901,7 +2988,7 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
}
final String reportTitle = (nvl(rr.getReportTitle()).length() > 0 ? rr.getReportTitle()
- : rr.getReportName());
+ : rr.getReportName());
final String reportDescr = rr.getReportDescr();
final int col = getColumnCountForDownloadFile(rr, rd);
@@ -2922,7 +3009,7 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
}
paintExcelParams(wb, rowNum, col, paramsList, rr.getFormFieldComments(request), sheet, reportTitle,
- reportDescr);
+ reportDescr);
} // if
rowNum = sheet.getLastRowNum();
@@ -2931,10 +3018,10 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
response.reset();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition",
- "attachment;filename=" + formattedReportName + formattedDate + user_id + ".xls");
+ "attachment;filename=" + formattedReportName + formattedDate + user_id + ".xls");
if (type == 3 && rr.getSemaphoreList() == null && !(rr.getReportType()
- .equals(AppConstants.RT_CROSSTAB))) { // type = 3 is whole
+ .equals(AppConstants.RT_CROSSTAB))) { //type = 3 is whole
String sql_whole = "";
sql_whole = (String) request.getAttribute(AppConstants.RI_REPORT_SQL_WHOLE);
@@ -2951,34 +3038,32 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
returnValue = paintExcelData(wb, rowNum, rd, styles, rr, sheet, "", request);
} else {
int downloadLimit =
- (rr.getMaxRowsInExcelDownload() > 0) ? rr.getMaxRowsInExcelDownload()
- : Globals.getDownloadLimit();
- String action = request.getParameter(AppConstants.RI_ACTION);
- if (!(rr.getReportType().equals(AppConstants.RT_CROSSTAB)) && !action.endsWith("session")) {
- rd = rr.loadReportData(-1, AppUtils.getUserID(request), downloadLimit, request,
- false /* download */);
- }
- if (rr.getSemaphoreList() != null) {
- if (rr.getReportType().equals(AppConstants.RT_CROSSTAB)) {
- returnValue = paintExcelData(wb, rowNum, rd, styles, rr, sheet, "", request);
- } else {
- rd = rr.loadReportData(-1, AppUtils.getUserID(request), downloadLimit, request, true);
- returnValue = paintExcelData(wb, rowNum, rd, styles, rr, sheet, "", request);
- }
- } else {
- String sql_whole = "";
- sql_whole = (String) request.getAttribute(AppConstants.RI_REPORT_SQL_WHOLE);
-
- if (sql_whole == null) {
- if (!rr.getReportType().equals(AppConstants.RT_HIVE)) {
- sql_whole = rr.getWholeSQL();
- } else {
- sql_whole = rr.getReportSQL();
- }
- }
+ (rr.getMaxRowsInExcelDownload() > 0) ? rr.getMaxRowsInExcelDownload() : Globals.getDownloadLimit();
+ String action = request.getParameter(AppConstants.RI_ACTION);
+ if (!(rr.getReportType().equals(AppConstants.RT_CROSSTAB)) && !action.endsWith("session")) {
+ rd = rr.loadReportData(-1, AppUtils.getUserID(request), downloadLimit, request, false /*download*/);
+ }
+ if (rr.getSemaphoreList() != null) {
+ if (rr.getReportType().equals(AppConstants.RT_CROSSTAB)) {
+ returnValue = paintExcelData(wb, rowNum, rd, styles, rr, sheet, "", request);
+ } else {
+ rd = rr.loadReportData(-1, AppUtils.getUserID(request), downloadLimit, request, true);
+ returnValue = paintExcelData(wb, rowNum, rd, styles, rr, sheet, "", request);
+ }
+ } else {
+ String sql_whole = "";
+ sql_whole = (String) request.getAttribute(AppConstants.RI_REPORT_SQL_WHOLE);
- returnValue = paintExcelData(wb, rowNum, rd, styles, rr, sheet, sql_whole, request);
+ if (sql_whole == null) {
+ if (!rr.getReportType().equals(AppConstants.RT_HIVE)) {
+ sql_whole = rr.getWholeSQL();
+ } else {
+ sql_whole = rr.getReportSQL();
}
+ }
+
+ returnValue = paintExcelData(wb, rowNum, rd, styles, rr, sheet, sql_whole, request);
+ }
}
if (returnValue == 0) {
if (Globals.getPrintFooterInDownload()) {
@@ -2986,15 +3071,15 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
rowNum += 2;
paintExcelFooter(wb, rowNum, col, sheet);
}
- // Alternatively:
+ //Alternatively:
wb.setPrintArea(
- 0, // sheet index
- 0, // start column
- col, // end column
- 0, // start row
- rowNum // end row
- );
- // TODO Remove comment
+ 0, //sheet index
+ 0, //start column
+ col, //end column
+ 0, //start row
+ rowNum //end row
+ );
+ //TODO Remove comment
try (final ServletOutputStream sos = response.getOutputStream();) {
wb.write(sos);
sos.flush();
@@ -3005,475 +3090,466 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
}
}
}
-
+
public void createFlatFileContent(Writer out, ReportData rd, ReportRuntime rr,
HttpServletRequest request, HttpServletResponse response, String user_id)
- throws IOException, Exception {
+ throws IOException, Exception {
ReportHandler rephandler = new ReportHandler();
String reportID = rr.getReportID();
rr = rephandler.loadReportRuntime(request, reportID);
String query = rr.getWholeSQL();
String dbInfo = rr.getDbInfo();
- // File f = new File(request.(arg0)("/"));
+ //File f = new File(request.(arg0)("/"));
DataSet ds = ConnectionUtils.getDataSet(query, dbInfo);
-
- // Writing Column names to the file
+
+ //Writing Column names to the file
List l = rr.getAllColumns();
StringBuffer allColumnsBuffer = new StringBuffer();
DataColumnType dct = null;
-
+
for (Iterator iter = l.iterator(); iter.hasNext();) {
dct = (DataColumnType) iter.next();
allColumnsBuffer.append(dct.getDisplayName());
- if (iter.hasNext())
- allColumnsBuffer.append("|");
+ if(iter.hasNext())
+ allColumnsBuffer.append("|");
}
- rd = rr.loadReportData(-1, user_id, -1, request, true);
- // PrintWriter txtOut = new PrintWriter(out);
- // response.setContentType("application/notepad");
- // response.setHeader("Content-disposition",
- // "attachment;filename=download_all_"+AppUtils.getUserID(request)+".txt");
+ rd = rr.loadReportData(-1, user_id, -1,request, true);
+ //PrintWriter txtOut = new PrintWriter(out);
+ //response.setContentType("application/notepad");
+ //response.setHeader("Content-disposition", "attachment;filename=download_all_"+AppUtils.getUserID(request)+".txt");
ServletOutputStream sos = response.getOutputStream();
-
- // No Report Title for flat file.
- // if (Globals.getPrintTitleInDownload() && reportTitle != null) {
- // txtOut.println();
- // txtOut.println("\"" + reportTitle + "\"");
- // txtOut.println();
- // if (Globals.getShowDescrAtRuntime() && nvl(reportDescr).length() > 0) {
- // txtOut.println("\"" + reportDescr + "\"");
- // txtOut.println();
- // }
- // } // if
+
+ //No Report Title for flat file.
+// if (Globals.getPrintTitleInDownload() && reportTitle != null) {
+// txtOut.println();
+// txtOut.println("\"" + reportTitle + "\"");
+// txtOut.println();
+// if (Globals.getShowDescrAtRuntime() && nvl(reportDescr).length() > 0) {
+// txtOut.println("\"" + reportDescr + "\"");
+// txtOut.println();
+// }
+// } // if
// No Params either
- // int count = 0;
- // if (Globals.getPrintParamsInDownload() && reportParamNameValues != null) {
- // for (Iterator iter = reportParamNameValues.iterator(); iter.hasNext();) {
- // count += 1;
- // if(count == 1) txtOut.println();
- // IdNameValue value = (IdNameValue) iter.next();
- // txtOut.println(value.getId() + " = " + value.getName());
- // if(!iter.hasNext()) txtOut.println();
- // } // for
- // } // if
+// int count = 0;
+// if (Globals.getPrintParamsInDownload() && reportParamNameValues != null) {
+// for (Iterator iter = reportParamNameValues.iterator(); iter.hasNext();) {
+// count += 1;
+// if(count == 1) txtOut.println();
+// IdNameValue value = (IdNameValue) iter.next();
+// txtOut.println(value.getId() + " = " + value.getName());
+// if(!iter.hasNext()) txtOut.println();
+// } // for
+// } // if
+
+
+
+ boolean firstPass = true;
+ for (rd.reportDataRows.resetNext(); rd.reportDataRows.hasNext();) {
+ DataRow dr = rd.reportDataRows.getNext();
+ for (rd.reportRowHeaderCols.resetNext(1); rd.reportRowHeaderCols.hasNext();) {
+ RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
+ if (firstPass)
+ rhc.resetNext();
+ RowHeader rh = rhc.getNext();
+
+ sos.print(rh.getRowTitle());
+ if(rhc.hasNext()) sos.print("|");
+ } // for
+ firstPass = false;
+
+ for (dr.resetNext(); dr.hasNext();) {
+ DataValue dv = dr.getNext();
+
+ sos.print( dv.getDisplayValue());
+ if(dr.hasNext()) sos.print("|");
+ } // for
+
+ sos.println();
+ } // for
+ //sos.flush();
+ sos.close();
+ } // createFlatFileContent
- boolean firstPass = true;
- for (rd.reportDataRows.resetNext(); rd.reportDataRows.hasNext();) {
- DataRow dr = rd.reportDataRows.getNext();
- for (rd.reportRowHeaderCols.resetNext(1); rd.reportRowHeaderCols.hasNext();) {
- RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
- if (firstPass)
- rhc.resetNext();
- RowHeader rh = rhc.getNext();
-
- sos.print(rh.getRowTitle());
- if (rhc.hasNext())
- sos.print("|");
- } // for
- firstPass = false;
-
- for (dr.resetNext(); dr.hasNext();) {
- DataValue dv = dr.getNext();
-
- sos.print(dv.getDisplayValue());
- if (dr.hasNext())
- sos.print("|");
- } // for
-
- sos.println();
- } // for
- // sos.flush();
- sos.close();
- } // createFlatFileContent
public void createExcel2007FileContent(Writer out, ReportData rd, ReportRuntime rr, HttpServletRequest request,
- HttpServletResponse response, String user_id, int type)
- throws Exception {
-
+ HttpServletResponse response, String user_id, int type)
+ throws Exception {
+
// to check performance
- int mb = 1024 * 1024;
- Runtime runtime = Runtime.getRuntime();
-
- logger.debug(EELFLoggerDelegate.debugLogger, ("STARTING.EXCELX DOWNLOAD...."));
- logger.debug(EELFLoggerDelegate.debugLogger, ("##### Heap utilization statistics [MB] #####"));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Used Memory:"
- + (runtime.totalMemory() - runtime.freeMemory()) / mb));
+ int mb = 1024*1024;
+ Runtime runtime = Runtime.getRuntime();
+
+ logger.debug(EELFLoggerDelegate.debugLogger, ("STARTING.EXCELX DOWNLOAD...."));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("##### Heap utilization statistics [MB] #####"));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Used Memory:"
+ + (runtime.totalMemory() - runtime.freeMemory()) / mb));
logger.debug(EELFLoggerDelegate.debugLogger, ("Free Memory:"
- + runtime.freeMemory() / mb));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Total Memory:" + runtime.totalMemory() / mb));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Max Memory:" + runtime.maxMemory() / mb));
- logger.debug(EELFLoggerDelegate.debugLogger, ("##### END #####"));
-
- // Adding utility for downloading Dashboard reports.
-
- Map<String, XSSFCellStyle> styles = new HashMap<String, XSSFCellStyle>();
- HttpSession session = request.getSession();
- XSSFWorkbook wb = null;
+ + runtime.freeMemory() / mb));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Total Memory:" + runtime.totalMemory() / mb));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Max Memory:" + runtime.maxMemory() / mb));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("##### END #####"));
+
+ // Adding utility for downloading Dashboard reports.
+
+ Map<String, XSSFCellStyle> styles = new HashMap<String, XSSFCellStyle>();
+ HttpSession session = request.getSession();
+ XSSFWorkbook wb = null;
String formattedReportName = new HtmlStripper().stripSpecialCharacters(rr.getReportName());
String formattedDate = new SimpleDateFormat("MMddyyyyHHmm").format(new Date());
- // Sheet name to be filled is taken from property. How would this be called if it is Dashboard?
- // commented out since application will create and leave it blank.
- // setSheetName(Globals.getSheetName());
+ //Sheet name to be filled is taken from property. How would this be called if it is Dashboard?
+ //commented out since application will create and leave it blank.
+ //setSheetName(Globals.getSheetName());
boolean isDashboard = false;
- if ((session.getAttribute(AppConstants.SI_DASHBOARD_REP_ID) != null)
- && (((String) session.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).equals(rr.getReportID()))) {
- isDashboard = true;
+ if ((session.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)!=null) && ( ((String) session.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).equals(rr.getReportID())) ) {
+ isDashboard = true;
}
- // boolean isDashboard = (session.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)!=null);
+ //boolean isDashboard = (session.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)!=null);
ArrayList sheetArrayList = new ArrayList();
-
- Map reportRuntimeMap = null;
- Map reportDataMap = null;
-
- ArrayList reportIDList = new ArrayList();
-
- // Map reportDisplayTypeMap = null;
- if (isDashboard) {
- reportRuntimeMap = (TreeMap) request.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP);
- reportDataMap = (TreeMap) request.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP);
-
- if (reportRuntimeMap != null) {
- Set setReportRuntime = reportRuntimeMap.entrySet();
- for (Iterator iter = setReportRuntime.iterator(); iter.hasNext();) {
- Map.Entry entry = (Entry) iter.next();
- ReportRuntime rrDashRep = (ReportRuntime) entry.getValue();
- reportIDList.add(rrDashRep.getReportID());
- }
- }
- }
-
- int col = 0;
- String reportTitle = (nvl(rr.getReportTitle()).length() > 0 ? rr.getReportTitle() : rr.getReportName());
- String reportDescr = rr.getReportDescr();
-
- // Total Columns visible in excel
- // col = getColumnCountForDownloadFile(rr, rd);
-
- int rowNum = 0;
-
- XSSFSheet sheet = null;
- // save the template
+
+ Map reportRuntimeMap = null;
+ Map reportDataMap = null;
+
+ ArrayList reportIDList = new ArrayList();
+
+ //Map reportDisplayTypeMap = null;
+ if(isDashboard) {
+ reportRuntimeMap = (TreeMap) request.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP);
+ reportDataMap = (TreeMap) request.getSession().getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP);
+
+ if(reportRuntimeMap!=null) {
+ Set setReportRuntime = reportRuntimeMap.entrySet();
+ for(Iterator iter = setReportRuntime.iterator(); iter.hasNext(); ) {
+ Map.Entry entry = (Entry) iter.next();
+ ReportRuntime rrDashRep = (ReportRuntime) entry.getValue();
+ reportIDList.add(rrDashRep.getReportID());
+ }
+ }
+ }
+
+
+
+
+ int col = 0;
+ String reportTitle = (nvl(rr.getReportTitle()).length()>0?rr.getReportTitle():rr.getReportName());
+ String reportDescr = rr.getReportDescr();
+
+ // Total Columns visible in excel
+ //col = getColumnCountForDownloadFile(rr, rd);
+
+ int rowNum = 0;
+
+
+ XSSFSheet sheet = null;
+ //save the template
String filename = "";
String extension = "";
String sheetRef = null;
-
- File templateFile = null;
-
- if (isDashboard) {
- if (reportRuntimeMap != null) {
-
- FileInputStream readTemplate = null;
- // Load customized styles
- int count = 0;
-
- // If template supplied by Application
- String templateFilename = rr.getTemplateFile();
- extension = templateFilename.substring(templateFilename.lastIndexOf(".") + 1);
- filename = formattedReportName + formattedDate + user_id;
-
- Set setReportRuntimeWB = reportRuntimeMap.entrySet();
- for (Iterator iter = setReportRuntimeWB.iterator(); iter.hasNext();) {
- count++;
- Map.Entry entry = (Entry) iter.next();
- ReportRuntime rrDashRep = (ReportRuntime) entry.getValue();
- try (FileOutputStream os = new FileOutputStream(
- AppUtils.getTempFolderPath() + filename + "T." + nvls(extension, "xlsx"))) {
-
- if (count == 1) {
- if (nvl(rr.getTemplateFile()).length() > 0) {
- readTemplate = new FileInputStream(
- org.onap.portalsdk.analytics.system.AppUtils.getExcelTemplatePath()
- + rr.getTemplateFile());
- wb = new XSSFWorkbook(readTemplate);
- } else {
- // copy the os file to new file and open new file in below line
- wb = new XSSFWorkbook();
- }
- } else {
- readTemplate = new FileInputStream(
- AppUtils.getTempFolderPath() + filename + "." + nvls(extension, "xlsx"));
- wb = new XSSFWorkbook(readTemplate);
- }
- String reportSheetName = "";
- if (rrDashRep != null) {
- styles = loadXSSFStyles(rrDashRep, wb, styles);
- reportSheetName = new HtmlStripper().stripSpecialCharacters(rrDashRep.getReportName());
- }
- if (nvl(reportSheetName).length() > 28)
- reportSheetName = reportSheetName.substring(0, 28);
- sheet = wb.createSheet(count + "-" + reportSheetName);
- if (!Globals.printExcelInLandscapeMode())
- sheet.getPrintSetup().setLandscape(false);
- else
- sheet.getPrintSetup().setLandscape(true);
- wb.write(os);
- os.flush();
- if (nvl(rr.getTemplateFile()).length() > 0) {
- readTemplate.close();
- }
-
- try (FileInputStream inF = new FileInputStream(
- AppUtils.getTempFolderPath() + filename + "T." + nvls(extension, "xlsx"));
- FileOutputStream outStream = new FileOutputStream(
- AppUtils.getTempFolderPath() + filename + "." + nvls(extension, "xlsx"))) {
- copyStream(inF, outStream);
- outStream.flush();
- }
-
- }
- }
- FileInputStream xlsIn = null;
- POIFSFileSystem fileSystem = null;
- FileOutputStream xlsOut = null;
- formattedDate = new SimpleDateFormat("MMddyyyyHHmm").format(new Date());
- String xlsFName = "dashboard" + formattedDate + user_id + ".xls";
-
- Set setReportRuntime = reportRuntimeMap.entrySet();
- Set setReportDataMap = reportDataMap.entrySet();
- Iterator iter2 = setReportDataMap.iterator();
-
- // filename = templateFilename.substring(0,
- // templateFilename.lastIndexOf("."))+"_"+formattedDate+user_id;
-
+
+ File templateFile = null;
+
+ if(isDashboard) {
+ if(reportRuntimeMap!=null) {
+
+ FileInputStream readTemplate = null;
+ //Load customized styles
+ int count = 0;
+
+ //If template supplied by Application
+ String templateFilename = rr.getTemplateFile();
+ extension = templateFilename.substring(templateFilename.lastIndexOf(".")+1);
+ filename = formattedReportName+formattedDate+user_id;
+
+ Set setReportRuntimeWB = reportRuntimeMap.entrySet();
+ for(Iterator iter = setReportRuntimeWB.iterator(); iter.hasNext(); ) {
+ count++;
+ Map.Entry entry = (Entry) iter.next();
+ ReportRuntime rrDashRep = (ReportRuntime) entry.getValue();
+ try(FileOutputStream os = new FileOutputStream(AppUtils.getTempFolderPath()+ filename+"T."+ nvls(extension, "xlsx"))){
+
+ if(count==1) {
+ if(nvl(rr.getTemplateFile()).length()>0) {
+ readTemplate = new FileInputStream(org.onap.portalsdk.analytics.system.AppUtils.getExcelTemplatePath()+rr.getTemplateFile());
+ wb=new XSSFWorkbook(readTemplate);
+ } else {
+ //copy the os file to new file and open new file in below line
+ wb=new XSSFWorkbook();
+ }
+ } else {
+ readTemplate = new FileInputStream(AppUtils.getTempFolderPath()+ filename+"."+ nvls(extension, "xlsx"));
+ wb=new XSSFWorkbook(readTemplate);
+ }
+ String reportSheetName = "";
+ if(rrDashRep!=null){
+ styles = loadXSSFStyles(rrDashRep, wb, styles);
+ reportSheetName = new HtmlStripper().stripSpecialCharacters(rrDashRep.getReportName());
+ }
+ if(nvl(reportSheetName).length()>28)
+ reportSheetName = reportSheetName.substring(0, 28);
+ sheet = wb.createSheet(count+"-"+reportSheetName);
+ if(!Globals.printExcelInLandscapeMode())
+ sheet.getPrintSetup().setLandscape(false);
+ else
+ sheet.getPrintSetup().setLandscape(true);
+ wb.write(os);
+ os.flush();
+ if(nvl(rr.getTemplateFile()).length()>0) {
+ readTemplate.close();
+ }
+
+ try(FileInputStream inF = new FileInputStream(AppUtils.getTempFolderPath()+ filename+"T."+ nvls(extension, "xlsx"));
+ FileOutputStream outStream = new FileOutputStream(AppUtils.getTempFolderPath()+ filename+"."+ nvls(extension, "xlsx"))){
+ copyStream(inF, outStream);
+ outStream.flush();
+ }
+
+ }
+ }
+ FileInputStream xlsIn = null;
+ POIFSFileSystem fileSystem = null;
+ FileOutputStream xlsOut = null;
+ formattedDate = new SimpleDateFormat("MMddyyyyHHmm").format(new Date());
+ String xlsFName = "dashboard"+formattedDate+user_id+".xls";
+
+ Set setReportRuntime = reportRuntimeMap.entrySet();
+ Set setReportDataMap = reportDataMap.entrySet();
+ Iterator iter2 = setReportDataMap.iterator();
+
+
+ //filename = templateFilename.substring(0, templateFilename.lastIndexOf("."))+"_"+formattedDate+user_id;
+
count = 0;
- for (Iterator iter = setReportRuntime.iterator(); iter.hasNext();) {
- count++;
-
- Map.Entry entry = (Entry) iter.next();
- Map.Entry entryData = (Entry) iter2.next();
- ReportRuntime rrDashRep = (ReportRuntime) entry.getValue();
- ReportData rdDashRep = (ReportData) entryData.getValue();
-
- String reportSheetName = new HtmlStripper().stripSpecialCharacters(rrDashRep.getReportName());
- if (nvl(reportSheetName).length() > 28)
- reportSheetName = reportSheetName.substring(0, 28);
- sheet = wb.getSheet(count + "-" + reportSheetName);
- sheetRef = sheet.getPackagePart().getPartName().getName();
-
- // Step 2. Generate XML file.
- File tmp = File.createTempFile("sheet", ".xml");
- try (FileOutputStream fileOutTemp = new FileOutputStream(tmp);
- Writer fw = new OutputStreamWriter(fileOutTemp, XML_ENCODING)) {
-
- String sql_whole = rrDashRep.getWholeSQL();
-
- SpreadsheetWriter sw = new SpreadsheetWriter(fw);
- sw.beginSheet();
-
- generate(wb, sw, styles, rdDashRep, sql_whole, rrDashRep, request, sheet);
-
- sw.endSheet();
-
- fw.flush();
- fileOutTemp.flush();
- }
-
- // Step 3. Substitute the template entry with the generated data
-
- try (FileOutputStream outF = new FileOutputStream(
- AppUtils.getTempFolderPath() + filename + "." + nvls(extension, "xlsx"))) {
- templateFile =
- new File(AppUtils.getTempFolderPath() + filename + "T." + nvls(extension, "xlsx"));
- substitute(templateFile, tmp, sheetRef.substring(1), outF);
- outF.flush();
- }
-
- try (FileInputStream inF = new FileInputStream(
- AppUtils.getTempFolderPath() + filename + "." + nvls(extension, "xlsx"));
- FileOutputStream outStream = new FileOutputStream(
- AppUtils.getTempFolderPath() + filename + "T." + nvls(extension, "xlsx"))) {
- copyStream(inF, outStream);
- outStream.flush();
- }
- }
- }
+ for(Iterator iter = setReportRuntime.iterator(); iter.hasNext(); ) {
+ count++;
+
+ Map.Entry entry = (Entry) iter.next();
+ Map.Entry entryData = (Entry) iter2.next();
+ ReportRuntime rrDashRep = (ReportRuntime) entry.getValue();
+ ReportData rdDashRep = (ReportData) entryData.getValue();
+
+ String reportSheetName = new HtmlStripper().stripSpecialCharacters(rrDashRep.getReportName());
+ if(nvl(reportSheetName).length()>28)
+ reportSheetName = reportSheetName.substring(0, 28);
+ sheet = wb.getSheet(count+"-"+reportSheetName);
+ sheetRef = sheet.getPackagePart().getPartName().getName();
+
+ //Step 2. Generate XML file.
+ File tmp = File.createTempFile("sheet", ".xml");
+ try(FileOutputStream fileOutTemp = new FileOutputStream(tmp);
+ Writer fw = new OutputStreamWriter(fileOutTemp, XML_ENCODING)){
+
+ String sql_whole = rrDashRep.getWholeSQL();
+
+ SpreadsheetWriter sw = new SpreadsheetWriter(fw);
+ sw.beginSheet();
+
+
+ generate(wb, sw, styles, rdDashRep, sql_whole, rrDashRep, request, sheet);
+
+
+ sw.endSheet();
+
+ fw.flush();
+ fileOutTemp.flush();
+ }
+
+ //Step 3. Substitute the template entry with the generated data
+
+ try(FileOutputStream outF = new FileOutputStream(AppUtils.getTempFolderPath()+ filename+"."+ nvls(extension, "xlsx"))){
+ templateFile = new File(AppUtils.getTempFolderPath()+ filename+"T."+ nvls(extension, "xlsx"));
+ substitute(templateFile, tmp, sheetRef.substring(1), outF);
+ outF.flush();
+ }
+
+ try(FileInputStream inF = new FileInputStream(AppUtils.getTempFolderPath()+ filename+"."+ nvls(extension, "xlsx"));
+ FileOutputStream outStream = new FileOutputStream(AppUtils.getTempFolderPath()+ filename+"T."+ nvls(extension, "xlsx"))){
+ copyStream(inF, outStream);
+ outStream.flush();
+ }
+ }
+ }
+ } else {
+ //If template supplied by Application
+ if(nvl(rr.getTemplateFile()).length()>0) {
+ String templateFilename = rr.getTemplateFile();
+ extension = templateFilename.substring(templateFilename.lastIndexOf(".")+1);
+ filename = formattedReportName+formattedDate+user_id;
+ //filename = templateFilename.substring(0, templateFilename.lastIndexOf("."))+"_"+formattedDate+user_id;
} else {
- // If template supplied by Application
- if (nvl(rr.getTemplateFile()).length() > 0) {
- String templateFilename = rr.getTemplateFile();
- extension = templateFilename.substring(templateFilename.lastIndexOf(".") + 1);
- filename = formattedReportName + formattedDate + user_id;
- // filename = templateFilename.substring(0,
- // templateFilename.lastIndexOf("."))+"_"+formattedDate+user_id;
- } else {
- filename = formattedReportName + formattedDate + user_id;
- }
-
- if (nvl(rr.getTemplateFile()).length() <= 0) {
- try (FileOutputStream os = new FileOutputStream(
- AppUtils.getTempFolderPath() + "template" + formattedDate + user_id + ".xlsx")) {
- wb = new XSSFWorkbook();
- // Load customized styles
- if (rr != null)
- styles = loadXSSFStyles(rr, wb, styles);
- // create data sheet
- if (isDashboard) {
-
- } else {
-
- }
- String reportSheetName = new HtmlStripper().stripSpecialCharacters(rr.getReportName());
- if (nvl(reportSheetName).length() > 28)
- reportSheetName = reportSheetName.substring(0, 28);
- sheet = wb.createSheet(reportSheetName);
-
- // customized mode
- if (!Globals.printExcelInLandscapeMode())
- sheet.getPrintSetup().setLandscape(false);
- else
- sheet.getPrintSetup().setLandscape(true);
- // get data sheet name
- sheetRef = sheet.getPackagePart().getPartName().getName();
- wb.write(os);
- os.flush();
- // wb = null;
- }
-
- } else {
- try (FileOutputStream os =
- new FileOutputStream(AppUtils.getTempFolderPath() + filename + "T." + nvls(extension, "xlsx"));
- FileInputStream readTemplate =
- new FileInputStream(org.onap.portalsdk.analytics.system.AppUtils.getExcelTemplatePath()
- + rr.getTemplateFile());) {
- wb = new XSSFWorkbook(readTemplate);
- if (rr != null)
- styles = loadXSSFStyles(rr, wb, styles);
- sheet = wb.getSheetAt(0);
- if (!Globals.printExcelInLandscapeMode())
- sheet.getPrintSetup().setLandscape(false);
- else
- sheet.getPrintSetup().setLandscape(true);
- // sheet = wb.getSheet(getSheetName());
- sheetRef = sheet.getPackagePart().getPartName().getName();
- wb.write(os);
- os.flush();
- // wb = null;
- }
- }
-
- // Step 2. Generate XML file.
- File tmp = File.createTempFile("sheet", ".xml");
- try (FileOutputStream fileOutTemp = new FileOutputStream(tmp);
- Writer fw = new OutputStreamWriter(fileOutTemp, XML_ENCODING)) {
-
- // String sql_whole = (String) request.getAttribute(AppConstants.RI_REPORT_SQL_WHOLE);
- String sql_whole = "";
- sql_whole = (String) request.getAttribute(AppConstants.RI_REPORT_SQL_WHOLE);
-
- if (sql_whole == null) {
- if (!rr.getReportType().equals(AppConstants.RT_HIVE))
- sql_whole = rr.getWholeSQL();
- else
- sql_whole = rr.getReportSQL();
- }
-
- SpreadsheetWriter sw = new SpreadsheetWriter(fw);
-
- sw.beginSheet();
-
- if ((rd.getDataRowCount() >= rr.getReportDataSize())
- && !rr.getReportType().equals(AppConstants.RT_HIVE)) {
- sql_whole = "";
- }
-
- generate(wb, sw, styles, rd, sql_whole, rr, request, sheet);
-
- sw.endSheet();
-
- fw.flush();
- fileOutTemp.flush();
- }
- // Step 3. Substitute the template entry with the generated data
-
- try (FileOutputStream outF =
- new FileOutputStream(AppUtils.getTempFolderPath() + filename + "." + nvls(extension, "xlsx"))) {
-
- if (nvl(rr.getTemplateFile()).length() > 0) {
- templateFile = new File(AppUtils.getTempFolderPath() + filename + "T." + nvls(extension, "xlsx"));
- } else {
- templateFile =
- new File(AppUtils.getTempFolderPath() + "template" + formattedDate + user_id + ".xlsx");
- }
- substitute(templateFile, tmp, sheetRef.substring(1), outF);
- outF.flush();
- }
-
- }
- // get servlet output stream
-
- response.reset();
- try (BufferedInputStream buf = new BufferedInputStream(
- new FileInputStream(AppUtils.getTempFolderPath() + filename + "." + nvls(extension, "xlsx")));
- ServletOutputStream sos = response.getOutputStream()) {
-
- String mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
- if (extension.equals("xlsm"))
- mime_type = "application/vnd.ms-excel.sheet.macroEnabled.12";
- response.setContentType(mime_type);
-
- response.setHeader("Content-disposition",
- "attachment;filename=" + filename + "." + nvls(extension, "xlsx"));
-
- int readBytes = 0;
-
- // read from the file; write to the ServletOutputStream
- while ((readBytes = buf.read()) != -1)
- sos.write(readBytes);
-
- sos.flush();
+ filename = formattedReportName+formattedDate+user_id;
}
- logger.debug(EELFLoggerDelegate.debugLogger, ("ENDING..DOWNLOADING XLSX..."));
- logger.debug(EELFLoggerDelegate.debugLogger, ("##### Heap utilization statistics [MB] #####"));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Used Memory:"
- + (runtime.totalMemory() - runtime.freeMemory()) / mb));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Free Memory:"
- + runtime.freeMemory() / mb));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Total Memory:" + runtime.totalMemory() / mb));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Max Memory:" + runtime.maxMemory() / mb));
- logger.debug(EELFLoggerDelegate.debugLogger, ("##### END #####"));
- }
- /**
- *
- * @param zipfile the template file
- * @param tmpfile the XML file with the sheet data
- * @param entry the name of the sheet entry to substitute, e.g. xl/worksheets/sheet1.xml
- * @param out the stream to write the result to
- */
- private static void substitute(File zipfile, File tmpfile, String entry, OutputStream out) throws IOException {
- try (ZipFile zip = new ZipFile(zipfile);
- ZipOutputStream zos = new ZipOutputStream(out)) {
-
- @SuppressWarnings("unchecked")
- Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries();
- while (en.hasMoreElements()) {
- ZipEntry ze = en.nextElement();
- if (!ze.getName().equals(entry)) {
- zos.putNextEntry(new ZipEntry(ze.getName()));
- try (InputStream is = zip.getInputStream(ze)) {
- copyStream(is, zos);
- }
- }
- }
- zos.putNextEntry(new ZipEntry(entry));
- try (InputStream is = new FileInputStream(tmpfile)) {
- copyStream(is, zos);
+ if(nvl(rr.getTemplateFile()).length()<=0) {
+ try(FileOutputStream os = new FileOutputStream(AppUtils.getTempFolderPath()+"template"+formattedDate+user_id+".xlsx")){
+ wb=new XSSFWorkbook();
+ //Load customized styles
+ if (rr != null)
+ styles = loadXSSFStyles(rr, wb, styles);
+ //create data sheet
+ if(isDashboard) {
+
+ } else {
+
+ }
+ String reportSheetName = new HtmlStripper().stripSpecialCharacters(rr.getReportName());
+ if(nvl(reportSheetName).length()>28)
+ reportSheetName = reportSheetName.substring(0, 28);
+ sheet = wb.createSheet(reportSheetName);
+
+ //customized mode
+ if(!Globals.printExcelInLandscapeMode())
+ sheet.getPrintSetup().setLandscape(false);
+ else
+ sheet.getPrintSetup().setLandscape(true);
+ //get data sheet name
+ sheetRef = sheet.getPackagePart().getPartName().getName();
+ wb.write(os);
+ os.flush();
+ //wb = null;
+ }
+
+ } else {
+ try(FileOutputStream os = new FileOutputStream(AppUtils.getTempFolderPath()+ filename+"T."+ nvls(extension, "xlsx"));
+ FileInputStream readTemplate = new FileInputStream(org.onap.portalsdk.analytics.system.AppUtils.getExcelTemplatePath()+rr.getTemplateFile());){
+ wb=new XSSFWorkbook(readTemplate);
+ if (rr != null)
+ styles = loadXSSFStyles(rr, wb, styles);
+ sheet = wb.getSheetAt(0);
+ if(!Globals.printExcelInLandscapeMode())
+ sheet.getPrintSetup().setLandscape(false);
+ else
+ sheet.getPrintSetup().setLandscape(true);
+ //sheet = wb.getSheet(getSheetName());
+ sheetRef = sheet.getPackagePart().getPartName().getName();
+ wb.write(os);
+ os.flush();
+ //wb = null;
+ }
+ }
+
+ //Step 2. Generate XML file.
+ File tmp = File.createTempFile("sheet", ".xml");
+ try(FileOutputStream fileOutTemp = new FileOutputStream(tmp);
+ Writer fw = new OutputStreamWriter(fileOutTemp, XML_ENCODING)){
+
+ //String sql_whole = (String) request.getAttribute(AppConstants.RI_REPORT_SQL_WHOLE);
+ String sql_whole = "";
+ sql_whole = (String) request.getAttribute(AppConstants.RI_REPORT_SQL_WHOLE);
+
+ if(sql_whole==null) {
+ if (!rr.getReportType().equals(AppConstants.RT_HIVE))
+ sql_whole = rr.getWholeSQL();
+ else
+ sql_whole = rr.getReportSQL();
+ }
+
+ SpreadsheetWriter sw = new SpreadsheetWriter(fw);
+
+ sw.beginSheet();
+
+ if((rd.getDataRowCount() >= rr.getReportDataSize()) && !rr.getReportType().equals(AppConstants.RT_HIVE)) {
+ sql_whole="";
+ }
+
+ generate(wb, sw, styles, rd, sql_whole, rr, request, sheet);
+
+ sw.endSheet();
+
+ fw.flush();
+ fileOutTemp.flush();
}
- zos.flush();
- }
+ //Step 3. Substitute the template entry with the generated data
+
+ try(FileOutputStream outF = new FileOutputStream(AppUtils.getTempFolderPath()+ filename+"."+ nvls(extension, "xlsx"))){
+
+ if(nvl(rr.getTemplateFile()).length()>0) {
+ templateFile = new File(AppUtils.getTempFolderPath()+ filename+"T."+ nvls(extension, "xlsx"));
+ } else {
+ templateFile = new File(AppUtils.getTempFolderPath()+"template"+formattedDate+user_id+".xlsx");
+ }
+ substitute(templateFile, tmp, sheetRef.substring(1), outF);
+ outF.flush();
+ }
+
+ }
+ //get servlet output stream
+
+
+ response.reset();
+ try(BufferedInputStream buf = new BufferedInputStream(new FileInputStream(AppUtils.getTempFolderPath()+filename + "."+ nvls(extension, "xlsx")));
+ ServletOutputStream sos = response.getOutputStream()){
+
+ String mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
+ if(extension.equals("xlsm"))
+ mime_type = "application/vnd.ms-excel.sheet.macroEnabled.12";
+ response.setContentType(mime_type);
+
+ response.setHeader("Content-disposition", "attachment;filename="+filename+"."+ nvls(extension, "xlsx"));
+
+
+ int readBytes = 0;
+
+ //read from the file; write to the ServletOutputStream
+ while ((readBytes = buf.read()) != -1)
+ sos.write(readBytes);
+
+
+ sos.flush();
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger, ("ENDING..DOWNLOADING XLSX..."));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("##### Heap utilization statistics [MB] #####"));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Used Memory:"
+ + (runtime.totalMemory() - runtime.freeMemory()) / mb));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Free Memory:"
+ + runtime.freeMemory() / mb));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Total Memory:" + runtime.totalMemory() / mb));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Max Memory:" + runtime.maxMemory() / mb));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("##### END #####"));
}
- private static void copyStream(InputStream in, OutputStream out) throws IOException {
- byte[] chunk = new byte[1024];
- int count;
- while ((count = in.read(chunk)) >= 0) {
- out.write(chunk, 0, count);
- }
- }
+ /**
+ *
+ * @param zipfile the template file
+ * @param tmpfile the XML file with the sheet data
+ * @param entry the name of the sheet entry to substitute, e.g. xl/worksheets/sheet1.xml
+ * @param out the stream to write the result to
+ */
+ private static void substitute(File zipfile, File tmpfile, String entry, OutputStream out) throws IOException {
+ try(ZipFile zip = new ZipFile(zipfile);
+ ZipOutputStream zos = new ZipOutputStream(out)){
+
+
+
+ @SuppressWarnings("unchecked")
+ Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries();
+ while (en.hasMoreElements()) {
+ ZipEntry ze = en.nextElement();
+ if(!ze.getName().equals(entry)){
+ zos.putNextEntry(new ZipEntry(ze.getName()));
+ try(InputStream is = zip.getInputStream(ze)){
+ copyStream(is, zos);
+ }
+ }
+ }
+ zos.putNextEntry(new ZipEntry(entry));
+ try(InputStream is = new FileInputStream(tmpfile)){
+ copyStream(is, zos);
+ }
+ zos.flush();
+ }
+ }
+
+ private static void copyStream(InputStream in, OutputStream out) throws IOException {
+ byte[] chunk = new byte[1024];
+ int count;
+ while ((count = in.read(chunk)) >=0 ) {
+ out.write(chunk,0,count);
+ }
+ }
+
public void createCSVFileContent(final Writer out, final ReportData rd, final ReportRuntime rr,
- final HttpServletRequest request, final HttpServletResponse response) throws RaptorException {
+ final HttpServletRequest request, final HttpServletResponse response) throws RaptorException {
final String formattedReportName = new HtmlStripper().stripSpecialCharacters(rr.getReportName());
final String formattedDate = new SimpleDateFormat("MMddyyyyHHmm").format(new Date());
@@ -3489,13 +3565,13 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
final int mb = 1024 * 1024;
try (final PrintWriter csvOut =
- new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "UTF-8")),
- false);) {
+ new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "UTF-8")),
+ false);) {
final HtmlStripper strip = new HtmlStripper();
ColumnHeaderRow chr = null;
if (!raw) {
final String reportTitle = (nvl(rr.getReportTitle()).length() > 0 ? rr.getReportTitle()
- : rr.getReportName());
+ : rr.getReportName());
csvOut.println();
csvOut.print("\"" + reportTitle + "\",");
csvOut.println();
@@ -3517,12 +3593,12 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
paramsList = (ArrayList) request.getSession().getAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO);
}
int paramSeq = 0;
- for (final Iterator iter = paramsList.iterator(); iter.hasNext();) {
+ for (final Iterator iter = paramsList.iterator(); iter.hasNext(); ) {
final IdNameValue value = (IdNameValue) iter.next();
if (nvl(value.getId()).trim().length() > 0 && (!"BLANK".equals(nvl(value.getId()).trim()))) {
paramSeq += 1;
if (paramSeq <= 1) {
- csvOut.print("\"" + RUNTIME_PARAMETERS + "\"");
+ csvOut.print("\"" + "Run-time Parameters" + "\"");
csvOut.println();
}
csvOut.print("\"" + value.getId() + ":" + "\",");
@@ -3532,15 +3608,14 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
} else {
if (valueName.startsWith("(") && valueName.endsWith(")")) {
csvOut.print(
- "\"" + valueName.replaceAll("~", ",").substring(1, valueName.length() - 1)
- + "\",");
+ "\"" + valueName.replaceAll("~", ",").substring(1, valueName.length() - 1) + "\",");
} else {
csvOut.print("\"" + valueName.replaceAll("~", ",") + "\",");
}
}
csvOut.println();
}
- } // for
+ } //for
csvOut.println();
csvOut.println();
}
@@ -3563,8 +3638,8 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
if (nvl(sql_whole).length() > 0) {
try (final Connection conn = ConnectionUtils.getConnection(rr.getDbInfo());
- final Statement st = conn.createStatement();
- final ResultSet rs = st.executeQuery(sql_whole)) {
+ final Statement st = conn.createStatement();
+ final ResultSet rs = st.executeQuery(sql_whole)) {
System.out.println("************* Map Whole SQL *************");
System.out.println(sql_whole);
@@ -3574,9 +3649,9 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
String title = "";
if (rd != null) {
- for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) {
+ for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext(); ) {
chr = rd.reportColumnHeaderRows.getNext();
- for (chr.resetNext(); chr.hasNext();) {
+ for (chr.resetNext(); chr.hasNext(); ) {
ColumnHeader ch = chr.getNext();
title = ch.getColumnTitle();
title = Utils.replaceInString(title, "_nl_", " \n");
@@ -3597,16 +3672,15 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
for (int i = 1; i <= numberOfColumns; i++) {
colHash.put(rsmd.getColumnLabel(i).toUpperCase(), rs.getString(i));
}
- for (chr.resetNext(); chr.hasNext();) {
+ for (chr.resetNext(); chr.hasNext(); ) {
final ColumnHeader ch = chr.getNext();
title = ch.getColumnTitle();
title = Utils.replaceInString(title, "_nl_", " \n");
if (ch.isVisible() && nvl(title).length() > 0) {
csvOut.print(
- "\"" + strip
- .stripCSVHtml(
- nvl((String) colHash.get(ch.getColId().toUpperCase())))
+ "\"" + strip
+ .stripCSVHtml(nvl((String) colHash.get(ch.getColId().toUpperCase())))
+ "\",");
}
@@ -3615,12 +3689,12 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
}
if (rd.reportDataTotalRow != null) {
- for (rd.reportDataTotalRow.resetNext(); rd.reportDataTotalRow.hasNext();) {
+ for (rd.reportDataTotalRow.resetNext(); rd.reportDataTotalRow.hasNext(); ) {
final DataRow dr = rd.reportDataTotalRow.getNext();
csvOut.print("\"" + "Total" + "\",");
dr.resetNext();
dr.getNext();
- for (; dr.hasNext();) {
+ for (; dr.hasNext(); ) {
final DataValue dv = dr.getNext();
if (dv.isVisible()) {
csvOut.print("\"" + strip.stripCSVHtml(dv.getDisplayValue()) + "\",");
@@ -3663,9 +3737,9 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
csvOut.print("\"" + "#" + "\",");
}
- for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) {
+ for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext(); ) {
chr = rd.reportColumnHeaderRows.getNext();
- for (rd.reportRowHeaderCols.resetNext(1); rd.reportRowHeaderCols.hasNext();) {
+ for (rd.reportRowHeaderCols.resetNext(1); rd.reportRowHeaderCols.hasNext(); ) {
RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
if (firstPass) {
@@ -3675,7 +3749,7 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
} // for
firstPass = false;
- for (chr.resetNext(); chr.hasNext();) {
+ for (chr.resetNext(); chr.hasNext(); ) {
ColumnHeader ch = chr.getNext();
if (ch.isVisible()) {
csvOut.print("\"" + ch.getColumnTitle() + "\",");
@@ -3690,7 +3764,7 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
firstPass = true;
int rowCount = 0;
- for (rd.reportDataRows.resetNext(); rd.reportDataRows.hasNext();) {
+ for (rd.reportDataRows.resetNext(); rd.reportDataRows.hasNext(); ) {
if (rd.reportDataTotalRow != null) {
rowCount++;
csvOut.print("\"" + rowCount + "\",");
@@ -3698,7 +3772,7 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
final DataRow dr = rd.reportDataRows.getNext();
- for (rd.reportRowHeaderCols.resetNext(1); rd.reportRowHeaderCols.hasNext();) {
+ for (rd.reportRowHeaderCols.resetNext(1); rd.reportRowHeaderCols.hasNext(); ) {
final RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
if (firstPass) {
rhc.resetNext();
@@ -3709,7 +3783,7 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
} // for
firstPass = false;
- for (dr.resetNext(); dr.hasNext();) {
+ for (dr.resetNext(); dr.hasNext(); ) {
DataValue dv = dr.getNext();
if (dv.isVisible()) {
csvOut.print("\"" + strip.stripCSVHtml(dv.getDisplayValue()) + "\",");
@@ -3719,12 +3793,12 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
csvOut.println();
} // for
if (rd.reportDataTotalRow != null) {
- for (rd.reportDataTotalRow.resetNext(); rd.reportDataTotalRow.hasNext();) {
+ for (rd.reportDataTotalRow.resetNext(); rd.reportDataTotalRow.hasNext(); ) {
DataRow dr = rd.reportDataTotalRow.getNext();
csvOut.print("\"" + "Total" + "\",");
firstPass = false;
- for (dr.resetNext(); dr.hasNext();) {
+ for (dr.resetNext(); dr.hasNext(); ) {
DataValue dv = dr.getNext();
if (dv.isVisible()) {
csvOut.print("\"" + strip.stripCSVHtml(dv.getDisplayValue()) + "\",");
@@ -3758,8 +3832,8 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
if (!raw) {
try (final ZipOutputStream zos =
- new ZipOutputStream(new FileOutputStream(AppUtils.getTempFolderPath() + "" + zipFName));
- final FileInputStream fis = new FileInputStream(fileName)) {
+ new ZipOutputStream(new FileOutputStream(AppUtils.getTempFolderPath() + "" + zipFName));
+ final FileInputStream fis = new FileInputStream(fileName)) {
int size = 0;
final byte[] buffer = new byte[1024];
@@ -3793,11 +3867,11 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
}
try (final ServletOutputStream sos = response.getOutputStream();
- final FileInputStream fileIn = new FileInputStream(file);
- final BufferedInputStream buf = new BufferedInputStream(fileIn);) {
+ final FileInputStream fileIn = new FileInputStream(file);
+ final BufferedInputStream buf = new BufferedInputStream(fileIn);) {
final byte[] bOut = new byte[4096];
- // read from the file; write to the ServletOutputStream
+ //read from the file; write to the ServletOutputStream
int readBytes = 0;
while ((readBytes = buf.read(bOut, 0, 4096)) > 0) {
buf.available();
@@ -3823,349 +3897,336 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
} // createCSVFileContent
- public String saveXMLFile(HttpServletRequest request, String reportName, String reportXML) {
- try {
- String xmlFName = AppUtils.generateUniqueFileName(request, reportName, AppConstants.FT_XML);
-
- try (PrintWriter xmlOut = new PrintWriter(new BufferedWriter(new FileWriter(new File(
- AppUtils.getTempFolderPath() + xmlFName))))) {
- xmlOut.println(reportXML);
- }
-
- // return AppUtils.getTempFolderURL()
- // + java.net.URLEncoder.encode(java.net.URLDecoder.decode(xmlFName));
+ public String saveXMLFile(HttpServletRequest request, String reportName, String reportXML) {
+ try {
+ String xmlFName = AppUtils.generateUniqueFileName(request, reportName, AppConstants.FT_XML);
+
+ try(PrintWriter xmlOut = new PrintWriter(new BufferedWriter(new FileWriter(new File(
+ AppUtils.getTempFolderPath() + xmlFName))))){
+ xmlOut.println(reportXML);
+ }
+
+ //return AppUtils.getTempFolderURL()
+ // + java.net.URLEncoder.encode(java.net.URLDecoder.decode(xmlFName));
return java.net.URLEncoder.encode(java.net.URLDecoder.decode(xmlFName));
-
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "Exception in saveXMLFile", e);
- (new ErrorHandler()).processError(request,
- "Exception saving XML source to file system: " + e.getMessage());
- return null;
- }
- } // saveXMLFile
-
- public ReportRuntime loadReportRuntime(HttpServletRequest request, String reportID)
- throws RaptorException {
- return loadReportRuntime(request, reportID, true);
- } // loadReportRuntime
-
- public ReportRuntime loadReportRuntime(HttpServletRequest request, String reportID,
- boolean prepareForExecution) throws RaptorException {
- return loadReportRuntime(request, reportID, true, 2); // where 2 is adding to session
- }
-
- public ReportRuntime loadReportRuntime(HttpServletRequest request, String reportID,
- boolean prepareForExecution, int requestFlag) throws RaptorException {
+
+ } catch (Exception e) {
+ (new ErrorHandler()).processError(request,
+ "Exception saving XML source to file system: " + e.getMessage());
+ return null;
+ }
+ } // saveXMLFile
+
+ public ReportRuntime loadReportRuntime(HttpServletRequest request, String reportID)
+ throws RaptorException {
+ return loadReportRuntime(request, reportID, true);
+ } // loadReportRuntime
+
+ public ReportRuntime loadReportRuntime(HttpServletRequest request, String reportID,
+ boolean prepareForExecution) throws RaptorException {
+ return loadReportRuntime(request, reportID, true, 2); // where 2 is adding to session
+ }
+ public ReportRuntime loadReportRuntime(HttpServletRequest request, String reportID,
+ boolean prepareForExecution, int requestFlag) throws RaptorException {
boolean refresh = nvl(request.getParameter(AppConstants.RI_REFRESH)).toUpperCase().startsWith("Y");
- boolean rDisplayContent = AppUtils.getRequestFlag(request,
- AppConstants.RI_DISPLAY_CONTENT)
- || AppUtils.getRequestFlag(request, "noFormFields");
-
- ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(
- AppConstants.SI_REPORT_RUNTIME);
- boolean inSchedule = AppUtils.getRequestFlag(request, AppConstants.SCHEDULE_ACTION);
- if (rr != null) {
- if (requestFlag == 7) { // DASH
- String reportXML = ReportLoader.loadCustomReportXML(reportID);
- logger.debug(EELFLoggerDelegate.debugLogger,
- ("[DEBUG MESSAGE FROM RAPTOR] Report [" + reportID + "]: XML loaded"));
- rr = ReportRuntime.unmarshal(reportXML, reportID, request);
- rr.setParamValues(request, false, refresh);
- rr.setDisplayFlags(true, true); // show content even at the first time
- return rr;
- } else {
- logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] Load Report Runtime "
- + reportID + " " + rr.getReportID() + " " + request.getParameter("refresh")));
- if (reportID.equals(rr.getReportID())
- && (request.getParameter("refresh") == null || !request.getParameter("refresh").equals("Y"))) {
- // The report runtime is already in the session
- if (prepareForExecution) {
- boolean resetParams = AppUtils.getRequestFlag(request,
- AppConstants.RI_RESET_PARAMS);
- rr.setParamValues(request, resetParams, refresh);
-
- if (resetParams)
- rr.resetVisualSettings();
- rr.setDisplayFlags(nvl(request.getParameter(AppConstants.RI_SOURCE_PAGE))
- .length() == 0, rDisplayContent || rr.isDisplayOptionHideForm());
- } // if
-
- return rr;
- } // if
- }
+ boolean rDisplayContent = AppUtils.getRequestFlag(request,
+ AppConstants.RI_DISPLAY_CONTENT)
+ || AppUtils.getRequestFlag(request, "noFormFields");
+
+ ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(
+ AppConstants.SI_REPORT_RUNTIME);
+ boolean inSchedule = AppUtils.getRequestFlag(request, AppConstants.SCHEDULE_ACTION);
+ if (rr != null ) {
+ if(requestFlag == 7) { // DASH
+ String reportXML = ReportLoader.loadCustomReportXML(reportID);
+ logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] Report [" + reportID + "]: XML loaded"));
+ rr = ReportRuntime.unmarshal(reportXML, reportID, request);
+ rr.setParamValues(request, false,refresh);
+ rr.setDisplayFlags(true, true); // show content even at the first time
+ return rr;
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] Load Report Runtime "+ reportID + " " +rr.getReportID() + " " + request.getParameter("refresh") ));
+ if (reportID.equals(rr.getReportID()) && (request.getParameter("refresh")==null || !request.getParameter("refresh").equals("Y"))) {
+ // The report runtime is already in the session
+ if (prepareForExecution) {
+ boolean resetParams = AppUtils.getRequestFlag(request,
+ AppConstants.RI_RESET_PARAMS);
+ rr.setParamValues(request, resetParams,refresh);
+
+ if (resetParams)
+ rr.resetVisualSettings();
+ rr.setDisplayFlags(nvl(request.getParameter(AppConstants.RI_SOURCE_PAGE))
+ .length() == 0, rDisplayContent || rr.isDisplayOptionHideForm());
+ } // if
+
+ return rr;
+ } // if
+ }
}
- /*
- * Cannot convert the definition => XML file not saved for preview also, commented code not
- * maintained up to date ReportDefinition rdef = (ReportDefinition)
- * request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION); if(rdef!=null)
- * if(reportID.equals(rdef.getReportID())) { // The report definition is in the session => create
- * report runtime from it rr = new ReportRuntime(rdef, request); if(prepareForExecution) {
- * request.getSession().setAttribute(AppConstants.SI_REPORT_RUNTIME, rr);
- * rr.setDisplayFlags(request.getParameter(AppConstants.RI_SOURCE_PAGE)==null); } // if return rr; }
- * // if
- */
-
- // Report is NOT in the session => load from the database
- String reportXML = ReportLoader.loadCustomReportXML(reportID);
- logger.debug(EELFLoggerDelegate.debugLogger,
- ("[DEBUG MESSAGE FROM RAPTOR] Report [" + reportID + "]: XML loaded"));
-
- rr = ReportRuntime.unmarshal(reportXML, reportID, request);
- if (prepareForExecution) {
- String userID;
- int flag = 0;
- if (request.getAttribute("schedule_email_userId") != null) {
- userID = (String) request.getAttribute("schedule_email_userId");
- flag = 1;
- } else
- userID = AppUtils.getUserID(request);
- // If it is dashboard type then report can be viewed without specific privilege to report
- String dashboardId = AppUtils.getRequestValue(request, AppConstants.RI_DASHBOARD_ID);
- // System.out.println("USSSSSSSSSSSSERID " + userID);
- // System.out.println("PDF " + AppUtils.getRequestNvlValue(request, "pdfAttachmentKey") );
- if (!rr.isDashboardType() && !(isReportAddedAsDashboard(request, dashboardId, rr.getReportID()))) {
- if (AppUtils.getRequestNvlValue(request, "pdfAttachmentKey").length() <= 0)
- if (flag == 1)
- rr.checkUserReadAccess(request, userID);
- else
- rr.checkUserReadAccess(request);
+ /*
+ * Cannot convert the definition => XML file not saved for preview also,
+ * commented code not maintained up to date ReportDefinition rdef =
+ * (ReportDefinition)
+ * request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
+ * if(rdef!=null) if(reportID.equals(rdef.getReportID())) { // The
+ * report definition is in the session => create report runtime from it
+ * rr = new ReportRuntime(rdef, request); if(prepareForExecution) {
+ * request.getSession().setAttribute(AppConstants.SI_REPORT_RUNTIME,
+ * rr);
+ * rr.setDisplayFlags(request.getParameter(AppConstants.RI_SOURCE_PAGE)==null); } //
+ * if return rr; } // if
+ */
+
+ // Report is NOT in the session => load from the database
+ String reportXML = ReportLoader.loadCustomReportXML(reportID);
+ logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] Report [" + reportID + "]: XML loaded"));
+
+ rr = ReportRuntime.unmarshal(reportXML, reportID, request);
+ if (prepareForExecution) {
+ String userID ;
+ int flag = 0;
+ if(request.getAttribute("schedule_email_userId") != null) {
+ userID = (String)request.getAttribute("schedule_email_userId");
+ flag = 1;
+ }
+ else
+ userID = AppUtils.getUserID(request);
+ // If it is dashboard type then report can be viewed without specific privilege to report
+ String dashboardId = AppUtils.getRequestValue(request, AppConstants.RI_DASHBOARD_ID);
+ //System.out.println("USSSSSSSSSSSSERID " + userID);
+ //System.out.println("PDF " + AppUtils.getRequestNvlValue(request, "pdfAttachmentKey") );
+ if(!rr.isDashboardType() && !(isReportAddedAsDashboard(request, dashboardId, rr.getReportID()))) {
+ if ( AppUtils.getRequestNvlValue(request, "pdfAttachmentKey").length()<=0 )
+ if(flag == 1 )rr.checkUserReadAccess(request, userID);
+ else rr.checkUserReadAccess(request);
}
// TODO ON Demand
- // rr.setXmlFileName(saveXMLFile(request, rr.getReportName(), reportXML));
- if (rDisplayContent) {
- // System.out.println("In rDisplayContent ");
- rr.setParamValues(request, false, true);
- // if (requestFlag==2)
- request.getSession().setAttribute(AppConstants.SI_REPORT_RUNTIME, rr);
- }
- if (inSchedule) {
- // System.out.println("In inSchedule ");
- rr.setParamValues(request, false, false);
- }
- if (requestFlag == 7) { // DASH
- rr.setDisplayFlags(true, true);
- } else {
- rr.setDisplayFlags(request.getParameter(AppConstants.RI_SOURCE_PAGE) == null,
- rDisplayContent || rr.isDisplayOptionHideForm());
+ //rr.setXmlFileName(saveXMLFile(request, rr.getReportName(), reportXML));
+ if (rDisplayContent) {
+ //System.out.println("In rDisplayContent ");
+ rr.setParamValues(request, false,true);
+ //if (requestFlag==2)
+ request.getSession().setAttribute(AppConstants.SI_REPORT_RUNTIME, rr);
+ }
+ if(inSchedule) {
+ //System.out.println("In inSchedule ");
+ rr.setParamValues(request, false,false);
+ }
+ if( requestFlag == 7 ) { // DASH
+ rr.setDisplayFlags(true, true);
+ } else {
+ rr.setDisplayFlags(request.getParameter(AppConstants.RI_SOURCE_PAGE) == null,
+ rDisplayContent || rr.isDisplayOptionHideForm());
+ }
+// System.out.println("Report ID B4 Id in reportHandler "
+// + ( request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)!=null?((ReportRuntime)request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).getReportID():"Not in session"));
+// System.out.println("requestFlag " + requestFlag);
+ if(requestFlag==2 && !rDisplayContent) {
+ //System.out.println("In Request Flag ");
+ request.getSession().setAttribute(AppConstants.SI_REPORT_RUNTIME, rr);
+ rr.setParamValues(request, false, false);
}
- // System.out.println("Report ID B4 Id in reportHandler "
- // + (
- // request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)!=null?((ReportRuntime)request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).getReportID():"Not
- // in session"));
- // System.out.println("requestFlag " + requestFlag);
- if (requestFlag == 2 && !rDisplayContent) {
- // System.out.println("In Request Flag ");
- request.getSession().setAttribute(AppConstants.SI_REPORT_RUNTIME, rr);
- rr.setParamValues(request, false, false);
- } else if (requestFlag == 1) {
- rr.setParamValues(request, false, refresh);
- request.setAttribute(AppConstants.SI_REPORT_RUNTIME, rr);
-
- }
- // System.out.println("Report ID B4 Id in reportHandler "
- // + (
- // request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)!=null?((ReportRuntime)request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).getReportID():"Not
- // in session"));
- // request.setAttribute(AppConstants.SI_REPORT_RUNTIME, rr);
- } // if
-
- return rr;
- } // loadReportRuntime
-
- private boolean isReportAddedAsDashboard(HttpServletRequest request, String dashboardId, String reportId)
- throws RaptorException {
- if (nvl(dashboardId).length() <= 0)
- return false;
- String reportXML = ReportLoader.loadCustomReportXML(dashboardId);
- ReportDefinition rdef = createReportDefinition(request, dashboardId, reportXML);
- List l = rdef.getDashBoardReports().getReportsList();
+ else if(requestFlag==1) {
+ rr.setParamValues(request, false,refresh);
+ request.setAttribute(AppConstants.SI_REPORT_RUNTIME, rr);
+
+ }
+// System.out.println("Report ID B4 Id in reportHandler "
+// + ( request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)!=null?((ReportRuntime)request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).getReportID():"Not in session"));
+ //request.setAttribute(AppConstants.SI_REPORT_RUNTIME, rr);
+ } // if
+
+ return rr;
+ } // loadReportRuntime
+
+ private boolean isReportAddedAsDashboard(HttpServletRequest request, String dashboardId, String reportId)throws RaptorException {
+ if(nvl(dashboardId).length() <= 0)
+ return false;
+ String reportXML = ReportLoader.loadCustomReportXML(dashboardId);
+ ReportDefinition rdef = createReportDefinition(request, dashboardId, reportXML);
+ List l = rdef.getDashBoardReports().getReportsList();
for (Iterator iterator = l.iterator(); iterator.hasNext();) {
- Reports reports = (Reports) iterator.next();
- if (reports.getReportId().equals(reportId))
- return true;
-
- }
- return false;
+ Reports reports = (Reports) iterator.next();
+ if(reports.getReportId().equals(reportId)) return true;
+
+ }
+ return false;
+ }
+
+ public ReportDefinition createReportDefinition(HttpServletRequest request,
+ String reportID, String reportXML) throws RaptorException {
+ ReportDefinition rdef = ReportDefinition.unmarshal(reportXML, reportID, request);
+ rdef.generateWizardSequence(request);
+ return rdef;
+ } // createReportDefinition
+
+ public ReportDefinition loadReportDefinition(HttpServletRequest request, String reportID)
+ throws RaptorException {
+ //System.out.println("********* ReportID " + reportID);
+ boolean isReportIDBlank = (reportID.length() == 0 || reportID.equals("-1"));
+ String actionKey = nvl(request.getParameter(AppConstants.RI_ACTION), "");
+ String wizardActionKey = nvl(request.getParameter(AppConstants.RI_WIZARD_ACTION), "");
+ ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(
+ AppConstants.SI_REPORT_DEFINITION);
+ if(nvl(actionKey).equals("report.edit"))
+ rdef = null;
+ //ReportDefinition rdef = null;
+ if (rdef != null)
+ if (isReportIDBlank || reportID.equals(rdef.getReportID())) {
+ // The report definition is already in the session
+ return rdef;
+ }
+
+ ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(
+ AppConstants.SI_REPORT_RUNTIME);
+ if (rr != null)
+ if (isReportIDBlank || reportID.equals(rr.getReportID())) {
+ // The report runtime is in the session => create report
+ // definition from it
+ rdef = new ReportDefinition(rr, request);
+ String userID = AppUtils.getUserID(request);
+ rdef.generateWizardSequence(request);
+ // rdef.checkUserWriteAccess(userID);
+
+ request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
+ return rdef;
+ } // if
+
+ // Report is NOT in the session => load from the database
+ if (isReportIDBlank)
+ rdef = ReportDefinition.createBlank(request);
+ else {
+ String reportXML = ReportLoader.loadCustomReportXML(reportID);
+ logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] Report [" + reportID + "]: XML loaded"));
+ rdef = createReportDefinition(request, reportID, reportXML);
+ } // else
+
+ request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
+ return rdef;
+ } // loadReportDefinition
+
+ public void setSheetName( String sheet_name ) {
+ SHEET_NAME = sheet_name;
}
-
- public ReportDefinition createReportDefinition(HttpServletRequest request,
- String reportID, String reportXML) throws RaptorException {
- ReportDefinition rdef = ReportDefinition.unmarshal(reportXML, reportID, request);
- rdef.generateWizardSequence(request);
- return rdef;
- } // createReportDefinition
-
- public ReportDefinition loadReportDefinition(HttpServletRequest request, String reportID)
- throws RaptorException {
- // System.out.println("********* ReportID " + reportID);
- boolean isReportIDBlank = (reportID.length() == 0 || reportID.equals("-1"));
- String actionKey = nvl(request.getParameter(AppConstants.RI_ACTION), "");
- String wizardActionKey = nvl(request.getParameter(AppConstants.RI_WIZARD_ACTION), "");
- ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(
- AppConstants.SI_REPORT_DEFINITION);
- if (nvl(actionKey).equals("report.edit"))
- rdef = null;
- // ReportDefinition rdef = null;
- if (rdef != null)
- if (isReportIDBlank || reportID.equals(rdef.getReportID())) {
- // The report definition is already in the session
- return rdef;
- }
-
- ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(
- AppConstants.SI_REPORT_RUNTIME);
- if (rr != null)
- if (isReportIDBlank || reportID.equals(rr.getReportID())) {
- // The report runtime is in the session => create report
- // definition from it
- rdef = new ReportDefinition(rr, request);
- String userID = AppUtils.getUserID(request);
- rdef.generateWizardSequence(request);
- // rdef.checkUserWriteAccess(userID);
-
- request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
- return rdef;
- } // if
-
- // Report is NOT in the session => load from the database
- if (isReportIDBlank)
- rdef = ReportDefinition.createBlank(request);
- else {
- String reportXML = ReportLoader.loadCustomReportXML(reportID);
- logger.debug(EELFLoggerDelegate.debugLogger,
- ("[DEBUG MESSAGE FROM RAPTOR] Report [" + reportID + "]: XML loaded"));
- rdef = createReportDefinition(request, reportID, reportXML);
- } // else
-
- request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
- return rdef;
- } // loadReportDefinition
-
- public void setSheetName(String sheet_name) {
- sheetName = sheet_name;
- }
-
+
public String getSheetName() {
- return sheetName;
+ return SHEET_NAME;
}
- /**
- * Writes spreadsheet data in a Writer. (YK: in future it may evolve in a full-featured API for
- * streaming data in Excel)
- */
- public static class SpreadsheetWriter {
- private final Writer _out;
- private int _rownum;
-
- public SpreadsheetWriter(Writer out) {
- _out = out;
- }
-
- public void beginSheet() throws IOException {
- _out.write("<?xml version=\"1.0\" encoding=\"" + XML_ENCODING + "\"?>" +
- "<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">");
- _out.write("<sheetData>\n");
- }
-
- public void endSheet() throws IOException {
- _out.write("</sheetData>");
- _out.write("</worksheet>");
- }
-
- /**
- * Insert a new row
- *
- * @param rownum 0-based row number
- */
- public void insertRow(int rownum) throws IOException {
- _out.write("<row r=\"" + (rownum + 1) + "\">\n");
- this._rownum = rownum;
- }
-
- /**
- * Insert row end marker
- */
- public void endRow() throws IOException {
- _out.write("</row>\n");
- }
-
- public void createCell(int columnIndex, String value, int styleIndex) throws IOException {
- String ref = new CellReference(_rownum, columnIndex).formatAsString();
- _out.write("<c r=\"" + ref + "\" t=\"inlineStr\"");
- if (styleIndex != -1)
- _out.write(" s=\"" + styleIndex + "\"");
- _out.write(">");
- _out.write("<is><t>" + value + "</t></is>");
- _out.write("</c>");
- }
-
- public void createCell(int columnIndex, String value) throws IOException {
- createCell(columnIndex, value, -1);
- }
-
- public void createCell(int columnIndex, double value, int styleIndex) throws IOException {
- String ref = new CellReference(_rownum, columnIndex).formatAsString();
- _out.write("<c r=\"" + ref + "\" t=\"n\"");
- if (styleIndex != -1)
- _out.write(" s=\"" + styleIndex + "\"");
- _out.write(">");
- _out.write("<v>" + value + "</v>");
- _out.write("</c>");
- }
-
- public void createCell(int columnIndex, double value) throws IOException {
- createCell(columnIndex, value, -1);
- }
-
- public void createCell(int columnIndex, Calendar value, int styleIndex) throws IOException {
- createCell(columnIndex, DateUtil.getExcelDate(value, false), styleIndex);
- }
- }
-
- public int getColumnCountForDownloadFile(ReportRuntime rr, ReportData rd) {
- int columnCount = 0;
- for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) {
- ColumnHeaderRow chr = rd.reportColumnHeaderRows.getNext();
- for (chr.resetNext(); chr.hasNext();) {
- ColumnHeader ch = chr.getNext();
- if (ch.isVisible()) {
- columnCount++;
- }
- }
- }
- if (rr.getReportType().equals(AppConstants.RT_CROSSTAB)) {
- for (rd.reportRowHeaderCols.resetNext(); rd.reportRowHeaderCols.hasNext();) {
- RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
- if (rhc.isVisible()) {
- columnCount++;
- }
- }
- }
- return columnCount;
- }
-
- private Map<String, XSSFCellStyle> loadXSSFStyles(ReportRuntime rr, XSSFWorkbook wb,
- Map<String, XSSFCellStyle> loadedStyles) {
- XSSFCellStyle styleDefault = wb.createCellStyle();
- // System.out.println("Load Styles");
- // Style default will be normal with no background
- XSSFFont fontDefault = wb.createFont();
-
- XSSFDataFormat xssffmt = wb.createDataFormat();
- // The default will be plain .
- fontDefault.setColor((short) HSSFFont.COLOR_NORMAL);
- fontDefault.setFontHeight((short) (FONT_SIZE / 0.05));
- fontDefault.setFontName(FONT_TAHOMA);
-
- styleDefault.setAlignment(XSSFCellStyle.ALIGN_CENTER);
- styleDefault.setBorderBottom(XSSFCellStyle.BORDER_THIN);
- styleDefault.setBorderTop(XSSFCellStyle.BORDER_THIN);
- styleDefault.setBorderLeft(XSSFCellStyle.BORDER_THIN);
- styleDefault.setBorderRight(XSSFCellStyle.BORDER_THIN);
- // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleDefault.setFillPattern(XSSFCellStyle.NO_FILL);
- styleDefault.setFont(fontDefault);
+ /**
+ * Writes spreadsheet data in a Writer.
+ * (YK: in future it may evolve in a full-featured API for streaming data in Excel)
+ */
+ public static class SpreadsheetWriter {
+ private final Writer _out;
+ private int _rownum;
+
+ public SpreadsheetWriter(Writer out){
+ _out = out;
+ }
+
+ public void beginSheet() throws IOException {
+ _out.write("<?xml version=\"1.0\" encoding=\""+XML_ENCODING+"\"?>" +
+ "<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">" );
+ _out.write("<sheetData>\n");
+ }
+
+ public void endSheet() throws IOException {
+ _out.write("</sheetData>");
+ _out.write("</worksheet>");
+ }
+
+ /**
+ * Insert a new row
+ *
+ * @param rownum 0-based row number
+ */
+ public void insertRow(int rownum) throws IOException {
+ _out.write("<row r=\""+(rownum+1)+"\">\n");
+ this._rownum = rownum;
+ }
+
+ /**
+ * Insert row end marker
+ */
+ public void endRow() throws IOException {
+ _out.write("</row>\n");
+ }
+
+ public void createCell(int columnIndex, String value, int styleIndex) throws IOException {
+ String ref = new CellReference(_rownum, columnIndex).formatAsString();
+ _out.write("<c r=\""+ref+"\" t=\"inlineStr\"");
+ if(styleIndex != -1) _out.write(" s=\""+styleIndex+"\"");
+ _out.write(">");
+ _out.write("<is><t>"+value+"</t></is>");
+ _out.write("</c>");
+ }
+
+ public void createCell(int columnIndex, String value) throws IOException {
+ createCell(columnIndex, value, -1);
+ }
+
+ public void createCell(int columnIndex, double value, int styleIndex) throws IOException {
+ String ref = new CellReference(_rownum, columnIndex).formatAsString();
+ _out.write("<c r=\""+ref+"\" t=\"n\"");
+ if(styleIndex != -1) _out.write(" s=\""+styleIndex+"\"");
+ _out.write(">");
+ _out.write("<v>"+value+"</v>");
+ _out.write("</c>");
+ }
+
+ public void createCell(int columnIndex, double value) throws IOException {
+ createCell(columnIndex, value, -1);
+ }
+
+ public void createCell(int columnIndex, Calendar value, int styleIndex) throws IOException {
+ createCell(columnIndex, DateUtil.getExcelDate(value, false), styleIndex);
+ }
+ }
+
+ public int getColumnCountForDownloadFile(ReportRuntime rr, ReportData rd) {
+ int columnCount = 0;
+ for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) {
+ ColumnHeaderRow chr = rd.reportColumnHeaderRows.getNext();
+ for(chr.resetNext(); chr.hasNext(); ) {
+ ColumnHeader ch = chr.getNext();
+ if(ch.isVisible()) {
+ columnCount++;
+ }
+ }
+ }
+ if(rr.getReportType().equals(AppConstants.RT_CROSSTAB)) {
+ for (rd.reportRowHeaderCols.resetNext(); rd.reportRowHeaderCols.hasNext();) {
+ RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
+ if(rhc.isVisible()) {
+ columnCount++;
+ }
+ }
+ }
+ return columnCount;
+ }
+
+ private Map<String, XSSFCellStyle> loadXSSFStyles(ReportRuntime rr, XSSFWorkbook wb, Map<String, XSSFCellStyle> loadedStyles) {
+ XSSFCellStyle styleDefault = wb.createCellStyle();
+ //System.out.println("Load Styles");
+ // Style default will be normal with no background
+ XSSFFont fontDefault = wb.createFont();
+
+ XSSFDataFormat xssffmt = wb.createDataFormat();
+ // The default will be plain .
+ fontDefault.setColor((short) HSSFFont.COLOR_NORMAL);
+ fontDefault.setFontHeight((short) (font_size / 0.05));
+ fontDefault.setFontName("Tahoma");
+
+ styleDefault.setAlignment(HorizontalAlignment.CENTER);
+ styleDefault.setBorderBottom(BorderStyle.THIN);
+ styleDefault.setBorderTop(BorderStyle.THIN);
+ styleDefault.setBorderLeft(BorderStyle.THIN);
+ styleDefault.setBorderRight(BorderStyle.THIN);
+ // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
+ styleDefault.setFillPattern(FillPatternType.NO_FILL);
+ styleDefault.setFont(fontDefault);
ArrayList semColumnList = new ArrayList();
List dsList = rr.getDataSourceList().getDataSource();
for (Iterator iter = dsList.iterator(); iter.hasNext();) {
@@ -4174,271 +4235,303 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
for (Iterator iterator = dcList.iterator(); iterator.hasNext();) {
DataColumnType element1 = (DataColumnType) iterator.next();
semColumnList.add(element1.getSemaphoreId());
-
+
}
}
- SemaphoreList semList = rr.getSemaphoreList();
- Map<String, XSSFCellStyle> hashMapStyles = new HashMap<String, XSSFCellStyle>();;
- Map<String, XSSFFont> hashMapFonts = new HashMap<String, XSSFFont>();
- hashMapFonts.put(DEFAULT, fontDefault);
- hashMapStyles.put(DEFAULT, styleDefault);
- XSSFCellStyle styleLeftDefault = wb.createCellStyle();
- styleLeftDefault.setAlignment(XSSFCellStyle.ALIGN_LEFT);
- styleLeftDefault.setBorderBottom(XSSFCellStyle.BORDER_THIN);
- styleLeftDefault.setBorderTop(XSSFCellStyle.BORDER_THIN);
- styleLeftDefault.setBorderLeft(XSSFCellStyle.BORDER_THIN);
- styleLeftDefault.setBorderRight(XSSFCellStyle.BORDER_THIN);
- // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleLeftDefault.setFillPattern(XSSFCellStyle.NO_FILL);
- styleLeftDefault.setFont(fontDefault);
- hashMapStyles.put("defaultLeft", styleLeftDefault);
-
+ SemaphoreList semList = rr.getSemaphoreList();
+ Map<String, XSSFCellStyle> hashMapStyles = new HashMap<String, XSSFCellStyle>();;
+ Map<String, XSSFFont> hashMapFonts = new HashMap<String, XSSFFont>();
+ hashMapFonts.put("default", fontDefault);
+ hashMapStyles.put("default", styleDefault);
+ XSSFCellStyle styleLeftDefault = wb.createCellStyle();
+ styleLeftDefault.setAlignment(HorizontalAlignment.LEFT);
+ styleLeftDefault.setBorderBottom(BorderStyle.THIN);
+ styleLeftDefault.setBorderTop(BorderStyle.THIN);
+ styleLeftDefault.setBorderLeft(BorderStyle.THIN);
+ styleLeftDefault.setBorderRight(BorderStyle.THIN);
+ // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
+ styleLeftDefault.setFillPattern(FillPatternType.NO_FILL);
+ styleLeftDefault.setFont(fontDefault);
+ hashMapStyles.put("defaultLeft", styleLeftDefault);
+
+
XSSFCellStyle styleDate = wb.createCellStyle();
- styleDate.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
+ styleDate.setAlignment(HorizontalAlignment.RIGHT);
styleDate.setDataFormat(xssffmt.getFormat("d-mmm-yy"));
- styleDate.setAlignment(XSSFCellStyle.ALIGN_CENTER);
- styleDate.setBorderBottom(XSSFCellStyle.BORDER_THIN);
- styleDate.setBorderTop(XSSFCellStyle.BORDER_THIN);
- styleDate.setBorderLeft(XSSFCellStyle.BORDER_THIN);
- styleDate.setBorderRight(XSSFCellStyle.BORDER_THIN);
- // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleDate.setFillPattern(XSSFCellStyle.NO_FILL);
+ styleDate.setAlignment(HorizontalAlignment.CENTER);
+ styleDate.setBorderBottom(BorderStyle.THIN);
+ styleDate.setBorderTop(BorderStyle.THIN);
+ styleDate.setBorderLeft(BorderStyle.THIN);
+ styleDate.setBorderRight(BorderStyle.THIN);
+ // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
+ styleDate.setFillPattern(FillPatternType.NO_FILL);
styleDate.setFont(fontDefault);
hashMapStyles.put("date", styleDate);
-
- XSSFCellStyle rowHeaderStyle = wb.createCellStyle();
- XSSFFont headerFont = wb.createFont();
- headerFont.setBold(true);
- rowHeaderStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
- rowHeaderStyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
- rowHeaderStyle.setFont(headerFont);
- rowHeaderStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);
- rowHeaderStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
- rowHeaderStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
- rowHeaderStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);
- hashMapStyles.put("header", rowHeaderStyle);
-
- XSSFCellStyle boldStyle = wb.createCellStyle();
- // headerFont = wb.createFont();
- // headerFont.setBold(true);
- boldStyle.setFont(headerFont);
- boldStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);
- boldStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
- boldStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
- boldStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);
- boldStyle.setAlignment(HorizontalAlignment.CENTER);
- hashMapStyles.put("title", boldStyle);
-
- XSSFCellStyle cellStyle = null;
- if (semList == null || semList.getSemaphore() == null) {
- hashMapStyles.put(DEFAULT, styleDefault);
- } /*
- * else { for (Iterator iter = semList.getSemaphore().iterator(); iter.hasNext();) { SemaphoreType
- * sem = (SemaphoreType) iter.next(); if(!semColumnList.contains(sem.getSemaphoreId())) continue;
- * //System.out.println("SemphoreId ----> " + sem.getSemaphoreId()); FormatList fList =
- * sem.getFormatList(); List formatList = fList.getFormat(); for (Iterator fIter =
- * formatList.iterator(); fIter.hasNext();) { FormatType fmt = (FormatType) fIter.next();
- * if(fmt!=null){ //if (fmt.getLessThanValue().length() > 0) { cellStyle = wb.createCellStyle();
- * XSSFFont cellFont = wb.createFont(); //System.out.println("Format Id " + fmt.getFormatId()); if
- * (nvl(fmt.getBgColor()).length() > 0) { // System.out.println("Load Styles " + //
- * fmt.getFormatId() // + " " +fmt.getBgColor() + " " + //
- * ExcelColorDef.getExcelColor(fmt.getBgColor()));
- * cellStyle.setFillForegroundColor(ExcelColorDef.getExcelColor(fmt .getBgColor()));
- * cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); } if (nvl(fmt.getFontColor()).length()
- * > 0) { cellFont.setColor(ExcelColorDef.getExcelColor(fmt.getFontColor())); } else
- * cellFont.setColor((short) HSSFFont.COLOR_NORMAL); if (fmt.isBold())
- * cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); if (fmt.isItalic()) cellFont.setItalic(true);
- * if (fmt.isUnderline()) cellFont.setUnderline(HSSFFont.U_SINGLE);
- * if(nvl(fmt.getFontFace()).length()>0) cellFont.setFontName(fmt.getFontFace()); else
- * cellFont.setFontName(FONT_TAHOMA); //cellFont.setFontHeight((short) (10 / 0.05));
- *
- * if(nvl(fmt.getFontSize()).length()>0) { try { cellFont.setFontHeight((short)
- * (Integer.parseInt(fmt.getFontSize()) / 0.05)); } catch(NumberFormatException e){
- * cellFont.setFontHeight((short) (font_size / 0.05)); } } else cellFont.setFontHeight((short)
- * (font_size / 0.05)); cellStyle.setFont(cellFont);
- * cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- * cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- * cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
- * cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- * cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); hashMapStyles.put(fmt.getFormatId(),
- * cellStyle); } else { //hashMapStyles.put(fmt.getFormatId(), styleDefault);
- * hashMapStyles.put(DEFAULT, styleDefault); } }
- *
- * } }
- */
- loadedStyles.putAll(hashMapStyles);
- return loadedStyles;
- }
-
- private void generate(XSSFWorkbook wb, SpreadsheetWriter sw, Map<String, XSSFCellStyle> styles, ReportData rd,
- String sql_whole, ReportRuntime rr, HttpServletRequest request, XSSFSheet sheet) throws Exception {
+
+ XSSFCellStyle rowHeaderStyle = wb.createCellStyle();
+ XSSFFont headerFont = wb.createFont();
+ headerFont.setBold(true);
+ rowHeaderStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+ rowHeaderStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+ rowHeaderStyle.setFont(headerFont);
+ rowHeaderStyle.setBorderTop(BorderStyle.THIN);
+ rowHeaderStyle.setBorderLeft(BorderStyle.THIN);
+ rowHeaderStyle.setBorderBottom(BorderStyle.THIN);
+ rowHeaderStyle.setBorderRight(BorderStyle.THIN);
+ hashMapStyles.put("header", rowHeaderStyle);
+
+
+ XSSFCellStyle boldStyle = wb.createCellStyle();
+ //headerFont = wb.createFont();
+ //headerFont.setBold(true);
+ boldStyle.setFont(headerFont);
+ boldStyle.setBorderTop(BorderStyle.THIN);
+ boldStyle.setBorderLeft(BorderStyle.THIN);
+ boldStyle.setBorderBottom(BorderStyle.THIN);
+ boldStyle.setBorderRight(BorderStyle.THIN);
+ boldStyle.setAlignment(HorizontalAlignment.CENTER);
+ hashMapStyles.put("title", boldStyle);
+
+ XSSFCellStyle cellStyle = null;
+ if (semList == null || semList.getSemaphore() == null) {
+ hashMapStyles.put("default", styleDefault);
+ } /*else {
+ for (Iterator iter = semList.getSemaphore().iterator(); iter.hasNext();) {
+ SemaphoreType sem = (SemaphoreType) iter.next();
+ if(!semColumnList.contains(sem.getSemaphoreId())) continue;
+ //System.out.println("SemphoreId ----> " + sem.getSemaphoreId());
+ FormatList fList = sem.getFormatList();
+ List formatList = fList.getFormat();
+ for (Iterator fIter = formatList.iterator(); fIter.hasNext();) {
+ FormatType fmt = (FormatType) fIter.next();
+ if(fmt!=null){
+ //if (fmt.getLessThanValue().length() > 0) {
+ cellStyle = wb.createCellStyle();
+ XSSFFont cellFont = wb.createFont();
+ //System.out.println("Format Id " + fmt.getFormatId());
+ if (nvl(fmt.getBgColor()).length() > 0) {
+// System.out.println("Load Styles " +
+// fmt.getFormatId()
+// + " " +fmt.getBgColor() + " " +
+// ExcelColorDef.getExcelColor(fmt.getBgColor()));
+ cellStyle.setFillForegroundColor(ExcelColorDef.getExcelColor(fmt
+ .getBgColor()));
+ cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND );
+ }
+ if (nvl(fmt.getFontColor()).length() > 0) {
+ cellFont.setColor(ExcelColorDef.getExcelColor(fmt.getFontColor()));
+ } else
+ cellFont.setColor((short) HSSFFont.COLOR_NORMAL);
+ if (fmt.isBold())
+ cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+ if (fmt.isItalic())
+ cellFont.setItalic(true);
+ if (fmt.isUnderline())
+ cellFont.setUnderline(HSSFFont.U_SINGLE);
+ if(nvl(fmt.getFontFace()).length()>0)
+ cellFont.setFontName(fmt.getFontFace());
+ else
+ cellFont.setFontName("Tahoma");
+ //cellFont.setFontHeight((short) (10 / 0.05));
+
+ if(nvl(fmt.getFontSize()).length()>0) {
+ try {
+ cellFont.setFontHeight((short) (Integer.parseInt(fmt.getFontSize()) / 0.05));
+ } catch(NumberFormatException e){
+ cellFont.setFontHeight((short) (font_size / 0.05));
+ }
+ }
+ else
+ cellFont.setFontHeight((short) (font_size / 0.05));
+ cellStyle.setFont(cellFont);
+ cellStyle.setAlignment(HorizontalAlignment.CENTER);
+ cellStyle.setBorderBottom(BorderStyle.THIN);
+ cellStyle.setBorderTop(BorderStyle.THIN);
+ cellStyle.setBorderLeft(BorderStyle.THIN);
+ cellStyle.setBorderRight(BorderStyle.THIN);
+ hashMapStyles.put(fmt.getFormatId(), cellStyle);
+ } else {
+ //hashMapStyles.put(fmt.getFormatId(), styleDefault);
+ hashMapStyles.put("default", styleDefault);
+ }
+ }
+
+ }
+ }*/
+ loadedStyles.putAll(hashMapStyles);
+ return loadedStyles;
+ }
+
+ private void generate(XSSFWorkbook wb, SpreadsheetWriter sw, Map<String, XSSFCellStyle> styles, ReportData rd, String sql_whole, ReportRuntime rr, HttpServletRequest request, XSSFSheet sheet) throws Exception {
HtmlStripper strip = new HtmlStripper();
XSSFCellStyle styleCell = null;
XSSFCellStyle styleRowCell = null;
XSSFCellStyle styleDefaultCell = null;
-
- styleDefaultCell = (XSSFCellStyle) styles.get(DEFAULT);
-
+
+ styleDefaultCell = (XSSFCellStyle) styles.get("default");
+
+
// to check performance
- int mb = 1024 * 1024;
- Runtime runtime = Runtime.getRuntime();
-
+ int mb = 1024*1024;
+ Runtime runtime = Runtime.getRuntime();
+
int rowNum = 0;
- /*
- * short s1 = 0, s2 = (short) (col-1); rowNum += 1; sw.insertRow(rowNum); int styleIndex =
- * styles.get("header").getIndex(); sw.createCell(rowNum, reportTitle, styleIndex);
- *
- * //header.setCenter(HSSFHeader.font(FONT_TAHOMA, "")+ HSSFHeader.fontSize((short)
- * 9)+reportTitle+"\n"+((Globals.getShowDescrAtRuntime() && nvl(reportDescr).length() >
- * 0)?reportDescr:""));
- *
- * // Report Description if (Globals.getShowDescrAtRuntime() && nvl(reportDescr).length() > 0) {
- * sw.createCell(rowNum, reportDescr, styleIndex); } rowNum += 2; sw.insertRow(rowNum);
- */
+ /*short s1 = 0, s2 = (short) (col-1);
+ rowNum += 1;
+ sw.insertRow(rowNum);
+ int styleIndex = styles.get("header").getIndex();
+ sw.createCell(rowNum, reportTitle, styleIndex);
+
+ //header.setCenter(HSSFHeader.font("Tahoma", "")+ HSSFHeader.fontSize((short) 9)+reportTitle+"\n"+((Globals.getShowDescrAtRuntime() && nvl(reportDescr).length() > 0)?reportDescr:""));
+
+ // Report Description
+ if (Globals.getShowDescrAtRuntime() && nvl(reportDescr).length() > 0) {
+ sw.createCell(rowNum, reportDescr, styleIndex);
+ }
+ rowNum += 2;
+ sw.insertRow(rowNum);*/
int cellNum = 0;
-
+
+
ColumnHeaderRow chr = null;
java.util.HashMap dataTypeMap = new java.util.HashMap();
boolean firstPass = true;
- int columnRows = rr.getVisibleColumnCount();
-
- HttpSession session = request.getSession();
- String drilldown_index = (String) session.getAttribute("drilldown_index");
- int index = 0;
- try {
- index = Integer.parseInt(drilldown_index);
- } catch (NumberFormatException ex) {
- index = 0;
- }
- String header = (String) session.getAttribute("TITLE_" + index);
- String subtitle = (String) session.getAttribute("SUBTITLE_" + index);
- if (nvl(header).length() > 0) {
- header = Utils.replaceInString(header, "<BR/>", " ");
- header = Utils.replaceInString(header, "<br/>", " ");
- header = Utils.replaceInString(header, "<br>", " ");
- header = strip.stripHtml(nvl(header).trim());
- subtitle = Utils.replaceInString(subtitle, "<BR/>", " ");
- subtitle = Utils.replaceInString(subtitle, "<br/>", " ");
- subtitle = Utils.replaceInString(subtitle, "<br>", " ");
- subtitle = strip.stripHtml(nvl(subtitle).trim());
- // XSSFRow row = sheet.createRow(rowNum);
- sw.insertRow(rowNum);
- cellNum = 0;
- // XSSFCell cell = row.createCell(cellNum);
- sw.createCell(cellNum, Utils.excelEncode(header));
- for (int i = 1; i <= columnRows; i++) {
- sw.createCell(cellNum + i, "");
- }
- sheet.addMergedRegion(new CellRangeAddress(rowNum + 1, rowNum + 1, cellNum + 1, columnRows));
- sw.endRow();
- /*
- * cell.setCellValue(Utils.excelEncode(header)); cell.setCellStyle(styles.get("title"));
- */ // sw.createCell(cellNum,Utils.excelEncode(header), styles.get("title").getIndex());
- // sheet.addMergedRegion(new CellRangeAddress(rowNum+1, rowNum+1, cellNum+1, columnRows));
- rowNum += 1;
- // row = sheet.createRow(rowNum);
- sw.insertRow(rowNum);
- cellNum = 0;
- /*
- * cell = row.createCell(cellNum); cell.setCellValue(Utils.excelEncode(subtitle));
- * cell.setCellStyle(styles.get("title"));
- */ // sw.createCell(cellNum,Utils.excelEncode(header), styles.get("title").getIndex());
-
- sheet.addMergedRegion(new CellRangeAddress(rowNum + 1, rowNum + 1, cellNum + 1, columnRows));
- sw.createCell(cellNum, Utils.excelEncode(subtitle));
- sw.endRow();
- // sheet.addMergedRegion(new CellRangeAddress(rowNum+1, rowNum+1, cellNum+1, columnRows));
- /*
- * sw.insertRow(rowNum); cellNum = 0; sw.createCell(cellNum,Utils.excelEncode(subtitle),
- * styles.get("title").getIndex()); sheet.addMergedRegion(new CellRangeAddress(rowNum+1, rowNum+1,
- * cellNum+1, columnRows));
- *
- */ rowNum += 1;
- }
- cellNum = 0;
- String title = "";
- for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) {
- sw.insertRow(rowNum);
- cellNum = -1;
- /*
- * if(rd.reportTotalRowHeaderCols!=null) { cellNum +=1; sw.createCell(cellNum, "No.",
- * styles.get("header").getIndex());
- *
- * //row.getCell((short) cellNum).setCellStyle(styleDataHeader); }
- */
- chr = rd.reportColumnHeaderRows.getNext();
-
- if (nvl(sql_whole).length() <= 0 || (!rr.getReportType().equals(AppConstants.RT_LINEAR))) {
-
- for (rd.reportRowHeaderCols.resetNext(1); rd.reportRowHeaderCols.hasNext();) {
- cellNum += 1;
- RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
- title = rhc.getColumnTitle();
- title = Utils.replaceInString(title, "_nl_", " \n");
-
- sw.createCell(cellNum, Utils.excelEncode(title), styles.get("header").getIndex());
- // sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum+columnRows, (short) cellNum, (short)
- // (cellNum)));
-
- // System.out.println(" **************** Row Header Title " + rhc.getColumnTitle() + " " + cellNum +
- // " " );
- // System.out.println(cellNum + " " + cellWidth.size());
- } // for
-
- }
-
- firstPass = false;
- for (chr.resetNext(); chr.hasNext();) {
- ColumnHeader ch = chr.getNext();
- if (ch.isVisible()) {
- cellNum += 1;
- int colSpan = ch.getColSpan() - 1;
- title = ch.getColumnTitle();
- title = Utils.replaceInString(title, "_nl_", " \n");
- sw.createCell(cellNum, Utils.excelEncode(title), styles.get("header").getIndex());
- if (colSpan > 0) {
- for (int k = 1; k <= colSpan; k++) {
- sw.createCell(cellNum + k, "", styles.get("header").getIndex());
- }
- // sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short)
- // (cellNum+colSpan)));
- }
- if (colSpan > 0)
- cellNum += colSpan;
- }
- } // for
- rowNum += 1;
- } // for
-
- sw.endRow();
- // All the possible combinations of date format
+ int columnRows = rr.getVisibleColumnCount() ;
+
+ HttpSession session = request.getSession();
+ String drilldown_index = (String) session.getAttribute("drilldown_index");
+ int index = 0;
+ try {
+ index = Integer.parseInt(drilldown_index);
+ } catch (NumberFormatException ex) {
+ index = 0;
+ }
+ String header = (String) session.getAttribute("TITLE_"+index);
+ String subtitle = (String) session.getAttribute("SUBTITLE_"+index);
+ if(nvl(header).length()>0) {
+ header = Utils.replaceInString(header, "<BR/>", " ");
+ header = Utils.replaceInString(header, "<br/>", " ");
+ header = Utils.replaceInString(header, "<br>", " ");
+ header = strip.stripHtml(nvl(header).trim());
+ subtitle = Utils.replaceInString(subtitle, "<BR/>", " ");
+ subtitle = Utils.replaceInString(subtitle, "<br/>", " ");
+ subtitle = Utils.replaceInString(subtitle, "<br>", " ");
+ subtitle = strip.stripHtml(nvl(subtitle).trim());
+ //XSSFRow row = sheet.createRow(rowNum);
+ sw.insertRow(rowNum);
+ cellNum = 0;
+ //XSSFCell cell = row.createCell(cellNum);
+ sw.createCell(cellNum, Utils.excelEncode(header));
+ for (int i = 1; i <= columnRows; i++) {
+ sw.createCell(cellNum+i, "");
+ }
+ sheet.addMergedRegion(new CellRangeAddress(rowNum+1, rowNum+1, cellNum+1, columnRows));
+ sw.endRow();
+/* cell.setCellValue(Utils.excelEncode(header));
+ cell.setCellStyle(styles.get("title"));
+*/ //sw.createCell(cellNum,Utils.excelEncode(header), styles.get("title").getIndex());
+// sheet.addMergedRegion(new CellRangeAddress(rowNum+1, rowNum+1, cellNum+1, columnRows));
+ rowNum += 1;
+// row = sheet.createRow(rowNum);
+ sw.insertRow(rowNum);
+ cellNum = 0;
+/* cell = row.createCell(cellNum);
+ cell.setCellValue(Utils.excelEncode(subtitle));
+ cell.setCellStyle(styles.get("title"));
+*/ //sw.createCell(cellNum,Utils.excelEncode(header), styles.get("title").getIndex());
+
+ sheet.addMergedRegion(new CellRangeAddress(rowNum+1, rowNum+1, cellNum+1, columnRows));
+ sw.createCell(cellNum, Utils.excelEncode(subtitle));
+ sw.endRow();
+ //sheet.addMergedRegion(new CellRangeAddress(rowNum+1, rowNum+1, cellNum+1, columnRows));
+/* sw.insertRow(rowNum);
+ cellNum = 0;
+ sw.createCell(cellNum,Utils.excelEncode(subtitle), styles.get("title").getIndex());
+ sheet.addMergedRegion(new CellRangeAddress(rowNum+1, rowNum+1, cellNum+1, columnRows));
+
+*/ rowNum += 1;
+ }
+ cellNum = 0;
+ String title = "";
+ for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) {
+ sw.insertRow(rowNum);
+ cellNum = -1;
+ /*if(rd.reportTotalRowHeaderCols!=null) {
+ cellNum +=1;
+ sw.createCell(cellNum, "No.", styles.get("header").getIndex());
+
+ //row.getCell((short) cellNum).setCellStyle(styleDataHeader);
+ }*/
+ chr = rd.reportColumnHeaderRows.getNext();
+
+ if(nvl(sql_whole).length() <= 0 || (!rr.getReportType().equals(AppConstants.RT_LINEAR))) {
+
+ for (rd.reportRowHeaderCols.resetNext(1); rd.reportRowHeaderCols.hasNext();) {
+ cellNum += 1;
+ RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
+ title = rhc.getColumnTitle();
+ title = Utils.replaceInString(title,"_nl_", " \n");
+
+ sw.createCell(cellNum,Utils.excelEncode(title), styles.get("header").getIndex());
+ //sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum+columnRows, (short) cellNum, (short) (cellNum)));
+
+ //System.out.println(" **************** Row Header Title " + rhc.getColumnTitle() + " " + cellNum + " " );
+ //System.out.println(cellNum + " " + cellWidth.size());
+ } // for
+
+ }
+
+ firstPass = false;
+ for (chr.resetNext(); chr.hasNext();) {
+ ColumnHeader ch = chr.getNext();
+ if(ch.isVisible()) {
+ cellNum += 1;
+ int colSpan = ch.getColSpan()-1;
+ title = ch.getColumnTitle();
+ title = Utils.replaceInString(title,"_nl_", " \n");
+ sw.createCell(cellNum, Utils.excelEncode(title), styles.get("header").getIndex());
+ if(colSpan > 0) {
+ for ( int k = 1; k <= colSpan; k++ ) {
+ sw.createCell(cellNum+k, "", styles.get("header").getIndex());
+ }
+ //sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, (short) cellNum, (short) (cellNum+colSpan)));
+ }
+ if(colSpan > 0)
+ cellNum += colSpan;
+ }
+ } // for
+ rowNum += 1;
+ } // for
+
+ sw.endRow();
+ //All the possible combinations of date format
CreationHelper createHelper = wb.getCreationHelper();
HashMap<String, Short> dateFormatMap = new HashMap<String, Short>();
- SimpleDateFormat MMDDYYYYFormat = new SimpleDateFormat("MM/dd/yyyy");
- SimpleDateFormat YYYYMMDDFormat = new SimpleDateFormat("yyyy/MM/dd");
- SimpleDateFormat MONYYYYFormat = new SimpleDateFormat("MMM yyyy");
- SimpleDateFormat MMYYYYFormat = new SimpleDateFormat("MM/yyyy");
+ SimpleDateFormat MMDDYYYYFormat = new SimpleDateFormat("MM/dd/yyyy");
+ 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 YYYYMMDDDASHFormat = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- SimpleDateFormat DDMONYYYYFormat = new SimpleDateFormat("dd-MMM-yyyy");
- SimpleDateFormat MONTHYYYYFormat = new SimpleDateFormat("MMMMM, yyyy");
- 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 DDMONYYHHMMFormat = new SimpleDateFormat("dd-MMM-yy 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 MMDDYYYYHHMMZFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm z");
- SimpleDateFormat MMMMMDDYYYYHHMMSS = new SimpleDateFormat("MMMMM-dd-yyyy HH:mm:ss");
-
+ SimpleDateFormat YYYYMMDDDASHFormat = new SimpleDateFormat("yyyy-MM-dd");
+ SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ SimpleDateFormat DDMONYYYYFormat = new SimpleDateFormat("dd-MMM-yyyy");
+ SimpleDateFormat MONTHYYYYFormat = new SimpleDateFormat("MMMMM, yyyy");
+ 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 DDMONYYHHMMFormat = new SimpleDateFormat("dd-MMM-yy 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 MMDDYYYYHHMMZFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm z");
+ SimpleDateFormat MMMMMDDYYYYHHMMSS = new SimpleDateFormat("MMMMM-dd-yyyy HH:mm:ss");
+
short dateFormat = createHelper.createDataFormat().getFormat("MM/dd/yyyy");
- dateFormatMap.put("MMDDYYYY", new Short(dateFormat));
+ dateFormatMap.put("MMDDYYYY", new Short(dateFormat));
dateFormat = createHelper.createDataFormat().getFormat("yyyy/MM/dd");
dateFormatMap.put("YYYYMMDD", new Short(dateFormat));
dateFormat = createHelper.createDataFormat().getFormat("MMM yyyy");
@@ -4481,1879 +4574,1813 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
dateFormatMap.put("MMDDYYYYHHMMZ", new Short(dateFormat));
dateFormat = createHelper.createDataFormat().getFormat("MMMMM-dd-yyyy HH:mm:ss");
dateFormatMap.put("MMMMMDDYYYYHHMMSS", new Short(dateFormat));
-
+
ResultSetMetaData rsmd = null;
- if (nvl(sql_whole).length() > 0 && (rr.getReportType().equals(AppConstants.RT_LINEAR)
- || rr.getReportType().equals(AppConstants.RT_HIVE))) {
- try (Connection conn = ConnectionUtils.getConnection(rr.getDbInfo());
- Statement st = conn.createStatement();
- ResultSet rs = st.executeQuery(sql_whole)) {
-
- logger.debug(EELFLoggerDelegate.debugLogger, ("************* Map Whole SQL *************"));
- logger.debug(EELFLoggerDelegate.debugLogger, (sql_whole));
- logger.debug(EELFLoggerDelegate.debugLogger, ("*****************************************"));
- rsmd = rs.getMetaData();
- int numberOfColumns = rsmd.getColumnCount();
- HashMap colHash = new HashMap();
- DataRow dr = null;
- int j = 0;
- int rowCount = 0;
- while (rs.next()) {
-
- rowCount++;
-
- if (rowCount % 10000 == 0) {
- // to check performance
- logger.debug(EELFLoggerDelegate.debugLogger,
- ("Performance check for " + rowCount + " starting**************"));
- logger.debug(EELFLoggerDelegate.debugLogger, ("##### Heap utilization statistics [MB] #####"));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Used Memory:"
- + (runtime.totalMemory() - runtime.freeMemory()) / mb));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Free Memory:"
- + runtime.freeMemory() / mb));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Total Memory:" + runtime.totalMemory() / mb));
- logger.debug(EELFLoggerDelegate.debugLogger, ("Max Memory:" + runtime.maxMemory() / mb));
- System.out.println(rowCount + "TH ROW****##### END #####");
-
- //
- }
- sw.insertRow(rowNum);
- cellNum = -1;
- colHash = new HashMap();
- for (int i = 1; i <= numberOfColumns; i++) {
- colHash.put(rsmd.getColumnLabel(i).toUpperCase(), strip.stripHtml(rs.getString(i)));
- }
- rd.reportDataRows.resetNext();
- dr = rd.reportDataRows.getNext();
- styleRowCell = null;
- if (dr.isRowFormat() && styles != null)
- styleRowCell = (XSSFCellStyle) styles.get(nvl(/* dr.getFormatId(), */"", DEFAULT));
- j = 0;
- // if(rowCount%1000 == 0) wb.write(sos);
-
- /*
- * if(rd.reportTotalRowHeaderCols!=null) { //cellNum = -1; //for
- * (rd.reportRowHeaderCols.resetNext(); rd.reportRowHeaderCols.hasNext();) { cellNum += 1;
- * //RowHeaderCol rhc = rd.reportRowHeaderCols.getRowHeaderCol(0); //if (firstPass) //
- * rhc.resetNext(); //RowHeader rh = rhc.getRowHeader(rowCount-1); sw.createCell(cellNum, rowCount,
- * styleDefaultCell.getIndex());
- *
- * //} // for }
- */
- firstPass = false;
- // cellNum = -1;
- for (dr.resetNext(); dr.hasNext(); j++) {
- styleCell = null;
- // for (chr.resetNext(); chr.hasNext();) {
- // ColumnHeader ch = chr.getNext();
- DataValue dv = dr.getNext();
- HtmlFormatter htmlFormat = dv.getCellFormatter();
-
- if (htmlFormat != null && dv.getFormatId() != null && styles != null)
- styleCell = (XSSFCellStyle) styles.get(nvl(/* dv.getFormatId() */"", DEFAULT));
- String value = nvl((String) colHash.get(dv.getColId().toUpperCase()));
-
- boolean bold = false;
-
- if (dv.isVisible()) {
- cellNum += 1;
- // System.out.println("Stripping HTML 1");
- // cell.setCellValue(strip.stripHtml(dv.getDisplayValue()));
- String dataType = (String) (dataTypeMap.get(dv.getColId()));
- // System.out.println("Value " + value + " " + (( dataType !=null &&
- // dataType.equals("DATE")) || (dv.getColName()!=null &&
- // dv.getColName().toLowerCase().endsWith("date"))) );
- if (dataType != null && dataType.equals("NUMBER")) {
- // cellNumber = row.createCell((short) cellNum);
- // cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
- // cellNumber.setCellValue(dv.getDisplayValue());
- // cellCurrencyNumber = row.createCell((short) cellNum);
- int zInt = 0;
- if (value.equals("null")) {
- sw.createCell(cellNum, zInt,
- styles.get(nvl(/* dv.getFormatId() */"", DEFAULT)).getIndex());
- } else {
-
- if ((value.indexOf(".")) != -1) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
-
- // if (dv.getDisplayValue().startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempDollar = dv.getDisplayValue().trim();
- tempDollar = tempDollar.replaceAll(" ", "").substring(0);
- tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempDollar);
- // System.out.println("Before copy Value |" + tempDollar);
- // tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1,
- // tempDollar.length()-1);
- // System.out.println("After copy Value |" + tempDollar);
- if ((tempDollar.indexOf(",")) != -1) {
- tempDollar = tempDollar.replaceAll(",", "");
- }
- // System.out.println("The final string 1 is "+tempDollar);
- double tempDoubleDollar = 0.0;
- try {
- tempDoubleDollar = Double.parseDouble(tempDollar);
- if (styleRowCell != null)
- sw.createCell(cellNum, tempDoubleDollar, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempDoubleDollar, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempDoubleDollar, styles
- .get(nvl(/* dv.getFormatId() */"", DEFAULT)).getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempDollar),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempDollar),
- styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(tempDollar), styles
- .get(nvl(/* dv.getFormatId() */"", DEFAULT)).getIndex());
- }
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- double tempDouble = 0.0;
- try {
- tempDouble = Double.parseDouble(value);
- if (styleRowCell != null)
- sw.createCell(cellNum, tempDouble, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempDouble, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempDouble, styles
- .get(nvl(/* dv.getFormatId() */"", DEFAULT)).getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(value),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(value),
- styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(value), styles
- .get(nvl(/* dv.getFormatId() */"", DEFAULT)).getIndex());
- }
-
- }
- } else {
- if (!(value.equals(""))) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
- // if (dv.getDisplayValue().startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempInt = value.trim();
- tempInt = tempInt.replaceAll(" ", "").substring(0);
- tempInt = tempInt.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempInt);
- // System.out.println("Before copy Value |" + tempInt);
- // tempInt = String.copyValueOf(tempInt.toCharArray(), 1,
- // tempInt.length()-1);
- // System.out.println("After copy Value |" + tempInt);
- if ((tempInt.indexOf(",")) != -1) {
- tempInt = tempInt.replaceAll(",", "");
- }
- // System.out.println("The final string INT is "+tempInt);
- Long tempIntDollar = 0L;
- try {
- tempIntDollar = Long.parseLong(tempInt);
- if (styleRowCell != null)
- sw.createCell(cellNum, tempIntDollar, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempIntDollar, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempIntDollar,
- styles.get(nvl(/* dv.getFormatId() */"", DEFAULT))
- .getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, tempInt, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempInt, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempInt,
- styles.get(nvl(/* dv.getFormatId() */"", DEFAULT))
- .getIndex());
- }
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- String tempStr = value.trim();
- if ((tempStr.indexOf(",")) != -1) {
- tempStr = tempStr.replaceAll(",", "");
- }
- Long temp = 0L;
-
- try {
- temp = Long.parseLong(tempStr);
- if (styleRowCell != null)
- sw.createCell(cellNum, temp, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, temp, styleCell.getIndex());
- else
- sw.createCell(cellNum, temp,
- styles.get(nvl(/* dv.getFormatId() */"", DEFAULT))
- .getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempStr),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempStr),
- styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(tempStr),
- styles.get(nvl(/* dv.getFormatId() */"", DEFAULT))
- .getIndex());
- }
- }
- }
- }
- }
-
- } else if ((dataType != null && dataType.equals("DATE"))
- || (dv.getDisplayName() != null
- && dv.getDisplayName().toLowerCase().endsWith("date"))
- ||
- (dv.getColId() != null && dv.getColId().toLowerCase().endsWith("date")) ||
- (dv.getColName() != null && dv.getColName().toLowerCase().endsWith("date"))) {
- XSSFCellStyle cellStyle = null;
- if (styleRowCell != null) {
- cellStyle = styleRowCell;
- } else if (styleCell != null) {
- cellStyle = styleCell;
- } else {
- cellStyle = styles.get(nvl(/* dv.getFormatId() */"", "date"));
- }
-
- Date date = null;
- int flag = 0;
- date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMDDYYHHMMSS"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMDDYYHHMM"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMDDYY"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMDDYYYYHHMMSS"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMDDYYYYHHMM"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMDDYYYY"));
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("YYYYMMDD"));
- flag = 1;
- }
- if (date == null)
- date = timestampFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("timestamp"));
- flag = 1;
- }
- if (date == null)
- date = MONYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MONYYYY"));
- flag = 1;
- }
- if (date == null)
- date = MMYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMYYYY"));
- flag = 1;
- }
- if (date == null)
- date = MMMMMDDYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMMMMDDYYYY"));
- flag = 1;
- }
- if (date == null)
- date = MONTHYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MONTHYYYY"));
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("YYYYMMDDHHMMSS"));
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDDASHFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("YYYYMMDDDASH"));
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("YYYYMMDDHHMM"));
- flag = 1;
- }
- if (date == null)
- date = DDMONYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("DDMONYYYYHHMMSS"));
- flag = 1;
- }
- if (date == null)
- date = DDMONYYYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("DDMONYYYYHHMM"));
- flag = 1;
- }
- if (date == null)
- date = DDMONYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("DDMONYYHHMM"));
- flag = 1;
- }
- if (date == null)
- date = DDMONYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("DDMONYYYY"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMDDYYHHMMSS"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMDDYYHHMM"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMDDYY"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMDDYYHHMM"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMDDYYHHMMSS"));
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYHHMMZFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMDDYYYYHHMMZ"));
- flag = 1;
- }
- if (date == null)
- date = MMMMMDDYYYYHHMMSS.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- cellStyle.setDataFormat(dateFormatMap.get("MMMMMDDYYYYHHMMSS"));
- flag = 1;
- }
-
- if (date != null) {
- // System.out.println("ExcelDate " + HSSFDateUtil.getExcelDate(date));
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- // sw.createCell(cellNum,
- // cal,styles.get(nvl(/*dv.getFormatId()*/"",DEFAULT)).getIndex());
- // if(styleRowCell!=null)
- sw.createCell(cellNum, cal, cellStyle.getIndex());
- // else if (styleCell!=null)
- // sw.createCell(cellNum, cal, cellStyle.getIndex());
- // else
- // sw.createCell(cellNum, cal, cellStyle.getIndex());
- } else {
- // cell.getCellStyle().setDataFormat((short)0);
- // if(styleRowCell!=null)
- sw.createCell(cellNum, Utils.excelEncode(value), cellStyle.getIndex());
- // else if (styleCell!=null)
- // sw.createCell(cellNum, Utils.excelEncode(value), cellStyle.getIndex());
- // else
- // sw.createCell(cellNum, Utils.excelEncode(value), cellStyle.getIndex());
-
- }
- // cellDate.setCellValue(date);
- // cellDate.setCellValue(value); //cellDate.setCellValue(date);
- // cellDate.setCellValue(dv.getDisplayValue());
-
- } else if ((dv.getDisplayTotal() != null && dv.getDisplayTotal().equals("SUM("))
- || (dv.getColName() != null && dv.getColName().indexOf("999") != -1)) {
- // cellNumber = row.createCell((short) cellNum);
- // cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
- // cellNumber.setCellValue(dv.getDisplayValue());
- int zInt = 0;
- if (value.equals("null")) {
- if (styleRowCell != null)
- sw.createCell(cellNum, zInt, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, zInt, styleCell.getIndex());
- else
- sw.createCell(cellNum, zInt, styleDefaultCell.getIndex());
-
- } else {
-
- if ((value.indexOf(".")) != -1) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
-
- // if (value.startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempDollar = value.trim();
- tempDollar = tempDollar.replaceAll(" ", "").substring(0);
- tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempDollar);
- // System.out.println("Before copy Value |" + tempDollar);
- // tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1,
- // tempDollar.length()-1);
- // System.out.println("After copy Value |" + tempDollar);
- if ((tempDollar.indexOf(",")) != -1) {
- tempDollar = tempDollar.replaceAll(",", "");
- }
- // System.out.println("The final string 2IF is "+tempDollar);
- double tempDoubleDollar = 0.0;
- try {
- tempDoubleDollar = Double.parseDouble(tempDollar);
- if (styleRowCell != null)
- sw.createCell(cellNum, tempDoubleDollar, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempDoubleDollar, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempDoubleDollar, styles
- .get(nvl(/* dv.getFormatId() */"", DEFAULT)).getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempDollar),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempDollar),
- styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(tempDollar), styles
- .get(nvl(/* dv.getFormatId() */"", DEFAULT)).getIndex());
- }
-
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- String tempDoubleStr = value.trim();
- tempDoubleStr = tempDoubleStr.replaceAll(" ", "").substring(0);
- if ((tempDoubleStr.indexOf(",")) != -1) {
- tempDoubleStr = tempDoubleStr.replaceAll(",", "");
- }
- double tempDouble = 0.0;
- try {
- tempDouble = Double.parseDouble(tempDoubleStr);
- if (styleRowCell != null)
- sw.createCell(cellNum, tempDouble, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempDouble, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempDouble, styles
- .get(nvl(/* dv.getFormatId() */"", DEFAULT)).getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempDoubleStr),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempDoubleStr),
- styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(tempDoubleStr), styles
- .get(nvl(/* dv.getFormatId() */"", DEFAULT)).getIndex());
- }
- }
-
- } else {
- if (!(value.equals(""))) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
- // if (value.startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempInt = value.trim();
- tempInt = tempInt.replaceAll(" ", "").substring(0);
- tempInt = tempInt.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempInt);
- // System.out.println("Before copy Value |" + tempInt);
- // tempInt = String.copyValueOf(tempInt.toCharArray(), 1,
- // tempInt.length()-1);
- // System.out.println("After copy Value |" + tempInt);
- if ((tempInt.indexOf(",")) != -1) {
- tempInt = tempInt.replaceAll(",", "");
- }
- // System.out.println("The final string INT 2 is "+tempInt);
-
- Long tempIntDollar = 0L;
-
- try {
- tempIntDollar = Long.parseLong(tempInt);
- if (styleRowCell != null)
- sw.createCell(cellNum, tempIntDollar, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempIntDollar, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempIntDollar,
- styles.get(nvl(/* dv.getFormatId() */"", DEFAULT))
- .getIndex());
-
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempInt),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempInt),
- styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(tempInt),
- styles.get(nvl(/* dv.getFormatId() */"", DEFAULT))
- .getIndex());
- }
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- String tempStr = value.trim();
- if ((tempStr.indexOf(",")) != -1) {
- tempStr = tempStr.replaceAll(",", "");
- }
- Long temp = 0L;
-
- try {
- temp = Long.parseLong(tempStr);
- if (styleRowCell != null)
- sw.createCell(cellNum, temp, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, temp, styleCell.getIndex());
- else
- sw.createCell(cellNum, temp,
- styles.get(nvl(/* dv.getFormatId() */"", DEFAULT))
- .getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempStr),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempStr),
- styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(tempStr),
- styles.get(nvl(/* dv.getFormatId() */"", DEFAULT))
- .getIndex());
-
- }
- }
- } else {
- sw.createCell(cellNum, "",
- styles.get(nvl(/* dv.getFormatId() */"", DEFAULT)).getIndex());
- }
- }
- }
-
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("General"));
- if (styleRowCell != null)
- sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)),
- styleCell.getIndex());
- else {
- if (nvl(value).startsWith(" "))
- sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)),
- styles.get(nvl(/* dv.getFormatId(), */"", "defaultLeft")).getIndex());
- else
- sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)),
- styles.get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
-
- }
-
- }
- if (dv.isBold()) {
- if ((dv.getDisplayTotal() != null && dv.getDisplayTotal().equals("SUM("))
- || (dv.getColName() != null && dv.getColName().indexOf("999") != -1)) {
- if (value != null && (value.trim().startsWith("$"))
- || (value.trim().startsWith("-$"))) {
- // cell.setCellStyle(styleCurrencyTotal);
- } else {
- // cell.setCellStyle(styleTotal);
- }
- } else {
- // cell.setCellStyle(styleDefaultTotal);
- }
- bold = true;
- }
- // System.out.println("2IF "+ (dr.isRowFormat()) + " " + (dv.isCellFormat()) + " " +
- // (styles!=null));
- if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null) {
- // cell.setCellStyle((HSSFCellStyle) styles.get(nvl(dr.getFormatId(),DEFAULT)));
- continue;
- }
- // System.out.println("3IF "+ (htmlFormat != null) + " " + (dv.getFormatId() != null) + " "
- // + (bold == false) + " "+ (styles != null));
- if (htmlFormat != null && dv.getFormatId() != null && bold == false
- && styles != null) {
- // cell.setCellStyle((HSSFCellStyle) styles.get(nvl(/*dv.getFormatId()*/"",DEFAULT)));
- } // else if (bold == false)
- // cell.setCellStyle(styleDefault);
- } // dv.isVisible
-
- }
- rowNum += 1;
- sw.endRow();
-
- }
- if (rd.reportTotalRowHeaderCols != null) {
- rowCount++;
- sw.insertRow(rowNum);
- cellNum = -1;
- rd.reportTotalRowHeaderCols.resetNext();
- cellNum += 1;
- RowHeaderCol rhc = rd.reportTotalRowHeaderCols.getNext();
- RowHeader rh = rhc.getRowHeader(0);
- if (dr.isRowFormat() && styles != null)
- styleRowCell = (XSSFCellStyle) styles.get(nvl(/* dr.getFormatId(), */"", DEFAULT));
-
- if (styleRowCell != null)
- sw.createCell(cellNum, strip.stripHtml(rh.getRowTitle()), styleRowCell.getIndex());
+ if(nvl(sql_whole).length() >0 && (rr.getReportType().equals(AppConstants.RT_LINEAR) || rr.getReportType().equals(AppConstants.RT_HIVE) )) {
+ try(Connection conn = ConnectionUtils.getConnection(rr.getDbInfo());
+ Statement st = conn.createStatement();
+ ResultSet rs = st.executeQuery(sql_whole)) {
+
+ logger.debug(EELFLoggerDelegate.debugLogger, ("************* Map Whole SQL *************"));
+ logger.debug(EELFLoggerDelegate.debugLogger, (sql_whole));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("*****************************************"));
+ rsmd = rs.getMetaData();
+ int numberOfColumns = rsmd.getColumnCount();
+ HashMap colHash = new HashMap();
+ DataRow dr = null;
+ int j = 0;
+ int rowCount = 0;
+ while(rs.next()) {
+
+ rowCount++;
+
+ if(rowCount%10000 == 0) {
+ // to check performance
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Performance check for "+rowCount+" starting**************"));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("##### Heap utilization statistics [MB] #####"));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Used Memory:"
+ + (runtime.totalMemory() - runtime.freeMemory()) / mb));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Free Memory:"
+ + runtime.freeMemory() / mb));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Total Memory:" + runtime.totalMemory() / mb));
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Max Memory:" + runtime.maxMemory() / mb));
+ System.out.println(rowCount+"TH ROW****##### END #####");
+
+ //
+ }
+ sw.insertRow(rowNum);
+ cellNum = -1;
+ colHash = new HashMap();
+ for (int i = 1; i <= numberOfColumns; i++) {
+ colHash.put(rsmd.getColumnLabel(i).toUpperCase(), strip.stripHtml(rs.getString(i)));
+ }
+ rd.reportDataRows.resetNext();
+ dr = rd.reportDataRows.getNext();
+ styleRowCell = null;
+ if (dr.isRowFormat() && styles != null)
+ styleRowCell = (XSSFCellStyle) styles.get(nvl(/*dr.getFormatId(),*/"","default"));
+ j = 0;
+ //if(rowCount%1000 == 0) wb.write(sos);
+
+ /*if(rd.reportTotalRowHeaderCols!=null) {
+ //cellNum = -1;
+ //for (rd.reportRowHeaderCols.resetNext(); rd.reportRowHeaderCols.hasNext();) {
+ cellNum += 1;
+ //RowHeaderCol rhc = rd.reportRowHeaderCols.getRowHeaderCol(0);
+ //if (firstPass)
+ // rhc.resetNext();
+ //RowHeader rh = rhc.getRowHeader(rowCount-1);
+ sw.createCell(cellNum, rowCount, styleDefaultCell.getIndex());
+
+ //} // for
+ }*/
+ firstPass = false;
+ //cellNum = -1;
+ for (dr.resetNext(); dr.hasNext();j++) {
+ styleCell = null;
+ //for (chr.resetNext(); chr.hasNext();) {
+ //ColumnHeader ch = chr.getNext();
+ DataValue dv = dr.getNext();
+ HtmlFormatter htmlFormat = dv.getCellFormatter();
+
+ if (htmlFormat != null && dv.getFormatId() != null && styles != null)
+ styleCell = (XSSFCellStyle) styles.get(nvl(/*dv.getFormatId()*/"","default"));
+ String value = nvl((String)colHash.get(dv.getColId().toUpperCase()));
+
+ boolean bold = false;
+
+ if(dv.isVisible()) {
+ cellNum += 1;
+ //System.out.println("Stripping HTML 1");
+ //cell.setCellValue(strip.stripHtml(dv.getDisplayValue()));
+ String dataType = (String) (dataTypeMap.get(dv.getColId()));
+ //System.out.println("Value " + value + " " + (( dataType !=null && dataType.equals("DATE")) || (dv.getColName()!=null && dv.getColName().toLowerCase().endsWith("date"))) );
+ if (dataType!=null && dataType.equals("NUMBER")){
+ //cellNumber = row.createCell((short) cellNum);
+ //cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
+ //cellNumber.setCellValue(dv.getDisplayValue());
+ //cellCurrencyNumber = row.createCell((short) cellNum);
+ int zInt = 0;
+ if (value.equals("null")){
+ sw.createCell(cellNum,zInt,styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ }else{
+
+ if ((value.indexOf("."))!= -1){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+
+ //if (dv.getDisplayValue().startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempDollar = dv.getDisplayValue().trim();
+ tempDollar = tempDollar.replaceAll(" ", "").substring(0);
+ tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempDollar);
+ //System.out.println("Before copy Value |" + tempDollar);
+ //tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1, tempDollar.length()-1);
+ //System.out.println("After copy Value |" + tempDollar);
+ if ((tempDollar.indexOf(","))!= -1){
+ tempDollar = tempDollar.replaceAll(",", "");
+ }
+ //System.out.println("The final string 1 is "+tempDollar);
+ double tempDoubleDollar = 0.0;
+ try {
+ tempDoubleDollar = Double.parseDouble(tempDollar);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempDoubleDollar, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempDoubleDollar, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempDoubleDollar, styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempDollar), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempDollar), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(tempDollar), styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ }
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ double tempDouble = 0.0;
+ try {
+ tempDouble = Double.parseDouble(value);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempDouble, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempDouble, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempDouble, styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(value),styleRowCell.getIndex() );
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(value), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(value), styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ }
+
+ }
+ }else {
+ if (!(value.equals(""))){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ //if (dv.getDisplayValue().startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempInt = value.trim();
+ tempInt = tempInt.replaceAll(" ", "").substring(0);
+ tempInt = tempInt.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempInt);
+ //System.out.println("Before copy Value |" + tempInt);
+ //tempInt = String.copyValueOf(tempInt.toCharArray(), 1, tempInt.length()-1);
+ //System.out.println("After copy Value |" + tempInt);
+ if ((tempInt.indexOf(","))!= -1){
+ tempInt = tempInt.replaceAll(",", "");
+ }
+ //System.out.println("The final string INT is "+tempInt);
+ Long tempIntDollar = 0L;
+ try {
+ tempIntDollar = Long.parseLong(tempInt);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempIntDollar, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempIntDollar, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempIntDollar, styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempInt, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempInt, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempInt, styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ }
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempStr = value.trim();
+ if ((tempStr.indexOf(","))!= -1){
+ tempStr = tempStr.replaceAll(",", "");
+ }
+ Long temp = 0L;
+
+ try {
+ temp = Long.parseLong(tempStr);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, temp, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, temp, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, temp, styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempStr), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempStr), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(tempStr), styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ }
+ }
+ }
+ }
+ }
+
+ } else if ( ( dataType !=null && dataType.equals("DATE")) || (dv.getDisplayName()!=null && dv.getDisplayName().toLowerCase().endsWith("date")) ||
+ (dv.getColId()!=null && dv.getColId().toLowerCase().endsWith("date")) ||
+ (dv.getColName()!=null && dv.getColName().toLowerCase().endsWith("date")) ) {
+ XSSFCellStyle cellStyle = null;
+ if(styleRowCell!=null) {
+ cellStyle = styleRowCell;
+ } else if (styleCell!=null) {
+ cellStyle = styleCell;
+ } else {
+ cellStyle = styles.get(nvl(/*dv.getFormatId()*/"","date"));
+ }
+
+
+ Date date = null;
+ int flag = 0;
+ date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMDDYYHHMMSS"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMDDYYHHMM"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMDDYY"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMDDYYYYHHMMSS"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMDDYYYYHHMM"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMDDYYYY"));
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("YYYYMMDD"));
+ flag = 1;
+ }
+ if(date==null)
+ date = timestampFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("timestamp"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MONYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MONYYYY"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMYYYY"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMMMMDDYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMMMMDDYYYY"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MONTHYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MONTHYYYY"));
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("YYYYMMDDHHMMSS"));
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDDASHFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("YYYYMMDDDASH"));
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("YYYYMMDDHHMM"));
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("DDMONYYYYHHMMSS"));
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("DDMONYYYYHHMM"));
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("DDMONYYHHMM"));
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("DDMONYYYY"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMDDYYHHMMSS"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMDDYYHHMM"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMDDYY"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMDDYYHHMM"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMDDYYHHMMSS"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYHHMMZFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMDDYYYYHHMMZ"));
+ flag = 1;
+ }
+ if(date==null)
+ date = MMMMMDDYYYYHHMMSS.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ cellStyle.setDataFormat(dateFormatMap.get("MMMMMDDYYYYHHMMSS"));
+ flag = 1;
+ }
+
+ if(date!=null) {
+ //System.out.println("ExcelDate " + HSSFDateUtil.getExcelDate(date));
+ Calendar cal=Calendar.getInstance();
+ cal.setTime(date);
+ //sw.createCell(cellNum, cal,styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ //if(styleRowCell!=null)
+ sw.createCell(cellNum, cal, cellStyle.getIndex());
+ //else if (styleCell!=null)
+ //sw.createCell(cellNum, cal, cellStyle.getIndex());
+ //else
+ //sw.createCell(cellNum, cal, cellStyle.getIndex());
+ } else {
+ //cell.getCellStyle().setDataFormat((short)0);
+ //if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(value), cellStyle.getIndex());
+ //else if (styleCell!=null)
+ //sw.createCell(cellNum, Utils.excelEncode(value), cellStyle.getIndex());
+ //else
+ //sw.createCell(cellNum, Utils.excelEncode(value), cellStyle.getIndex());
+
+ }
+ //cellDate.setCellValue(date);
+ //cellDate.setCellValue(value); //cellDate.setCellValue(date);
+ //cellDate.setCellValue(dv.getDisplayValue());
+
+ } else if((dv.getDisplayTotal()!=null && dv.getDisplayTotal().equals("SUM(")) || (dv.getColName()!=null && dv.getColName().indexOf("999")!=-1)){
+ //cellNumber = row.createCell((short) cellNum);
+ //cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
+ //cellNumber.setCellValue(dv.getDisplayValue());
+ int zInt = 0;
+ if (value.equals("null")){
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, zInt, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, zInt, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, zInt, styleDefaultCell.getIndex());
+
+ } else {
+
+ if ((value.indexOf("."))!= -1){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempDollar = value.trim();
+ tempDollar = tempDollar.replaceAll(" ", "").substring(0);
+ tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempDollar);
+ //System.out.println("Before copy Value |" + tempDollar);
+ //tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1, tempDollar.length()-1);
+ //System.out.println("After copy Value |" + tempDollar);
+ if ((tempDollar.indexOf(","))!= -1){
+ tempDollar = tempDollar.replaceAll(",", "");
+ }
+ //System.out.println("The final string 2IF is "+tempDollar);
+ double tempDoubleDollar = 0.0;
+ try {
+ tempDoubleDollar = Double.parseDouble(tempDollar);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempDoubleDollar,styleRowCell.getIndex() );
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempDoubleDollar, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempDoubleDollar, styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempDollar), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempDollar), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(tempDollar), styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ }
+
+
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempDoubleStr = value.trim();
+ tempDoubleStr = tempDoubleStr.replaceAll(" ", "").substring(0);
+ if ((tempDoubleStr.indexOf(","))!= -1){
+ tempDoubleStr = tempDoubleStr.replaceAll(",", "");
+ }
+ double tempDouble = 0.0;
+ try {
+ tempDouble = Double.parseDouble(tempDoubleStr);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempDouble, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempDouble, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempDouble, styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempDoubleStr), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempDoubleStr), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(tempDoubleStr), styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ }
+ }
+
+ }else {
+ if (!(value.equals(""))){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempInt = value.trim();
+ tempInt = tempInt.replaceAll(" ", "").substring(0);
+ tempInt = tempInt.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempInt);
+ //System.out.println("Before copy Value |" + tempInt);
+ //tempInt = String.copyValueOf(tempInt.toCharArray(), 1, tempInt.length()-1);
+ //System.out.println("After copy Value |" + tempInt);
+ if ((tempInt.indexOf(","))!= -1){
+ tempInt = tempInt.replaceAll(",", "");
+ }
+ //System.out.println("The final string INT 2 is "+tempInt);
+
+ Long tempIntDollar = 0L;
+
+ try {
+ tempIntDollar = Long.parseLong(tempInt);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempIntDollar,styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempIntDollar,styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempIntDollar,styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempInt), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempInt),styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(tempInt), styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ }
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempStr = value.trim();
+ if ((tempStr.indexOf(","))!= -1){
+ tempStr = tempStr.replaceAll(",", "");
+ }
+ Long temp = 0L;
+
+ try {
+ temp = Long.parseLong(tempStr);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, temp, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, temp, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, temp, styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempStr), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempStr), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(tempStr), styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+
+ }
+ }
+ } else {
+ sw.createCell(cellNum, "", styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ }
+ }
+ }
+
+
+ }
+ else {
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("General"));
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)), styleCell.getIndex());
+ else {
+ if(nvl(value).startsWith(" "))
+ sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)), styles.get(nvl(/*dv.getFormatId(),*/"","defaultLeft")).getIndex());
+ else
+ sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)), styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+
+ }
+
+ }
+
+ if (dv.isBold()) {
+ if((dv.getDisplayTotal()!=null && dv.getDisplayTotal().equals("SUM(")) || (dv.getColName()!=null && dv.getColName().indexOf("999")!=-1)){
+ if (value!=null && (value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ //cell.setCellStyle(styleCurrencyTotal);
+ }
+ else {
+ //cell.setCellStyle(styleTotal);
+ }
+ } else {
+ //cell.setCellStyle(styleDefaultTotal);
+ }
+ bold = true;
+ }
+ //System.out.println("2IF "+ (dr.isRowFormat()) + " " + (dv.isCellFormat()) + " " + (styles!=null));
+ if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null) {
+ //cell.setCellStyle((HSSFCellStyle) styles.get(nvl(dr.getFormatId(),"default")));
+ continue;
+ }
+ //System.out.println("3IF "+ (htmlFormat != null) + " " + (dv.getFormatId() != null) + " " + (bold == false) + " "+ (styles != null));
+ if (htmlFormat != null && dv.getFormatId() != null && bold == false
+ && styles != null) {
+ //cell.setCellStyle((HSSFCellStyle) styles.get(nvl(/*dv.getFormatId()*/"","default")));
+ } //else if (bold == false)
+ //cell.setCellStyle(styleDefault);
+ } // dv.isVisible
+
+ }
+ rowNum += 1;
+ sw.endRow();
+
+ }
+ if(rd.reportTotalRowHeaderCols!=null) {
+ rowCount++;
+ sw.insertRow(rowNum);
+ cellNum = -1;
+ rd.reportTotalRowHeaderCols.resetNext();
+ cellNum += 1;
+ RowHeaderCol rhc = rd.reportTotalRowHeaderCols.getNext();
+ RowHeader rh = rhc.getRowHeader(0);
+ if (dr.isRowFormat() && styles != null)
+ styleRowCell = (XSSFCellStyle) styles.get(nvl(/*dr.getFormatId(),*/"","default"));
+
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, strip.stripHtml(rh.getRowTitle()), styleRowCell.getIndex());
else
- sw.createCell(cellNum, strip.stripHtml(rh.getRowTitle()), styleDefaultCell.getIndex());
+ sw.createCell(cellNum, strip.stripHtml(rh.getRowTitle()), styleDefaultCell.getIndex());
rd.reportDataTotalRow.resetNext();
- // rd.reportDataTotalRow.getNext();
- DataRow drTotal = rd.reportDataTotalRow.getNext();
- if (drTotal != null) {
- drTotal.resetNext();
- drTotal.getNext();
- for (; drTotal.hasNext();) {
- DataValue dv = drTotal.getNext();
- if (dv.isVisible()) {
- cellNum += 1;
- styleCell = null;
- String value = dv.getDisplayValue();
- sw.createCell(cellNum, value,
- styles.get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- }
- }
- }
- rowNum += 1;
- sw.endRow();
- }
-
- /*
- * // To Display Total Values for Linear report if(rd.reportDataTotalRow!=null) { row =
- * sheet.createRow(rowNum); cellNum = -1; rd.reportTotalRowHeaderCols.resetNext(); //for
- * (rd.reportTotalRowHeaderCols.resetNext(); rd.reportTotalRowHeaderCols.hasNext();) { cellNum += 1;
- * RowHeaderCol rhc = rd.reportTotalRowHeaderCols.getNext(); RowHeader rh = rhc.getRowHeader(0);
- * row.createCell((short) cellNum).setCellValue(strip.stripHtml(rh.getRowTitle()));
- * row.getCell((short) cellNum).setCellStyle(styleDefaultTotal); //}
- *
- * DataRow drTotal = rd.reportDataTotalRow.getNext(); //cellNum = -1; for (drTotal.resetNext();
- * drTotal.hasNext();j++) { cellNum += 1; cell = row.createCell((short) cellNum); DataValue dv =
- * drTotal.getNext(); String value = dv.getDisplayValue(); cell.setCellValue(value); boolean bold =
- * false; if (dv.isBold()) { if((dv.getDisplayTotal()!=null && dv.getDisplayTotal().equals("SUM("))
- * || (dv.getColName()!=null && dv.getColName().indexOf("999")!=-1)){ if (value!=null &&
- * (value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
- * cell.setCellStyle(styleCurrencyTotal); } else { cell.setCellStyle(styleTotal); } } else {
- * cell.setCellStyle(styleDefaultTotal); } bold = true; } } }
- */
-
- } catch (SQLException ex) {
- throw new RaptorException(ex);
- } catch (ReportSQLException ex) {
- throw new RaptorException(ex);
- } catch (Exception ex) {
- if (!(ex.getCause() instanceof java.net.SocketException))
- throw new RaptorException(ex);
- }
-
- String footer = (String) session.getAttribute("FOOTER_" + index);
- if (nvl(footer).length() > 0) {
- footer = Utils.replaceInString(footer, "<BR/>", " ");
- footer = Utils.replaceInString(footer, "<br/>", " ");
- footer = Utils.replaceInString(footer, "<br>", " ");
- footer = strip.stripHtml(nvl(footer).trim());
- rowNum += 1;
- sw.insertRow(rowNum);
- cellNum = 0;
- sw.createCell(cellNum, footer.replaceAll("&", "&amp;"), styleDefaultCell.getIndex());
- sw.endRow();
- rowNum += 1;
- }
-
- if (Globals.getShowDisclaimer()) {
- rowNum += 1;
- sw.insertRow(rowNum);
- cellNum = 0;
-
- sw.createCell(cellNum,
- org.onap.portalsdk.analytics.system.Globals.getFooterFirstLine().replaceAll("&", "&amp;"),
- styleDefaultCell.getIndex());
+ //rd.reportDataTotalRow.getNext();
+ DataRow drTotal = rd.reportDataTotalRow.getNext();
+ if(drTotal!=null) {
+ drTotal.resetNext(); drTotal.getNext();
+ for (; drTotal.hasNext();) {
+ DataValue dv = drTotal.getNext();
+ if(dv.isVisible()) {
+ cellNum += 1;
+ styleCell = null;
+ String value = dv.getDisplayValue();
+ sw.createCell(cellNum,value,styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ }
+ }
+ }
+ rowNum += 1;
+ sw.endRow();
+ }
+
+
+
+
+
+/* // To Display Total Values for Linear report
+ if(rd.reportDataTotalRow!=null) {
+ row = sheet.createRow(rowNum);
+ cellNum = -1;
+ rd.reportTotalRowHeaderCols.resetNext();
+ //for (rd.reportTotalRowHeaderCols.resetNext(); rd.reportTotalRowHeaderCols.hasNext();) {
+ cellNum += 1;
+ RowHeaderCol rhc = rd.reportTotalRowHeaderCols.getNext();
+ RowHeader rh = rhc.getRowHeader(0);
+ row.createCell((short) cellNum).setCellValue(strip.stripHtml(rh.getRowTitle()));
+ row.getCell((short) cellNum).setCellStyle(styleDefaultTotal);
+ //}
+
+ DataRow drTotal = rd.reportDataTotalRow.getNext();
+ //cellNum = -1;
+ for (drTotal.resetNext(); drTotal.hasNext();j++) {
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+ DataValue dv = drTotal.getNext();
+ String value = dv.getDisplayValue();
+ cell.setCellValue(value);
+ boolean bold = false;
+ if (dv.isBold()) {
+ if((dv.getDisplayTotal()!=null && dv.getDisplayTotal().equals("SUM(")) || (dv.getColName()!=null && dv.getColName().indexOf("999")!=-1)){
+ if (value!=null && (value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ cell.setCellStyle(styleCurrencyTotal);
+ } else {
+ cell.setCellStyle(styleTotal);
+ }
+ } else {
+ cell.setCellStyle(styleDefaultTotal);
+ }
+ bold = true;
+ }
+ }
+ }*/
+
+ } catch (SQLException ex) {
+ throw new RaptorException(ex);
+ } catch (ReportSQLException ex) {
+ throw new RaptorException(ex);
+ } catch (Exception ex) {
+ if(!(ex.getCause() instanceof java.net.SocketException) )
+ throw new RaptorException (ex);
+ }
+
+ String footer = (String) session.getAttribute("FOOTER_"+index);
+ if(nvl(footer).length()>0) {
+ footer = Utils.replaceInString(footer, "<BR/>", " ");
+ footer = Utils.replaceInString(footer, "<br/>", " ");
+ footer = Utils.replaceInString(footer, "<br>", " ");
+ footer = strip.stripHtml(nvl(footer).trim());
+ rowNum += 1;
+ sw.insertRow(rowNum);
+ cellNum = 0;
+ sw.createCell(cellNum, footer.replaceAll("&", "&amp;"), styleDefaultCell.getIndex());
+ sw.endRow();
+ rowNum += 1;
+ }
+
+ if(Globals.getShowDisclaimer()) {
+ rowNum += 1;
+ sw.insertRow(rowNum);
+ cellNum = 0;
+
+ sw.createCell(cellNum, org.onap.portalsdk.analytics.system.Globals.getFooterFirstLine().replaceAll("&", "&amp;"), styleDefaultCell.getIndex());
+ sw.endRow();
+ rowNum += 1;
+ sw.insertRow(rowNum);
+ cellNum = 0;
+ sw.createCell(cellNum, org.onap.portalsdk.analytics.system.Globals.getFooterSecondLine().replaceAll("&", "&amp;"), styleDefaultCell.getIndex());
+ sw.endRow();
+ }
+
+ } else {
+ //start data from rd
+
+ int rowCount = 0;
+ DataRow dr = null;
+ for (rd.reportDataRows.resetNext(); rd.reportDataRows.hasNext();) {
+ rowCount++;
+
+
+ dr = rd.reportDataRows.getNext();
+ sw.insertRow(rowNum);
+
+ cellNum = -1;
+
+ if (rr.getReportType().equals(AppConstants.RT_LINEAR) && rd.reportTotalRowHeaderCols!=null) {
+ rd.reportRowHeaderCols.resetNext(0);
+ if(rd.reportTotalRowHeaderCols!=null) {
+ //cellNum = -1;
+ //for (rd.reportRowHeaderCols.resetNext(); rd.reportRowHeaderCols.hasNext();) {
+ //a commented to suppress rownum
+ //a cellNum += 1;
+ //RowHeaderCol rhc = rd.reportRowHeaderCols.getRowHeaderCol(0);
+ //if (firstPass)
+ // rhc.resetNext();
+ //RowHeader rh = rhc.getRowHeader(rowCount-1);
+ //a sw.createCell(cellNum, rowCount, styleDefaultCell.getIndex());
+ //} // for
+ }
+
+ }
+ firstPass = false;
+ //cellNum = -1;
+ int j = 0;
+
+ for (dr.resetNext(); dr.hasNext();j++) {
+ DataValue dv = dr.getNext();
+ styleCell = null;
+ boolean bold = false;
+ String value = nvl(dv.getDisplayValue());
+ value = strip.stripHtml(value);
+ HtmlFormatter htmlFormat = dv.getCellFormatter();
+ if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null)
+ styleCell = (XSSFCellStyle) styles.get(nvl(/*dr.getFormatId(),*/"","default"));
+ if (htmlFormat != null && dv.getFormatId() != null && styles != null)
+ styleCell = (XSSFCellStyle) styles.get(nvl(/*dv.getFormatId(),*/"","default"));
+
+ if(dv.isVisible()) {
+ cellNum += 1;
+ //cell = row.createCell((short) cellNum);
+ //System.out.println("Stripping HTML 1");
+ //cell.setCellValue(strip.stripHtml(value));
+ String dataType = (String) (dataTypeMap.get(dv.getColId()));
+ //System.out.println(" The Display Value is ********"+value + " " + dv.getDisplayTotal() + " " + dv.getColName());
+
+ if (dataType!=null && dataType.equals("NUMBER")){
+ //cellNumber = row.createCell((short) cellNum);
+ //cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
+ //cellNumber.setCellValue(value);
+ //cellCurrencyNumber = row.createCell((short) cellNum);
+ int zInt = 0;
+ if (value.equals("null")){
+ sw.createCell(cellNum,zInt,styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ }else{
+
+ if ((value.indexOf("."))!= -1){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempDollar = value.trim();
+ tempDollar = tempDollar.replaceAll(" ", "").substring(0);
+ tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempDollar);
+ //System.out.println("Before copy Value |" + tempDollar);
+ //tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1, tempDollar.length()-1);
+ //System.out.println("After copy Value |" + tempDollar);
+ if ((tempDollar.indexOf(","))!= -1){
+ tempDollar = tempDollar.replaceAll(",", "");
+ }
+ //System.out.println("The final string 1 is "+tempDollar);
+ double tempDoubleDollar = 0.0;
+ try {
+ tempDoubleDollar = Double.parseDouble(tempDollar);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempDoubleDollar, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempDoubleDollar, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempDoubleDollar, styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempDollar), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempDollar), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(tempDollar), styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ }
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ double tempDouble = 0.0;
+ try {
+ tempDouble = Double.parseDouble(value);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempDouble, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempDouble, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempDouble, styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(value),styleRowCell.getIndex() );
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(value), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(value), styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ }
+
+ }
+ }else {
+ if (!(value.equals(""))){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempInt = value.trim();
+ tempInt = tempInt.replaceAll(" ", "").substring(0);
+ tempInt = tempInt.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempInt);
+ //System.out.println("Before copy Value |" + tempInt);
+ //tempInt = String.copyValueOf(tempInt.toCharArray(), 1, tempInt.length()-1);
+ //System.out.println("After copy Value |" + tempInt);
+ if ((tempInt.indexOf(","))!= -1){
+ tempInt = tempInt.replaceAll(",", "");
+ }
+ //System.out.println("The final string INT is "+tempInt);
+ Long tempIntDollar = 0L;
+ try {
+ tempIntDollar = Long.parseLong(tempInt);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempIntDollar, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempIntDollar, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempIntDollar, styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempInt, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempInt, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempInt, styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ }
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempStr = value.trim();
+ if ((tempStr.indexOf(","))!= -1){
+ tempStr = tempStr.replaceAll(",", "");
+ }
+ Long temp = 0L;
+
+ try {
+ temp = Long.parseLong(tempStr);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, temp, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, temp, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, temp, styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempStr), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempStr), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(tempStr), styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ }
+
+
+ }
+ //int temp = Integer.parseInt(value.trim());
+ // cell.setCellValue(temp);
+ //}else{
+ // cell.setCellValue(strip.stripHtml(value));
+ //}
+ }
+ }
+ }
+
+ }else if ( ( dataType !=null && dataType.equals("DATE")) || (dv.getDisplayName()!=null && dv.getDisplayName().toLowerCase().endsWith("date")) ||
+ (dv.getColId()!=null && dv.getColId().toLowerCase().endsWith("date")) ||
+ (dv.getColName()!=null && dv.getColName().toLowerCase().endsWith("date")) ) {
+ Date date = null;
+ int flag = 0;
+ date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = timestampFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MONYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMMMMDDYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MONTHYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDDASHFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = YYYYMMDDHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = DDMONYYYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMDDYYYYHHMMZFormat.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+ if(date==null)
+ date = MMMMMDDYYYYHHMMSS.parse(value, new ParsePosition(0));
+ if(date != null && flag == 0) {
+ flag = 1;
+ }
+
+
+ if(date!=null) {
+ Calendar cal=Calendar.getInstance();
+ cal.setTime(date);
+ //sw.createCell(cellNum, cal,styles.get(nvl(/*dv.getFormatId()*/"","default")).getIndex());
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, cal, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, cal, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, cal, styles.get(nvl(/*dv.getFormatId()*/"","date")).getIndex());
+
+ } else {
+ /*cell.getCellStyle().setDataFormat((short)0);*/
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(value), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(value), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(value), styles.get(nvl(/*dv.getFormatId(),*/"","date")).getIndex());
+
+ }
+ //cellDate.setCellValue(date);
+ //cellDate.setCellValue(value);
+
+ }else if((dv.getDisplayTotal()!=null && dv.getDisplayTotal().equals("SUM(")) || (dv.getColName()!=null && dv.getColName().indexOf("999")!=-1)){
+ //cellNumber = row.createCell((short) cellNum);
+ //cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
+ //cellNumber.setCellValue(value);
+ int zInt = 0;
+ if (value.equals("null")){
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, zInt, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, zInt, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, zInt, styleDefaultCell.getIndex());
+ } else {
+
+ if ((value.indexOf("."))!= -1){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempDollar = value.trim();
+ tempDollar = tempDollar.replaceAll(" ", "").substring(0);
+ tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempDollar);
+ //System.out.println("Before copy Value |" + tempDollar);
+ //tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1, tempDollar.length()-1);
+ //System.out.println("After copy Value |" + tempDollar);
+ if ((tempDollar.indexOf(","))!= -1){
+ tempDollar = tempDollar.replaceAll(",", "");
+ }
+ //System.out.println("The final string 2IF is "+tempDollar);
+ double tempDoubleDollar = 0.0;
+ try {
+ tempDoubleDollar = Double.parseDouble(tempDollar);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempDoubleDollar,styleRowCell.getIndex() );
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempDoubleDollar, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempDoubleDollar, styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempDollar), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempDollar), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(tempDollar), styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ }
+
+
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempDoubleStr = value.trim();
+ tempDoubleStr = tempDoubleStr.replaceAll(" ", "").substring(0);
+ if ((tempDoubleStr.indexOf(","))!= -1){
+ tempDoubleStr = tempDoubleStr.replaceAll(",", "");
+ }
+ double tempDouble = 0.0;
+ try {
+ tempDouble = Double.parseDouble(tempDoubleStr);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempDouble, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempDouble, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempDouble, styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempDoubleStr), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempDoubleStr), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(tempDoubleStr), styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ }
+ }
+
+ }else {
+ if (!(value.equals(""))){
+ if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ //if (value.startsWith("$")){
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
+ String tempInt = value.trim();
+ tempInt = tempInt.replaceAll(" ", "").substring(0);
+ tempInt = tempInt.replaceAll("\\$", "").substring(0);
+ //System.out.println("SUBSTRING |" + tempInt);
+ //System.out.println("Before copy Value |" + tempInt);
+ //tempInt = String.copyValueOf(tempInt.toCharArray(), 1, tempInt.length()-1);
+ //System.out.println("After copy Value |" + tempInt);
+ if ((tempInt.indexOf(","))!= -1){
+ tempInt = tempInt.replaceAll(",", "");
+ }
+ //System.out.println("The final string INT 2 is "+tempInt);
+
+ Long tempIntDollar = 0L;
+
+ try {
+ tempIntDollar = Long.parseLong(tempInt);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, tempIntDollar,styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, tempIntDollar,styleCell.getIndex());
+ else
+ sw.createCell(cellNum, tempIntDollar,styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempInt), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempInt),styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(tempInt), styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ }
+ }else{
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
+ String tempStr = value.trim();
+ if ((tempStr.indexOf(","))!= -1){
+ tempStr = tempStr.replaceAll(",", "");
+ }
+ Long temp = 0L;
+
+ try {
+ temp = Long.parseLong(tempStr);
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, temp, styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, temp, styleCell.getIndex());
+ else
+ sw.createCell(cellNum, temp, styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ } catch (NumberFormatException ne) {
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempStr), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, Utils.excelEncode(tempStr), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, Utils.excelEncode(tempStr), styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ }
+ }
+ //int temp = Integer.parseInt(value.trim());
+ // cell.setCellValue(temp);
+ //}else{
+ // cell.setCellValue(strip.stripHtml(value));
+ //}
+ } else {
+ sw.createCell(cellNum, "", styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ }
+ }
+ }
+
+
+ }
+ else {
+ //styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("General"));
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)), styleRowCell.getIndex());
+ else if (styleCell!=null)
+ sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)), styleCell.getIndex());
+ else
+ sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)), styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ }
+
+ //if (!(value.equals(""))){
+ //int temp = Integer.parseInt(value.trim());
+ //cell.setCellValue(temp);
+ //}else{
+ // cell.setCellValue(strip.stripHtml(value));
+ //}
+ //HSSFCellStyle styleFormat = null;
+ //HSSFCellStyle numberStyle = null;
+ //HSSFFont formatFont = null;
+ //short fgcolor = 0;
+ //short fillpattern = 0;
+ //System.out.println("1IF "+ (dv.isBold()) + " "+ value + " " + dv.getDisplayTotal() + " " + dv.getColName() );
+ if (dv.isBold()) {
+ if((dv.getDisplayTotal()!=null && dv.getDisplayTotal().equals("SUM(")) || (dv.getColName()!=null && dv.getColName().indexOf("999")!=-1)){
+ if (value!=null && (value.trim().startsWith("$")) || (value.trim().startsWith("-$") )) {
+ //cell.setCellStyle(styleCurrencyTotal);
+ }
+ else {
+ //cell.setCellStyle(styleTotal);
+ }
+ } else {
+ //cell.setCellStyle(styleDefaultTotal);
+ }
+ bold = true;
+ }
+ //System.out.println("2IF "+ (dr.isRowFormat()) + " " + (dv.isCellFormat()) + " " + (styles!=null));
+ if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null) {
+ //cell.setCellStyle((HSSFCellStyle) styles.get(nvl(dr.getFormatId(),"default")));
+ continue;
+ }
+ //System.out.println("3IF "+ (htmlFormat != null) + " " + (dv.getFormatId() != null) + " " + (bold == false) + " "+ (styles != null));
+ if (htmlFormat != null && dv.getFormatId() != null && bold == false
+ && styles != null) {
+ // cell.setCellStyle((HSSFCellStyle) styles.get(nvl(/*dv.getFormatId()*/"","default")));
+ } //else if (bold == false)
+ //cell.setCellStyle(styleDefault);
+ } // if (dv.isVisible)
+ } // for
+
+ /*for (int tmp=0; tmp<dataTypeMap.size(); tmp++){
+ String dataTypeStr = (String)(dataTypeMap.get(tmp));
+ if(dataTypeStr.equals("NUMBER")){
+ cell.setCellStyle(styleNumber);
+ }else if (dataTypeStr.equals("VARCHAR2")){
+ cell.setCellStyle(styleDefault);
+
+ }else if (dataTypeStr.equals("DATE")){
+ cell.setCellStyle(styleDate);
+ }else{
+
+ }
+
+ }*/
+ rowNum += 1;
sw.endRow();
- rowNum += 1;
- sw.insertRow(rowNum);
- cellNum = 0;
- sw.createCell(cellNum,
- org.onap.portalsdk.analytics.system.Globals.getFooterSecondLine().replaceAll("&", "&amp;"),
- styleDefaultCell.getIndex());
- sw.endRow();
- }
-
- } else {
- // start data from rd
-
- int rowCount = 0;
- DataRow dr = null;
- for (rd.reportDataRows.resetNext(); rd.reportDataRows.hasNext();) {
- rowCount++;
-
- dr = rd.reportDataRows.getNext();
- sw.insertRow(rowNum);
-
- cellNum = -1;
-
- if (rr.getReportType().equals(AppConstants.RT_LINEAR) && rd.reportTotalRowHeaderCols != null) {
- rd.reportRowHeaderCols.resetNext(0);
- if (rd.reportTotalRowHeaderCols != null) {
- // cellNum = -1;
- // for (rd.reportRowHeaderCols.resetNext(); rd.reportRowHeaderCols.hasNext();) {
- // a commented to suppress rownum
- // a cellNum += 1;
- // RowHeaderCol rhc = rd.reportRowHeaderCols.getRowHeaderCol(0);
- // if (firstPass)
- // rhc.resetNext();
- // RowHeader rh = rhc.getRowHeader(rowCount-1);
- // a sw.createCell(cellNum, rowCount, styleDefaultCell.getIndex());
- // } // for
- }
-
- }
- firstPass = false;
- // cellNum = -1;
- int j = 0;
-
- for (dr.resetNext(); dr.hasNext(); j++) {
- DataValue dv = dr.getNext();
- styleCell = null;
- boolean bold = false;
- String value = nvl(dv.getDisplayValue());
- value = strip.stripHtml(value);
- HtmlFormatter htmlFormat = dv.getCellFormatter();
- if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null)
- styleCell = (XSSFCellStyle) styles.get(nvl(/* dr.getFormatId(), */"", DEFAULT));
- if (htmlFormat != null && dv.getFormatId() != null && styles != null)
- styleCell = (XSSFCellStyle) styles.get(nvl(/* dv.getFormatId(), */"", DEFAULT));
-
- if (dv.isVisible()) {
- cellNum += 1;
- // cell = row.createCell((short) cellNum);
- // System.out.println("Stripping HTML 1");
- // cell.setCellValue(strip.stripHtml(value));
- String dataType = (String) (dataTypeMap.get(dv.getColId()));
- // System.out.println(" The Display Value is ********"+value + " " + dv.getDisplayTotal() + " "
- // + dv.getColName());
-
- if (dataType != null && dataType.equals("NUMBER")) {
- // cellNumber = row.createCell((short) cellNum);
- // cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
- // cellNumber.setCellValue(value);
- // cellCurrencyNumber = row.createCell((short) cellNum);
- int zInt = 0;
- if (value.equals("null")) {
- sw.createCell(cellNum, zInt,
- styles.get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- } else {
-
- if ((value.indexOf(".")) != -1) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
-
- // if (value.startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempDollar = value.trim();
- tempDollar = tempDollar.replaceAll(" ", "").substring(0);
- tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempDollar);
- // System.out.println("Before copy Value |" + tempDollar);
- // tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1,
- // tempDollar.length()-1);
- // System.out.println("After copy Value |" + tempDollar);
- if ((tempDollar.indexOf(",")) != -1) {
- tempDollar = tempDollar.replaceAll(",", "");
- }
- // System.out.println("The final string 1 is "+tempDollar);
- double tempDoubleDollar = 0.0;
- try {
- tempDoubleDollar = Double.parseDouble(tempDollar);
- if (styleRowCell != null)
- sw.createCell(cellNum, tempDoubleDollar, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempDoubleDollar, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempDoubleDollar, styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempDollar),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempDollar),
- styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(tempDollar), styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- }
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- double tempDouble = 0.0;
- try {
- tempDouble = Double.parseDouble(value);
- if (styleRowCell != null)
- sw.createCell(cellNum, tempDouble, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempDouble, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempDouble, styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(value),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(value), styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(value), styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- }
-
- }
- } else {
- if (!(value.equals(""))) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
- // if (value.startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempInt = value.trim();
- tempInt = tempInt.replaceAll(" ", "").substring(0);
- tempInt = tempInt.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempInt);
- // System.out.println("Before copy Value |" + tempInt);
- // tempInt = String.copyValueOf(tempInt.toCharArray(), 1,
- // tempInt.length()-1);
- // System.out.println("After copy Value |" + tempInt);
- if ((tempInt.indexOf(",")) != -1) {
- tempInt = tempInt.replaceAll(",", "");
- }
- // System.out.println("The final string INT is "+tempInt);
- Long tempIntDollar = 0L;
- try {
- tempIntDollar = Long.parseLong(tempInt);
- if (styleRowCell != null)
- sw.createCell(cellNum, tempIntDollar, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempIntDollar, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempIntDollar, styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, tempInt, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempInt, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempInt, styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- }
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- String tempStr = value.trim();
- if ((tempStr.indexOf(",")) != -1) {
- tempStr = tempStr.replaceAll(",", "");
- }
- Long temp = 0L;
-
- try {
- temp = Long.parseLong(tempStr);
- if (styleRowCell != null)
- sw.createCell(cellNum, temp, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, temp, styleCell.getIndex());
- else
- sw.createCell(cellNum, temp, styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempStr),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempStr),
- styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(tempStr), styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- }
-
- }
- // int temp = Integer.parseInt(value.trim());
- // cell.setCellValue(temp);
- // }else{
- // cell.setCellValue(strip.stripHtml(value));
- // }
- }
- }
- }
-
- } else if ((dataType != null && dataType.equals("DATE"))
- || (dv.getDisplayName() != null && dv.getDisplayName().toLowerCase().endsWith("date"))
- ||
- (dv.getColId() != null && dv.getColId().toLowerCase().endsWith("date")) ||
- (dv.getColName() != null && dv.getColName().toLowerCase().endsWith("date"))) {
- Date date = null;
- int flag = 0;
- date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMDDYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = timestampFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MONYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMMMMDDYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MONTHYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDDASHFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = YYYYMMDDHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = DDMONYYYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = DDMONYYYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = DDMONYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = DDMONYYYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMDDYYFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMDDYYHHMMSSFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMDDYYYYHHMMZFormat.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
- if (date == null)
- date = MMMMMDDYYYYHHMMSS.parse(value, new ParsePosition(0));
- if (date != null && flag == 0) {
- flag = 1;
- }
-
- if (date != null) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- // sw.createCell(cellNum,
- // cal,styles.get(nvl(/*dv.getFormatId()*/"",DEFAULT)).getIndex());
- if (styleRowCell != null)
- sw.createCell(cellNum, cal, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, cal, styleCell.getIndex());
- else
- sw.createCell(cellNum, cal,
- styles.get(nvl(/* dv.getFormatId() */"", "date")).getIndex());
-
- } else {
- /* cell.getCellStyle().setDataFormat((short)0); */
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(value), styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(value), styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(value),
- styles.get(nvl(/* dv.getFormatId(), */"", "date")).getIndex());
-
- }
- // cellDate.setCellValue(date);
- // cellDate.setCellValue(value);
-
- } else if ((dv.getDisplayTotal() != null && dv.getDisplayTotal().equals("SUM("))
- || (dv.getColName() != null && dv.getColName().indexOf("999") != -1)) {
- // cellNumber = row.createCell((short) cellNum);
- // cellNumber.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
- // cellNumber.setCellValue(value);
- int zInt = 0;
- if (value.equals("null")) {
- if (styleRowCell != null)
- sw.createCell(cellNum, zInt, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, zInt, styleCell.getIndex());
- else
- sw.createCell(cellNum, zInt, styleDefaultCell.getIndex());
- } else {
-
- if ((value.indexOf(".")) != -1) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
-
- // if (value.startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempDollar = value.trim();
- tempDollar = tempDollar.replaceAll(" ", "").substring(0);
- tempDollar = tempDollar.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempDollar);
- // System.out.println("Before copy Value |" + tempDollar);
- // tempDollar = String.copyValueOf(tempDollar.toCharArray(), 1,
- // tempDollar.length()-1);
- // System.out.println("After copy Value |" + tempDollar);
- if ((tempDollar.indexOf(",")) != -1) {
- tempDollar = tempDollar.replaceAll(",", "");
- }
- // System.out.println("The final string 2IF is "+tempDollar);
- double tempDoubleDollar = 0.0;
- try {
- tempDoubleDollar = Double.parseDouble(tempDollar);
- if (styleRowCell != null)
- sw.createCell(cellNum, tempDoubleDollar, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempDoubleDollar, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempDoubleDollar, styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempDollar),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempDollar),
- styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(tempDollar), styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- }
-
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- String tempDoubleStr = value.trim();
- tempDoubleStr = tempDoubleStr.replaceAll(" ", "").substring(0);
- if ((tempDoubleStr.indexOf(",")) != -1) {
- tempDoubleStr = tempDoubleStr.replaceAll(",", "");
- }
- double tempDouble = 0.0;
- try {
- tempDouble = Double.parseDouble(tempDoubleStr);
- if (styleRowCell != null)
- sw.createCell(cellNum, tempDouble, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempDouble, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempDouble, styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempDoubleStr),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempDoubleStr),
- styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(tempDoubleStr), styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- }
- }
-
- } else {
- if (!(value.equals(""))) {
- if ((value.trim().startsWith("$")) || (value.trim().startsWith("-$"))) {
- // if (value.startsWith("$")){
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("($#,##0.00);($#,##0.00)"));
- String tempInt = value.trim();
- tempInt = tempInt.replaceAll(" ", "").substring(0);
- tempInt = tempInt.replaceAll("\\$", "").substring(0);
- // System.out.println("SUBSTRING |" + tempInt);
- // System.out.println("Before copy Value |" + tempInt);
- // tempInt = String.copyValueOf(tempInt.toCharArray(), 1,
- // tempInt.length()-1);
- // System.out.println("After copy Value |" + tempInt);
- if ((tempInt.indexOf(",")) != -1) {
- tempInt = tempInt.replaceAll(",", "");
- }
- // System.out.println("The final string INT 2 is "+tempInt);
-
- Long tempIntDollar = 0L;
-
- try {
- tempIntDollar = Long.parseLong(tempInt);
- if (styleRowCell != null)
- sw.createCell(cellNum, tempIntDollar, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, tempIntDollar, styleCell.getIndex());
- else
- sw.createCell(cellNum, tempIntDollar, styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempInt),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempInt),
- styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(tempInt), styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- }
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));
- String tempStr = value.trim();
- if ((tempStr.indexOf(",")) != -1) {
- tempStr = tempStr.replaceAll(",", "");
- }
- Long temp = 0L;
-
- try {
- temp = Long.parseLong(tempStr);
- if (styleRowCell != null)
- sw.createCell(cellNum, temp, styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, temp, styleCell.getIndex());
- else
- sw.createCell(cellNum, temp, styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- } catch (NumberFormatException ne) {
- if (styleRowCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempStr),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, Utils.excelEncode(tempStr),
- styleCell.getIndex());
- else
- sw.createCell(cellNum, Utils.excelEncode(tempStr), styles
- .get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- }
- }
- // int temp = Integer.parseInt(value.trim());
- // cell.setCellValue(temp);
- // }else{
- // cell.setCellValue(strip.stripHtml(value));
- // }
- } else {
- sw.createCell(cellNum, "",
- styles.get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- }
- }
- }
-
- } else {
- // styleDefault.setDataFormat(HSSFDataFormat.getBuiltinFormat("General"));
- if (styleRowCell != null)
- sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)),
- styleRowCell.getIndex());
- else if (styleCell != null)
- sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)), styleCell.getIndex());
- else
- sw.createCell(cellNum, strip.stripHtml(Utils.excelEncode(value)),
- styles.get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- }
-
- // if (!(value.equals(""))){
- // int temp = Integer.parseInt(value.trim());
- // cell.setCellValue(temp);
- // }else{
- // cell.setCellValue(strip.stripHtml(value));
- // }
- // HSSFCellStyle styleFormat = null;
- // HSSFCellStyle numberStyle = null;
- // HSSFFont formatFont = null;
- // short fgcolor = 0;
- // short fillpattern = 0;
- // System.out.println("1IF "+ (dv.isBold()) + " "+ value + " " + dv.getDisplayTotal() + " " +
- // dv.getColName() );
- if (dv.isBold()) {
- if ((dv.getDisplayTotal() != null && dv.getDisplayTotal().equals("SUM("))
- || (dv.getColName() != null && dv.getColName().indexOf("999") != -1)) {
- if (value != null && (value.trim().startsWith("$"))
- || (value.trim().startsWith("-$"))) {
- // cell.setCellStyle(styleCurrencyTotal);
- } else {
- // cell.setCellStyle(styleTotal);
- }
- } else {
- // cell.setCellStyle(styleDefaultTotal);
- }
- bold = true;
- }
- // System.out.println("2IF "+ (dr.isRowFormat()) + " " + (dv.isCellFormat()) + " " +
- // (styles!=null));
- if ((dr.isRowFormat() && !dv.isCellFormat()) && styles != null) {
- // cell.setCellStyle((HSSFCellStyle) styles.get(nvl(dr.getFormatId(),DEFAULT)));
- continue;
- }
- // System.out.println("3IF "+ (htmlFormat != null) + " " + (dv.getFormatId() != null) + " " +
- // (bold == false) + " "+ (styles != null));
- if (htmlFormat != null && dv.getFormatId() != null && bold == false
- && styles != null) {
- // cell.setCellStyle((HSSFCellStyle) styles.get(nvl(/*dv.getFormatId()*/"",DEFAULT)));
- } // else if (bold == false)
- // cell.setCellStyle(styleDefault);
- } // if (dv.isVisible)
- } // for
-
- /*
- * for (int tmp=0; tmp<dataTypeMap.size(); tmp++){ String dataTypeStr =
- * (String)(dataTypeMap.get(tmp)); if(dataTypeStr.equals("NUMBER")){ cell.setCellStyle(styleNumber);
- * }else if (dataTypeStr.equals("VARCHAR2")){ cell.setCellStyle(styleDefault);
- *
- * }else if (dataTypeStr.equals("DATE")){ cell.setCellStyle(styleDate); }else{
- *
- * }
- *
- * }
- */
- rowNum += 1;
- sw.endRow();
- } // for
-
- if (rr.getReportType().equals(AppConstants.RT_LINEAR) && rd.reportTotalRowHeaderCols != null) {
-
- for (rd.reportDataTotalRow.resetNext(); rd.reportDataTotalRow.hasNext();) {
- rowCount++;
- sw.insertRow(rowNum);
- cellNum = -1;
- cellNum += 1;
-
- RowHeaderCol rhc = rd.reportTotalRowHeaderCols.getNext();
- RowHeader rh = rhc.getRowHeader(0);
- if (dr.isRowFormat() && styles != null)
- styleRowCell = (XSSFCellStyle) styles.get(nvl(/* dr.getFormatId(), */"", DEFAULT));
- if (styleRowCell != null)
- sw.createCell(cellNum, strip.stripHtml(rh.getRowTitle()), styleRowCell.getIndex());
- else
- sw.createCell(cellNum, strip.stripHtml(rh.getRowTitle()), styleDefaultCell.getIndex());
-
- DataRow drTotal = rd.reportDataTotalRow.getNext();
- if (drTotal != null) {
- drTotal.resetNext();
- drTotal.getNext();
- for (; drTotal.hasNext();) {
- cellNum += 1;
- styleCell = null;
- DataValue dv = drTotal.getNext();
- String value = dv.getDisplayValue();
- sw.createCell(cellNum, value,
- styles.get(nvl(/* dv.getFormatId(), */"", DEFAULT)).getIndex());
- }
- }
-
- rowNum += 1;
- sw.endRow();
- }
-
- String footer = (String) session.getAttribute("FOOTER_" + index);
- if (nvl(footer).length() > 0) {
- footer = Utils.replaceInString(footer, "<BR/>", " ");
- footer = Utils.replaceInString(footer, "<br/>", " ");
- footer = Utils.replaceInString(footer, "<br>", " ");
- footer = strip.stripHtml(nvl(footer).trim());
- rowNum += 1;
- sw.insertRow(rowNum);
- cellNum = 0;
- sw.createCell(cellNum, footer.replaceAll("&", "&amp;"), styleDefaultCell.getIndex());
- sw.endRow();
- rowNum += 1;
- }
-
- if (Globals.getShowDisclaimer()) {
- rowNum += 1;
- sw.insertRow(rowNum);
- cellNum = 0;
-
- sw.createCell(cellNum,
- org.onap.portalsdk.analytics.system.Globals.getFooterFirstLine().replaceAll("&", "&amp;"),
- styleDefaultCell.getIndex());
- sw.endRow();
- rowNum += 1;
- sw.insertRow(rowNum);
- cellNum = 0;
- sw.createCell(cellNum,
- org.onap.portalsdk.analytics.system.Globals.getFooterSecondLine().replaceAll("&", "&amp;"),
- styleDefaultCell.getIndex());
- sw.endRow();
- }
-
- }
- // end data from rd
- }
-
- // System.out.println(" Last Row " + wb.getSheetAt(0).getLastRowNum());
- }
-
- private void paintXSSFExcelParams(XSSFWorkbook wb, int rowNum, int col, ArrayList paramsList,
- String customizedParamInfo, XSSFSheet sheet, String reportTitle, String reportDescr) throws IOException {
- // HSSFSheet sheet = wb.getSheet(getSheetName());
+ } // for
+
+ if (rr.getReportType().equals(AppConstants.RT_LINEAR) && rd.reportTotalRowHeaderCols!=null) {
+
+ for (rd.reportDataTotalRow.resetNext(); rd.reportDataTotalRow.hasNext();) {
+ rowCount++;
+ sw.insertRow(rowNum);
+ cellNum = -1;
+ cellNum += 1;
+
+ RowHeaderCol rhc = rd.reportTotalRowHeaderCols.getNext();
+ RowHeader rh = rhc.getRowHeader(0);
+ if (dr.isRowFormat() && styles != null)
+ styleRowCell = (XSSFCellStyle) styles.get(nvl(/*dr.getFormatId(),*/"","default"));
+ if(styleRowCell!=null)
+ sw.createCell(cellNum, strip.stripHtml(rh.getRowTitle()), styleRowCell.getIndex());
+ else
+ sw.createCell(cellNum, strip.stripHtml(rh.getRowTitle()), styleDefaultCell.getIndex());
+
+ DataRow drTotal = rd.reportDataTotalRow.getNext();
+ if(drTotal!=null) {
+ drTotal.resetNext(); drTotal.getNext();
+ for (; drTotal.hasNext();) {
+ cellNum += 1;
+ styleCell = null;
+ DataValue dv = drTotal.getNext();
+ String value = dv.getDisplayValue();
+ sw.createCell(cellNum,value,styles.get(nvl(/*dv.getFormatId(),*/"","default")).getIndex());
+ }
+ }
+
+ rowNum += 1;
+ sw.endRow();
+ }
+
+
+ String footer = (String) session.getAttribute("FOOTER_"+index);
+ if(nvl(footer).length()>0) {
+ footer = Utils.replaceInString(footer, "<BR/>", " ");
+ footer = Utils.replaceInString(footer, "<br/>", " ");
+ footer = Utils.replaceInString(footer, "<br>", " ");
+ footer = strip.stripHtml(nvl(footer).trim());
+ rowNum += 1;
+ sw.insertRow(rowNum);
+ cellNum = 0;
+ sw.createCell(cellNum, footer.replaceAll("&", "&amp;"), styleDefaultCell.getIndex());
+ sw.endRow();
+ rowNum += 1;
+ }
+
+
+ if(Globals.getShowDisclaimer()) {
+ rowNum += 1;
+ sw.insertRow(rowNum);
+ cellNum = 0;
+
+ sw.createCell(cellNum, org.onap.portalsdk.analytics.system.Globals.getFooterFirstLine().replaceAll("&", "&amp;"), styleDefaultCell.getIndex());
+ sw.endRow();
+ rowNum += 1;
+ sw.insertRow(rowNum);
+ cellNum = 0;
+ sw.createCell(cellNum, org.onap.portalsdk.analytics.system.Globals.getFooterSecondLine().replaceAll("&", "&amp;"), styleDefaultCell.getIndex());
+ sw.endRow();
+ }
+
+
+ }
+ // end data from rd
+ }
+
+ // System.out.println(" Last Row " + wb.getSheetAt(0).getLastRowNum());
+ }
+
+ private void paintXSSFExcelParams(XSSFWorkbook wb,int rowNum,int col,ArrayList paramsList, String customizedParamInfo, XSSFSheet sheet, String reportTitle, String reportDescr) throws IOException {
+ //HSSFSheet sheet = wb.getSheet(getSheetName());
int cellNum = 0;
XSSFRow row = null;
short s1 = 0, s2 = (short) 1;
HtmlStripper strip = new HtmlStripper();
// Name Style
XSSFCellStyle styleName = wb.createCellStyle();
- // styleName.setFillBackgroundColor(HSSFColor.GREY_80_PERCENT.index);
+ //styleName.setFillBackgroundColor(HSSFColor.GREY_80_PERCENT.index);
styleName.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
- // styleName.setFillPattern(HSSFCellStyle.SPARSE_DOTS);
- styleName.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleName.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleName.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleName.setBorderRight(HSSFCellStyle.BORDER_THIN);
- styleName.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleName.setDataFormat((short) 0);
+ //styleName.setFillPattern(HSSFCellStyle.SPARSE_DOTS);
+ styleName.setAlignment(HorizontalAlignment.CENTER);
+ styleName.setBorderBottom(BorderStyle.THIN);
+ styleName.setBorderTop(BorderStyle.THIN);
+ styleName.setBorderRight(BorderStyle.THIN);
+ styleName.setBorderLeft(BorderStyle.THIN);
+ styleName.setDataFormat((short)0);
XSSFFont font = wb.createFont();
- font.setFontHeight((short) (FONT_SIZE / 0.05));
- font.setFontName(FONT_TAHOMA);
+ font.setFontHeight((short) (font_size / 0.05));
+ font.setFontName("Tahoma");
font.setColor(HSSFColor.BLACK.index);
- font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+ font.setBold(true);
styleName.setFont(font);
- // Data Style
-
+ //Data Style
+
// Create some fonts.
XSSFFont fontDefault = wb.createFont();
// Initialize the styles & fonts.
// The default will be plain .
fontDefault.setColor((short) HSSFFont.COLOR_NORMAL);
- fontDefault.setFontHeight((short) (FONT_SIZE / 0.05));
- fontDefault.setFontName(FONT_TAHOMA);
+ fontDefault.setFontHeight((short) (font_size / 0.05));
+ fontDefault.setFontName("Tahoma");
fontDefault.setItalic(true);
// Style default will be normal with no background
XSSFCellStyle styleValue = wb.createCellStyle();
- styleValue.setDataFormat((short) 0);
- styleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- styleValue.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- styleValue.setBorderTop(HSSFCellStyle.BORDER_THIN);
- styleValue.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- styleValue.setBorderRight(HSSFCellStyle.BORDER_THIN);
+ styleValue.setDataFormat((short)0);
+ styleValue.setAlignment(HorizontalAlignment.CENTER);
+ styleValue.setBorderBottom(BorderStyle.THIN);
+ styleValue.setBorderTop(BorderStyle.THIN);
+ styleValue.setBorderLeft(BorderStyle.THIN);
+ styleValue.setBorderRight(BorderStyle.THIN);
// styleValue.setFillForegroundColor(HSSFColor.YELLOW.index);
- styleValue.setFillPattern(HSSFCellStyle.NO_FILL);
+ styleValue.setFillPattern(FillPatternType.NO_FILL);
styleValue.setFont(fontDefault);
XSSFCell cell = null;
XSSFCellStyle styleDescription = wb.createCellStyle();
- styleDescription.setAlignment(HSSFCellStyle.ALIGN_CENTER);
- // styleDescription.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- // styleDescription.setBorderTop(HSSFCellStyle.BORDER_THIN);
- // styleDescription.setBorderRight(HSSFCellStyle.BORDER_THIN);
- // styleDescription.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+ styleDescription.setAlignment(HorizontalAlignment.CENTER);
+// styleDescription.setBorderBottom(BorderStyle.THIN);
+// styleDescription.setBorderTop(BorderStyle.THIN);
+// styleDescription.setBorderRight(BorderStyle.THIN);
+// styleDescription.setBorderLeft(BorderStyle.THIN);
XSSFFont fontDescr = wb.createFont();
- fontDescr.setFontHeight((short) (FONT_HEADER_DESCR_SIZE / 0.05));
- fontDescr.setFontName(FONT_TAHOMA);
+ fontDescr.setFontHeight((short) (font_header_descr_size / 0.05));
+ fontDescr.setFontName("Tahoma");
fontDescr.setColor(HSSFColor.BLACK.index);
- fontDescr.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+ fontDescr.setBold(true);
styleDescription.setFont(font);
XSSFCell cellDescr = null;
int paramSeq = 0;
Header header = sheet.getHeader();
- StringBuffer strBuf = new StringBuffer();
- if (!Globals.customizeFormFieldInfo() || customizedParamInfo.length() <= 0) {
- for (Iterator iter = paramsList.iterator(); iter.hasNext();) {
- IdNameValue value = (IdNameValue) iter.next();
- // System.out.println("\"" + value.getId() + " = " + value.getName() + "\"");
- if (nvl(value.getId()).trim().length() > 0 && (!nvl(value.getId()).trim().equals("BLANK"))) {
- paramSeq += 1;
- if (paramSeq <= 1) {
- row = sheet.createRow(++rowNum);
- cell = row.createCell((short) 0);
- sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
- cellDescr = row.createCell((short) 0);
- cellDescr.setCellValue(RUNTIME_PARAMETERS);
- cellDescr.setCellStyle(styleDescription);
-
- strBuf.append(reportTitle + "\n");
- // strBuf.append("Run-time Parameters\n");
- }
- row = sheet.createRow(++rowNum);
- cellNum = 0;
- // System.out.println("RowNum " + rowNum + " " + value.getId() + " " +value.getName());
- cell = row.createCell((short) cellNum);
- cell.setCellValue(value.getId());
- cell.setCellStyle(styleName);
- cellNum += 1;
- cell = row.createCell((short) cellNum);
- cell.setCellValue(value.getName().replaceAll("~", ","));
- cell.setCellStyle(styleValue);
-
- // strBuf.append(value.getId()+": "+ value.getName()+"\n");
- }
- } // for
+ StringBuffer strBuf = new StringBuffer();
+ if(!Globals.customizeFormFieldInfo() || customizedParamInfo.length()<=0) {
+ for (Iterator iter = paramsList.iterator(); iter.hasNext();) {
+ IdNameValue value = (IdNameValue) iter.next();
+ //System.out.println("\"" + value.getId() + " = " + value.getName() + "\"");
+ if(nvl(value.getId()).trim().length()>0 && (!nvl(value.getId()).trim().equals("BLANK"))) {
+ paramSeq += 1;
+ if(paramSeq <= 1) {
+ row = sheet.createRow(++rowNum);
+ cell = row.createCell((short) 0);
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
+ cellDescr = row.createCell((short) 0);
+ cellDescr.setCellValue("Run-time Parameters");
+ cellDescr.setCellStyle(styleDescription);
+
+
+ strBuf.append(reportTitle+"\n");
+ //strBuf.append("Run-time Parameters\n");
+ }
+ row = sheet.createRow(++rowNum);
+ cellNum = 0;
+ //System.out.println("RowNum " + rowNum + " " + value.getId() + " " +value.getName());
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue(value.getId());
+ cell.setCellStyle(styleName);
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue(value.getName().replaceAll("~",","));
+ cell.setCellStyle(styleValue);
+
+ //strBuf.append(value.getId()+": "+ value.getName()+"\n");
+ }
+ } //for
} else {
- strBuf.append(reportTitle + "\n");
- Document document = new Document();
- document.open();
+ strBuf.append(reportTitle+"\n");
+ Document document = new Document();
+ document.open();
HTMLWorker worker = new HTMLWorker(document);
- StyleSheet style = new StyleSheet();
- style.loadTagStyle("body", "leading", "16,0");
- ArrayList p = HTMLWorker.parseToList(new StringReader(customizedParamInfo), style);
- String name = "";
- String token = "";
- String value = "";
- String s = "";
- PdfPTable pdfTable = null;
- for (int k = 0; k < p.size(); ++k) {
- if (p.get(k) instanceof Paragraph)
- s = ((Paragraph) p.get(k)).toString();
- else { /* if ((p.get(k) instanceof PdfPTable)) */
- pdfTable = ((PdfPTable) p.get(k));
- }
- // todo: Logic for parsing pdfTable should be added after upgrading to iText 5.0.0
- // s = Utils.replaceInString(s, ",", "|");
- s = s.replaceAll(",", "|");
- s = s.replaceAll("~", ",");
- if (s.indexOf(":") != -1) {
- // System.out.println("|"+s+"|");
- row = sheet.createRow(++rowNum);
+ StyleSheet style = new StyleSheet();
+ style.loadTagStyle("body", "leading", "16,0");
+ ArrayList p = HTMLWorker.parseToList(new StringReader(customizedParamInfo), style);
+ String name = "";
+ String token = "";
+ String value = "";
+ String s = "";
+ PdfPTable pdfTable = null;
+ for (int k = 0; k < p.size(); ++k){
+ if(p.get(k) instanceof Paragraph)
+ s = ((Paragraph)p.get(k)).toString();
+ else { /*if ((p.get(k) instanceof PdfPTable))*/
+ pdfTable = ((PdfPTable)p.get(k));
+ }
+ //todo: Logic for parsing pdfTable should be added after upgrading to iText 5.0.0
+ //s = Utils.replaceInString(s, ",", "|");
+ s = s.replaceAll(",", "|");
+ s = s.replaceAll("~", ",");
+ if(s.indexOf(":")!= -1) {
+ //System.out.println("|"+s+"|");
+ row = sheet.createRow(++rowNum);
cell = row.createCell((short) 0);
sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
cellDescr = row.createCell((short) 0);
- cellDescr.setCellValue(RUNTIME_PARAMETERS);
- cellDescr.setCellStyle(styleDescription);
-
- // strBuf.append("Run-time Parameters\n");
- StringTokenizer st = new StringTokenizer(s.trim(), "|");
- while (st.hasMoreTokens()) {
- token = st.nextToken();
- token = token.trim();
- if (!(token.trim().equals("|") || token.trim().equals("]]") || token.trim().equals("]")
- || token.trim().equals("["))) {
- if (token.endsWith(":")) {
- name = token;
- name = name.substring(0, name.length() - 1);
- if (name.startsWith("["))
- name = name.substring(1);
- value = st.nextToken();
- if (nvl(value).endsWith("]"))
- value = nvl(value).substring(0, nvl(value).length() - 1);
- } /*
- * else if(name != null && name.length() > 0) { value = st.nextToken();
- * if(value.endsWith("]]"))value = value.substring(0, value.length()-1); }
- */
- if (name != null && name.trim().length() > 0) {
- row = sheet.createRow((short) ++rowNum);
- cellNum = 0;
- cell = row.createCell((short) cellNum);
- cell.setCellValue(name.trim());
- cell.setCellStyle(styleName);
- cellNum += 1;
- cell = row.createCell((short) cellNum);
- cell.setCellValue(value.trim());
- cell.setCellStyle(styleValue);
- // strBuf.append(name.trim()+": "+ value.trim()+"\n");
- }
- /*
- * if(token.endsWith(":") && (value!=null && value.trim().length()<=0) && (name!=null &&
- * name.trim().length()>0 && name.endsWith(":"))) { name = name.substring(0,
- * name.indexOf(":")+1); //value = token.substring(token.indexOf(":")+1); row =
- * sheet.createRow((short) ++rowNum); cellNum = 0; cell = row.createCell((short) cellNum);
- * cell.setCellValue(name.trim()); cell.setCellStyle(styleName); cellNum += 1; cell =
- * row.createCell((short) cellNum); cell.setCellValue(value.trim());
- * cell.setCellStyle(styleValue);
- *
- * //strBuf.append(name.trim()+": "+ value.trim()+"\n"); value = ""; name = ""; }
- */ }
- int cw = 0;
- cw = name.trim().length() + 12;
- // if(i!=cellWidth.size()-1)
- if (sheet.getColumnWidth((short) 0) < (short) name.trim().length())
- sheet.setColumnWidth((short) 0, (short) name.trim().length());
- if (sheet.getColumnWidth((short) 1) < (short) value.trim().length())
- sheet.setColumnWidth((short) 1, (short) value.trim().length());
- name = "";
- value = "";
-
- }
-
- try {
- SimpleDateFormat oracleDateFormat = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss");
- Date sysdate = oracleDateFormat.parse(ReportLoader.getSystemDateTime());
- SimpleDateFormat dtimestamp = new SimpleDateFormat(Globals.getScheduleDatePattern());
-
- row = sheet.createRow((short) ++rowNum);
- cellNum = 0;
- cell = row.createCell((short) cellNum);
- cell.setCellValue("Report Date/Time");
- cell.setCellStyle(styleName);
- cellNum += 1;
- cell = row.createCell((short) cellNum);
-
- cell.setCellValue(dtimestamp.format(sysdate) + " " + Globals.getTimeZone());
- cell.setCellStyle(styleValue);
-
- } catch (Exception ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "Excetion occured", ex);
- }
-
- }
- }
-
- /*
- * Iterator iter1 = paramsList.iterator(); s1 = 0; s2 = (short)10; if(iter1.hasNext()) { row =
- * sheet.createRow((short) ++rowNum); cellNum = 0; cell = row.createCell((short) cellNum);
- * sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
- * cell.setCellValue(strip.stripHtml(customizedParamInfo)); }
- */
- /*
- * rowNum += 2; row = sheet.createRow(rowNum);
- */
- } // if
+ cellDescr.setCellValue("Run-time Parameters");
+ cellDescr.setCellStyle(styleDescription);
+
+ //strBuf.append("Run-time Parameters\n");
+ StringTokenizer st = new StringTokenizer(s.trim(), "|");
+ while(st.hasMoreTokens()) {
+ token = st.nextToken();
+ token = token.trim();
+ if (!(token.trim().equals("|") || token.trim().equals("]]") || token.trim().equals("]") || token.trim().equals("[") )) {
+ if(token.endsWith(":")) {
+ name = token;
+ name = name.substring(0, name.length()-1);
+ if(name.startsWith("["))
+ name = name.substring(1);
+ value = st.nextToken();
+ if(nvl(value).endsWith("]"))value = nvl(value).substring(0, nvl(value).length()-1);
+ } /*else if(name != null && name.length() > 0) {
+ value = st.nextToken();
+ if(value.endsWith("]]"))value = value.substring(0, value.length()-1);
+ }*/
+ if(name!=null && name.trim().length()>0) {
+ row = sheet.createRow((short) ++rowNum);
+ cellNum = 0;
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue(name.trim());
+ cell.setCellStyle(styleName);
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue(value.trim());
+ cell.setCellStyle(styleValue);
+ //strBuf.append(name.trim()+": "+ value.trim()+"\n");
+ }
+/* if(token.endsWith(":") && (value!=null && value.trim().length()<=0) && (name!=null && name.trim().length()>0 && name.endsWith(":"))) {
+ name = name.substring(0, name.indexOf(":")+1);
+ //value = token.substring(token.indexOf(":")+1);
+ row = sheet.createRow((short) ++rowNum);
+ cellNum = 0;
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue(name.trim());
+ cell.setCellStyle(styleName);
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue(value.trim());
+ cell.setCellStyle(styleValue);
+
+ //strBuf.append(name.trim()+": "+ value.trim()+"\n");
+ value = "";
+ name = "";
+ }
+*/ }
+ int cw = 0;
+ cw = name.trim().length() + 12;
+ // if(i!=cellWidth.size()-1)
+ if(sheet.getColumnWidth((short)0)< (short) name.trim().length())
+ sheet.setColumnWidth((short)0, (short) name.trim().length());
+ if(sheet.getColumnWidth((short)1)< (short) value.trim().length())
+ sheet.setColumnWidth((short)1, (short) value.trim().length());
+ name = "";
+ value = "";
+
+ }
+
+ try {
+ SimpleDateFormat oracleDateFormat = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss");
+ Date sysdate = oracleDateFormat.parse(ReportLoader.getSystemDateTime());
+ SimpleDateFormat dtimestamp = new SimpleDateFormat(Globals.getScheduleDatePattern());
+
+ row = sheet.createRow((short) ++rowNum);
+ cellNum = 0;
+ cell = row.createCell((short) cellNum);
+ cell.setCellValue("Report Date/Time");
+ cell.setCellStyle(styleName);
+ cellNum += 1;
+ cell = row.createCell((short) cellNum);
+
+ cell.setCellValue(dtimestamp.format(sysdate)+" "+Globals.getTimeZone());
+ cell.setCellStyle(styleValue);
+
+ } catch(Exception ex) {
+ //ex.printStackTrace();
+ }
+
+
+ }
+ }
+
+
+/* Iterator iter1 = paramsList.iterator();
+ s1 = 0; s2 = (short)10;
+ if(iter1.hasNext()) {
+ row = sheet.createRow((short) ++rowNum);
+ cellNum = 0;
+ cell = row.createCell((short) cellNum);
+ sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, s1, s2));
+ cell.setCellValue(strip.stripHtml(customizedParamInfo));
+ }
+*/
+/* rowNum += 2;
+ row = sheet.createRow(rowNum);*/
+ } // if
Iterator iterCheck = paramsList.iterator();
- if (iterCheck.hasNext()) {
+ if(iterCheck.hasNext()) {
rowNum += 2;
row = sheet.createRow(rowNum);
}
- header.setCenter(HSSFHeader.font(FONT_TAHOMA, "") + HSSFHeader.fontSize((short) FONT_HEADER_TITLE_SIZE)
- + strBuf.toString());
+ header.setCenter(HSSFHeader.font("Tahoma", "")+ HSSFHeader.fontSize((short) font_header_title_size)+strBuf.toString());
}
-
- // Trying different -->
- public void createHTMLFileContent(Writer out, ReportData rd,
- ReportRuntime rr, String sql_whole, HttpServletRequest request, HttpServletResponse response)
- throws RaptorException, IOException {
- // response.setContentType("application/vnd.ms-excel");
- // response.setHeader("Content-disposition",
- // "attachment; filename=" +
- // "Example.xls" );
- PrintWriter csvOut = response.getWriter();
- HtmlStripper strip = new HtmlStripper();
- ResultSet rs = null;
+
+ // Trying different -->
+ public void createHTMLFileContent(Writer out, ReportData rd,
+ ReportRuntime rr, String sql_whole, HttpServletRequest request, HttpServletResponse response)
+ throws RaptorException, IOException {
+ //response.setContentType("application/vnd.ms-excel");
+ //response.setHeader("Content-disposition",
+ // "attachment; filename=" +
+ // "Example.xls" );
+ PrintWriter csvOut = response.getWriter();
+ HtmlStripper strip = new HtmlStripper();
+ ResultSet rs = null;
Connection conn = null;
Statement st = null;
ResultSetMetaData rsmd = null;
ColumnHeaderRow chr = null;
- int mb = 1024 * 1024;
- Runtime runtime = Runtime.getRuntime();
- csvOut.println("<HTML>\n" +
+ int mb = 1024*1024;
+ Runtime runtime = Runtime.getRuntime();
+ csvOut.println("<HTML>\n" +
"<HEAD><TITLE>" + rr.getReportName() + "</TITLE></HEAD>\n" +
- "<BODY>\n");
- System.out.println("HTML-Excel Generation Triggered: " + new java.util.Date());
- csvOut.print("<TABLE>");
+ "<BODY>\n" );
+ System.out.println("HTML-Excel Generation Triggered: " + new java.util.Date());
+ csvOut.print("<TABLE>");
if (Globals.getPrintParamsInCSVDownload()) {
- ArrayList paramsList = rr.getParamNameValuePairsforPDFExcel(request, 1);
+ ArrayList paramsList = rr.getParamNameValuePairsforPDFExcel(request, 1);
int paramSeq = 0;
- for (Iterator iter = paramsList.iterator(); iter.hasNext();) {
- IdNameValue value = (IdNameValue) iter.next();
- // System.out.println("\"" + value.getId() + " = " + value.getName() + "\"");
- if (nvl(value.getId()).trim().length() > 0 && (!nvl(value.getId()).trim().equals("BLANK"))) {
- paramSeq += 1;
- if (paramSeq <= 1) {
- csvOut.println("<TR><TD COLSPAN=\"2\">" + RUNTIME_PARAMETERS + "</TD></TR>");
- // strBuf.append("Run-time Parameters\n");
- }
- csvOut.println("<TR><TD>" + value.getId() + "</TD>");
- csvOut.println("<TD>" + value.getName().replaceAll("~", ",") + "</TD>");
- csvOut.println("</TR>");
-
- // strBuf.append(value.getId()+": "+ value.getName()+"\n");
- }
- } // for
- csvOut.println("<TR><TD COLSPAN=\"2\"> &nbsp;</TD></TR>");
- csvOut.println("<TR><TD COLSPAN=\"2\"> &nbsp;</TD></TR>");
- System.out.println("HTML-Excel: Header Rendering complete " + new java.util.Date());
+ for (Iterator iter = paramsList.iterator(); iter.hasNext();) {
+ IdNameValue value = (IdNameValue) iter.next();
+ //System.out.println("\"" + value.getId() + " = " + value.getName() + "\"");
+ if(nvl(value.getId()).trim().length()>0 && (!nvl(value.getId()).trim().equals("BLANK"))) {
+ paramSeq += 1;
+ if(paramSeq <= 1) {
+ csvOut.println("<TR><TD COLSPAN=\"2\">" + "Run-time Parameters" + "</TD></TR>");
+ //strBuf.append("Run-time Parameters\n");
+ }
+ csvOut.println("<TR><TD>" + value.getId() +"</TD>");
+ csvOut.println("<TD>" + value.getName().replaceAll("~",",")+ "</TD>");
+ csvOut.println("</TR>");
+
+ //strBuf.append(value.getId()+": "+ value.getName()+"\n");
+ }
+ } //for
+ csvOut.println("<TR><TD COLSPAN=\"2\"> &nbsp;</TD></TR>");
+ csvOut.println("<TR><TD COLSPAN=\"2\"> &nbsp;</TD></TR>");
+ System.out.println("HTML-Excel: Header Rendering complete " + new java.util.Date());
}
int rowCount = 0;
- if (nvl(sql_whole).length() > 0) {
- try {
- conn = ConnectionUtils.getConnection(rr.getDbInfo());
- st = conn.createStatement();
- Log.write("[SQL] " + sql_whole, 4);
- int downloadLimit = Globals.getDownloadLimit();
- Callable<ResultSet> callable = new ExecuteQuery(st, sql_whole, downloadLimit);
- ExecutorService executor = new ScheduledThreadPoolExecutor(5);
- System.out.println("Time Started" + new java.util.Date());
- Future<ResultSet> future = executor.submit(callable);
- try {
- rs = future.get(900, TimeUnit.SECONDS);
- } catch (TimeoutException ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "TimeoutException occured", ex);
- logger.debug(EELFLoggerDelegate.debugLogger, "Cancelling Query");
- st.cancel();
- logger.debug(EELFLoggerDelegate.debugLogger, "Query Cancelled");
- throw new Exception("user requested");
- }
- rsmd = rs.getMetaData();
- int numberOfColumns = rsmd.getColumnCount();
- HashMap colHash = new HashMap();
-
- if (rd != null) {
- for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) {
- chr = rd.reportColumnHeaderRows.getNext();
- csvOut.println("<TR>");
- if (chr != null) {
- for (chr.resetNext(); chr.hasNext();) {
- ColumnHeader ch = chr.getNext();
- if (ch.isVisible()) {
- csvOut.print("<TD bgColor=\"8F9381\">" + ch.getColumnTitle() + "</TD>");
- // for (int i = 1; i < ch.getColSpan(); i++)
- // csvOut.print(",");
-
- }
- } // for
- }
- csvOut.println("</TR>");
- } // for
-
- while (rs.next()) {
- csvOut.println("<TR>");
- /*
- * if(runtime.freeMemory()/mb <= ((runtime.maxMemory()/mb)*Globals.getMemoryThreshold()/100) ) {
- * csvOut.print(Globals.getUserDefinedMessageForMemoryLimitReached() + " " + rowCount
- * +"records out of " + rr.getReportDataSize() + " were downloaded to CSV."); break; }
- */ rowCount++;
- colHash = new HashMap();
- for (int i = 1; i <= numberOfColumns; i++) {
- colHash.put(rsmd.getColumnName(i), rs.getString(i));
- }
- if (chr != null) {
- for (chr.resetNext(); chr.hasNext();) {
- ColumnHeader ch = chr.getNext();
- if (ch.isVisible()) {
- csvOut.println("<TD>"
- + strip.stripCSVHtml(
- nvl((String) colHash.get(ch.getLinkColId().toUpperCase())))
- + "</TD>");
- }
-
- }
- }
- csvOut.println("</TR>");
- }
- System.out.println("Downloaded Rows in HTML-Excel " + rowCount + " : " + new java.util.Date());
- if (rowCount == 0) {
- csvOut.print("<TR><TD COLSPAN=\"" + numberOfColumns + "\">No Data Found</TD></TR>");
- } else {
- }
- } else {
- csvOut.println("<TR><TD COLSPAN=\"" + numberOfColumns + "\">No Data Found</TD></TR>");
- }
- csvOut.println("</TABLE></BODY>\n</HTML>");
-
- } catch (Exception ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "Exception occured", ex);
- throw new RaptorException(ex);
- } finally {
- try {
- if (conn != null)
- conn.close();
- if (st != null)
- st.close();
- if (rs != null)
- rs.close();
- } catch (SQLException ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "SQLException occured", ex);
- }
- }
- // csvOut.flush();
+ if(nvl(sql_whole).length()>0) {
+ try {
+ conn = ConnectionUtils.getConnection(rr.getDbInfo());
+ st = conn.createStatement();
+ Log.write("[SQL] " + sql_whole, 4);
+ int downloadLimit = Globals.getDownloadLimit();
+ Callable<ResultSet> callable = new ExecuteQuery(st, sql_whole, downloadLimit);
+ ExecutorService executor = new ScheduledThreadPoolExecutor(5);
+ System.out.println("Time Started" + new java.util.Date());
+ Future<ResultSet> future = executor.submit(callable);
+ try {
+ rs = future.get(900, TimeUnit.SECONDS);
+ } catch (TimeoutException ex) {
+ System.out.println("Cancelling Query");
+ st.cancel();
+ System.out.println("Query Cancelled");
+ throw new Exception("user requested");
+ }
+ rsmd = rs.getMetaData();
+ int numberOfColumns = rsmd.getColumnCount();
+ HashMap colHash = new HashMap();
+
+ if(rd!=null) {
+ for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) {
+ chr = rd.reportColumnHeaderRows.getNext();
+ csvOut.println("<TR>");
+ if(chr!=null){
+ for (chr.resetNext(); chr.hasNext();) {
+ ColumnHeader ch = chr.getNext();
+ if(ch.isVisible()) {
+ csvOut.print("<TD bgColor=\"8F9381\">" + ch.getColumnTitle() + "</TD>");
+ //for (int i = 1; i < ch.getColSpan(); i++)
+ // csvOut.print(",");
+
+ }
+ } // for
+ }
+ csvOut.println("</TR>");
+ } // for
+
+
+ while(rs.next()) {
+ csvOut.println("<TR>");
+/* if(runtime.freeMemory()/mb <= ((runtime.maxMemory()/mb)*Globals.getMemoryThreshold()/100) ) {
+ csvOut.print(Globals.getUserDefinedMessageForMemoryLimitReached() + " " + rowCount +"records out of " + rr.getReportDataSize() + " were downloaded to CSV.");
+ break;
+ }
+*/ rowCount++;
+ colHash = new HashMap();
+ for (int i = 1; i <= numberOfColumns; i++) {
+ colHash.put(rsmd.getColumnName(i), rs.getString(i));
+ }
+ for (chr.resetNext(); chr.hasNext();) {
+ ColumnHeader ch = chr.getNext();
+ if(ch.isVisible()) {
+ csvOut.println("<TD>" + strip.stripCSVHtml(nvl((String)colHash.get(ch.getLinkColId().toUpperCase()))) + "</TD>");
+ }
+
+ }
+ csvOut.println("</TR>");
+ }
+ System.out.println("Downloaded Rows in HTML-Excel " + rowCount + " : "+ new java.util.Date());
+ if(rowCount == 0) {
+ csvOut.print("<TR><TD COLSPAN=\""+ numberOfColumns + "\">No Data Found</TD></TR>");
+ } else {
+ }
+ } else {
+ csvOut.println("<TR><TD COLSPAN=\""+ numberOfColumns + "\">No Data Found</TD></TR>");
+ }
+ csvOut.println("</TABLE></BODY>\n</HTML>");
+
+ } catch (SQLException ex) {
+ throw new RaptorException(ex);
+ } catch (ReportSQLException ex) {
+ throw new RaptorException(ex);
+ } catch (Exception ex) {
+ throw new RaptorException (ex);
+ } finally {
+ try {
+ if(conn!=null)
+ conn.close();
+ if(st!=null)
+ st.close();
+ if(rs!=null)
+ rs.close();
+ } catch (SQLException ex) {
+ throw new RaptorException(ex);
+ }
+ }
+ //csvOut.flush();
} else {
- boolean firstPass = true;
- int numberOfColumns = 0;
- if (rd != null) {
- for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) {
- chr = rd.reportColumnHeaderRows.getNext();
- csvOut.println("<TR>");
- for (rd.reportRowHeaderCols.resetNext(1); rd.reportRowHeaderCols.hasNext();) {
- RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
-
- if (firstPass) {
- numberOfColumns++;
- csvOut.print("<TD bgColor=\"8F9381\">" + rhc.getColumnTitle() + "</TD>");
- }
- // csvOut.print(",");
- } // for
-
- for (chr.resetNext(); chr.hasNext();) {
- ColumnHeader ch = chr.getNext();
- if (ch.isVisible()) {
- if (firstPass)
- numberOfColumns++;
- csvOut.print("<TD bgColor=\"8F9381\">" + ch.getColumnTitle() + "</TD>");
- // for (int i = 1; i < ch.getColSpan(); i++)
- // csvOut.print(",");
- }
- } // for
- firstPass = false;
- csvOut.println("</TR>");
- } // for
-
- firstPass = true;
- for (rd.reportDataRows.resetNext(); rd.reportDataRows.hasNext();) {
- DataRow dr = rd.reportDataRows.getNext();
- csvOut.println("<TR>");
- for (rd.reportRowHeaderCols.resetNext(1); rd.reportRowHeaderCols.hasNext();) {
- RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
- if (firstPass)
- rhc.resetNext();
- RowHeader rh = rhc.getNext();
-
- csvOut.print("<TD bgColor=\"8F9381\">" + strip.stripCSVHtml(rh.getRowTitle()) + "</TD>");
- } // for
- firstPass = false;
-
- for (dr.resetNext(); dr.hasNext();) {
- DataValue dv = dr.getNext();
- if (dv.isVisible())
- csvOut.print(
- "<TD bgColor=\"8F9381\">" + strip.stripCSVHtml(dv.getDisplayValue()) + "</TD>");
- } // for
-
- csvOut.println("</TR>");
-
- } // for
- // csvOut.flush();
- } else {
- csvOut.println("<TR><TD COLSPAN=\"" + numberOfColumns + "\">No Data Found</TD></TR>");
- }
- }
- csvOut.println("</TABLE></BODY>\n</HTML>");
- System.out.println("HTML-Excel Generation: Data Rendering complete " + new java.util.Date());
- System.out.println("##### Heap utilization statistics [MB] #####");
- System.out.println("Used Memory:"
- + (runtime.maxMemory() - runtime.freeMemory()) / mb);
- System.out.println("Free Memory:"
- + runtime.freeMemory() / mb);
- System.out.println("Total Memory:" + runtime.totalMemory() / mb);
- System.out.println("Max Memory:" + runtime.maxMemory() / mb);
-
- } // createCSVFileContent
-
- /**
- * Checking if every row and cell in merging region exists, and create those which are not
- *
- * @param sheet in which check is performed
- * @param region to check
- * @param cellStyle cell style to apply for whole region
- */
- private void cleanBeforeMergeOnValidCells(XSSFSheet sheet, CellRangeAddress region, XSSFCellStyle cellStyle) {
- for (int rowNum = region.getFirstRow(); rowNum <= region.getLastRow(); rowNum++) {
- XSSFRow row = sheet.getRow(rowNum);
- if (row == null) {
- sheet.createRow(rowNum);
- }
- if (row != null) {
- for (int colNum = region.getFirstColumn(); colNum <= region.getLastColumn(); colNum++) {
- XSSFCell currentCell = row.getCell(colNum);
- if (currentCell == null) {
- currentCell = row.createCell(colNum);
- }
- currentCell.setCellStyle(cellStyle);
- }
- }
+ boolean firstPass = true;
+ int numberOfColumns = 0;
+ if(rd!=null) {
+ for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) {
+ chr = rd.reportColumnHeaderRows.getNext();
+ csvOut.println("<TR>");
+ for (rd.reportRowHeaderCols.resetNext(1); rd.reportRowHeaderCols.hasNext();) {
+ RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
+
+ if (firstPass) {
+ numberOfColumns++;
+ csvOut.print("<TD bgColor=\"8F9381\">" + rhc.getColumnTitle() + "</TD>");
+ }
+ //csvOut.print(",");
+ } // for
+
+
+ for (chr.resetNext(); chr.hasNext();) {
+ ColumnHeader ch = chr.getNext();
+ if(ch.isVisible()) {
+ if(firstPass) numberOfColumns++;
+ csvOut.print("<TD bgColor=\"8F9381\">" + ch.getColumnTitle() + "</TD>");
+ //for (int i = 1; i < ch.getColSpan(); i++)
+ //csvOut.print(",");
+ }
+ } // for
+ firstPass = false;
+ csvOut.println("</TR>");
+ } // for
+
+ firstPass = true;
+ for (rd.reportDataRows.resetNext(); rd.reportDataRows.hasNext();) {
+ DataRow dr = rd.reportDataRows.getNext();
+ csvOut.println("<TR>");
+ for (rd.reportRowHeaderCols.resetNext(1); rd.reportRowHeaderCols.hasNext();) {
+ RowHeaderCol rhc = rd.reportRowHeaderCols.getNext();
+ if (firstPass)
+ rhc.resetNext();
+ RowHeader rh = rhc.getNext();
+
+ csvOut.print("<TD bgColor=\"8F9381\">" + strip.stripCSVHtml(rh.getRowTitle()) + "</TD>");
+ } // for
+ firstPass = false;
+
+ for (dr.resetNext(); dr.hasNext();) {
+ DataValue dv = dr.getNext();
+ if(dv.isVisible())
+ csvOut.print("<TD bgColor=\"8F9381\">" + strip.stripCSVHtml(dv.getDisplayValue()) + "</TD>");
+ } // for
+
+ csvOut.println("</TR>");
+
+ } // for
+ //csvOut.flush();
+ } else {
+ csvOut.println("<TR><TD COLSPAN=\""+ numberOfColumns + "\">No Data Found</TD></TR>");
}
- }
+ }
+ csvOut.println("</TABLE></BODY>\n</HTML>");
+ System.out.println("HTML-Excel Generation: Data Rendering complete " + new java.util.Date());
+ System.out.println("##### Heap utilization statistics [MB] #####");
+ System.out.println("Used Memory:"
+ + (runtime.maxMemory() - runtime.freeMemory()) / mb);
+ System.out.println("Free Memory:"
+ + runtime.freeMemory() / mb);
+ System.out.println("Total Memory:" + runtime.totalMemory() / mb);
+ System.out.println("Max Memory:" + runtime.maxMemory() / mb);
+
+ } // createCSVFileContent
+
+ /**
+ * Checking if every row and cell in merging region exists, and create those which are not
+ * @param sheet in which check is performed
+ * @param region to check
+ * @param cellStyle cell style to apply for whole region
+ */
+ private void cleanBeforeMergeOnValidCells(XSSFSheet sheet,CellRangeAddress region, XSSFCellStyle cellStyle )
+ {
+ for(int rowNum =region.getFirstRow();rowNum<=region.getLastRow();rowNum++){
+ XSSFRow row= sheet.getRow(rowNum);
+ if(row==null){
+ sheet.createRow(rowNum);
+ }
+ if(row!=null){
+ for(int colNum=region.getFirstColumn();colNum<=region.getLastColumn();colNum++){
+ XSSFCell currentCell = row.getCell(colNum);
+ if(currentCell==null){
+ currentCell = row.createCell(colNum);
+ }
+
+ currentCell.setCellStyle(cellStyle);
+
+ }
+ }
+
+ }
+
+
+ }
} // ReportHandler
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java
index 1dce0e36..b76be5c2 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- *
+ *
*/
package org.onap.portalsdk.analytics.model.base;
@@ -113,3256 +113,3473 @@ import org.onap.portalsdk.core.util.SecurityCodecUtil;
import org.owasp.esapi.ESAPI;
/**<HR/>
- * This class is part of <B><I>RAPTOR (Rapid Application Programming Tool for OLAP Reporting)</I></B><BR/>
+ * This class is part of <B><I>RAPTOR (Rapid Application Programming Tool for OLAP Reporting)</I></B><BR/>
* <HR/>
*
* --------------------------------------------------------------------------------------------------<BR/>
- * <B>ReportWrapper.java</B> - This is the base class for the RAPTOR. This involves in creating,<BR/>
- * modifying, running RAPTOR reports.<BR/>
+ * <B>ReportWrapper.java</B> - This is the base class for the RAPTOR. This involves in creating,<BR/>
+ * modifying, running RAPTOR reports.<BR/>
* --------------------------------------------------------------------------------------------------<BR/>
*
*
* <U>Change Log</U><BR/><BR/>
*
- * 31-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> All the elements in the meta xml is copied to the target reports. </LI></UL>
- * 18-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> request Object is passed to prevent caching user/roles - Datamining/Hosting. </LI></UL>
+ * 31-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> All the elements in the meta xml is copied to the target reports. </LI></UL>
+ * 18-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> request Object is passed to prevent caching user/roles - Datamining/Hosting. </LI></UL>
* 27-Jul-2009 : Version 8.4 (Sundar); <UL><LI> verifySQLBasedReportAccess method checks for Admin user instead of super user. </LI></UL>
* 09-Jul-2009 : Version 8.4 (Sundar); <UL><LI> Bug due to parsing and removing formfields from "and" is bulletproofed to the right "and" to which the formfield is associated. </LI></UL>
* 08-Jul-2009 : Version 8.4 (Sundar); <UL><LI> Bug due to parsing and removing formfields when there is no parameter for Daytona specific database is resolved. </LI></UL>
* 29-Jun-2009 : Version 8.4 (Sundar); <UL><LI> isLastSeriesALineChart() and setLastSeriesALineChart(String value) method have been added for the Bar Chart enhancements. </LI></UL>
- * 23-Jun-2009 : Version 8.4 (Sundar); <UL><LI> check for cr.getChartAdditionalOptions() for null value is added.</LI></UL>
- * 22-Jun-2009 : Version 8.4 (Sundar); <UL><LI> Wrapper functions to call JAXB were added. These Wrapper
- * functions are related to the Pareto chart, Time Difference Chart, Multiple Pie Chart and generic Chart Options.</LI></UL>
+ * 23-Jun-2009 : Version 8.4 (Sundar); <UL><LI> check for cr.getChartAdditionalOptions() for null value is added.</LI></UL>
+ * 22-Jun-2009 : Version 8.4 (Sundar); <UL><LI> Wrapper functions to call JAXB were added. These Wrapper
+ * functions are related to the Pareto chart, Time Difference Chart, Multiple Pie Chart and generic Chart Options.</LI></UL>
*
*/
-public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject {
+public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject {
- private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportWrapper.class);
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportWrapper.class);
protected CustomReportType cr = null;
- protected Vector allColumns = null;
-
- protected Vector allVisibleColumns = null;
-
- protected Vector allFilters = null;
-
- protected String generatedSQL = null;
-
- protected String generatedChartSQL = null;
-
- protected String wholeSQL = null; // For display purposes only
-
-
- protected String reportID = null;
-
- protected String menuID = "";
-
- protected boolean menuApproved = false;
-
- protected String reportDefType = "";
-
- protected ReportSecurity reportSecurity = null;
-
- protected String reportSQLWithRowNum = null;
-
- protected String reportSQLOnlyFirstPart = null;
-
-
- private ReportWrapper(CustomReportType cr, String reportID, ReportSecurity reportSecurity) {
- super();
-
- if (reportID == null)
- reportID = "-1";
-
- this.cr = cr;
- this.reportID = reportID;
-
- this.reportSecurity = reportSecurity;
- } // ReportWrapper
-
- public ReportWrapper(ReportWrapper rw) {
- this(rw.getCustomReport(), // .cloneCustomReport()
- rw.getReportID(), rw.reportSecurity);
-
- this.menuID = rw.getMenuID();
- this.menuApproved = rw.isMenuApproved();
-
- this.reportDefType = rw.getReportDefType();
- } // ReportWrapper
-
- public ReportWrapper(CustomReportType cr, String reportID, String ownerID, String createID,
- String createDate, String updateID, String updateDate, String menuID,
- boolean menuApproved) throws RaptorException {
- this(cr, reportID, null);
-
- if (ownerID == null)
- // Need to load the report record from the database
- if (!reportID.equals("-1"))
- try {
- /*DataSet ds = DbUtils
- .executeQuery("SELECT NVL(cr.owner_id, cr.create_id) owner_id, cr.create_id, TO_CHAR(cr.create_date, '"
- + Globals.getOracleTimeFormat()
- + "') create_date, maint_id, TO_CHAR(cr.maint_date, '"
- + Globals.getOracleTimeFormat()
- + "') update_date, cr.menu_id, cr.menu_approved_yn FROM cr_report cr WHERE cr.rep_id="
- + reportID);*/
-
- String r_sql = Globals.getReportWrapperFormat();
- r_sql = r_sql.replace("[Globals.getTimeFormat()]", Globals.getTimeFormat());
- r_sql = r_sql.replace("[reportID]", reportID);
-
- DataSet ds = DbUtils
- .executeQuery(r_sql);
-
- ownerID = ds.getString(0, 0);
- createID = ds.getString(0, 1);
- createDate = ds.getString(0, 2);
- updateID = ds.getString(0, 3);
- updateDate = ds.getString(0, 4);
- menuID = nvl(ds.getString(0, 5));
- menuApproved = nvl(ds.getString(0, 6)).equals("Y");
- } catch (Exception e) {
- String eMsg = "ReportWrapper.ReportWrapper: Unable to load report record details. Exception: "
- + e.getMessage();
- //Log.write(eMsg);
- logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] "+ eMsg));
- throw new RaptorRuntimeException(eMsg);
- }
-
- this.menuID = nvl(menuID);
- this.menuApproved = menuApproved;
-
- if (!reportID.equals("-1"))
- updateReportDefType();
-
- reportSecurity = new ReportSecurity(reportID, ownerID, createID, createDate, updateID,
- updateDate, cr.isPublic());
- } // ReportWrapper
-
- public CustomReportType getCustomReport() {
- return cr;
- }
-
- public String getReportID() {
- return reportID;
- }
-
- public String getMenuID() {
- return menuID;
- }
-
- public boolean checkMenuIDSelected(String chkMenuID) {
- return ("|" + menuID + "|").indexOf("|" + chkMenuID + "|") >= 0;
- }
-
- public boolean isMenuApproved() {
- return menuApproved;
- }
-
- public String getReportDefType() {
- return reportDefType;
- }
-
- public void setMenuID(String menuID) {
- this.menuID = menuID;
- }
-
- public void setMenuApproved(boolean menuApproved) {
- this.menuApproved = menuApproved;
- }
-
- public void setReportDefType(String reportDefType) {
- this.reportDefType = reportDefType;
- }
-
- public void updateReportDefType() {
- this.reportDefType = (nvl(cr.getReportSQL()).length() > 0) ? ((cr.getDataminingOptions()!=null && nvl(cr.getDataminingOptions().getClassifier()).length()>0) ?
- AppConstants.RD_SQL_BASED_DATAMIN:AppConstants.RD_SQL_BASED)
- : AppConstants.RD_VISUAL;
- }
-
- public String getJavascriptElement() {
- return cr.getJavascriptElement();
- }
-
- public int getPageSize() {
- return cr.getPageSize()==null?50:cr.getPageSize();
- }
-
- public int getMaxRowsInExcelDownload() {
- return cr.getMaxRowsInExcelDownload()==null?500:cr.getMaxRowsInExcelDownload();
- }
+ protected Vector allColumns = null;
+
+ protected Vector allVisibleColumns = null;
+
+ protected Vector allFilters = null;
+
+ protected String generatedSQL = null;
+
+ protected String generatedChartSQL = null;
+
+ protected String wholeSQL = null; // For display purposes only
+
+ protected String reportID = null;
+
+ protected String menuID = "";
+
+ protected boolean menuApproved = false;
+
+ protected String reportDefType = "";
+
+ protected ReportSecurity reportSecurity = null;
+
+ protected String reportSQLWithRowNum = null;
+
+ protected String reportSQLOnlyFirstPart = null;
+
+ private ReportWrapper(CustomReportType cr, String reportID, ReportSecurity reportSecurity) {
+ super();
+
+ if (reportID == null)
+ reportID = "-1";
+
+ this.cr = cr;
+ this.reportID = reportID;
+
+ this.reportSecurity = reportSecurity;
+ } // ReportWrapper
+
+ public ReportWrapper(ReportWrapper rw) {
+ this(rw.getCustomReport(), // .cloneCustomReport()
+ rw.getReportID(), rw.reportSecurity);
+
+ this.menuID = rw.getMenuID();
+ this.menuApproved = rw.isMenuApproved();
+
+ this.reportDefType = rw.getReportDefType();
+ } // ReportWrapper
+
+ public ReportWrapper(CustomReportType cr, String reportID, String ownerID, String createID,
+ String createDate, String updateID, String updateDate, String menuID,
+ boolean menuApproved) throws RaptorException {
+ this(cr, reportID, null);
+
+ if (ownerID == null && !"-1".equals(reportID)) {
+ // Need to load the report record from the database
+ try {
+ /*
+ * DataSet ds = DbUtils
+ * .executeQuery("SELECT NVL(cr.owner_id, cr.create_id) owner_id, cr.create_id, TO_CHAR(cr.create_date, '"
+ * + Globals.getOracleTimeFormat() + "') create_date, maint_id, TO_CHAR(cr.maint_date, '" +
+ * Globals.getOracleTimeFormat() +
+ * "') update_date, cr.menu_id, cr.menu_approved_yn FROM cr_report cr WHERE cr.rep_id=" + reportID);
+ */
+
+ String rSql = Globals.getReportWrapperFormat();
+ rSql = rSql.replace("[Globals.getTimeFormat()]", Globals.getTimeFormat());
+ rSql = rSql.replace("[reportID]", reportID);
+
+ DataSet ds = DbUtils
+ .executeQuery(rSql);
+
+ ownerID = ds.getString(0, 0);
+ createID = ds.getString(0, 1);
+ createDate = ds.getString(0, 2);
+ updateID = ds.getString(0, 3);
+ updateDate = ds.getString(0, 4);
+ menuID = nvl(ds.getString(0, 5));
+ menuApproved = nvl(ds.getString(0, 6)).equals("Y");
+ } catch (Exception e) {
+ String eMsg = "ReportWrapper.ReportWrapper: Unable to load report record details. Exception: ";
+ // Log.write(eMsg);
+ logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] " + eMsg), e);
+ throw new RaptorRuntimeException(eMsg);
+ }
+ }
+ this.menuID = nvl(menuID);
+ this.menuApproved = menuApproved;
+
+ if (!"-1".equals(reportID)) {
+ updateReportDefType();
+ }
+
+ reportSecurity = new ReportSecurity(reportID, ownerID, createID, createDate, updateID,
+ updateDate, cr.isPublic());
+ } // ReportWrapper
+
+ public CustomReportType getCustomReport() {
+ return cr;
+ }
+
+ public String getReportID() {
+ return reportID;
+ }
+
+ public String getMenuID() {
+ return menuID;
+ }
+
+ public boolean checkMenuIDSelected(String chkMenuID) {
+ return ("|" + menuID + "|").indexOf("|" + chkMenuID + "|") >= 0;
+ }
+
+ public boolean isMenuApproved() {
+ return menuApproved;
+ }
+
+ public String getReportDefType() {
+ return reportDefType;
+ }
+
+ public void setMenuID(String menuID) {
+ this.menuID = menuID;
+ }
+
+ public void setMenuApproved(boolean menuApproved) {
+ this.menuApproved = menuApproved;
+ }
+
+ public void setReportDefType(String reportDefType) {
+ this.reportDefType = reportDefType;
+ }
+
+ public void updateReportDefType() {
+ this.reportDefType = (nvl(cr.getReportSQL()).length() > 0)
+ ? ((cr.getDataminingOptions() != null && nvl(cr.getDataminingOptions().getClassifier()).length() > 0)
+ ? AppConstants.RD_SQL_BASED_DATAMIN
+ : AppConstants.RD_SQL_BASED)
+ : AppConstants.RD_VISUAL;
+ }
+
+ public String getJavascriptElement() {
+ return cr.getJavascriptElement();
+ }
+
+ public int getPageSize() {
+ return cr.getPageSize() == null ? 50 : cr.getPageSize();
+ }
+
+ public int getMaxRowsInExcelDownload() {
+ return cr.getMaxRowsInExcelDownload() == null ? 500 : cr.getMaxRowsInExcelDownload();
+ }
public boolean isDisplayFolderTree() {
- return cr.isDisplayFolderTree()!=null?cr.isDisplayFolderTree().booleanValue():false;
+ return cr.isDisplayFolderTree() != null ? cr.isDisplayFolderTree().booleanValue() : false;
+ }
+
+ public boolean isHideFormFieldAfterRun() {
+ return cr.isHideFormFieldAfterRun() != null ? cr.isHideFormFieldAfterRun().booleanValue() : false;
+ }
+
+ public void setHideFormFieldAfterRun(boolean hideFormFieldAfterRun) {
+ cr.setHideFormFieldAfterRun(hideFormFieldAfterRun);
}
-
- public boolean isHideFormFieldAfterRun() {
- return cr.isHideFormFieldAfterRun()!=null?cr.isHideFormFieldAfterRun().booleanValue():false;
- }
- public void setHideFormFieldAfterRun(boolean hideFormFieldAfterRun) {
- cr.setHideFormFieldAfterRun(hideFormFieldAfterRun);
- }
-
public boolean isReportInNewWindow() {
- return cr.isReportInNewWindow()!=null?cr.isReportInNewWindow().booleanValue():false;
+ return cr.isReportInNewWindow() != null ? cr.isReportInNewWindow().booleanValue() : false;
}
-
+
public String getReportType() {
- return cr.getReportType();
- }
-
- public String getReportName() {
- return cr.getReportName();
- }
-
- public String getDBInfo() {
- return cr.getDbInfo();
- }
-
- public String getDBType() {
- return cr.getDbType();
- }
-
- public boolean isDrillDownURLInPopupPresent() {
- return cr.isDrillURLInPoPUpPresent()!=null?cr.isDrillURLInPoPUpPresent().booleanValue():false;
- }
-
- public void setDrillDownURLInPopupPresent(boolean value) {
- cr.setDrillURLInPoPUpPresent(value);
- }
-
- public String getReportDescr() {
- return cr.getReportDescr();
- }
-
- public String getChartType() {
- return cr.getChartType();
- }
-
- public boolean displayChartTitle() {
- return cr.isShowChartTitle();
- }
-
- public void setShowChartTitle(boolean showTitle) {
- cr.setShowChartTitle(showTitle);
- }
-
-
- public String getChartTypeFixed() {
- return cr.getChartTypeFixed();
- }
-
- public boolean isChartTypeFixed() {
- return nvl(cr.getChartTypeFixed()).length() > 0 ? cr.getChartTypeFixed().equals("Y")
- : (!Globals.getAllowRuntimeChartSel());
- }
-
- public String getChartLeftAxisLabel() {
- return cr.getChartLeftAxisLabel();
- }
-
- public String getChartRightAxisLabel() {
- return cr.getChartRightAxisLabel();
- }
-
- public String getChartWidth() {
- return cr.getChartWidth();
- }
-
- public int getChartWidthAsInt() {
- return getIntValue(cr.getChartWidth(), Globals.getDefaultChartWidth());
- }
-
- public String getChartHeight() {
- return cr.getChartHeight()==null?"500":cr.getChartHeight();
- }
-
- /*public boolean isChartMultiSeries() {
- //String s = cr.getChartMultiSeries();
- return
- return (nvl(s).length()>0)? (s.equals("Y")||s.equals("y")||s.equalsIgnoreCase("true")?true:false):true;
- }*/
-
- public boolean displayPieOrderinRunPage() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getChartMultiplePieOrder():"";
- if(nvl(s).indexOf("|")!= -1) {
- s = s.substring(s.indexOf("|")+1);
- return getFlagInBoolean(s);
- } else return false;
- }
-
- public boolean isMultiplePieOrderByRow() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getChartMultiplePieOrder():"";
- if(nvl(s).indexOf("|")!= -1) s = s.substring(0, s.indexOf("|"));
- return (nvl(s).length()>0)? (s.equals("row")?true:false):true;
- }
-
- public boolean isMultiplePieOrderByColumn() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getChartMultiplePieOrder():"";
- if(nvl(s).indexOf("|")!= -1) s = s.substring(0, s.indexOf("|"));
- return (nvl(s).length()>0)&&(s.equals("column"))?true:false;
- }
-
- public boolean displayPieLabelDisplayinRunPage() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getChartMultiplePieLabelDisplay():"";
- if(nvl(s).indexOf("|")!= -1) {
- s = s.substring(s.indexOf("|")+1);
- return getFlagInBoolean(s);
- } else return false;
- }
-
- public String getMultiplePieLabelDisplay() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getChartMultiplePieLabelDisplay():"";
- if(nvl(s).indexOf("|")!= -1) s = s.substring(0, s.indexOf("|"));
- return s;
- }
-
- public boolean displayChartDisplayinRunPage() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getChartDisplay():"";
- if(nvl(s).indexOf("|")!= -1) {
- s = s.substring(s.indexOf("|")+1);
- return getFlagInBoolean(s);
- } else return false;
- }
-
- public boolean isChartDisplayIn3D() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getChartDisplay():"";
- if(nvl(s).length()<=0) return true;
- if(nvl(s).indexOf("|")!= -1) s = s.substring(0, s.indexOf("|"));
- return (nvl(s).length()>0)&&(s.equals("3D"))?true:false;
- }
-
- public boolean displayChartOrientationInRunPage() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getChartOrientation():"";
- if(nvl(s).indexOf("|")!= -1) {
- s = s.substring(s.indexOf("|")+1);
- return getFlagInBoolean(s);
- } else return false;
-
- }
-
- public String getLinearRegression() {
- String s = "";
- s = nvl((cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getLinearRegression():"Y");
- return s;
- }
-
- public void setLinearRegression(String linear) {
- cr.getChartAdditionalOptions().setLinearRegression(linear);
- }
-
- public String getLinearRegressionColor() {
- return (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getLinearRegressionColor():"";
- }
-
- public String getCustomizedRegressionPoint() {
- return (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getMaxRegression():"";
- }
-
- public void setCustomizedRegressionPoint( String d) {
- cr.getChartAdditionalOptions().setMaxRegression(d);
- }
-
- public void setLinearRegressionColor(String color) {
- cr.getChartAdditionalOptions().setLinearRegressionColor(color);
- }
-
- public String getExponentialRegressionColor() {
- return (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getExponentialRegressionColor():"";
- }
-
- public void setExponentialRegressionColor(String color) {
- cr.getChartAdditionalOptions().setExponentialRegressionColor(color);
- }
-
- public void setRangeAxisUpperLimit(String d) {
- if(cr.getChartAdditionalOptions()!=null)
- cr.getChartAdditionalOptions().setRangeAxisUpperLimit(d);
- }
-
- public void setRangeAxisLowerLimit(String d) {
- if(cr.getChartAdditionalOptions()!=null)
- cr.getChartAdditionalOptions().setRangeAxisLowerLimit(d);
- }
-
- public String getRangeAxisUpperLimit() {
- return (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getRangeAxisUpperLimit():"";
- }
-
- public String getRangeAxisLowerLimit() {
- return (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getRangeAxisLowerLimit():"";
- }
-
- public boolean isChartAnimate() {
- return (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().isAnimate()!=null?cr.getChartAdditionalOptions().isAnimate():false):false;
- }
-
- public boolean isAnimateAnimatedChart() {
- return (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().isAnimateAnimatedChart()!=null?cr.getChartAdditionalOptions().isAnimateAnimatedChart():false):true;
- }
-
- public void setAnimateAnimatedChart(boolean animate) {
- cr.getChartAdditionalOptions().setAnimateAnimatedChart(animate);
- }
-
- public void setChartStacked(boolean stacked) {
- cr.getChartAdditionalOptions().setStacked(stacked);
- }
-
- public boolean isChartStacked() {
- return (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().isStacked()!=null?cr.getChartAdditionalOptions().isStacked():true):false;
- }
-
- public void setBarControls(boolean barControls) {
- cr.getChartAdditionalOptions().setBarControls(barControls);
- }
-
- public boolean displayBarControls() {
- return (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().isBarControls()!=null?cr.getChartAdditionalOptions().isBarControls():false):false;
- }
-
- public void setXAxisDateType(boolean dateType) {
- cr.getChartAdditionalOptions().setXAxisDateType(dateType);
- }
-
- public boolean isXAxisDateType() {
- return (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().isXAxisDateType()!=null?cr.getChartAdditionalOptions().isXAxisDateType():false):false;
- }
-
- public void setLessXaxisTickers(boolean lessTickers) {
- cr.getChartAdditionalOptions().setLessXaxisTickers(lessTickers);
- }
-
- public boolean isLessXaxisTickers() {
- return (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().isLessXaxisTickers()!=null?cr.getChartAdditionalOptions().isLessXaxisTickers():false):false;
- }
-
- public void setTimeAxis(boolean timeAxis) {
- cr.getChartAdditionalOptions().setTimeAxis(timeAxis);
- }
-
- public boolean isTimeAxis() {
- return (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().isTimeAxis()!=null?cr.getChartAdditionalOptions().isTimeAxis():true):true;
- }
-
- public void setLogScale(boolean logScale) {
- cr.getChartAdditionalOptions().setLogScale(logScale);
- }
-
- public boolean isLogScale() {
- return (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().isLogScale()!=null?cr.getChartAdditionalOptions().isLogScale():false):false;
- }
-
-
- public void setMultiSeries(boolean multiSeries) {
- cr.getChartAdditionalOptions().setMultiSeries(multiSeries);
- cr.setChartMultiSeries(multiSeries?"Y":"N");
- }
-
- public boolean isMultiSeries() {
- if(AppUtils.nvl(cr.getChartMultiSeries()).equals("Y"))
- cr.getChartAdditionalOptions().setMultiSeries(true);
- return (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().isMultiSeries()!=null?cr.getChartAdditionalOptions().isMultiSeries():false):false;
- }
-
- public void setTimeSeriesRender(String timeSeriesRenderer) {
- cr.getChartAdditionalOptions().setTimeSeriesRender(timeSeriesRenderer);
- }
-
- public String getTimeSeriesRender() {
- return (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getTimeSeriesRender():"line";
- }
-
- public void setShowXAxisLabel(boolean showXaxisLabel) {
- cr.getChartAdditionalOptions().setShowXAxisLabel(showXaxisLabel);
- }
-
- public boolean isShowXaxisLabel() {
- return (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().isShowXAxisLabel()!=null?cr.getChartAdditionalOptions().isShowXAxisLabel():false):false;
- }
-
- public void setAddXAxisTickers(boolean addXAxisTickers) {
- cr.getChartAdditionalOptions().setAddXAxisTickers(addXAxisTickers);
- }
-
- public boolean isAddXAxisTickers() {
- return (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().isAddXAxisTickers()!=null?cr.getChartAdditionalOptions().isAddXAxisTickers():false):true;
- }
-
- public void setZoomIn(Integer zoomIn) {
- cr.getChartAdditionalOptions().setZoomIn(zoomIn);
- }
-
- public Integer getZoomIn() {
- return (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().getZoomIn()!=null?cr.getChartAdditionalOptions().getZoomIn():new Integer("25")): new Integer("25");
- }
-
- public void setTimeAxisType(String timeAxisType) {
- cr.getChartAdditionalOptions().setTimeAxisType(timeAxisType);
- }
-
- public String getTimeAxisType() {
- return (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().getTimeAxisType()!=null?cr.getChartAdditionalOptions().getTimeAxisType():"hourly"): "hourly";
- }
-
- public void setTopMargin(Integer topMargin) {
- cr.getChartAdditionalOptions().setTopMargin(topMargin);
- }
-
- public Integer getTopMargin() {
- return (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getTopMargin(): new Integer("30");
- }
-
- public void setBottomMargin(Integer bottomMargin) {
- cr.getChartAdditionalOptions().setBottomMargin(bottomMargin);
- }
-
- public Integer getBottomMargin() {
- return (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getBottomMargin(): new Integer("50");
- }
-
- public void setRightMargin(Integer rightMargin) {
- cr.getChartAdditionalOptions().setRightMargin(rightMargin);
- }
-
- public Integer getRightMargin() {
- return (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getRightMargin(): new Integer("60");
- }
-
- public void setLeftMargin(Integer leftMargin) {
- cr.getChartAdditionalOptions().setLeftMargin(leftMargin);
- }
-
- public Integer getLeftMargin() {
- return (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getLeftMargin(): new Integer("100");
- }
-
-
- public boolean isVerticalOrientation() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getChartOrientation():"";
- if(nvl(s).length()<=0) return true;
- if(nvl(s).indexOf("|")!= -1) s = s.substring(0, s.indexOf("|"));
- return (nvl(s).length()>0)&&(s.equals("vertical"))?true:false;
- }
-
- public boolean isHorizontalOrientation() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getChartOrientation():"";
- if(nvl(s).indexOf("|")!= -1) s = s.substring(0, s.indexOf("|"));
- return (nvl(s).length()>0)&&(s.equals("horizontal"))?true:false;
- }
-
- public boolean displaySecondaryChartRendererInRunPage() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getSecondaryChartRenderer():"";
- if(nvl(s).indexOf("|")!= -1) {
- s = s.substring(s.indexOf("|")+1);
- return getFlagInBoolean(s);
- } else return false;
-
- }
-
- public String getSecondaryChartRenderer() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getSecondaryChartRenderer():"";
- if(nvl(s).indexOf("|")!= -1) s = s.substring(0, s.indexOf("|"));
- return s;
- }
-
- public String getOverlayItemValueOnStackBar() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getOverlayItemValueOnStackBar():"N";
- return s;
- }
-
- public boolean displayIntervalInputInRunPage() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getIntervalFromdate():"";
- if(nvl(s).indexOf("|")!= -1) {
- s = s.substring(s.indexOf("|")+1);
- return getFlagInBoolean(s);
- } else return false;
- }
-
- public boolean showLegendDisplayOptionsInRunPage() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getHidechartLegend():"";
- if(nvl(s).indexOf("|")!= -1) {
- s = s.substring(s.indexOf("|")+1);
- return getFlagInBoolean(s);
- } else return false;
- }
-
- public String getIntervalFromdate() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getIntervalFromdate():"";
- if(nvl(s).indexOf("|")!= -1) s = s.substring(0, s.indexOf("|"));
- return nvl(s,"");
- }
-
- public String getIntervalTodate() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getIntervalTodate():"";
- if(nvl(s).indexOf("|")!= -1) s = s.substring(0, s.indexOf("|"));
- return nvl(s,"");
- }
-
- public String getIntervalLabel() {
- return cr.getChartAdditionalOptions()!=null ? nvl(cr.getChartAdditionalOptions().getIntervalLabel()):"";
- }
-
- public String getLegendPosition() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getLegendPosition():"";
- return nvl(s,"bottom");
- }
-
- public String getLegendLabelAngle() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getLabelAngle():"";
- return nvl(s,"UP90");
- }
-
- public String getMaxLabelsInDomainAxis() {
- String s = "";
- s = (cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getMaxLabelsInDomainAxis():"";
- return nvl(s,"99");
- }
-
- public boolean isLastSeriesALineChart() {
- String s = "";
- s = nvl((cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getLastSeriesALineChart():"");
- return s.equals("Y");
- }
-
- public boolean isLastSeriesABarChart() {
- String s = "";
- s = nvl((cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getLastSeriesABarChart():"");
- return s.equals("Y");
- }
-
- public void setChartLegendDisplay(String value) {
+ return cr.getReportType();
+ }
+
+ public String getReportName() {
+ return cr.getReportName();
+ }
+
+ public String getDBInfo() {
+ return cr.getDbInfo();
+ }
+
+ public String getDBType() {
+ return cr.getDbType();
+ }
+
+ public boolean isDrillDownURLInPopupPresent() {
+ return cr.isDrillURLInPoPUpPresent() != null ? cr.isDrillURLInPoPUpPresent().booleanValue() : false;
+ }
+
+ public void setDrillDownURLInPopupPresent(boolean value) {
+ cr.setDrillURLInPoPUpPresent(value);
+ }
+
+ public String getReportDescr() {
+ return cr.getReportDescr();
+ }
+
+ public String getChartType() {
+ return cr.getChartType();
+ }
+
+ public boolean displayChartTitle() {
+ return cr.isShowChartTitle();
+ }
+
+ public void setShowChartTitle(boolean showTitle) {
+ cr.setShowChartTitle(showTitle);
+ }
+
+ public String getChartTypeFixed() {
+ return cr.getChartTypeFixed();
+ }
+
+ public boolean isChartTypeFixed() {
+ return nvl(cr.getChartTypeFixed()).length() > 0 ? "Y".equals(cr.getChartTypeFixed())
+ : (!Globals.getAllowRuntimeChartSel());
+ }
+
+ public String getChartLeftAxisLabel() {
+ return cr.getChartLeftAxisLabel();
+ }
+
+ public String getChartRightAxisLabel() {
+ return cr.getChartRightAxisLabel();
+ }
+
+ public String getChartWidth() {
+ return cr.getChartWidth();
+ }
+
+ public int getChartWidthAsInt() {
+ return getIntValue(cr.getChartWidth(), Globals.getDefaultChartWidth());
+ }
+
+ public String getChartHeight() {
+ return cr.getChartHeight() == null ? "500" : cr.getChartHeight();
+ }
+
+ /*
+ * public boolean isChartMultiSeries() { //String s = cr.getChartMultiSeries(); return return
+ * (nvl(s).length()>0)? (s.equals("Y")||s.equals("y")||s.equalsIgnoreCase("true")?true:false):true;
+ * }
+ */
+
+ public boolean displayPieOrderinRunPage() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getChartMultiplePieOrder() : "";
+ if (nvl(s).indexOf("|") != -1) {
+ s = s.substring(s.indexOf("|") + 1);
+ return getFlagInBoolean(s);
+ } else
+ return false;
+ }
+
+ public boolean isMultiplePieOrderByRow() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getChartMultiplePieOrder() : "";
+ if (nvl(s).indexOf("|") != -1)
+ s = s.substring(0, s.indexOf("|"));
+ return (nvl(s).length() > 0) ? ("row".equals(s) ? true : false) : true;
+ }
+
+ public boolean isMultiplePieOrderByColumn() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getChartMultiplePieOrder() : "";
+ if (nvl(s).indexOf("|") != -1)
+ s = s.substring(0, s.indexOf("|"));
+ return (nvl(s).length() > 0) && ("column".equals(s)) ? true : false;
+ }
+
+ public boolean displayPieLabelDisplayinRunPage() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getChartMultiplePieLabelDisplay()
+ : "";
+ if (nvl(s).indexOf("|") != -1) {
+ s = s.substring(s.indexOf("|") + 1);
+ return getFlagInBoolean(s);
+ } else
+ return false;
+ }
+
+ public String getMultiplePieLabelDisplay() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getChartMultiplePieLabelDisplay()
+ : "";
+ if (nvl(s).indexOf("|") != -1)
+ s = s.substring(0, s.indexOf("|"));
+ return s;
+ }
+
+ public boolean displayChartDisplayinRunPage() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getChartDisplay() : "";
+ if (nvl(s).indexOf("|") != -1) {
+ s = s.substring(s.indexOf("|") + 1);
+ return getFlagInBoolean(s);
+ } else
+ return false;
+ }
+
+ public boolean isChartDisplayIn3D() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getChartDisplay() : "";
+ if (nvl(s).length() <= 0)
+ return true;
+ if (nvl(s).indexOf("|") != -1)
+ s = s.substring(0, s.indexOf("|"));
+ return (nvl(s).length() > 0) && ("3D".equals(s)) ? true : false;
+ }
+
+ public boolean displayChartOrientationInRunPage() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getChartOrientation() : "";
+ if (nvl(s).indexOf("|") != -1) {
+ s = s.substring(s.indexOf("|") + 1);
+ return getFlagInBoolean(s);
+ } else
+ return false;
+
+ }
+
+ public String getLinearRegression() {
+ String s = "";
+ s = nvl((cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getLinearRegression() : "Y");
+ return s;
+ }
+
+ public void setLinearRegression(String linear) {
+ cr.getChartAdditionalOptions().setLinearRegression(linear);
+ }
+
+ public String getLinearRegressionColor() {
+ return (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getLinearRegressionColor()
+ : "";
+ }
+
+ public String getCustomizedRegressionPoint() {
+ return (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getMaxRegression() : "";
+ }
+
+ public void setCustomizedRegressionPoint(String d) {
+ cr.getChartAdditionalOptions().setMaxRegression(d);
+ }
+
+ public void setLinearRegressionColor(String color) {
+ cr.getChartAdditionalOptions().setLinearRegressionColor(color);
+ }
+
+ public String getExponentialRegressionColor() {
+ return (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getExponentialRegressionColor()
+ : "";
+ }
+
+ public void setExponentialRegressionColor(String color) {
+ cr.getChartAdditionalOptions().setExponentialRegressionColor(color);
+ }
+
+ public void setRangeAxisUpperLimit(String d) {
+ if (cr.getChartAdditionalOptions() != null)
+ cr.getChartAdditionalOptions().setRangeAxisUpperLimit(d);
+ }
+
+ public void setRangeAxisLowerLimit(String d) {
+ if (cr.getChartAdditionalOptions() != null)
+ cr.getChartAdditionalOptions().setRangeAxisLowerLimit(d);
+ }
+
+ public String getRangeAxisUpperLimit() {
+ return (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getRangeAxisUpperLimit() : "";
+ }
+
+ public String getRangeAxisLowerLimit() {
+ return (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getRangeAxisLowerLimit() : "";
+ }
+
+ public boolean isChartAnimate() {
+ return (cr.getChartAdditionalOptions() != null)
+ ? (cr.getChartAdditionalOptions().isAnimate() != null ? cr.getChartAdditionalOptions().isAnimate()
+ : false)
+ : false;
+ }
+
+ public boolean isAnimateAnimatedChart() {
+ return (cr.getChartAdditionalOptions() != null)
+ ? (cr.getChartAdditionalOptions().isAnimateAnimatedChart() != null
+ ? cr.getChartAdditionalOptions().isAnimateAnimatedChart()
+ : false)
+ : true;
+ }
+
+ public void setAnimateAnimatedChart(boolean animate) {
+ cr.getChartAdditionalOptions().setAnimateAnimatedChart(animate);
+ }
+
+ public void setChartStacked(boolean stacked) {
+ cr.getChartAdditionalOptions().setStacked(stacked);
+ }
+
+ public boolean isChartStacked() {
+ return (cr.getChartAdditionalOptions() != null)
+ ? (cr.getChartAdditionalOptions().isStacked() != null ? cr.getChartAdditionalOptions().isStacked()
+ : true)
+ : false;
+ }
+
+ public void setBarControls(boolean barControls) {
+ cr.getChartAdditionalOptions().setBarControls(barControls);
+ }
+
+ public boolean displayBarControls() {
+ return (cr.getChartAdditionalOptions() != null) ? (cr.getChartAdditionalOptions().isBarControls() != null
+ ? cr.getChartAdditionalOptions().isBarControls()
+ : false) : false;
+ }
+
+ public void setXAxisDateType(boolean dateType) {
+ cr.getChartAdditionalOptions().setXAxisDateType(dateType);
+ }
+
+ public boolean isXAxisDateType() {
+ return (cr.getChartAdditionalOptions() != null) ? (cr.getChartAdditionalOptions().isXAxisDateType() != null
+ ? cr.getChartAdditionalOptions().isXAxisDateType()
+ : false) : false;
+ }
+
+ public void setLessXaxisTickers(boolean lessTickers) {
+ cr.getChartAdditionalOptions().setLessXaxisTickers(lessTickers);
+ }
+
+ public boolean isLessXaxisTickers() {
+ return (cr.getChartAdditionalOptions() != null) ? (cr.getChartAdditionalOptions().isLessXaxisTickers() != null
+ ? cr.getChartAdditionalOptions().isLessXaxisTickers()
+ : false) : false;
+ }
+
+ public void setTimeAxis(boolean timeAxis) {
+ cr.getChartAdditionalOptions().setTimeAxis(timeAxis);
+ }
+
+ public boolean isTimeAxis() {
+ return (cr.getChartAdditionalOptions() != null)
+ ? (cr.getChartAdditionalOptions().isTimeAxis() != null ? cr.getChartAdditionalOptions().isTimeAxis()
+ : true)
+ : true;
+ }
+
+ public void setLogScale(boolean logScale) {
+ cr.getChartAdditionalOptions().setLogScale(logScale);
+ }
+
+ public boolean isLogScale() {
+ return (cr.getChartAdditionalOptions() != null)
+ ? (cr.getChartAdditionalOptions().isLogScale() != null ? cr.getChartAdditionalOptions().isLogScale()
+ : false)
+ : false;
+ }
+
+ public void setMultiSeries(boolean multiSeries) {
+ cr.getChartAdditionalOptions().setMultiSeries(multiSeries);
+ cr.setChartMultiSeries(multiSeries ? "Y" : "N");
+ }
+
+ public boolean isMultiSeries() {
+ if ("Y".equals(AppUtils.nvl(cr.getChartMultiSeries())))
+ cr.getChartAdditionalOptions().setMultiSeries(true);
+ return (cr.getChartAdditionalOptions() != null) ? (cr.getChartAdditionalOptions().isMultiSeries() != null
+ ? cr.getChartAdditionalOptions().isMultiSeries()
+ : false) : false;
+ }
+
+ public void setTimeSeriesRender(String timeSeriesRenderer) {
+ cr.getChartAdditionalOptions().setTimeSeriesRender(timeSeriesRenderer);
+ }
+
+ public String getTimeSeriesRender() {
+ return (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getTimeSeriesRender() : "line";
+ }
+
+ public void setShowXAxisLabel(boolean showXaxisLabel) {
+ cr.getChartAdditionalOptions().setShowXAxisLabel(showXaxisLabel);
+ }
+
+ public boolean isShowXaxisLabel() {
+ return (cr.getChartAdditionalOptions() != null) ? (cr.getChartAdditionalOptions().isShowXAxisLabel() != null
+ ? cr.getChartAdditionalOptions().isShowXAxisLabel()
+ : false) : false;
+ }
+
+ public void setAddXAxisTickers(boolean addXAxisTickers) {
+ cr.getChartAdditionalOptions().setAddXAxisTickers(addXAxisTickers);
+ }
+
+ public boolean isAddXAxisTickers() {
+ return (cr.getChartAdditionalOptions() != null) ? (cr.getChartAdditionalOptions().isAddXAxisTickers() != null
+ ? cr.getChartAdditionalOptions().isAddXAxisTickers()
+ : false) : true;
+ }
+
+ public void setZoomIn(Integer zoomIn) {
+ cr.getChartAdditionalOptions().setZoomIn(zoomIn);
+ }
+
+ public Integer getZoomIn() {
+ return (cr.getChartAdditionalOptions() != null)
+ ? (cr.getChartAdditionalOptions().getZoomIn() != null ? cr.getChartAdditionalOptions().getZoomIn()
+ : new Integer("25"))
+ : new Integer("25");
+ }
+
+ public void setTimeAxisType(String timeAxisType) {
+ cr.getChartAdditionalOptions().setTimeAxisType(timeAxisType);
+ }
+
+ public String getTimeAxisType() {
+ return (cr.getChartAdditionalOptions() != null) ? (cr.getChartAdditionalOptions().getTimeAxisType() != null
+ ? cr.getChartAdditionalOptions().getTimeAxisType()
+ : "hourly") : "hourly";
+ }
+
+ public void setTopMargin(Integer topMargin) {
+ cr.getChartAdditionalOptions().setTopMargin(topMargin);
+ }
+
+ public Integer getTopMargin() {
+ return (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getTopMargin()
+ : new Integer("30");
+ }
+
+ public void setBottomMargin(Integer bottomMargin) {
+ cr.getChartAdditionalOptions().setBottomMargin(bottomMargin);
+ }
+
+ public Integer getBottomMargin() {
+ return (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getBottomMargin()
+ : new Integer("50");
+ }
+
+ public void setRightMargin(Integer rightMargin) {
+ cr.getChartAdditionalOptions().setRightMargin(rightMargin);
+ }
+
+ public Integer getRightMargin() {
+ return (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getRightMargin()
+ : new Integer("60");
+ }
+
+ public void setLeftMargin(Integer leftMargin) {
+ cr.getChartAdditionalOptions().setLeftMargin(leftMargin);
+ }
+
+ public Integer getLeftMargin() {
+ return (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getLeftMargin()
+ : new Integer("100");
+ }
+
+ public boolean isVerticalOrientation() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getChartOrientation() : "";
+ if (nvl(s).length() <= 0)
+ return true;
+ if (nvl(s).indexOf("|") != -1)
+ s = s.substring(0, s.indexOf("|"));
+ return (nvl(s).length() > 0) && ("vertical".equals(s)) ? true : false;
+ }
+
+ public boolean isHorizontalOrientation() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getChartOrientation() : "";
+ if (nvl(s).indexOf("|") != -1)
+ s = s.substring(0, s.indexOf("|"));
+ return (nvl(s).length() > 0) && ("horizontal".equals(s)) ? true : false;
+ }
+
+ public boolean displaySecondaryChartRendererInRunPage() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getSecondaryChartRenderer() : "";
+ if (nvl(s).indexOf("|") != -1) {
+ s = s.substring(s.indexOf("|") + 1);
+ return getFlagInBoolean(s);
+ } else
+ return false;
+
+ }
+
+ public String getSecondaryChartRenderer() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getSecondaryChartRenderer() : "";
+ if (nvl(s).indexOf("|") != -1)
+ s = s.substring(0, s.indexOf("|"));
+ return s;
+ }
+
+ public String getOverlayItemValueOnStackBar() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getOverlayItemValueOnStackBar()
+ : "N";
+ return s;
+ }
+
+ public boolean displayIntervalInputInRunPage() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getIntervalFromdate() : "";
+ if (nvl(s).indexOf("|") != -1) {
+ s = s.substring(s.indexOf("|") + 1);
+ return getFlagInBoolean(s);
+ } else
+ return false;
+ }
+
+ public boolean showLegendDisplayOptionsInRunPage() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getHidechartLegend() : "";
+ if (nvl(s).indexOf("|") != -1) {
+ s = s.substring(s.indexOf("|") + 1);
+ return getFlagInBoolean(s);
+ } else
+ return false;
+ }
+
+ public String getIntervalFromdate() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getIntervalFromdate() : "";
+ if (nvl(s).indexOf("|") != -1)
+ s = s.substring(0, s.indexOf("|"));
+ return nvl(s, "");
+ }
+
+ public String getIntervalTodate() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getIntervalTodate() : "";
+ if (nvl(s).indexOf("|") != -1)
+ s = s.substring(0, s.indexOf("|"));
+ return nvl(s, "");
+ }
+
+ public String getIntervalLabel() {
+ return cr.getChartAdditionalOptions() != null ? nvl(cr.getChartAdditionalOptions().getIntervalLabel()) : "";
+ }
+
+ public String getLegendPosition() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getLegendPosition() : "";
+ return nvl(s, "bottom");
+ }
+
+ public String getLegendLabelAngle() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getLabelAngle() : "";
+ return nvl(s, "UP90");
+ }
+
+ public String getMaxLabelsInDomainAxis() {
+ String s = "";
+ s = (cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getMaxLabelsInDomainAxis() : "";
+ return nvl(s, "99");
+ }
+
+ public boolean isLastSeriesALineChart() {
+ String s = "";
+ s = nvl((cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getLastSeriesALineChart()
+ : "");
+ return s.equals("Y");
+ }
+
+ public boolean isLastSeriesABarChart() {
+ String s = "";
+ s = nvl((cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getLastSeriesABarChart()
+ : "");
+ return s.equals("Y");
+ }
+
+ public void setChartLegendDisplay(String value) {
cr.getChartAdditionalOptions().setHidechartLegend(value);
- }
-
- public boolean hideChartLegend() {
- String s = "";
- s = nvl((cr.getChartAdditionalOptions()!=null)?cr.getChartAdditionalOptions().getHidechartLegend():"N");
- if(nvl(s).length()<=0) s = "N";
- if(nvl(s).indexOf("|")!= -1) s = s.substring(0, s.indexOf("|"));
- return s.equals("Y");
- }
-
- public void setChartToolTips(String value) {
+ }
+
+ public boolean hideChartLegend() {
+ String s = "";
+ s = nvl((cr.getChartAdditionalOptions() != null) ? cr.getChartAdditionalOptions().getHidechartLegend() : "N");
+ if (nvl(s).length() <= 0)
+ s = "N";
+ if (nvl(s).indexOf("|") != -1)
+ s = s.substring(0, s.indexOf("|"));
+ return s.equals("Y");
+ }
+
+ public void setChartToolTips(String value) {
cr.getChartAdditionalOptions().setHideToolTips(value);
- }
+ }
- public void setDomainAxisValuesAsString(String value) {
+ public void setDomainAxisValuesAsString(String value) {
cr.getChartAdditionalOptions().setKeepDomainAxisValueAsString(value);
- }
-
- public boolean hideChartToolTips() {
- boolean s = true;
- s = (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().getHideToolTips()!=null?
- (cr.getChartAdditionalOptions().getHideToolTips().equals("Y")?true:false):(Globals.hideToolTipsGlobally()?true:false)):(Globals.hideToolTipsGlobally()?true:false);
- return s;
- }
-
- public boolean keepDomainAxisValueInChartAsString() {
- boolean s = true;
- s = (cr.getChartAdditionalOptions()!=null)?(cr.getChartAdditionalOptions().getKeepDomainAxisValueAsString()!=null?
- (cr.getChartAdditionalOptions().getKeepDomainAxisValueAsString().equals("Y")?true:false):false):false;
- return s;
- }
-
- public int getChartHeightAsInt() {
- return getIntValue(cr.getChartHeight(), Globals.getDefaultChartHeight());
- }
-
- public boolean isPublic() {
- return cr.isPublic();
- }
-
- public boolean isDashboardType() throws RaptorException {
- return cr.isDashboardType()!=null?cr.isDashboardType().booleanValue():false;
- }
-
- // public String getCreateId() { return cr.getCreateId(); }
- // public Calendar getCreateDate() { return cr.getCreateDate(); }
- public String getReportSQL() {
- return cr.getReportSQL();
- }
-
- public String getReportTitle() {
- return cr.getReportTitle();
- }
-
- public String getReportSubTitle() {
- return cr.getReportSubTitle();
- }
-
- public String getReportHeader() {
- return cr.getReportHeader();
- }
-
- public String getReportFooter() {
- return cr.getReportFooter();
- }
-
- public String getNumDashCols() {
- return cr.getNumDashCols();
- }
-
- public int getNumDashColsAsInt() {
- return getIntValue(cr.getNumDashCols(), 1);
- }
-
- public String getNumFormCols() {
- return cr.getNumFormCols();
- }
-
- public int getNumFormColsAsInt() {
- return getIntValue(cr.getNumFormCols(), 5);
- }
-
- public String getDisplayOptions() {
- return cr.getDisplayOptions();
- }
-
-
-
-//Additional Methods
-
- public int getJumpTo() {
- return cr.getJumpTo()==null?1:cr.getJumpTo();
- }
- public void setJumpTo(int value){
- cr.setJumpTo(value);
- }
-
-
- public int getSearchPageSize(){
- return cr.getSearchPageSize()==null?20:cr.getSearchPageSize();
- }
- public void setSearchPageSize(int value){
- cr.setSearchPageSize(value);
- }
-
-
- public boolean isToggleLayout(){
- if(cr.isToggleLayout()!=null)
- return cr.isToggleLayout();
-
- else
- return Globals.displayRuntimeOptionsAsDefault();
-
- }
- public void setToggleLayout(boolean value){
- cr.setToggleLayout(value);
- }
-
- public boolean isShowPageSize(){
- if(cr.isShowPageSize()!=null)
- return cr.isShowPageSize();
-
- else
- return Globals.displayRuntimeOptionsAsDefault();
-
- }
- public void setShowPageSize(boolean value){
- cr.setShowPageSize(value);
- }
-
- public boolean isShowNavPos(){
- if(cr.isShowNavPos()!=null)
- return cr.isShowNavPos();
-
- else
- return Globals.displayRuntimeOptionsAsDefault();
-
- }
- public void setShowNavPos(boolean value){
- cr.setShowNavPos(value);
- }
-
- public boolean isShowGotoOption(){
- if(cr.isShowGotoOption()!=null)
- return cr.isShowGotoOption();
-
- else
- return Globals.displayRuntimeOptionsAsDefault();
-
- }
- public void setShowGotoOption(boolean value){
- cr.setShowGotoOption(value);
- }
-
- public boolean isPageNav(){
-
- if(cr.isPageNav()!=null)
- return cr.isPageNav();
-
- else
- return Globals.displayRuntimeOptionsAsDefault();
-
- }
-
- public void setPageNav(boolean value){
- cr.setPageNav(value);
- }
-
-
- public String getNavPosition(){
- if(cr.getNavPosition()!=null)
- return cr.getNavPosition();
-
- else
- return "top";
- //return cr.getNavPosition();
- }
- public void setNavPosition(String value){
- cr.setNavPosition(value);
- }
-
-
- public String getDashboardEditor(){
- return getDashBoardReportsNew().getDashboardEditor();
- }
-
- public void setDashboardEditor(String value){
- getDashBoardReportsNew().setDashboardEditor(value);
- }
-
-
- public DashboardEditorList getDashboardEditorList(){
- return getDashBoardReportsNew().getDashboardEditorList();
- }
-
- public void setDashboardEditorList(DashboardEditorList value){
- getDashBoardReportsNew().setDashboardEditorList(value);
- }
-
- public PDFAdditionalOptions getPDFAdditionalOptions() {
- try {
- if(cr.getPdfAdditionalOptions()==null)
- addPDFAdditionalOptions(new ObjectFactory());
- } catch(RaptorException ex) {
- ex.printStackTrace();
- }
- return cr.getPdfAdditionalOptions();
- }
-
- public String getPDFFont(){
- return getPDFAdditionalOptions().getPDFFont()!=null?getPDFAdditionalOptions().getPDFFont():Globals.getDataFontFamily();
- }
- public void setPDFFont(String value){
- getPDFAdditionalOptions().setPDFFont(value);
- }
-
- public int getPDFFontSize() {
- return getPDFAdditionalOptions().getPDFFontSize()==null?9:getPDFAdditionalOptions().getPDFFontSize();
- }
- public void setPDFFontSize(int value){
- getPDFAdditionalOptions().setPDFFontSize(value);
- }
-
- public String getPDFOrientation(){
- return getPDFAdditionalOptions().getPDFOrientation()!=null?"portrait":"landscape";
- }
- public void setPDFOrientation(String value){
- getPDFAdditionalOptions().setPDFOrientation(value);
- }
-
- public String getPDFLogo1(){
- return getPDFAdditionalOptions().getPDFLogo1();
- }
- public void setPDFLogo1(String value){
- getPDFAdditionalOptions().setPDFLogo1(value);
- }
-
- public String getPDFLogo2(){
- return getPDFAdditionalOptions().getPDFLogo2();
- }
- public void setPDFLogo2(String value){
- getPDFAdditionalOptions().setPDFLogo2(value);
- }
-
- public int getPDFLogo1Size() {
- return getPDFAdditionalOptions().getPDFLogo1Size()==null?0:getPDFAdditionalOptions().getPDFLogo1Size();
- }
- public void setPDFLogo1Size(int value){
- getPDFAdditionalOptions().setPDFLogo1Size(value);
- }
-
- public int getPDFLogo2Size() {
- return getPDFAdditionalOptions().getPDFLogo2Size()==null?0:getPDFAdditionalOptions().getPDFLogo2Size();
- }
- public void setPDFLogo2Size(int value){
- getPDFAdditionalOptions().setPDFLogo2Size(value);
- }
-
- public boolean isPDFCoverPage(){
-
- if(getPDFAdditionalOptions().isPDFCoverPage()!=null)
- return getPDFAdditionalOptions().isPDFCoverPage();
-
- else
- return true;
-
- }
-
- public void setPDFCoverPage(boolean value){
- getPDFAdditionalOptions().setPDFCoverPage(value);
- }
-
- public String getPDFFooter1(){
- return getPDFAdditionalOptions().getPDFFooter1();
- }
- public void setPDFFooter1(String value){
- getPDFAdditionalOptions().setPDFFooter1(value);
- }
-
- public String getPDFFooter2(){
- return getPDFAdditionalOptions().getPDFFooter2();
- }
- public void setPDFFooter2(String value){
- getPDFAdditionalOptions().setPDFFooter2(value);
- }
-
-
-
-//End of Additional Methods
-
- public String getDataContainerHeight() {
- return cr.getDataContainerHeight();
- }
-
- public String getDataContainerWidth() {
- return cr.getDataContainerWidth();
- }
-
- public boolean isAllowSchedule() {
- String allowSchedule = getAllowSchedule();
- return (allowSchedule !=null )? allowSchedule.startsWith("Y"):false;
- }
-
- public String getAllowSchedule() {
- return cr.getAllowSchedule();
- }
-
- /* Multi Group */
-
- public boolean isMultiGroupColumn() {
- String multiGroupColumn = getMultiGroupColumn();
- return (multiGroupColumn !=null )? multiGroupColumn.startsWith("Y"):false;
- }
-
- public String getMultiGroupColumn() {
- return cr.getMultiGroupColumn();
- }
-
- public void setMultiGroupColumn(String value) {
- cr.setMultiGroupColumn(value);
- }
-
- private int getColumnGroupLevel(String colId) throws RaptorException {
- DataColumnType dc = getColumnById(colId);
- return (dc == null) ? 0 : dc.getLevel();
- } // getColumnGroupLevel
-
- public int getMaxGroupLevel() {
- List reportCols = getAllColumns();
- int maxLevel = 0;
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if (dc.getLevel()!=null) {
- if(maxLevel < dc.getLevel())
- maxLevel = dc.getLevel();
- }
- } // for
- return maxLevel;
- } // getMaxGroupLevel
-
- private int getColumnGroupStart(String colId) throws RaptorException {
- DataColumnType dc = getColumnById(colId);
- return (dc == null) ? 0 : dc.getStart();
- } // getColumnGroupStart
-
- private int getColumnGroupColSpan(String colId) throws RaptorException {
- DataColumnType dc = getColumnById(colId);
- return (dc == null) ? 0 : dc.getColspan();
- } // getColumnGroupColSpan
-
- public void setTopDown(String value) {
- cr.setTopDown(value);
- }
-
- public boolean isTopDown() {
- String topDown = getTopDownOption();
- return (topDown !=null )? topDown.startsWith("Y"):false;
- }
-
- public String getTopDownOption() {
- return cr.getTopDown();
- }
-
- public void setSizedByContent(String value) {
- cr.setSizedByContent(value);
- }
-
- public boolean isSizedByContent() {
- String sizedByContent = getSizedByContentOption();
- return (sizedByContent !=null )? sizedByContent.startsWith("Y"):false;
- }
-
- public String getSizedByContentOption() {
- return cr.getSizedByContent();
- }
-
- public String getDashboardOptions() {
- return cr.getDashboardOptions();
- }
-
- public boolean isDashboardOptionHideChart() {
- return nvl(getDashboardOptions()).length() > 0 && (getDashboardOptions().charAt(0) == 'Y');
- }
-
- public boolean isDashboardOptionHideData() {
- return nvl(getDashboardOptions()).length() > 0 && (getDashboardOptions().charAt(1) == 'Y');
- }
-
- public boolean isDashboardOptionHideBtns() {
- return nvl(getDashboardOptions()).length() > 0 && (getDashboardOptions().charAt(2) == 'Y');
- }
-
- public boolean isDisplayOptionHideForm() {
- return nvl(getDisplayOptions()).length() > 0 && (getDisplayOptions().charAt(0) == 'Y');
- }
-
- public boolean isDisplayOptionHideChart() {
- return nvl(getDisplayOptions()).length() > 1 && (getDisplayOptions().charAt(1) == 'Y');
- }
-
- public boolean isDisplayOptionHideData() {
- return nvl(getDisplayOptions()).length() > 2 && (getDisplayOptions().charAt(2) == 'Y');
- }
-
- public boolean isDisplayOptionHideBtns() {
- return nvl(getDisplayOptions()).length() > 3 && (getDisplayOptions().charAt(3) == 'Y');
- }
-
- public boolean isDisplayOptionHideMap() {
- return nvl(getDisplayOptions()).length() > 4 && (getDisplayOptions().charAt(4) == 'Y');
- }
-
- public boolean isDisplayOptionHideExcelIcons() {
- return nvl(getDisplayOptions()).length() > 5 && (getDisplayOptions().charAt(5) == 'Y');
- }
-
- public boolean isDisplayOptionHidePDFIcons() {
- return nvl(getDisplayOptions()).length() > 6 && (getDisplayOptions().charAt(6) == 'Y');
- }
-
- public String getComment() {
- return cr.getComment();
- }
-
- public DataSourceList getDataSourceList() {
- return cr.getDataSourceList();
- }
-
- public ChartAdditionalOptions getChartAdditionalOptions() {
- return cr.getChartAdditionalOptions();
- }
-
- public ChartDrillOptions getChartDrillOptions() {
- return cr.getChartDrillOptions();
- }
-
-
- public DataminingOptions getDataminingOptions() {
- return cr.getDataminingOptions();
- }
-
- public DashboardReports getDashBoardReports() {
- return cr.getDashBoardReports();
- }
-
-
- public DashboardReportsNew getDashBoardReportsNew() {
- try {
- if(cr.getDashBoardReportsNew()==null)
- addDashboardReportsNew(new ObjectFactory());
- } catch(RaptorException ex) {
- ex.printStackTrace();
- }
- return cr.getDashBoardReportsNew();
- }
-
- public String getDashboardLayoutHTML() {
- return cr.getDashboardLayoutHTML();
- }
-
- public FormFieldList getFormFieldList() {
- return cr.getFormFieldList();
- }
-
- public JavascriptList getJavascriptList() {
- return cr.getJavascriptList();
- }
-
- public SemaphoreList getSemaphoreList() {
- return cr.getSemaphoreList();
- }
-
- public void setPageSize(int value) {
- cr.setPageSize(value);
- }
-
- public void setAllowSchedule(String value) {
- cr.setAllowSchedule(value);
- }
-
- public void setMaxRowsInExcelDownload(int value) {
- cr.setMaxRowsInExcelDownload(value);
- }
-
- public void setReportInNewWindow (boolean value) {
- cr.setReportInNewWindow(value);
- }
-
- public void setDisplayFolderTree (boolean value) {
- cr.setDisplayFolderTree(value);
- }
-
- public void setReportType(String value) {
- cr.setReportType(value);
- }
-
- public void setReportName(String value) {
- cr.setReportName(value);
- }
-
- public void setDBInfo(String value) {
- if (!(cr.getDbInfo() != null && cr.getDbInfo().length() > 0))
- cr.setDbInfo(value);
- }
-
- public void setDBType(String value) {
- if (!(cr.getDbType() != null && cr.getDbType().length() > 0))
- cr.setDbType(value);
- }
-
- public void setReportDescr(String value) {
- cr.setReportDescr(value);
- }
-
- public void setChartType(String value) {
- cr.setChartType(value);
- }
-
- public void setChartMultiplePieOrder(String value) {
- cr.getChartAdditionalOptions().setChartMultiplePieOrder(value);
- }
-
- public void setChartMultiplePieLabelDisplay(String value) {
- cr.getChartAdditionalOptions().setChartMultiplePieLabelDisplay(value);
- }
-
- public void setChartOrientation(String value) {
- cr.getChartAdditionalOptions().setChartOrientation(value);
- }
-
- public void setSecondaryChartRenderer(String value) {
- cr.getChartAdditionalOptions().setSecondaryChartRenderer(value);
- }
-
- public void setOverlayItemValueOnStackBar(String value) {
- cr.getChartAdditionalOptions().setOverlayItemValueOnStackBar(value);
- }
-
- public void setIntervalFromdate(String value) {
- cr.getChartAdditionalOptions().setIntervalFromdate(value);
- }
-
- public void setIntervalLabel(String value) {
- cr.getChartAdditionalOptions().setIntervalLabel(value);
- }
-
- public void setIntervalTodate(String value) {
- cr.getChartAdditionalOptions().setIntervalTodate(value);
- }
-
- public void setLegendPosition(String value) {
- cr.getChartAdditionalOptions().setLegendPosition(value);
- }
-
- public void setLegendLabelAngle(String value) {
- cr.getChartAdditionalOptions().setLabelAngle(value);
- }
-
- public void setMaxLabelsInDomainAxis(String value) {
- if(nvl(value).length()<=0) value = "99";
- cr.getChartAdditionalOptions().setMaxLabelsInDomainAxis(value);
- }
-
- public void setLastSeriesALineChart(String value) {
- cr.getChartAdditionalOptions().setLastSeriesALineChart(value);
- }
-
- public void setLastSeriesABarChart(String value) {
- cr.getChartAdditionalOptions().setLastSeriesABarChart(value);
- }
-
- public void setChartDisplay(String value) {
- cr.getChartAdditionalOptions().setChartDisplay(value);
- }
-
- public void setChartAnimate(boolean animate) {
- if(cr.getChartAdditionalOptions()!=null)
- cr.getChartAdditionalOptions().setAnimate(animate);
- else {
- try {
- if(getChartAdditionalOptions()==null)
- addChartAdditionalOptions(new ObjectFactory());
- } catch(RaptorException ex) {
- ex.printStackTrace();
- }
- if(cr.getChartAdditionalOptions()!=null)
- cr.getChartAdditionalOptions().setAnimate(animate);
-
- }
-
- }
-
- public void addChartAdditionalOptions(ObjectFactory objFactory) throws RaptorException {
- ChartAdditionalOptions chartOptions = objFactory.createChartAdditionalOptions();
- cr.setChartAdditionalOptions(chartOptions);
- }
-
- public void addDashboardReportsNew(ObjectFactory objFactory) throws RaptorException {
- DashboardReportsNew dashboardReports = objFactory.createDashboardReportsNew();
- cr.setDashBoardReportsNew(dashboardReports);
- }
-
- public void addPDFAdditionalOptions(ObjectFactory objFactory) throws RaptorException {
- PDFAdditionalOptions pdfOptions = objFactory.createPDFAdditionalOptions();
- cr.setPdfAdditionalOptions(pdfOptions);
- }
-
- public void setChartTypeFixed(String value) {
- cr.setChartTypeFixed(value);
- }
-
- public void setChartLeftAxisLabel(String value) {
- cr.setChartLeftAxisLabel(value);
- }
-
- public void setChartRightAxisLabel(String value) {
- cr.setChartRightAxisLabel(value);
- }
-
- public void setChartWidth(String value) {
- cr.setChartWidth(value);
- }
-
- public void setChartHeight(String value) {
- cr.setChartHeight(value);
- }
-
- public void setChartMultiSeries(String value) {
- cr.setChartMultiSeries(value);
- }
-
- public void setPublic(boolean value) {
- cr.setPublic(value);
- if (reportSecurity != null)
- reportSecurity.setPublic(value);
- }
-
- // public void setCreateId(String value) { cr.setCreateId(value); }
- // public void setCreateDate(Calendar value) { cr.setCreateDate(value); }
- public void setReportSQL(String value) {
- cr.setReportSQL(value);
- }
-
- public void setReportTitle(String value) {
- cr.setReportTitle(value);
- }
-
- public void setReportSubTitle(String value) {
- cr.setReportSubTitle(value);
- }
-
- public void setReportHeader(String value) {
- cr.setReportHeader(value);
- }
-
- public void setReportFooter(String value) {
- cr.setReportFooter(value);
- }
-
- public void setNumFormCols(String value) {
- cr.setNumFormCols(value);
- }
-
- public void setNumDashCols(String value) {
- cr.setNumDashCols(value);
- }
-
- public void setDisplayOptions(String value) {
- cr.setDisplayOptions(value);
- }
-
- public void setDataContainerHeight(String value) {
- cr.setDataContainerHeight(value);
- }
-
- public void setDataContainerWidth(String value) {
- cr.setDataContainerWidth(value);
- }
-
- public void setDashboardOptions(String value) {
- cr.setDashboardOptions(value);
- }
-
- public void setComment(String value) {
- cr.setComment(value);
- }
-
- public void setDashboardType(boolean dashboardType) {
- cr.setDashboardType(dashboardType);
- }
-
- public void setDashboardLayoutHTML(String html) {
- cr.setDashboardLayoutHTML(html);
- }
-
- public void setDataSourceList(DataSourceList value) {
- cr.setDataSourceList(value);
- }
-
- public void setFormFieldList(FormFieldList value) {
- cr.setFormFieldList(value);
- }
-
- public void setDashBoardReports(DashboardReports value) {
- cr.setDashBoardReports(value);
- }
-
- public void setSemaphoreList(SemaphoreList value) {
- cr.setSemaphoreList(value);
- }
-
- public void setJavascriptList(JavascriptList value) {
- cr.setJavascriptList(value);
- }
-
- public void setJavascriptElement(String javascriptElement) {
- cr.setJavascriptElement(javascriptElement);
- }
-
- public void checkUserReadAccess(HttpServletRequest request) throws RaptorException {
- reportSecurity.checkUserReadAccess(request, null);
- }
- public void checkUserReadAccess(HttpServletRequest request, String userID) throws RaptorException {
- reportSecurity.checkUserReadAccess(request, userID);
- }
-
- public void checkUserWriteAccess(HttpServletRequest request) throws RaptorException {
- reportSecurity.checkUserWriteAccess(request);
- verifySQLBasedReportAccess(request);
- }
-
- public String getOwnerID() {
- return reportSecurity.getOwnerID();
- }
-
- public String getCreateID() {
- return reportSecurity.getCreateID();
- }
-
- public String getCreateDate() {
- return reportSecurity.getCreateDate();
- }
-
- public String getUpdateID() {
- return reportSecurity.getUpdateID();
- }
-
- public String getUpdateDate() {
- return reportSecurity.getUpdateDate();
- }
-
- public ReportSecurity getReportSecurity() {
- return reportSecurity;
- }
-
- /****Report Maps - Start****/
- public ReportMap getReportMap() {
- return cr.getReportMap();
- }
-
- public void setReportMap(ReportMap reportMap) {
- cr.setReportMap(reportMap);
- }
- /****Report Maps - End****/
-
- /****Report Chart Drilldown - Start****/
- public ChartDrillOptions getReportChartDrillOptions() {
- return cr.getChartDrillOptions();
- }
-
- public void setReportChartDrillOptions(ChartDrillOptions chartDrillOptions) {
- cr.setChartDrillOptions(chartDrillOptions);
- }
- /****Report Maps - End****/
-
-
- /** ************************************************************************************************* */
-
- public String getFormHelpText() {
- String formHelpText = nvl(getComment());
-
- if (formHelpText.indexOf('|') >= 0)
- formHelpText = formHelpText.substring(formHelpText.lastIndexOf('|') + 1);
-
- return formHelpText;
- } // getFormHelpText
-
- public void setFormHelpText(String formHelpText) {
- String comment = nvl(getComment());
-
- if (comment.indexOf('|') >= 0)
- comment = comment.substring(0, comment.lastIndexOf('|'));
- if (comment.length() > 0)
- comment += '|';
-
- setComment(comment + formHelpText);
- } // setFormHelpText
-
- public boolean isRuntimeColSortDisabled() {
- String comment = nvl(getComment());
-
- if (comment.indexOf('|') < 0)
- return false;
-
- return comment.substring(0, comment.indexOf('|')).equals("Y");
- } // isRuntimeColSortDisabled
-
- public void setRuntimeColSortDisabled(boolean value) {
- String comment = nvl(getComment());
-
- if (comment.indexOf('|') >= 0)
- comment = comment.substring(comment.indexOf('|') + 1);
-
- setComment((value ? "Y" : "N") + "|" + comment);
- } // setRuntimeColSortDisabled
-
- /** ************************************************************************************************* */
-
- protected void verifySQLBasedReportAccess(HttpServletRequest request) throws RaptorException {
- String userID = AppUtils.getUserID(request);
- if (getReportDefType().equals(AppConstants.RD_SQL_BASED)
- && (!Globals.getAllowSQLBasedReports()) && (!AppUtils.isAdminUser(request)))
- throw new org.onap.portalsdk.analytics.error.UserAccessException(reportID, "[" + userID + "] "
- + AppUtils.getUserName(request), AppConstants.UA_WRITE);
- } // verifySQLBasedReportAccess
-
- /** ************************************************************************************************* */
-
- private String getColumnNameById(String colId) throws RaptorException {
- DataColumnType dc = getColumnById(colId);
- return (dc == null) ? "NULL" : dc.getColName();
- } // getColumnNameById
-
- // Checks if drill-down URL points to individual record display (return
- // true) or another report (return false)
- private boolean isViewAction(String value) throws RaptorException {
- try {
- Vector viewActions = org.onap.portalsdk.analytics.model.DataCache.getDataViewActions();
-
- for (int i = 0; i < viewActions.size(); i++)
- if (value.equals(AppUtils.getBaseActionURL() + ((String) viewActions.get(i))))
- return true;
- } catch (Exception e) {
- throw new RaptorRuntimeException("ReportWrapper.isViewAction Exception: "
- + e.getMessage());
- }
-
- return false;
- } // isViewAction
-
- 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 getSelectExpr(DataColumnType dct, String colName) {
- String colType = dct.getColType();
- if(colType.equals(AppConstants.CT_NUMBER)) {
- return colName;
- } else
- 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
-
-
- /** ************************************************************************************************* */
-
- public DataSourceType getTableById(String tableId) {
- for (Iterator iter = getDataSourceList().getDataSource().iterator(); iter.hasNext();) {
- DataSourceType ds = (DataSourceType) iter.next();
- if (ds.getTableId().equals(tableId))
- return ds;
- } // for
-
- return null;
- } // getTableById
-
- public DataSourceType getTableByDBName(String tableName) {
- for (Iterator iter = getDataSourceList().getDataSource().iterator(); iter.hasNext();) {
- DataSourceType ds = (DataSourceType) iter.next();
- if (ds.getTableName().equals(tableName))
- return ds;
- } // for
-
- return null;
- } // getTableByDBName
-
- public DataSourceType getColumnTableById(String colId) {
- return getTableById(getColumnById(colId).getTableId());
- } // getColumnTableById
-
- public DataColumnType getColumnById(String colId) {
- List reportCols = getAllColumns();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if (dc.getColId().toLowerCase().equals(colId.toLowerCase()))
- return dc;
- } // for
-
- return null;
- } // getColumnById
-
- public DataColumnType getChartLegendColumn() {
- List reportCols = getAllColumns();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if (nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND))
- return dc;
- } // for
- return null;
- } // getChartLegendColumn
-
- /*
- * public DataColumnType getChartValueColumn() { List reportCols =
- * getAllColumns(); for(Iterator iter=reportCols.iterator(); iter.hasNext(); ) {
- * DataColumnType dc = (DataColumnType) iter.next(); if(dc.getChartSeq()>0)
- * return dc; } // for
- *
- * return null; } // getChartValueColumn
- */
-
- public List getChartValueColumnsList( int filter, HashMap formValues) { /*filter; all=0;create without new chart =1; createNewChart=2 */
- List reportCols = 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 = getDependsOnFormFieldFlag(dc, formValues);
-
- if( (dc.getChartSeq()!=null && dc.getChartSeq()> 0) && flag == 0 ) {
- if(!AppUtils.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 ListModelList<Item> getChartValueColumnsListModelList( int filter, HashMap formValues) { / *filter; all=0;create without new chart =1; createNewChart=2 * /
- List reportCols = getAllColumns();
-
- ArrayList chartValueCols = new ArrayList();
- ListModelList<Item> chartValueListModelList = new ListModelList<Item>();
- int flag = 0;
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- flag = 0;
- DataColumnType dc = (DataColumnType) iter.next();
-// if(filter == 2 || filter == 1) {
- flag = getDependsOnFormFieldFlag(dc, formValues);
-
- if( (dc.getChartSeq()!=null && dc.getChartSeq()> 0) && flag == 0 ) {
- 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);
- chartValueListModelList.add(new Item(dc.getColId(), dc.getDisplayName()));
- } // for
- Collections.sort(chartValueCols, new ChartSeqComparator());
- return chartValueListModelList;
- } // getChartValueColumnsList */
-
-
- /** Check whether chart has series (Category) columns **/
- public boolean hasSeriesColumn() {
- List reportCols = getAllColumns();
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if (dc.isChartSeries()!=null && dc.isChartSeries().booleanValue())
- return true;
- } // for
- return false;
- } // hasSeriesColumn
-
-
- public List getChartDisplayNamesList( int filter, HashMap formValues) { /*filter; all=0;create without new chart =1; createNewChart=2 */
- List reportCols = getAllColumns();
- ArrayList chartValueColNames = 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 = getDependsOnFormFieldFlag(dc, formValues);
-
- if( (dc.getChartSeq()!=null && dc.getChartSeq()> 0) && flag == 0) {
- if(nvl(dc.getChartGroup()).length()<=0) {
- if( filter == 2 && (dc.isCreateInNewChart()!=null && dc.isCreateInNewChart().booleanValue()) ) {
- chartValueColNames.add(dc.getDisplayName());
- } else if (filter == 1 && (dc.isCreateInNewChart()==null || !dc.isCreateInNewChart().booleanValue())) {
- chartValueColNames.add(dc.getDisplayName());
- }
- else if(filter == 0) chartValueColNames.add(dc.getDisplayName());
- } else if(filter == 0) chartValueColNames.add(dc.getDisplayName());
- }
- // } else
- // chartValueColNames.add(dc.getDisplayName());
-
- }
- return chartValueColNames;
- } // getChartDisplayNamesList
-
-
- public List getChartColumnColorsList(int filter, HashMap formValues) { /*filter; all=0;create without new chart =1; createNewChart=2 */
- List reportCols = getAllColumns();
- ArrayList chartValueColColors = 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 = getDependsOnFormFieldFlag(dc, formValues);
-
- if( (dc.getChartSeq()!=null && dc.getChartSeq()> 0) && flag == 0) {
- if(nvl(dc.getChartGroup()).length()<=0) {
- if( filter == 2 && (dc.isCreateInNewChart()!=null && dc.isCreateInNewChart().booleanValue()) ) {
- chartValueColColors.add(dc.getChartColor());
- } else if (filter == 1 && (dc.isCreateInNewChart()==null || !dc.isCreateInNewChart().booleanValue())) {
- chartValueColColors.add(dc.getChartColor());
- }
- else if(filter == 0) chartValueColColors.add(dc.getChartColor());
- } else if(filter == 0) chartValueColColors.add(dc.getChartColor());
- }
-// } else
-// chartValueColColors.add(dc.getChartColor());
- }
- return chartValueColColors;
- } // getChartColumnColorsList
-
- public List getChartValueColumnAxisList( int filter, HashMap formValues) { /*filter; all=0;create without new chart =1; createNewChart=2 */
- List reportCols = getAllColumns();
- ArrayList chartValueColAxis = 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 = getDependsOnFormFieldFlag(dc, formValues);
-
- if( (dc.getChartSeq()!=null && dc.getChartSeq()> 0) && flag == 0) {
- if(nvl(dc.getChartGroup()).length()<=0) {
- if( filter == 2 && (dc.isCreateInNewChart()!=null && dc.isCreateInNewChart().booleanValue())) {
- chartValueColAxis.add(nvl(dc.getColOnChart(), "0"));
- } else if (filter == 1 && (dc.isCreateInNewChart()==null || !dc.isCreateInNewChart().booleanValue())) {
- chartValueColAxis.add(nvl(dc.getColOnChart(), "0"));
- }
- else if(filter == 0) chartValueColAxis.add(nvl(dc.getColOnChart(), "0"));
- } else if(filter == 0) chartValueColAxis.add(nvl(dc.getColOnChart(), "0"));
- }
-// } else
-// chartValueColAxis.add(nvl(dc.getColOnChart(), "0"));
- }
- return chartValueColAxis;
- } // getChartColumnAxisList
-
-
- public List getChartValueNewChartList() {
- ArrayList chartValueNewChartAxis = new ArrayList();
- for (Iterator iter = getChartValueColumnsList(2, null).iterator(); iter.hasNext();)
- chartValueNewChartAxis.add(new Boolean(((DataColumnType) iter.next()).isCreateInNewChart()));
- return chartValueNewChartAxis;
- } // getChartValueNewChartList
-
- public List getAllChartGroups() {
- ArrayList chartGroups = new ArrayList();
- String chartGroupName="";
- List reportCols = getAllColumns();
- Set groupSet = new TreeSet();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if(dc.getChartSeq()!=null && dc.getChartSeq()> 0) {
- chartGroupName = dc.getChartGroup();
- if(nvl(chartGroupName).length()>0)
- groupSet.add(chartGroupName);
- }
- }
- List l = new ArrayList(groupSet);
- return l;
- } // getAllChartGroups
-
- public HashMap getAllChartYAxis(ReportParamValues reportParamValues) {
- String chartYAxis="";
- List reportCols = getAllColumns();
- HashMap hashMap = new HashMap();
- FormFieldList formFieldList = getFormFieldList();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if(dc.getChartSeq()!=null && dc.getChartSeq()> 0) {
- chartYAxis = dc.getYAxis();
- if(formFieldList!=null && reportParamValues!=null) {
- for (Iterator iter1 = getFormFieldList().getFormField().iterator(); iter1.hasNext();) {
- FormFieldType fft = (FormFieldType) iter1.next();
- String fieldDisplay = getFormFieldDisplayName(fft);
- String fieldId = "";
- if(fft!=null)
- fieldId = fft.getFieldId();
- if(!fft.getFieldType().equals(FormField.FFT_BLANK) && !fft.getFieldType().equals(FormField.FFT_LIST_MULTI) && !fft.getFieldType().equals(FormField.FFT_TEXTAREA)) {
- String paramValue = Utils.oracleSafe(nvl(reportParamValues.getParamValue(fieldId)));
- chartYAxis = Utils.replaceInString(chartYAxis, fieldDisplay, nvl(
- paramValue, ""));
- }
- }
- }
- if(nvl(dc.getChartGroup()).length()>0)
- hashMap.put(dc.getChartGroup(),chartYAxis);
- }
- }
- return hashMap;
- } // getAllChartGroups
-
- public List getChartGroupColumnAxisList( String chartGroupName, HashMap formValues ) { /*filter; all=0;create without new chart =1; createNewChart=2 */
- List reportCols = getAllColumns();
- ArrayList chartGroupColAxis = new ArrayList();
- String chartGroup = chartGroupName.substring(0,chartGroupName.lastIndexOf("|"));
- int flag = 0;
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- flag = 0;
- DataColumnType dc = (DataColumnType) iter.next();
-// if(filter == 2 || filter == 1) {
- flag = getDependsOnFormFieldFlag(dc, formValues);
-
- if( (dc.getChartSeq()!=null && dc.getChartSeq()> 0) && flag == 0) {
- if( nvl(dc.getChartGroup()).indexOf("|") > 0 && (nvl(dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))).equals(chartGroup))) {
- //if( nvl(dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))).equals(chartGroup)) {
- //System.out.println("$$$$$$$DC " + dc.getColId()+ " " + dc.getColOnChart());
- chartGroupColAxis.add(dc);
- }
- }
-// } else
-// chartValueColAxis.add(nvl(dc.getColOnChart(), "0"));
- }
- Collections.sort(chartGroupColAxis, new ChartSeqComparator());
- return chartGroupColAxis;
- } // getChartColumnAxisList
-
- public List getChartGroupValueColumnAxisList( String chartGroupName, HashMap formValues ) {
- List reportCols = getAllColumns();
- String index = chartGroupName.substring(chartGroupName.lastIndexOf("|")+1);
- String chartGroup = chartGroupName.substring(0,chartGroupName.lastIndexOf("|"));
- //System.out.println("$$$$INDEX " + index);
- ArrayList chartGroupValueColAxis = new ArrayList();
- int flag = 0;
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- flag = 0;
- DataColumnType dc = (DataColumnType) iter.next();
- flag = getDependsOnFormFieldFlag(dc, formValues);
-
- if( (dc.getChartSeq()!=null && dc.getChartSeq()> 0) && flag == 0) {
- //System.out.println(" Chartgroup " + dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|")));
- if( nvl(dc.getChartGroup()).indexOf("|") > 0 && (nvl(dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))).equals(chartGroup))) {
- //if( nvl(dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))).equals(chartGroup)) {
- //System.out.println(" Added Chartgroupname " + chartGroup + " " + dc.getChartGroup() + " " + index);
- chartGroupValueColAxis.add(dc);
- }
- }
- }
- return chartGroupValueColAxis;
- } // getChartColumnAxisList
-
- public List getChartGroupDisplayNamesList( String chartGroupName, HashMap formValues) {
- List reportCols = getAllColumns();
- ArrayList chartGroupValueColNames = new ArrayList();
- String chartGroup = chartGroupName.substring(0,chartGroupName.lastIndexOf("|"));
- int flag = 0;
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- flag = 0;
- DataColumnType dc = (DataColumnType) iter.next();
- //System.out.println("$$$$$CHART " + dc.getChartSeq()+ " " + dc.getChartGroup()+ " " + chartGroup);
- flag = getDependsOnFormFieldFlag(dc, formValues);
-
- if( (dc.getChartSeq()!=null && dc.getChartSeq()> 0) && flag == 0 ) {
- if( nvl(dc.getChartGroup()).indexOf("|") > 0 && (nvl(dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))).equals(chartGroup))) {
- chartGroupValueColNames.add(dc.getDisplayName());
- }
- }
- }
- return chartGroupValueColNames;
- } // getChartDisplayNamesList
-
-
- public List getChartGroupColumnColorsList(String chartGroupName, HashMap formValues) {
- List reportCols = getAllColumns();
- ArrayList chartValueColColors = new ArrayList();
- String chartGroup = chartGroupName.substring(0,chartGroupName.lastIndexOf("|"));
- int flag = 0;
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- flag = 0;
- DataColumnType dc = (DataColumnType) iter.next();
- flag = getDependsOnFormFieldFlag(dc, formValues);
-
- if( (dc.getChartSeq()!=null && dc.getChartSeq()> 0) && flag == 0 ) {
- if( nvl(dc.getChartGroup()).indexOf("|") > 0 && (nvl(dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))).equals(chartGroup))) {
- //if( nvl(dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))).equals(chartGroup)) {
- chartValueColColors.add(dc.getChartColor());
- }
- }
- }
- return chartValueColColors;
- } // getChartColumnColorsList
-
-
- public List getCrossTabRowColumns() {
- List reportCols = getAllColumns();
- Vector v = new Vector(reportCols.size());
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if (nvl(dc.getCrossTabValue()).equals(AppConstants.CV_ROW))
- v.add(dc);
- } // for
-
- return v;
- } // getCrossTabRowColumns
-
- public List getCrossTabColColumns() {
- List reportCols = getAllColumns();
- Vector v = new Vector(reportCols.size());
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if (nvl(dc.getCrossTabValue()).equals(AppConstants.CV_COLUMN))
- v.add(dc);
- } // for
-
- return v;
- } // getCrossTabColColumns
-
- public String getCrossTabDisplayTotal(String rowColPos) {
- DataColumnType dct = getCrossTabValueColumn();
- if (dct == null)
- return "";
-
- String displayTotal = nvl(dct.getDisplayTotal());
- if (displayTotal.indexOf('|') >= 0) {
- String displayColTotal = displayTotal.substring(0, displayTotal.indexOf('|'));
- String displayRowTotal = displayTotal.substring(displayTotal.indexOf('|') + 1);
-
- if (rowColPos.equals(AppConstants.CV_COLUMN))
- displayTotal = displayColTotal;
- else if (rowColPos.equals(AppConstants.CV_ROW))
- displayTotal = displayRowTotal;
- else if (displayColTotal.equals(displayRowTotal))
- displayTotal = displayColTotal;
- } // if
-
- return displayTotal;
- } // getCrossTabDisplayTotal
-
- public DataColumnType getCrossTabValueColumn() {
- List reportCols = getAllColumns();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if (nvl(dc.getCrossTabValue()).equals(AppConstants.CV_VALUE))
- return dc;
- } // for
-
- return null;
- } // getCrossTabValueColumn
-
- public int getCrossTabValueColumnIndex() { // Returns the index counting
- // only visible columns
- List reportCols = getAllColumns();
-
- int idx = 0;
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if (nvl(dc.getCrossTabValue()).equals(AppConstants.CV_VALUE))
- break;
- if (dc.isVisible())
- idx++;
- } // for
-
- return idx;
- } // getCrossTabValueColumnIndex
-
- public ColFilterType getFilterById(String colId, int filterIndex) {
- DataColumnType dc = getColumnById(colId);
- try {
- return (ColFilterType) dc.getColFilterList().getColFilter().get(filterIndex);
- } catch (Exception e) {
- return null;
- }
- } // getFilterById
-
- public boolean needFormInput() {
- List reportCols = getAllColumns();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
-
- if (dct.getColFilterList() != null) {
- List fList = dct.getColFilterList().getColFilter();
- for (Iterator iterF = fList.iterator(); iterF.hasNext();) {
- ColFilterType cft = (ColFilterType) iterF.next();
-
- if (nvl(cft.getArgType()).equals(AppConstants.AT_FORM))
- return true;
- } // for
- } // if
- } // for
-
- return false;
- } // needFormInput
-
- public int getNumSortColumns() {
- int numSortCols = 0;
- for (Iterator iter = getAllColumns().iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
- if (dct.getOrderBySeq() != null && dct.getOrderBySeq() > 0)
- numSortCols++;
- } // for
-
- return numSortCols;
- } // getNumSortColumns
-
- public SemaphoreType getSemaphoreById(String semaphoreId) {
- if (getSemaphoreList() != null && semaphoreId != null)
- for (Iterator iter = getSemaphoreList().getSemaphore().iterator(); iter.hasNext();) {
- SemaphoreType sem = (SemaphoreType) iter.next();
- if (sem.getSemaphoreId().equals(semaphoreId))
- return sem;
- } // for
-
- return null;
- } // getSemaphoreById
-
- public void deleteSemaphore(SemaphoreType semaphore) {
- if (getSemaphoreList() != null) {
- if(getSemaphoreList().getSemaphore()!= null)
- getSemaphoreList().getSemaphore().remove((SemaphoreType) semaphore);
- }
- } // deleteSemaphore
-
-
- public void setSemaphore(SemaphoreType sem) {
- if (getSemaphoreList() != null) {
- getSemaphoreList().getSemaphore().add(sem);
- }
-
- } // setSemaphore
-
- public static FormatType getSemaphoreFormatById(SemaphoreType semaphore, String formatId) {
- if (semaphore != null)
- for (Iterator iter = semaphore.getFormatList().getFormat().iterator(); iter
- .hasNext();) {
- FormatType fmt = (FormatType) iter.next();
- if (fmt.getFormatId().equals(formatId))
- return fmt;
- } // for
-
- return null;
- } // getSemaphoreFormatById
-
- public FormFieldType getFormFieldById(String fieldId) {
- if (getFormFieldList() != null && fieldId != null)
- for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) {
- FormFieldType fft = (FormFieldType) iter.next();
- if (fft.getFieldId().equals(fieldId))
- return fft;
- } // for
-
- return null;
- } // getFormFieldById
-
- public FormFieldType getFormFieldByDisplayValue(String fieldDisplay) {
- // fieldDisplay expected to be [fieldName]
- if (getFormFieldList() != null && fieldDisplay != null)
- for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) {
- FormFieldType fft = (FormFieldType) iter.next();
- if (fieldDisplay.equals(getFormFieldDisplayName(fft)))
- return fft;
- } // for
-
- return null;
- } // getFormFieldById
-
- public String getFormFieldDisplayName(FormFieldType fft) {
- return "[" + fft.getFieldName() + "]";
- } // getFormFieldDisplayName
-
- /** ************************************************************************************************* */
-
- public void resetCache(boolean sqlOnly) {
- generatedSQL = null;
- if (!sqlOnly) {
- allColumns = null;
- allFilters = null;
- }
- } // resetCache
-
- public String getOuterJoinType(DataSourceType curTable) {
- String refDefinition = nvl(curTable.getRefDefinition());
- int outerJoinIdx = refDefinition.indexOf(" (+)");
- if (outerJoinIdx < 0)
- // No outer join
- return "";
-
- int equalSignIdx = refDefinition.indexOf("=");
- if (refDefinition.indexOf(curTable.getTableId()) < equalSignIdx)
- // Cur. table is on the left side
- return (outerJoinIdx < equalSignIdx) ? AppConstants.OJ_CURRENT
- : AppConstants.OJ_JOINED;
- else
- // Joined table is on the left side
- return (outerJoinIdx < equalSignIdx) ? AppConstants.OJ_JOINED
- : AppConstants.OJ_CURRENT;
- } // getOuterJoinType
-
- public String getFormFieldName(ColFilterType filter) {
- FormFieldType fft = null;
- if (filter.getArgType().equals(AppConstants.AT_FORM))
- fft = getFormFieldByDisplayValue(filter.getArgValue());
-
- return (fft != null) ? fft.getFieldId() : filter.getColId() + "_f"
- + filter.getFilterSeq();
- } // getFormFieldName
-
- public String getFormFieldDisplayName(DataColumnType column, ColFilterType filter) {
- FormFieldType fft = null;
- if (filter.getArgType().equals(AppConstants.AT_FORM))
- fft = getFormFieldByDisplayValue(filter.getArgValue());
-
- return (fft != null) ? fft.getFieldName() : column.getDisplayName() + "&nbsp;"
- + filter.getExpression();
- } // getFormFieldDisplayName
-
- public Calendar getFormFieldRangeStart(ColFilterType filter) {
- FormFieldType fft = null;
- if (filter.getArgType().equals(AppConstants.AT_FORM))
- fft = getFormFieldByDisplayValue(filter.getArgValue());
-
- return (fft != null) ? fft.getRangeStartDate().toGregorianCalendar() : null;
- } // getFormFieldRangeStart
-
- public Calendar getFormFieldRangeEnd(ColFilterType filter) {
- FormFieldType fft = null;
- if (filter.getArgType().equals(AppConstants.AT_FORM))
- fft = getFormFieldByDisplayValue(filter.getArgValue());
-
- //System.out.println("as " + fft.getRangeEndDate());
- return (fft != null) ? fft.getRangeEndDate().toGregorianCalendar() : null;
- } // getFormFieldRangeEnd
-
- public String getFormFieldRangeStartSQL(ColFilterType filter) {
- FormFieldType fft = null;
- if (filter.getArgType().equals(AppConstants.AT_FORM))
- fft = getFormFieldByDisplayValue(filter.getArgValue());
-
- return (fft != null) ? fft.getRangeStartDateSQL() : null;
- } // getFormFieldRangeStart
-
- public String getFormFieldRangeEndSQL(ColFilterType filter) {
- FormFieldType fft = null;
- if (filter.getArgType().equals(AppConstants.AT_FORM))
- fft = getFormFieldByDisplayValue(filter.getArgValue());
-
- //System.out.println("as " + fft.getRangeEndDate());
- return (fft != null) ? fft.getRangeEndDateSQL() : null;
- } // getFormFieldRangeEnd
-
- public String getUniqueTableId(String tableName) {
- String tableIdPrefix = tableName.startsWith("MSA_") ? tableName.substring(4, 6)
- : tableName.substring(0, 2);
- String tableId = "";
-
- int tableIdN = getDataSourceList().getDataSource().size() + 1;
- do {
- tableId = tableIdPrefix.toLowerCase() + (tableIdN++);
- } while (getTableById(tableId) != null);
-
- return tableId;
- } // getUniqueTableId
-
- /** ************************************************************************************************* */
-
- protected void deleteDataSourceType(String tableId) {
- List dsList = getDataSourceList().getDataSource();
- for (Iterator iter = dsList.iterator(); iter.hasNext();) {
- DataSourceType dst = (DataSourceType) iter.next();
- if (dst.getTableId().equals(tableId))
- iter.remove();
- else if (nvl(dst.getRefTableId()).equals(tableId)) {
- dst.setRefTableId(null);
- dst.setRefDefinition(null);
- }
- } // for
-
- resetCache(false);
- } // deleteDataSourceType
-
- public static void adjustColumnType(DataColumnType dct) {
- dct.setColType(dct.getDbColType());
-
- if (dct.isCalculated())
- if (dct.getColName().startsWith("SUM(") || dct.getColName().startsWith("COUNT(")
- || dct.getColName().startsWith("AVG(")
- || dct.getColName().startsWith("STDDEV(")
- || dct.getColName().startsWith("VARIANCE("))
- dct.setColType(AppConstants.CT_NUMBER);
- else if (dct.getColName().startsWith("DECODE(") || dct.getColName().startsWith("coalesce("))
- dct.setColType(AppConstants.CT_CHAR);
- } // adjustColumnType
-
- public static boolean getColumnNoParseDateFlag(DataColumnType dct) {
- return (nvls(dct.getComment()).indexOf(AppConstants.CF_NO_PARSE_DATE) >= 0);
- } // getColumnNoParseDateFlag
-
- public static void setColumnNoParseDateFlag(DataColumnType dct, boolean noParseDateFlag) {
- dct.setComment(noParseDateFlag ? AppConstants.CF_NO_PARSE_DATE : null);
- } // setColumnNoParseDateFlag
-
- /** ************************************************************************************************* */
-
- public static String getSQLBasedFFTColTableName(String fftColId) {
- return fftColId.substring(0, fftColId.indexOf('.'));
- } // getSQLBasedFFTColTableName
-
- public static String getSQLBasedFFTColColumnName(String fftColId) {
- fftColId = (fftColId.indexOf('|') < 0) ? fftColId : fftColId.substring(0, fftColId
- .indexOf('|'));
- return fftColId.substring(fftColId.indexOf('.') + 1);
- } // getSQLBasedFFTColColumnName
-
- public static String getSQLBasedFFTColDisplayFormat(String fftColId) {
- return (fftColId.indexOf('|') < 0) ? "" : fftColId
- .substring(fftColId.indexOf('|') + 1);
- } // getSQLBasedFFTColDisplayFormat
-
- /** ************************************************************************************************* */
-
- public List<DataColumnType> getAllColumns() {
- if (cr == null)
- throw new NullPointerException("CustomReport not initialized");
-
- if (allColumns == null) {
- allColumns = new Vector();
-
- List dsList = getDataSourceList().getDataSource();
- for (Iterator iter = dsList.iterator(); iter.hasNext();) {
- DataSourceType ds = (DataSourceType) iter.next();
-
- // allColumns.addAll(ds.getDataColumnList().getDataColumn());
- List dcList = ds.getDataColumnList().getDataColumn();
- for (Iterator iterC = dcList.iterator(); iterC.hasNext();) {
- DataColumnType dc = (DataColumnType) iterC.next();
-
- allColumns.add(dc);
- } // for
- } // for
-
- Collections.sort(allColumns, new OrderSeqComparator());
- } // if
-
- return allColumns;
- } // getAllColumns
-
- public List getOnlyVisibleColumns() {
- if (cr == null)
- throw new NullPointerException("CustomReport not initialized");
-
- if (allVisibleColumns == null) {
- allVisibleColumns = new Vector();
-
- List dsList = getDataSourceList().getDataSource();
- for (Iterator iter = dsList.iterator(); iter.hasNext();) {
- DataSourceType ds = (DataSourceType) iter.next();
-
- // allColumns.addAll(ds.getDataColumnList().getDataColumn());
- List dcList = ds.getDataColumnList().getDataColumn();
- for (Iterator iterC = dcList.iterator(); iterC.hasNext();) {
- DataColumnType dc = (DataColumnType) iterC.next();
- if(dc.isVisible())
- allVisibleColumns.add(dc);
- } // for
- } // for
-
- Collections.sort(allVisibleColumns, new OrderSeqComparator());
- } // if
-
- return allVisibleColumns;
- } // getOnlyVisibleColumns
- public int getVisibleColumnCount() {
- if (cr == null)
- throw new NullPointerException("CustomReport not initialized");
- int colCount = 0;
- List dsList = getDataSourceList().getDataSource();
- for (Iterator iter = dsList.iterator(); iter.hasNext();) {
- DataSourceType ds = (DataSourceType) iter.next();
-
- // allColumns.addAll(ds.getDataColumnList().getDataColumn());
- List dcList = ds.getDataColumnList().getDataColumn();
- for (Iterator iterC = dcList.iterator(); iterC.hasNext();) {
- DataColumnType dc = (DataColumnType) iterC.next();
- if(dc.isVisible()) colCount ++;
- } // for
- } // for
-
- return colCount;
- }
-
- public List getAllFilters() {
- if (cr == null)
- throw new NullPointerException("CustomReport not initialized");
-
- // if(allFilters==null) {
- allFilters = new Vector();
-
- List reportCols = getAllColumns();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
-
- if (dct.getColFilterList() != null) {
- List colFilters = dct.getColFilterList().getColFilter();
-
- for (Iterator iterF = colFilters.iterator(); iterF.hasNext();) {
- ColFilterType cft = (ColFilterType) iterF.next();
-
- allFilters.add(cft);
- } // for
- } // if
- } // for
-
- // Collections.sort(allFilters, ??);
- // } // if
-
- return allFilters;
- } // getAllFilters
-
- private String formatValue(String value, DataColumnType dc, boolean useDefaultDateFormat) throws RaptorException {
- return formatValue(value, dc, useDefaultDateFormat, getColumnTableById(dc.getColId()), null);
- } // formatValue
-
- private String formatValue(String value, DataColumnType dc, boolean useDefaultDateFormat,
- DataSourceType ds, FormFieldType fft) throws RaptorException {
- String fmtValue = null;
-
- if (nvl(value).length() == 0)
- fmtValue = "";
- else if (value.equals(AppConstants.FILTER_MAX_VALUE)
- || value.equals(AppConstants.FILTER_MIN_VALUE))
- fmtValue = "(SELECT "
- + (value.equals(AppConstants.FILTER_MAX_VALUE) ? "MAX" : "MIN") + "("
- + dc.getColName() + ") FROM " + ds.getTableName() + ")";
- else if (dc.getColType().equals(AppConstants.CT_NUMBER)) {
- try {
- double vD = Double.parseDouble(value);
- fmtValue = value;
- } catch(NumberFormatException ex) {
- throw new UserDefinedException("Expected number, Given String for the form field \"" + fft.getFieldName()+"\"");
- }
- }
- else if (dc.getColType().equals(AppConstants.CT_DATE)) {
- if (fft!=null && (fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) ) {
- fmtValue = "TO_DATE('"
- + value
- + "', '"
- + (useDefaultDateFormat ? AppConstants.DEFAULT_DATE_FORMAT : nvl(dc
- .getColFormat(), AppConstants.DEFAULT_DATE_FORMAT));//+" HH24:MI:SS')";
- fmtValue = fmtValue + " HH24";
- if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC))
- fmtValue = fmtValue + ":MI";
- if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC))
- fmtValue = fmtValue + " HH24:MI:SS";
- } else {
- fmtValue = "TO_DATE('"
- + value
- + "', '"
- + (useDefaultDateFormat ? AppConstants.DEFAULT_DATE_FORMAT : nvl(dc
- .getColFormat(), AppConstants.DEFAULT_DATE_FORMAT)) + "')";
- if (Globals.getMonthFormatUseLastDay())
- if (!useDefaultDateFormat)
- if (nvl(dc.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT).equals(
- "MM/YYYY")
- || nvl(dc.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT)
- .equals("MONTH, YYYY"))
- fmtValue = "ADD_MONTHS(" + fmtValue + ", 1)-1";
- }
- }else {
- fmtValue = value;
- if (!fmtValue.startsWith("'"))
- fmtValue = "'" + fmtValue + "'";
- }
-
- return fmtValue;
- } // formatValue
-
- private String formatListValue(String listValue, DataColumnType dc,
- boolean useDefaultDateFormat, boolean useOnlyPipeDelimiter) throws RaptorException {
- return formatListValue("", listValue, dc, useDefaultDateFormat, useOnlyPipeDelimiter,
- getColumnTableById(dc.getColId()), null);
- } // formatListValue
-
- public String formatListValue(String fieldDisplay, String listValue, DataColumnType dc,
- boolean useDefaultDateFormat, boolean useOnlyPipeDelimiter, DataSourceType ds,
- String listBaseSQL) throws RaptorException {
- StringBuffer fmtValue = new StringBuffer("");
- //if(nvl(listValue,"").trim().length()>0) {
- // The below statement is commented so that pipe is taken out from parsing for text area form field
-// StringTokenizer st = new StringTokenizer(listValue, useOnlyPipeDelimiter ? "|"
- //: ",|\n\r\f");
- StringTokenizer st = new StringTokenizer(listValue, useOnlyPipeDelimiter ? "|"
- : ",\n\r\f");
-
- while (st.hasMoreTokens()) {
- if (fmtValue.length() > 0)
- fmtValue.append(", ");
-
- if (dc == null) {
- // For SQL-based reports - value always string
- String value = st.nextToken().trim();
- if (value.startsWith("'"))
- fmtValue.append(value);
- else
- fmtValue.append("'" + value + "'");
- } else
- fmtValue.append(formatValue(st.nextToken().trim(), dc, useDefaultDateFormat,
- ds, null) );
-
- } // while
-
- if (fmtValue.length() == 0) {
- if(nvl(fieldDisplay).length() > 0) {
- fmtValue.append("");
- } else {
- fmtValue.append("(");
- fmtValue.append(nvl(listBaseSQL, "NULL"));
- fmtValue.append(")");
- }
- } else if (fmtValue.charAt(0) != '(') {
- fmtValue.insert(0, '(');
- fmtValue.append(')');
- }
- /* } else {
- fmtValue = new StringBuffer("()");
- }*/
- return fmtValue.toString();
- } // formatListValue
-
- private String getColumnSelectStr(DataColumnType dc, ReportParamValues paramValues) {
- String colName = dc.isCalculated() ? dc.getColName()
- : ((nvl(dc.getTableId()).length() > 0) ? (dc.getTableId() + "." + dc
- .getColName()) : dc.getColName());
- String paramValue = null;
- if (dc.isCalculated())
- if (getFormFieldList() != null)
- for (Iterator iter2 = getFormFieldList().getFormField().iterator(); iter2
- .hasNext();) {
- FormFieldType fft = (FormFieldType) iter2.next();
- String fieldId = fft.getFieldId();
- String fieldDisplay = getFormFieldDisplayName(fft);
- if (!paramValues.isParameterMultiValue(fieldId)) {
- paramValue = paramValues.getParamValue(fieldId);
- if(paramValue!=null && paramValue.length() > 0) {
- colName = Utils.replaceInString(colName, fieldDisplay, Utils
- .oracleSafe(nvl(paramValue, "NULL")));
- } else {
- colName = Utils.replaceInString(colName, "'" + fieldDisplay + "'", nvl(
- paramValue, "NULL"));
- colName = Utils.replaceInString(colName, fieldDisplay, nvl(
- paramValue, "NULL"));
- }
- }
- } // for
-
- return colName;
- } // getColumnSelectStr
-
- private void addExtraIdSelect(StringBuffer selectExtraIdCl, String drillDownParams,
- boolean includeSelectExpr) {
- // drillDownParams - example value "c_master=[bo1.RECID$]"
- drillDownParams = drillDownParams.substring(10, drillDownParams.length() - 1); // i.e.
- // "bo1.RECID$"
-
- selectExtraIdCl.append(", ");
- if (includeSelectExpr) {
- selectExtraIdCl.append(drillDownParams);
- selectExtraIdCl.append(" ");
- } // if
- selectExtraIdCl.append(drillDownParams.replace('.', '_')); // i.e.
- // "bo1_RECID$"
- } // addExtraIdSelect
-
- private void addExtraDateSelect(StringBuffer selectExtraDateCl, String drillDownParams,
- ReportParamValues paramValues, boolean includeSelectExpr) {
- // drillDownParams - example value "ff1=[dl1]&fc2=[mo3]"
- String colId = "";
- while (drillDownParams.indexOf('[') >= 0) {
- int startIdx = drillDownParams.indexOf('[');
- int endIdx = drillDownParams.indexOf(']');
-
- if(startIdx<=endIdx) {
- colId = drillDownParams.substring(startIdx + 1, endIdx); // i.e.
- } else {
- drillDownParams = drillDownParams.substring(endIdx + 1);
- continue;
- }
- // "dl1"
-
- DataColumnType column = getColumnById(colId);
- if (column != null)
- if (column.getColType().equals(AppConstants.CT_DATE))
- if (!nvl(column.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT).equals(
- AppConstants.DEFAULT_DATE_FORMAT))
- if (selectExtraDateCl.toString().indexOf(
- " " + colId + AppConstants.DD_COL_EXTENSION) < 0) {
- selectExtraDateCl.append(", ");
- if (includeSelectExpr) {
- selectExtraDateCl.append("TO_CHAR("
- + getColumnSelectStr(column, paramValues) + ", '"
- + AppConstants.DEFAULT_DATE_FORMAT + "')");
- selectExtraDateCl.append(" ");
- } // if
- selectExtraDateCl.append(colId + AppConstants.DD_COL_EXTENSION); // i.e.
- // "dl1_dde"
- } // if
-
- drillDownParams = drillDownParams.substring(endIdx + 1);
- } // while
- } // addExtraDateSelect
-
- /*
- * public String generateSQL() { return generateSQL(null); } // generateSQL
- */
- public String generateSQL(String userId, HttpServletRequest request) throws RaptorException {
- return generateSQL(new ReportParamValues(), userId, request);
- } // generateSQL
-
- public String generateSQL(ReportParamValues paramValues, String userId, HttpServletRequest request) throws RaptorException {
- return generateSQL(paramValues, null, AppConstants.SO_ASC, userId, request);
- } // generateSQL
-
- public String generateSQL(ReportParamValues paramValues, String overrideSortByColId,
- String overrideSortByAscDesc, String userId, HttpServletRequest request) throws RaptorException {
- if (cr == null)
- throw new NullPointerException("CustomReport not initialized");
- if(nvl(getWholeSQL()).length()>0) return getWholeSQL();
- if (paramValues.size() > 0)
- resetCache(true);
- //resetCache(true);
- if (generatedSQL == null) {
- if (getReportDefType().equals(AppConstants.RD_SQL_BASED) || getReportDefType().equals(AppConstants.RD_SQL_BASED_DATAMIN)) {
- generatedSQL = generateSQLSQLBased(paramValues, overrideSortByColId,
- overrideSortByAscDesc, userId, request );
- generatedChartSQL = generateSQLSQLBased(paramValues, null,
- AppConstants.SO_ASC, userId, request );
- } else if (getReportDefType().equals(AppConstants.RD_VISUAL) && !getReportType().equals(AppConstants.RT_CROSSTAB)) {
- generatedSQL = generateSQLVisual(paramValues, overrideSortByColId,
- overrideSortByAscDesc, userId, request);
- generatedChartSQL = generateSQLVisual(paramValues, null,
- AppConstants.SO_ASC, userId, request);
- } else {
- generatedSQL = generateSQLCrossTabVisual(paramValues, overrideSortByColId,
- overrideSortByAscDesc, userId, request);
- }
-
- //debugLogger.debug("******************");
- //debugLogger.debug("SQL Before Changing new line \n" + generatedSQL);
- //debugLogger.debug("******************");
- generatedSQL = replaceNewLine(generatedSQL, ""+ '\n', " "+'\n'+" " );
- //chart sql should not be null
- if(nvl(generatedChartSQL).trim().length()>0)
- generatedChartSQL = replaceNewLine(generatedChartSQL, ""+ '\n', " "+'\n'+" " );
- //(generatedSQL, "\n", " \n ");
- //debugLogger.debug("******************");
- //debugLogger.debug("SQL After Changing new line \n" + generatedSQL);
- //debugLogger.debug("******************");
- //generatedSQL = replaceNewLine(generatedSQL, "SELECT", "SELECT ");
- //generatedSQL = replaceNewLine(generatedSQL, "select", "select ");
- //debugLogger.debug("SQL After Changing new line \n" + generatedSQL);
- //debugLogger.debug("[[[[[[[[[[[[[[[[[[");
- //generatedSQL = Utils.replaceInString(generatedSQL, "\n", " ");
- //generatedSQL = Utils.replaceInString(generatedSQL, "\t", " ");
- } // if
-
- return generatedSQL;
- } // generateSQL
-
- public String generateSQLSQLBased(ReportParamValues paramValues,
- String overrideSortByColId, String overrideSortByAscDesc, String userId, HttpServletRequest request) throws RaptorException {
- String sql = getReportSQL();
+ }
+
+ public boolean hideChartToolTips() {
+ boolean s = true;
+ s = (cr.getChartAdditionalOptions() != null)
+ ? (cr.getChartAdditionalOptions().getHideToolTips() != null
+ ? ("Y".equals(cr.getChartAdditionalOptions().getHideToolTips()) ? true : false)
+ : (Globals.hideToolTipsGlobally() ? true : false))
+ : (Globals.hideToolTipsGlobally() ? true : false);
+ return s;
+ }
+
+ public boolean keepDomainAxisValueInChartAsString() {
+ boolean s = true;
+ s = (cr.getChartAdditionalOptions() != null)
+ ? (cr.getChartAdditionalOptions().getKeepDomainAxisValueAsString() != null
+ ? ("Y".equals(cr.getChartAdditionalOptions().getKeepDomainAxisValueAsString()) ? true : false)
+ : false)
+ : false;
+ return s;
+ }
+
+ public int getChartHeightAsInt() {
+ return getIntValue(cr.getChartHeight(), Globals.getDefaultChartHeight());
+ }
+
+ public boolean isPublic() {
+ return cr.isPublic();
+ }
+
+ public boolean isDashboardType() throws RaptorException {
+ return cr.isDashboardType() != null ? cr.isDashboardType().booleanValue() : false;
+ }
+
+ // public String getCreateId() { return cr.getCreateId(); }
+ // public Calendar getCreateDate() { return cr.getCreateDate(); }
+ public String getReportSQL() {
+ return cr.getReportSQL();
+ }
+
+ public String getReportTitle() {
+ return cr.getReportTitle();
+ }
+
+ public String getReportSubTitle() {
+ return cr.getReportSubTitle();
+ }
+
+ public String getReportHeader() {
+ return cr.getReportHeader();
+ }
+
+ public String getReportFooter() {
+ return cr.getReportFooter();
+ }
+
+ public String getNumDashCols() {
+ return cr.getNumDashCols();
+ }
+
+ public int getNumDashColsAsInt() {
+ return getIntValue(cr.getNumDashCols(), 1);
+ }
+
+ public String getNumFormCols() {
+ return cr.getNumFormCols();
+ }
+
+ public int getNumFormColsAsInt() {
+ return getIntValue(cr.getNumFormCols(), 5);
+ }
+
+ public String getDisplayOptions() {
+ return cr.getDisplayOptions();
+ }
+
+ // Additional Methods
+
+ public int getJumpTo() {
+ return cr.getJumpTo() == null ? 1 : cr.getJumpTo();
+ }
+
+ public void setJumpTo(int value) {
+ cr.setJumpTo(value);
+ }
+
+ public int getSearchPageSize() {
+ return cr.getSearchPageSize() == null ? 20 : cr.getSearchPageSize();
+ }
+
+ public void setSearchPageSize(int value) {
+ cr.setSearchPageSize(value);
+ }
+
+ public boolean isToggleLayout() {
+ if (cr.isToggleLayout() != null)
+ return cr.isToggleLayout();
+
+ else
+ return Globals.displayRuntimeOptionsAsDefault();
+
+ }
+
+ public void setToggleLayout(boolean value) {
+ cr.setToggleLayout(value);
+ }
+
+ public boolean isShowPageSize() {
+ if (cr.isShowPageSize() != null)
+ return cr.isShowPageSize();
+
+ else
+ return Globals.displayRuntimeOptionsAsDefault();
+
+ }
+
+ public void setShowPageSize(boolean value) {
+ cr.setShowPageSize(value);
+ }
+
+ public boolean isShowNavPos() {
+ if (cr.isShowNavPos() != null)
+ return cr.isShowNavPos();
+
+ else
+ return Globals.displayRuntimeOptionsAsDefault();
+
+ }
+
+ public void setShowNavPos(boolean value) {
+ cr.setShowNavPos(value);
+ }
+
+ public boolean isShowGotoOption() {
+ if (cr.isShowGotoOption() != null)
+ return cr.isShowGotoOption();
+
+ else
+ return Globals.displayRuntimeOptionsAsDefault();
+
+ }
+
+ public void setShowGotoOption(boolean value) {
+ cr.setShowGotoOption(value);
+ }
+
+ public boolean isPageNav() {
+
+ if (cr.isPageNav() != null)
+ return cr.isPageNav();
+
+ else
+ return Globals.displayRuntimeOptionsAsDefault();
+
+ }
+
+ public void setPageNav(boolean value) {
+ cr.setPageNav(value);
+ }
+
+ public String getNavPosition() {
+ if (cr.getNavPosition() != null)
+ return cr.getNavPosition();
+
+ else
+ return "top";
+ // return cr.getNavPosition();
+ }
+
+ public void setNavPosition(String value) {
+ cr.setNavPosition(value);
+ }
+
+ public String getDashboardEditor() {
+ return getDashBoardReportsNew().getDashboardEditor();
+ }
+
+ public void setDashboardEditor(String value) {
+ getDashBoardReportsNew().setDashboardEditor(value);
+ }
+
+ public DashboardEditorList getDashboardEditorList() {
+ return getDashBoardReportsNew().getDashboardEditorList();
+ }
+
+ public void setDashboardEditorList(DashboardEditorList value) {
+ getDashBoardReportsNew().setDashboardEditorList(value);
+ }
+
+ public PDFAdditionalOptions getPDFAdditionalOptions() {
+ try {
+ if (cr.getPdfAdditionalOptions() == null)
+ addPDFAdditionalOptions(new ObjectFactory());
+ } catch (RaptorException ex) {
+ logger.error(EELFLoggerDelegate.debugLogger, "Exception occured in getPDFAdditionalOptions ", ex);
+ }
+ return cr.getPdfAdditionalOptions();
+ }
+
+ public String getPDFFont() {
+ return getPDFAdditionalOptions().getPDFFont() != null ? getPDFAdditionalOptions().getPDFFont()
+ : Globals.getDataFontFamily();
+ }
+
+ public void setPDFFont(String value) {
+ getPDFAdditionalOptions().setPDFFont(value);
+ }
+
+ public int getPDFFontSize() {
+ return getPDFAdditionalOptions().getPDFFontSize() == null ? 9 : getPDFAdditionalOptions().getPDFFontSize();
+ }
+
+ public void setPDFFontSize(int value) {
+ getPDFAdditionalOptions().setPDFFontSize(value);
+ }
+
+ public String getPDFOrientation() {
+ return getPDFAdditionalOptions().getPDFOrientation() != null ? "portrait" : "landscape";
+ }
+
+ public void setPDFOrientation(String value) {
+ getPDFAdditionalOptions().setPDFOrientation(value);
+ }
+
+ public String getPDFLogo1() {
+ return getPDFAdditionalOptions().getPDFLogo1();
+ }
+
+ public void setPDFLogo1(String value) {
+ getPDFAdditionalOptions().setPDFLogo1(value);
+ }
+
+ public String getPDFLogo2() {
+ return getPDFAdditionalOptions().getPDFLogo2();
+ }
+
+ public void setPDFLogo2(String value) {
+ getPDFAdditionalOptions().setPDFLogo2(value);
+ }
+
+ public int getPDFLogo1Size() {
+ return getPDFAdditionalOptions().getPDFLogo1Size() == null ? 0 : getPDFAdditionalOptions().getPDFLogo1Size();
+ }
+
+ public void setPDFLogo1Size(int value) {
+ getPDFAdditionalOptions().setPDFLogo1Size(value);
+ }
+
+ public int getPDFLogo2Size() {
+ return getPDFAdditionalOptions().getPDFLogo2Size() == null ? 0 : getPDFAdditionalOptions().getPDFLogo2Size();
+ }
+
+ public void setPDFLogo2Size(int value) {
+ getPDFAdditionalOptions().setPDFLogo2Size(value);
+ }
+
+ public boolean isPDFCoverPage() {
+
+ if (getPDFAdditionalOptions().isPDFCoverPage() != null)
+ return getPDFAdditionalOptions().isPDFCoverPage();
+
+ else
+ return true;
+
+ }
+
+ public void setPDFCoverPage(boolean value) {
+ getPDFAdditionalOptions().setPDFCoverPage(value);
+ }
+
+ public String getPDFFooter1() {
+ return getPDFAdditionalOptions().getPDFFooter1();
+ }
+
+ public void setPDFFooter1(String value) {
+ getPDFAdditionalOptions().setPDFFooter1(value);
+ }
+
+ public String getPDFFooter2() {
+ return getPDFAdditionalOptions().getPDFFooter2();
+ }
+
+ public void setPDFFooter2(String value) {
+ getPDFAdditionalOptions().setPDFFooter2(value);
+ }
+
+ // End of Additional Methods
+
+ public String getDataContainerHeight() {
+ return cr.getDataContainerHeight();
+ }
+
+ public String getDataContainerWidth() {
+ return cr.getDataContainerWidth();
+ }
+
+ public boolean isAllowSchedule() {
+ String allowSchedule = getAllowSchedule();
+ return (allowSchedule != null) ? allowSchedule.startsWith("Y") : false;
+ }
+
+ public String getAllowSchedule() {
+ return cr.getAllowSchedule();
+ }
+
+ /* Multi Group */
+
+ public boolean isMultiGroupColumn() {
+ String multiGroupColumn = getMultiGroupColumn();
+ return (multiGroupColumn != null) ? multiGroupColumn.startsWith("Y") : false;
+ }
+
+ public String getMultiGroupColumn() {
+ return cr.getMultiGroupColumn();
+ }
+
+ public void setMultiGroupColumn(String value) {
+ cr.setMultiGroupColumn(value);
+ }
+
+ private int getColumnGroupLevel(String colId) throws RaptorException {
+ DataColumnType dc = getColumnById(colId);
+ return (dc == null) ? 0 : dc.getLevel();
+ } // getColumnGroupLevel
+
+ public int getMaxGroupLevel() {
+ List reportCols = getAllColumns();
+ int maxLevel = 0;
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (dc.getLevel() != null) {
+ if (maxLevel < dc.getLevel())
+ maxLevel = dc.getLevel();
+ }
+ } // for
+ return maxLevel;
+ } // getMaxGroupLevel
+
+ private int getColumnGroupStart(String colId) throws RaptorException {
+ DataColumnType dc = getColumnById(colId);
+ return (dc == null) ? 0 : dc.getStart();
+ } // getColumnGroupStart
+
+ private int getColumnGroupColSpan(String colId) throws RaptorException {
+ DataColumnType dc = getColumnById(colId);
+ return (dc == null) ? 0 : dc.getColspan();
+ } // getColumnGroupColSpan
+
+ public void setTopDown(String value) {
+ cr.setTopDown(value);
+ }
+
+ public boolean isTopDown() {
+ String topDown = getTopDownOption();
+ return (topDown != null) ? topDown.startsWith("Y") : false;
+ }
+
+ public String getTopDownOption() {
+ return cr.getTopDown();
+ }
+
+ public void setSizedByContent(String value) {
+ cr.setSizedByContent(value);
+ }
+
+ public boolean isSizedByContent() {
+ String sizedByContent = getSizedByContentOption();
+ return (sizedByContent != null) ? sizedByContent.startsWith("Y") : false;
+ }
+
+ public String getSizedByContentOption() {
+ return cr.getSizedByContent();
+ }
+
+ public String getDashboardOptions() {
+ return cr.getDashboardOptions();
+ }
+
+ public boolean isDashboardOptionHideChart() {
+ return nvl(getDashboardOptions()).length() > 0 && (getDashboardOptions().charAt(0) == 'Y');
+ }
+
+ public boolean isDashboardOptionHideData() {
+ return nvl(getDashboardOptions()).length() > 0 && (getDashboardOptions().charAt(1) == 'Y');
+ }
+
+ public boolean isDashboardOptionHideBtns() {
+ return nvl(getDashboardOptions()).length() > 0 && (getDashboardOptions().charAt(2) == 'Y');
+ }
+
+ public boolean isDisplayOptionHideForm() {
+ return nvl(getDisplayOptions()).length() > 0 && (getDisplayOptions().charAt(0) == 'Y');
+ }
+
+ public boolean isDisplayOptionHideChart() {
+ return nvl(getDisplayOptions()).length() > 1 && (getDisplayOptions().charAt(1) == 'Y');
+ }
+
+ public boolean isDisplayOptionHideData() {
+ return nvl(getDisplayOptions()).length() > 2 && (getDisplayOptions().charAt(2) == 'Y');
+ }
+
+ public boolean isDisplayOptionHideBtns() {
+ return nvl(getDisplayOptions()).length() > 3 && (getDisplayOptions().charAt(3) == 'Y');
+ }
+
+ public boolean isDisplayOptionHideMap() {
+ return nvl(getDisplayOptions()).length() > 4 && (getDisplayOptions().charAt(4) == 'Y');
+ }
+
+ public boolean isDisplayOptionHideExcelIcons() {
+ return nvl(getDisplayOptions()).length() > 5 && (getDisplayOptions().charAt(5) == 'Y');
+ }
+
+ public boolean isDisplayOptionHidePDFIcons() {
+ return nvl(getDisplayOptions()).length() > 6 && (getDisplayOptions().charAt(6) == 'Y');
+ }
+
+ public String getComment() {
+ return cr.getComment();
+ }
+
+ public DataSourceList getDataSourceList() {
+ return cr.getDataSourceList();
+ }
+
+ public ChartAdditionalOptions getChartAdditionalOptions() {
+ return cr.getChartAdditionalOptions();
+ }
+
+ public ChartDrillOptions getChartDrillOptions() {
+ return cr.getChartDrillOptions();
+ }
+
+ public DataminingOptions getDataminingOptions() {
+ return cr.getDataminingOptions();
+ }
+
+ public DashboardReports getDashBoardReports() {
+ return cr.getDashBoardReports();
+ }
+
+ public DashboardReportsNew getDashBoardReportsNew() {
+ try {
+ if (cr.getDashBoardReportsNew() == null)
+ addDashboardReportsNew(new ObjectFactory());
+ } catch (RaptorException ex) {
+ ex.printStackTrace();
+ }
+ return cr.getDashBoardReportsNew();
+ }
+
+ public String getDashboardLayoutHTML() {
+ return cr.getDashboardLayoutHTML();
+ }
+
+ public FormFieldList getFormFieldList() {
+ return cr.getFormFieldList();
+ }
+
+ public JavascriptList getJavascriptList() {
+ return cr.getJavascriptList();
+ }
+
+ public SemaphoreList getSemaphoreList() {
+ return cr.getSemaphoreList();
+ }
+
+ public void setPageSize(int value) {
+ cr.setPageSize(value);
+ }
+
+ public void setAllowSchedule(String value) {
+ cr.setAllowSchedule(value);
+ }
+
+ public void setMaxRowsInExcelDownload(int value) {
+ cr.setMaxRowsInExcelDownload(value);
+ }
+
+ public void setReportInNewWindow(boolean value) {
+ cr.setReportInNewWindow(value);
+ }
+
+ public void setDisplayFolderTree(boolean value) {
+ cr.setDisplayFolderTree(value);
+ }
+
+ public void setReportType(String value) {
+ cr.setReportType(value);
+ }
+
+ public void setReportName(String value) {
+ cr.setReportName(value);
+ }
+
+ public void setDBInfo(String value) {
+ if (!(cr.getDbInfo() != null && cr.getDbInfo().length() > 0))
+ cr.setDbInfo(value);
+ }
+
+ public void setDBType(String value) {
+ if (!(cr.getDbType() != null && cr.getDbType().length() > 0))
+ cr.setDbType(value);
+ }
+
+ public void setReportDescr(String value) {
+ cr.setReportDescr(value);
+ }
+
+ public void setChartType(String value) {
+ cr.setChartType(value);
+ }
+
+ public void setChartMultiplePieOrder(String value) {
+ cr.getChartAdditionalOptions().setChartMultiplePieOrder(value);
+ }
+
+ public void setChartMultiplePieLabelDisplay(String value) {
+ cr.getChartAdditionalOptions().setChartMultiplePieLabelDisplay(value);
+ }
+
+ public void setChartOrientation(String value) {
+ cr.getChartAdditionalOptions().setChartOrientation(value);
+ }
+
+ public void setSecondaryChartRenderer(String value) {
+ cr.getChartAdditionalOptions().setSecondaryChartRenderer(value);
+ }
+
+ public void setOverlayItemValueOnStackBar(String value) {
+ cr.getChartAdditionalOptions().setOverlayItemValueOnStackBar(value);
+ }
+
+ public void setIntervalFromdate(String value) {
+ cr.getChartAdditionalOptions().setIntervalFromdate(value);
+ }
+
+ public void setIntervalLabel(String value) {
+ cr.getChartAdditionalOptions().setIntervalLabel(value);
+ }
+
+ public void setIntervalTodate(String value) {
+ cr.getChartAdditionalOptions().setIntervalTodate(value);
+ }
+
+ public void setLegendPosition(String value) {
+ cr.getChartAdditionalOptions().setLegendPosition(value);
+ }
+
+ public void setLegendLabelAngle(String value) {
+ cr.getChartAdditionalOptions().setLabelAngle(value);
+ }
+
+ public void setMaxLabelsInDomainAxis(String value) {
+ if (nvl(value).length() <= 0)
+ value = "99";
+ cr.getChartAdditionalOptions().setMaxLabelsInDomainAxis(value);
+ }
+
+ public void setLastSeriesALineChart(String value) {
+ cr.getChartAdditionalOptions().setLastSeriesALineChart(value);
+ }
+
+ public void setLastSeriesABarChart(String value) {
+ cr.getChartAdditionalOptions().setLastSeriesABarChart(value);
+ }
+
+ public void setChartDisplay(String value) {
+ cr.getChartAdditionalOptions().setChartDisplay(value);
+ }
+
+ public void setChartAnimate(boolean animate) {
+ if (cr.getChartAdditionalOptions() != null)
+ cr.getChartAdditionalOptions().setAnimate(animate);
+ else {
+ try {
+ if (getChartAdditionalOptions() == null)
+ addChartAdditionalOptions(new ObjectFactory());
+ } catch (RaptorException ex) {
+ logger.error(EELFLoggerDelegate.debugLogger, "Exception occured in setChartAnimate ", ex);
+ }
+ if (cr.getChartAdditionalOptions() != null)
+ cr.getChartAdditionalOptions().setAnimate(animate);
+
+ }
+
+ }
+
+ public void addChartAdditionalOptions(ObjectFactory objFactory) throws RaptorException {
+ ChartAdditionalOptions chartOptions = objFactory.createChartAdditionalOptions();
+ cr.setChartAdditionalOptions(chartOptions);
+ }
+
+ public void addDashboardReportsNew(ObjectFactory objFactory) throws RaptorException {
+ DashboardReportsNew dashboardReports = objFactory.createDashboardReportsNew();
+ cr.setDashBoardReportsNew(dashboardReports);
+ }
+
+ public void addPDFAdditionalOptions(ObjectFactory objFactory) throws RaptorException {
+ PDFAdditionalOptions pdfOptions = objFactory.createPDFAdditionalOptions();
+ cr.setPdfAdditionalOptions(pdfOptions);
+ }
+
+ public void setChartTypeFixed(String value) {
+ cr.setChartTypeFixed(value);
+ }
+
+ public void setChartLeftAxisLabel(String value) {
+ cr.setChartLeftAxisLabel(value);
+ }
+
+ public void setChartRightAxisLabel(String value) {
+ cr.setChartRightAxisLabel(value);
+ }
+
+ public void setChartWidth(String value) {
+ cr.setChartWidth(value);
+ }
+
+ public void setChartHeight(String value) {
+ cr.setChartHeight(value);
+ }
+
+ public void setChartMultiSeries(String value) {
+ cr.setChartMultiSeries(value);
+ }
+
+ public void setPublic(boolean value) {
+ cr.setPublic(value);
+ if (reportSecurity != null)
+ reportSecurity.setPublic(value);
+ }
+
+ // public void setCreateId(String value) { cr.setCreateId(value); }
+ // public void setCreateDate(Calendar value) { cr.setCreateDate(value); }
+ public void setReportSQL(String value) {
+ cr.setReportSQL(value);
+ }
+
+ public void setReportTitle(String value) {
+ cr.setReportTitle(value);
+ }
+
+ public void setReportSubTitle(String value) {
+ cr.setReportSubTitle(value);
+ }
+
+ public void setReportHeader(String value) {
+ cr.setReportHeader(value);
+ }
+
+ public void setReportFooter(String value) {
+ cr.setReportFooter(value);
+ }
+
+ public void setNumFormCols(String value) {
+ cr.setNumFormCols(value);
+ }
+
+ public void setNumDashCols(String value) {
+ cr.setNumDashCols(value);
+ }
+
+ public void setDisplayOptions(String value) {
+ cr.setDisplayOptions(value);
+ }
+
+ public void setDataContainerHeight(String value) {
+ cr.setDataContainerHeight(value);
+ }
+
+ public void setDataContainerWidth(String value) {
+ cr.setDataContainerWidth(value);
+ }
+
+ public void setDashboardOptions(String value) {
+ cr.setDashboardOptions(value);
+ }
+
+ public void setComment(String value) {
+ cr.setComment(value);
+ }
+
+ public void setDashboardType(boolean dashboardType) {
+ cr.setDashboardType(dashboardType);
+ }
+
+ public void setDashboardLayoutHTML(String html) {
+ cr.setDashboardLayoutHTML(html);
+ }
+
+ public void setDataSourceList(DataSourceList value) {
+ cr.setDataSourceList(value);
+ }
+
+ public void setFormFieldList(FormFieldList value) {
+ cr.setFormFieldList(value);
+ }
+
+ public void setDashBoardReports(DashboardReports value) {
+ cr.setDashBoardReports(value);
+ }
+
+ public void setSemaphoreList(SemaphoreList value) {
+ cr.setSemaphoreList(value);
+ }
+
+ public void setJavascriptList(JavascriptList value) {
+ cr.setJavascriptList(value);
+ }
+
+ public void setJavascriptElement(String javascriptElement) {
+ cr.setJavascriptElement(javascriptElement);
+ }
+
+ public void checkUserReadAccess(HttpServletRequest request) throws RaptorException {
+ reportSecurity.checkUserReadAccess(request, null);
+ }
+
+ public void checkUserReadAccess(HttpServletRequest request, String userID) throws RaptorException {
+ reportSecurity.checkUserReadAccess(request, userID);
+ }
+
+ public void checkUserWriteAccess(HttpServletRequest request) throws RaptorException {
+ reportSecurity.checkUserWriteAccess(request);
+ verifySQLBasedReportAccess(request);
+ }
+
+ public String getOwnerID() {
+ return reportSecurity.getOwnerID();
+ }
+
+ public String getCreateID() {
+ return reportSecurity.getCreateID();
+ }
+
+ public String getCreateDate() {
+ return reportSecurity.getCreateDate();
+ }
+
+ public String getUpdateID() {
+ return reportSecurity.getUpdateID();
+ }
+
+ public String getUpdateDate() {
+ return reportSecurity.getUpdateDate();
+ }
+
+ public ReportSecurity getReportSecurity() {
+ return reportSecurity;
+ }
+
+ /**** Report Maps - Start ****/
+ public ReportMap getReportMap() {
+ return cr.getReportMap();
+ }
+
+ public void setReportMap(ReportMap reportMap) {
+ cr.setReportMap(reportMap);
+ }
+
+ /**** Report Maps - End ****/
+
+ /**** Report Chart Drilldown - Start ****/
+ public ChartDrillOptions getReportChartDrillOptions() {
+ return cr.getChartDrillOptions();
+ }
+
+ public void setReportChartDrillOptions(ChartDrillOptions chartDrillOptions) {
+ cr.setChartDrillOptions(chartDrillOptions);
+ }
+
+ /**** Report Maps - End ****/
+
+ /**
+ * *************************************************************************************************
+ */
+
+ public String getFormHelpText() {
+ String formHelpText = nvl(getComment());
+
+ if (formHelpText.indexOf('|') >= 0)
+ formHelpText = formHelpText.substring(formHelpText.lastIndexOf('|') + 1);
+
+ return formHelpText;
+ } // getFormHelpText
+
+ public void setFormHelpText(String formHelpText) {
+ String comment = nvl(getComment());
+
+ if (comment.indexOf('|') >= 0)
+ comment = comment.substring(0, comment.lastIndexOf('|'));
+ if (comment.length() > 0)
+ comment += '|';
+
+ setComment(comment + formHelpText);
+ } // setFormHelpText
+
+ public boolean isRuntimeColSortDisabled() {
+ String comment = nvl(getComment());
+
+ if (comment.indexOf('|') < 0)
+ return false;
+
+ return "Y".equals(comment.substring(0, comment.indexOf('|')));
+ } // isRuntimeColSortDisabled
+
+ public void setRuntimeColSortDisabled(boolean value) {
+ String comment = nvl(getComment());
+
+ if (comment.indexOf('|') >= 0)
+ comment = comment.substring(comment.indexOf('|') + 1);
+
+ setComment((value ? "Y" : "N") + "|" + comment);
+ } // setRuntimeColSortDisabled
+
+ /**
+ * *************************************************************************************************
+ */
+
+ protected void verifySQLBasedReportAccess(HttpServletRequest request) throws RaptorException {
+ String userID = AppUtils.getUserID(request);
+ if (getReportDefType().equals(AppConstants.RD_SQL_BASED)
+ && (!Globals.getAllowSQLBasedReports()) && (!AppUtils.isAdminUser(request)))
+ throw new org.onap.portalsdk.analytics.error.UserAccessException(reportID, "[" + userID + "] "
+ + AppUtils.getUserName(request), AppConstants.UA_WRITE);
+ } // verifySQLBasedReportAccess
+
+ /**
+ * *************************************************************************************************
+ */
+
+ private String getColumnNameById(String colId) throws RaptorException {
+ DataColumnType dc = getColumnById(colId);
+ return (dc == null) ? "NULL" : dc.getColName();
+ } // getColumnNameById
+
+ // Checks if drill-down URL points to individual record display (return
+ // true) or another report (return false)
+ private boolean isViewAction(String value) throws RaptorException {
+ try {
+ Vector viewActions = org.onap.portalsdk.analytics.model.DataCache.getDataViewActions();
+
+ for (int i = 0; i < viewActions.size(); i++)
+ if (value.equals(AppUtils.getBaseActionURL() + ((String) viewActions.get(i))))
+ return true;
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.debugLogger, "Exception occured in isViewAction ", e);
+ throw new RaptorRuntimeException("ReportWrapper.isViewAction Exception: "
+ + e.getMessage());
+ }
+
+ return false;
+ } // isViewAction
+
+ 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 getSelectExpr(DataColumnType dct, String colName) {
+ String colType = dct.getColType();
+ if (colType.equals(AppConstants.CT_NUMBER)) {
+ return colName;
+ } else 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
+
+ /**
+ * *************************************************************************************************
+ */
+
+ public DataSourceType getTableById(String tableId) {
+ for (Iterator iter = getDataSourceList().getDataSource().iterator(); iter.hasNext();) {
+ DataSourceType ds = (DataSourceType) iter.next();
+ if (ds.getTableId().equals(tableId))
+ return ds;
+ } // for
+
+ return null;
+ } // getTableById
+
+ public DataSourceType getTableByDBName(String tableName) {
+ for (Iterator iter = getDataSourceList().getDataSource().iterator(); iter.hasNext();) {
+ DataSourceType ds = (DataSourceType) iter.next();
+ if (ds.getTableName().equals(tableName))
+ return ds;
+ } // for
+
+ return null;
+ } // getTableByDBName
+
+ public DataSourceType getColumnTableById(String colId) {
+ return getTableById(getColumnById(colId).getTableId());
+ } // getColumnTableById
+
+ public DataColumnType getColumnById(String colId) {
+ List reportCols = getAllColumns();
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (dc.getColId().equalsIgnoreCase(colId)) {
+ return dc;
+ }
+ } // for
+
+ return null;
+ } // getColumnById
+
+ public DataColumnType getChartLegendColumn() {
+ List reportCols = getAllColumns();
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND))
+ return dc;
+ } // for
+ return null;
+ } // getChartLegendColumn
+
+ /*
+ * public DataColumnType getChartValueColumn() { List reportCols = getAllColumns(); for(Iterator
+ * iter=reportCols.iterator(); iter.hasNext(); ) { DataColumnType dc = (DataColumnType) iter.next();
+ * if(dc.getChartSeq()>0) return dc; } // for
+ *
+ * return null; } // getChartValueColumn
+ */
+
+ public List getChartValueColumnsList(int filter, HashMap formValues) { /*
+ * filter; all=0;create without new chart =1;
+ * createNewChart=2
+ */
+ List reportCols = 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 = getDependsOnFormFieldFlag(dc, formValues);
+
+ if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) {
+ if (!AppUtils.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 ListModelList<Item> getChartValueColumnsListModelList( int filter, HashMap formValues) { /
+ * *filter; all=0;create without new chart =1; createNewChart=2 * / List reportCols =
+ * getAllColumns();
+ *
+ * ArrayList chartValueCols = new ArrayList(); ListModelList<Item> chartValueListModelList = new
+ * ListModelList<Item>(); int flag = 0; for (Iterator iter = reportCols.iterator(); iter.hasNext();)
+ * { flag = 0; DataColumnType dc = (DataColumnType) iter.next(); // if(filter == 2 || filter == 1) {
+ * flag = getDependsOnFormFieldFlag(dc, formValues);
+ *
+ * if( (dc.getChartSeq()!=null && dc.getChartSeq()> 0) && flag == 0 ) {
+ * 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); chartValueListModelList.add(new
+ * Item(dc.getColId(), dc.getDisplayName())); } // for Collections.sort(chartValueCols, new
+ * ChartSeqComparator()); return chartValueListModelList; } // getChartValueColumnsList
+ */
+
+ /** Check whether chart has series (Category) columns **/
+ public boolean hasSeriesColumn() {
+ List reportCols = getAllColumns();
+
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (dc.isChartSeries() != null && dc.isChartSeries().booleanValue())
+ return true;
+ } // for
+ return false;
+ } // hasSeriesColumn
+
+ public List getChartDisplayNamesList(int filter, HashMap formValues) { /*
+ * filter; all=0;create without new chart =1;
+ * createNewChart=2
+ */
+ List reportCols = getAllColumns();
+ ArrayList chartValueColNames = 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 = getDependsOnFormFieldFlag(dc, formValues);
+
+ if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) {
+ if (nvl(dc.getChartGroup()).length() <= 0) {
+ if (filter == 2 && (dc.isCreateInNewChart() != null && dc.isCreateInNewChart().booleanValue())) {
+ chartValueColNames.add(dc.getDisplayName());
+ } else if (filter == 1
+ && (dc.isCreateInNewChart() == null || !dc.isCreateInNewChart().booleanValue())) {
+ chartValueColNames.add(dc.getDisplayName());
+ } else if (filter == 0)
+ chartValueColNames.add(dc.getDisplayName());
+ } else if (filter == 0)
+ chartValueColNames.add(dc.getDisplayName());
+ }
+ // } else
+ // chartValueColNames.add(dc.getDisplayName());
+
+ }
+ return chartValueColNames;
+ } // getChartDisplayNamesList
+
+ public List getChartColumnColorsList(int filter, HashMap formValues) { /*
+ * filter; all=0;create without new chart =1;
+ * createNewChart=2
+ */
+ List reportCols = getAllColumns();
+ ArrayList chartValueColColors = 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 = getDependsOnFormFieldFlag(dc, formValues);
+
+ if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) {
+ if (nvl(dc.getChartGroup()).length() <= 0) {
+ if (filter == 2 && (dc.isCreateInNewChart() != null && dc.isCreateInNewChart().booleanValue())) {
+ chartValueColColors.add(dc.getChartColor());
+ } else if (filter == 1
+ && (dc.isCreateInNewChart() == null || !dc.isCreateInNewChart().booleanValue())) {
+ chartValueColColors.add(dc.getChartColor());
+ } else if (filter == 0)
+ chartValueColColors.add(dc.getChartColor());
+ } else if (filter == 0)
+ chartValueColColors.add(dc.getChartColor());
+ }
+ // } else
+ // chartValueColColors.add(dc.getChartColor());
+ }
+ return chartValueColColors;
+ } // getChartColumnColorsList
+
+ public List getChartValueColumnAxisList(int filter, HashMap formValues) { /*
+ * filter; all=0;create without new chart
+ * =1; createNewChart=2
+ */
+ List reportCols = getAllColumns();
+ ArrayList chartValueColAxis = 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 = getDependsOnFormFieldFlag(dc, formValues);
+
+ if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) {
+ if (nvl(dc.getChartGroup()).length() <= 0) {
+ if (filter == 2 && (dc.isCreateInNewChart() != null && dc.isCreateInNewChart().booleanValue())) {
+ chartValueColAxis.add(nvl(dc.getColOnChart(), "0"));
+ } else if (filter == 1
+ && (dc.isCreateInNewChart() == null || !dc.isCreateInNewChart().booleanValue())) {
+ chartValueColAxis.add(nvl(dc.getColOnChart(), "0"));
+ } else if (filter == 0)
+ chartValueColAxis.add(nvl(dc.getColOnChart(), "0"));
+ } else if (filter == 0)
+ chartValueColAxis.add(nvl(dc.getColOnChart(), "0"));
+ }
+ // } else
+ // chartValueColAxis.add(nvl(dc.getColOnChart(), "0"));
+ }
+ return chartValueColAxis;
+ } // getChartColumnAxisList
+
+ public List getChartValueNewChartList() {
+ ArrayList chartValueNewChartAxis = new ArrayList();
+ for (Iterator iter = getChartValueColumnsList(2, null).iterator(); iter.hasNext();)
+ chartValueNewChartAxis.add(new Boolean(((DataColumnType) iter.next()).isCreateInNewChart()));
+ return chartValueNewChartAxis;
+ } // getChartValueNewChartList
+
+ public List getAllChartGroups() {
+ ArrayList chartGroups = new ArrayList();
+ String chartGroupName = "";
+ List reportCols = getAllColumns();
+ Set groupSet = new TreeSet();
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (dc.getChartSeq() != null && dc.getChartSeq() > 0) {
+ chartGroupName = dc.getChartGroup();
+ if (nvl(chartGroupName).length() > 0)
+ groupSet.add(chartGroupName);
+ }
+ }
+ List l = new ArrayList(groupSet);
+ return l;
+ } // getAllChartGroups
+
+ public HashMap getAllChartYAxis(ReportParamValues reportParamValues) {
+ String chartYAxis = "";
+ List reportCols = getAllColumns();
+ HashMap hashMap = new HashMap();
+ FormFieldList formFieldList = getFormFieldList();
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (dc.getChartSeq() != null && dc.getChartSeq() > 0) {
+ chartYAxis = dc.getYAxis();
+ if (formFieldList != null && reportParamValues != null) {
+ for (Iterator iter1 = getFormFieldList().getFormField().iterator(); iter1.hasNext();) {
+ FormFieldType fft = (FormFieldType) iter1.next();
+ String fieldDisplay = getFormFieldDisplayName(fft);
+ String fieldId = "";
+ if (fft != null)
+ fieldId = fft.getFieldId();
+ if (fft != null && !fft.getFieldType().equals(FormField.FFT_BLANK)
+ && !fft.getFieldType().equals(FormField.FFT_LIST_MULTI)
+ && !fft.getFieldType().equals(FormField.FFT_TEXTAREA)) {
+ String paramValue = Utils.oracleSafe(nvl(reportParamValues.getParamValue(fieldId)));
+ chartYAxis = Utils.replaceInString(chartYAxis, fieldDisplay, nvl(
+ paramValue, ""));
+ }
+ }
+ }
+ if (nvl(dc.getChartGroup()).length() > 0)
+ hashMap.put(dc.getChartGroup(), chartYAxis);
+ }
+ }
+ return hashMap;
+ } // getAllChartGroups
+
+ public List getChartGroupColumnAxisList(String chartGroupName, HashMap formValues) { /*
+ * filter; all=0;create without
+ * new chart =1;
+ * createNewChart=2
+ */
+ List reportCols = getAllColumns();
+ ArrayList chartGroupColAxis = new ArrayList();
+ String chartGroup = chartGroupName.substring(0, chartGroupName.lastIndexOf("|"));
+ int flag = 0;
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ flag = 0;
+ DataColumnType dc = (DataColumnType) iter.next();
+ // if(filter == 2 || filter == 1) {
+ flag = getDependsOnFormFieldFlag(dc, formValues);
+
+ if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) {
+ if (nvl(dc.getChartGroup()).indexOf("|") > 0
+ && (nvl(dc.getChartGroup().substring(0, dc.getChartGroup().lastIndexOf("|")))
+ .equals(chartGroup))) {
+ // if( nvl(dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))).equals(chartGroup))
+ // {
+ // System.out.println("$$$$$$$DC " + dc.getColId()+ " " + dc.getColOnChart());
+ chartGroupColAxis.add(dc);
+ }
+ }
+ // } else
+ // chartValueColAxis.add(nvl(dc.getColOnChart(), "0"));
+ }
+ Collections.sort(chartGroupColAxis, new ChartSeqComparator());
+ return chartGroupColAxis;
+ } // getChartColumnAxisList
+
+ public List getChartGroupValueColumnAxisList(String chartGroupName, HashMap formValues) {
+ List reportCols = getAllColumns();
+ String index = chartGroupName.substring(chartGroupName.lastIndexOf("|") + 1);
+ String chartGroup = chartGroupName.substring(0, chartGroupName.lastIndexOf("|"));
+ // System.out.println("$$$$INDEX " + index);
+ ArrayList chartGroupValueColAxis = new ArrayList();
+ int flag = 0;
+
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ flag = 0;
+ DataColumnType dc = (DataColumnType) iter.next();
+ flag = getDependsOnFormFieldFlag(dc, formValues);
+
+ if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) {
+ // System.out.println(" Chartgroup " +
+ // dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|")));
+ if (nvl(dc.getChartGroup()).indexOf("|") > 0
+ && (nvl(dc.getChartGroup().substring(0, dc.getChartGroup().lastIndexOf("|")))
+ .equals(chartGroup))) {
+ // if( nvl(dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))).equals(chartGroup))
+ // {
+ // System.out.println(" Added Chartgroupname " + chartGroup + " " + dc.getChartGroup() + " " +
+ // index);
+ chartGroupValueColAxis.add(dc);
+ }
+ }
+ }
+ return chartGroupValueColAxis;
+ } // getChartColumnAxisList
+
+ public List getChartGroupDisplayNamesList(String chartGroupName, HashMap formValues) {
+ List reportCols = getAllColumns();
+ ArrayList chartGroupValueColNames = new ArrayList();
+ String chartGroup = chartGroupName.substring(0, chartGroupName.lastIndexOf("|"));
+ int flag = 0;
+
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ flag = 0;
+ DataColumnType dc = (DataColumnType) iter.next();
+ // System.out.println("$$$$$CHART " + dc.getChartSeq()+ " " + dc.getChartGroup()+ " " + chartGroup);
+ flag = getDependsOnFormFieldFlag(dc, formValues);
+
+ if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) {
+ if (nvl(dc.getChartGroup()).indexOf("|") > 0
+ && (nvl(dc.getChartGroup().substring(0, dc.getChartGroup().lastIndexOf("|")))
+ .equals(chartGroup))) {
+ chartGroupValueColNames.add(dc.getDisplayName());
+ }
+ }
+ }
+ return chartGroupValueColNames;
+ } // getChartDisplayNamesList
+
+ public List getChartGroupColumnColorsList(String chartGroupName, HashMap formValues) {
+ List reportCols = getAllColumns();
+ ArrayList chartValueColColors = new ArrayList();
+ String chartGroup = chartGroupName.substring(0, chartGroupName.lastIndexOf("|"));
+ int flag = 0;
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ flag = 0;
+ DataColumnType dc = (DataColumnType) iter.next();
+ flag = getDependsOnFormFieldFlag(dc, formValues);
+
+ if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) {
+ if (nvl(dc.getChartGroup()).indexOf("|") > 0
+ && (nvl(dc.getChartGroup().substring(0, dc.getChartGroup().lastIndexOf("|")))
+ .equals(chartGroup))) {
+ // if( nvl(dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))).equals(chartGroup))
+ // {
+ chartValueColColors.add(dc.getChartColor());
+ }
+ }
+ }
+ return chartValueColColors;
+ } // getChartColumnColorsList
+
+ public List getCrossTabRowColumns() {
+ List reportCols = getAllColumns();
+ Vector v = new Vector(reportCols.size());
+
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (nvl(dc.getCrossTabValue()).equals(AppConstants.CV_ROW))
+ v.add(dc);
+ } // for
+
+ return v;
+ } // getCrossTabRowColumns
+
+ public List getCrossTabColColumns() {
+ List reportCols = getAllColumns();
+ Vector v = new Vector(reportCols.size());
+
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (nvl(dc.getCrossTabValue()).equals(AppConstants.CV_COLUMN))
+ v.add(dc);
+ } // for
+
+ return v;
+ } // getCrossTabColColumns
+
+ public String getCrossTabDisplayTotal(String rowColPos) {
+ DataColumnType dct = getCrossTabValueColumn();
+ if (dct == null)
+ return "";
+
+ String displayTotal = nvl(dct.getDisplayTotal());
+ if (displayTotal.indexOf('|') >= 0) {
+ String displayColTotal = displayTotal.substring(0, displayTotal.indexOf('|'));
+ String displayRowTotal = displayTotal.substring(displayTotal.indexOf('|') + 1);
+
+ if (rowColPos.equals(AppConstants.CV_COLUMN))
+ displayTotal = displayColTotal;
+ else if (rowColPos.equals(AppConstants.CV_ROW))
+ displayTotal = displayRowTotal;
+ else if (displayColTotal.equals(displayRowTotal))
+ displayTotal = displayColTotal;
+ } // if
+
+ return displayTotal;
+ } // getCrossTabDisplayTotal
+
+ public DataColumnType getCrossTabValueColumn() {
+ List reportCols = getAllColumns();
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (nvl(dc.getCrossTabValue()).equals(AppConstants.CV_VALUE))
+ return dc;
+ } // for
+
+ return null;
+ } // getCrossTabValueColumn
+
+ public int getCrossTabValueColumnIndex() { // Returns the index counting
+ // only visible columns
+ List reportCols = getAllColumns();
+
+ int idx = 0;
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (nvl(dc.getCrossTabValue()).equals(AppConstants.CV_VALUE))
+ break;
+ if (dc.isVisible())
+ idx++;
+ } // for
+
+ return idx;
+ } // getCrossTabValueColumnIndex
+
+ public ColFilterType getFilterById(String colId, int filterIndex) {
+ DataColumnType dc = getColumnById(colId);
+ try {
+ return dc.getColFilterList().getColFilter().get(filterIndex);
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.debugLogger, "Exception occured in getFilterById ", e);
+ return null;
+ }
+ } // getFilterById
+
+ public boolean needFormInput() {
+ List reportCols = getAllColumns();
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dct = (DataColumnType) iter.next();
+
+ if (dct.getColFilterList() != null) {
+ List fList = dct.getColFilterList().getColFilter();
+ for (Iterator iterF = fList.iterator(); iterF.hasNext();) {
+ ColFilterType cft = (ColFilterType) iterF.next();
+
+ if (nvl(cft.getArgType()).equals(AppConstants.AT_FORM))
+ return true;
+ } // for
+ } // if
+ } // for
+
+ return false;
+ } // needFormInput
+
+ public int getNumSortColumns() {
+ int numSortCols = 0;
+ for (Iterator iter = getAllColumns().iterator(); iter.hasNext();) {
+ DataColumnType dct = (DataColumnType) iter.next();
+ if (dct.getOrderBySeq() != null && dct.getOrderBySeq() > 0)
+ numSortCols++;
+ } // for
+
+ return numSortCols;
+ } // getNumSortColumns
+
+ public SemaphoreType getSemaphoreById(String semaphoreId) {
+ if (getSemaphoreList() != null && semaphoreId != null)
+ for (Iterator iter = getSemaphoreList().getSemaphore().iterator(); iter.hasNext();) {
+ SemaphoreType sem = (SemaphoreType) iter.next();
+ if (sem.getSemaphoreId().equals(semaphoreId))
+ return sem;
+ } // for
+
+ return null;
+ } // getSemaphoreById
+
+ public void deleteSemaphore(SemaphoreType semaphore) {
+ if (getSemaphoreList() != null) {
+ if (getSemaphoreList().getSemaphore() != null)
+ getSemaphoreList().getSemaphore().remove((SemaphoreType) semaphore);
+ }
+ } // deleteSemaphore
+
+ public void setSemaphore(SemaphoreType sem) {
+ if (getSemaphoreList() != null) {
+ getSemaphoreList().getSemaphore().add(sem);
+ }
+
+ } // setSemaphore
+
+ public static FormatType getSemaphoreFormatById(SemaphoreType semaphore, String formatId) {
+ if (semaphore != null)
+ for (Iterator iter = semaphore.getFormatList().getFormat().iterator(); iter
+ .hasNext();) {
+ FormatType fmt = (FormatType) iter.next();
+ if (fmt.getFormatId().equals(formatId))
+ return fmt;
+ } // for
+
+ return null;
+ } // getSemaphoreFormatById
+
+ public FormFieldType getFormFieldById(String fieldId) {
+ if (getFormFieldList() != null && fieldId != null)
+ for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) {
+ FormFieldType fft = (FormFieldType) iter.next();
+ if (fft.getFieldId().equals(fieldId))
+ return fft;
+ } // for
+
+ return null;
+ } // getFormFieldById
+
+ public FormFieldType getFormFieldByDisplayValue(String fieldDisplay) {
+ // fieldDisplay expected to be [fieldName]
+ if (getFormFieldList() != null && fieldDisplay != null)
+ for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) {
+ FormFieldType fft = (FormFieldType) iter.next();
+ if (fieldDisplay.equals(getFormFieldDisplayName(fft)))
+ return fft;
+ } // for
+
+ return null;
+ } // getFormFieldById
+
+ public String getFormFieldDisplayName(FormFieldType fft) {
+ return "[" + fft.getFieldName() + "]";
+ } // getFormFieldDisplayName
+
+ /**
+ * *************************************************************************************************
+ */
+
+ public void resetCache(boolean sqlOnly) {
+ generatedSQL = null;
+ if (!sqlOnly) {
+ allColumns = null;
+ allFilters = null;
+ }
+ } // resetCache
+
+ public String getOuterJoinType(DataSourceType curTable) {
+ String refDefinition = nvl(curTable.getRefDefinition());
+ int outerJoinIdx = refDefinition.indexOf(" (+)");
+ if (outerJoinIdx < 0)
+ // No outer join
+ return "";
+
+ int equalSignIdx = refDefinition.indexOf("=");
+ if (refDefinition.indexOf(curTable.getTableId()) < equalSignIdx)
+ // Cur. table is on the left side
+ return (outerJoinIdx < equalSignIdx) ? AppConstants.OJ_CURRENT
+ : AppConstants.OJ_JOINED;
+ else
+ // Joined table is on the left side
+ return (outerJoinIdx < equalSignIdx) ? AppConstants.OJ_JOINED
+ : AppConstants.OJ_CURRENT;
+ } // getOuterJoinType
+
+ public String getFormFieldName(ColFilterType filter) {
+ FormFieldType fft = null;
+ if (filter.getArgType().equals(AppConstants.AT_FORM))
+ fft = getFormFieldByDisplayValue(filter.getArgValue());
+
+ return (fft != null) ? fft.getFieldId()
+ : filter.getColId() + "_f"
+ + filter.getFilterSeq();
+ } // getFormFieldName
+
+ public String getFormFieldDisplayName(DataColumnType column, ColFilterType filter) {
+ FormFieldType fft = null;
+ if (filter.getArgType().equals(AppConstants.AT_FORM))
+ fft = getFormFieldByDisplayValue(filter.getArgValue());
+
+ return (fft != null) ? fft.getFieldName()
+ : column.getDisplayName() + "&nbsp;"
+ + filter.getExpression();
+ } // getFormFieldDisplayName
+
+ public Calendar getFormFieldRangeStart(ColFilterType filter) {
+ FormFieldType fft = null;
+ if (filter.getArgType().equals(AppConstants.AT_FORM))
+ fft = getFormFieldByDisplayValue(filter.getArgValue());
+
+ return (fft != null) ? fft.getRangeStartDate().toGregorianCalendar() : null;
+ } // getFormFieldRangeStart
+
+ public Calendar getFormFieldRangeEnd(ColFilterType filter) {
+ FormFieldType fft = null;
+ if (filter.getArgType().equals(AppConstants.AT_FORM))
+ fft = getFormFieldByDisplayValue(filter.getArgValue());
+
+ // System.out.println("as " + fft.getRangeEndDate());
+ return (fft != null) ? fft.getRangeEndDate().toGregorianCalendar() : null;
+ } // getFormFieldRangeEnd
+
+ public String getFormFieldRangeStartSQL(ColFilterType filter) {
+ FormFieldType fft = null;
+ if (filter.getArgType().equals(AppConstants.AT_FORM))
+ fft = getFormFieldByDisplayValue(filter.getArgValue());
+
+ return (fft != null) ? fft.getRangeStartDateSQL() : null;
+ } // getFormFieldRangeStart
+
+ public String getFormFieldRangeEndSQL(ColFilterType filter) {
+ FormFieldType fft = null;
+ if (filter.getArgType().equals(AppConstants.AT_FORM))
+ fft = getFormFieldByDisplayValue(filter.getArgValue());
+
+ // System.out.println("as " + fft.getRangeEndDate());
+ return (fft != null) ? fft.getRangeEndDateSQL() : null;
+ } // getFormFieldRangeEnd
+
+ public String getUniqueTableId(String tableName) {
+ String tableIdPrefix = tableName.startsWith("MSA_") ? tableName.substring(4, 6)
+ : tableName.substring(0, 2);
+ String tableId = "";
+
+ int tableIdN = getDataSourceList().getDataSource().size() + 1;
+ do {
+ tableId = tableIdPrefix.toLowerCase() + (tableIdN++);
+ } while (getTableById(tableId) != null);
+
+ return tableId;
+ } // getUniqueTableId
+
+ /**
+ * *************************************************************************************************
+ */
+
+ protected void deleteDataSourceType(String tableId) {
+ List dsList = getDataSourceList().getDataSource();
+ for (Iterator iter = dsList.iterator(); iter.hasNext();) {
+ DataSourceType dst = (DataSourceType) iter.next();
+ if (dst.getTableId().equals(tableId))
+ iter.remove();
+ else if (nvl(dst.getRefTableId()).equals(tableId)) {
+ dst.setRefTableId(null);
+ dst.setRefDefinition(null);
+ }
+ } // for
+
+ resetCache(false);
+ } // deleteDataSourceType
+
+ public static void adjustColumnType(DataColumnType dct) {
+ dct.setColType(dct.getDbColType());
+
+ if (dct.isCalculated())
+ if (dct.getColName().startsWith("SUM(") || dct.getColName().startsWith("COUNT(")
+ || dct.getColName().startsWith("AVG(")
+ || dct.getColName().startsWith("STDDEV(")
+ || dct.getColName().startsWith("VARIANCE("))
+ dct.setColType(AppConstants.CT_NUMBER);
+ else if (dct.getColName().startsWith("DECODE(") || dct.getColName().startsWith("coalesce("))
+ dct.setColType(AppConstants.CT_CHAR);
+ } // adjustColumnType
+
+ public static boolean getColumnNoParseDateFlag(DataColumnType dct) {
+ return (nvls(dct.getComment()).indexOf(AppConstants.CF_NO_PARSE_DATE) >= 0);
+ } // getColumnNoParseDateFlag
+
+ public static void setColumnNoParseDateFlag(DataColumnType dct, boolean noParseDateFlag) {
+ dct.setComment(noParseDateFlag ? AppConstants.CF_NO_PARSE_DATE : null);
+ } // setColumnNoParseDateFlag
+
+ /**
+ * *************************************************************************************************
+ */
+
+ public static String getSQLBasedFFTColTableName(String fftColId) {
+ return fftColId.substring(0, fftColId.indexOf('.'));
+ } // getSQLBasedFFTColTableName
+
+ public static String getSQLBasedFFTColColumnName(String fftColId) {
+ fftColId = (fftColId.indexOf('|') < 0) ? fftColId
+ : fftColId.substring(0, fftColId
+ .indexOf('|'));
+ return fftColId.substring(fftColId.indexOf('.') + 1);
+ } // getSQLBasedFFTColColumnName
+
+ public static String getSQLBasedFFTColDisplayFormat(String fftColId) {
+ return (fftColId.indexOf('|') < 0) ? ""
+ : fftColId
+ .substring(fftColId.indexOf('|') + 1);
+ } // getSQLBasedFFTColDisplayFormat
+
+ /**
+ * *************************************************************************************************
+ */
+
+ public List<DataColumnType> getAllColumns() {
+ if (cr == null)
+ throw new NullPointerException("CustomReport not initialized");
+
+ if (allColumns == null) {
+ allColumns = new Vector();
+
+ List dsList = getDataSourceList().getDataSource();
+ for (Iterator iter = dsList.iterator(); iter.hasNext();) {
+ DataSourceType ds = (DataSourceType) iter.next();
+
+ // allColumns.addAll(ds.getDataColumnList().getDataColumn());
+ List dcList = ds.getDataColumnList().getDataColumn();
+ for (Iterator iterC = dcList.iterator(); iterC.hasNext();) {
+ DataColumnType dc = (DataColumnType) iterC.next();
+
+ allColumns.add(dc);
+ } // for
+ } // for
+
+ Collections.sort(allColumns, new OrderSeqComparator());
+ } // if
+
+ return allColumns;
+ } // getAllColumns
+
+ public List getOnlyVisibleColumns() {
+ if (cr == null)
+ throw new NullPointerException("CustomReport not initialized");
+
+ if (allVisibleColumns == null) {
+ allVisibleColumns = new Vector();
+
+ List dsList = getDataSourceList().getDataSource();
+ for (Iterator iter = dsList.iterator(); iter.hasNext();) {
+ DataSourceType ds = (DataSourceType) iter.next();
+
+ // allColumns.addAll(ds.getDataColumnList().getDataColumn());
+ List dcList = ds.getDataColumnList().getDataColumn();
+ for (Iterator iterC = dcList.iterator(); iterC.hasNext();) {
+ DataColumnType dc = (DataColumnType) iterC.next();
+ if (dc.isVisible())
+ allVisibleColumns.add(dc);
+ } // for
+ } // for
+
+ Collections.sort(allVisibleColumns, new OrderSeqComparator());
+ } // if
+
+ return allVisibleColumns;
+ } // getOnlyVisibleColumns
+
+ public int getVisibleColumnCount() {
+ if (cr == null)
+ throw new NullPointerException("CustomReport not initialized");
+ int colCount = 0;
+ List dsList = getDataSourceList().getDataSource();
+ for (Iterator iter = dsList.iterator(); iter.hasNext();) {
+ DataSourceType ds = (DataSourceType) iter.next();
+
+ // allColumns.addAll(ds.getDataColumnList().getDataColumn());
+ List dcList = ds.getDataColumnList().getDataColumn();
+ for (Iterator iterC = dcList.iterator(); iterC.hasNext();) {
+ DataColumnType dc = (DataColumnType) iterC.next();
+ if (dc.isVisible())
+ colCount++;
+ } // for
+ } // for
+
+ return colCount;
+ }
+
+ public List getAllFilters() {
+ if (cr == null)
+ throw new NullPointerException("CustomReport not initialized");
+
+ // if(allFilters==null) {
+ allFilters = new Vector();
+
+ List reportCols = getAllColumns();
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dct = (DataColumnType) iter.next();
+
+ if (dct.getColFilterList() != null) {
+ List colFilters = dct.getColFilterList().getColFilter();
+
+ for (Iterator iterF = colFilters.iterator(); iterF.hasNext();) {
+ ColFilterType cft = (ColFilterType) iterF.next();
+
+ allFilters.add(cft);
+ } // for
+ } // if
+ } // for
+
+ // Collections.sort(allFilters, ??);
+ // } // if
+
+ return allFilters;
+ } // getAllFilters
+
+ private String formatValue(String value, DataColumnType dc, boolean useDefaultDateFormat) throws RaptorException {
+ return formatValue(value, dc, useDefaultDateFormat, getColumnTableById(dc.getColId()), null);
+ } // formatValue
+
+ private String formatValue(String value, DataColumnType dc, boolean useDefaultDateFormat,
+ DataSourceType ds, FormFieldType fft) throws RaptorException {
+ String fmtValue = null;
+
+ if (nvl(value).length() == 0)
+ fmtValue = "";
+ else if (value.equals(AppConstants.FILTER_MAX_VALUE)
+ || value.equals(AppConstants.FILTER_MIN_VALUE))
+ fmtValue = "(SELECT "
+ + (value.equals(AppConstants.FILTER_MAX_VALUE) ? "MAX" : "MIN") + "("
+ + dc.getColName() + ") FROM " + ds.getTableName() + ")";
+ else if (dc.getColType().equals(AppConstants.CT_NUMBER)) {
+ try {
+ double vD = Double.parseDouble(value);
+ fmtValue = value;
+ } catch (NumberFormatException ex) {
+ throw new UserDefinedException(
+ "Expected number, Given String for the form field \"" + fft.getFieldName() + "\"");
+ }
+ } else if (dc.getColType().equals(AppConstants.CT_DATE)) {
+ if (fft != null && (fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)
+ || fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)
+ || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC))) {
+ fmtValue = "TO_DATE('"
+ + value
+ + "', '"
+ + (useDefaultDateFormat ? AppConstants.DEFAULT_DATE_FORMAT
+ : nvl(dc
+ .getColFormat(), AppConstants.DEFAULT_DATE_FORMAT));// +" HH24:MI:SS')";
+ fmtValue = fmtValue + " HH24";
+ if (fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)
+ || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC))
+ fmtValue = fmtValue + ":MI";
+ if (fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC))
+ fmtValue = fmtValue + " HH24:MI:SS";
+ } else {
+ fmtValue = "TO_DATE('"
+ + value
+ + "', '"
+ + (useDefaultDateFormat ? AppConstants.DEFAULT_DATE_FORMAT
+ : nvl(dc
+ .getColFormat(), AppConstants.DEFAULT_DATE_FORMAT))
+ + "')";
+ if (Globals.getMonthFormatUseLastDay())
+ if (!useDefaultDateFormat)
+ if ("MM/YYYY".equals(nvl(dc.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT))
+ || "MONTH, YYYY"
+ .equals(nvl(dc.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT)))
+ fmtValue = "ADD_MONTHS(" + fmtValue + ", 1)-1";
+ }
+ } else {
+ fmtValue = value;
+ if (!fmtValue.startsWith("'"))
+ fmtValue = "'" + fmtValue + "'";
+ }
+
+ return fmtValue;
+ } // formatValue
+
+ private String formatListValue(String listValue, DataColumnType dc,
+ boolean useDefaultDateFormat, boolean useOnlyPipeDelimiter) throws RaptorException {
+ return formatListValue("", listValue, dc, useDefaultDateFormat, useOnlyPipeDelimiter,
+ getColumnTableById(dc.getColId()), null);
+ } // formatListValue
+
+ public String formatListValue(String fieldDisplay, String listValue, DataColumnType dc,
+ boolean useDefaultDateFormat, boolean useOnlyPipeDelimiter, DataSourceType ds,
+ String listBaseSQL) throws RaptorException {
+ StringBuffer fmtValue = new StringBuffer("");
+ // if(nvl(listValue,"").trim().length()>0) {
+ // The below statement is commented so that pipe is taken out from parsing for text area form field
+ // StringTokenizer st = new StringTokenizer(listValue, useOnlyPipeDelimiter ? "|"
+ // : ",|\n\r\f");
+ StringTokenizer st = new StringTokenizer(listValue, useOnlyPipeDelimiter ? "|"
+ : ",\n\r\f");
+
+ while (st.hasMoreTokens()) {
+ if (fmtValue.length() > 0)
+ fmtValue.append(", ");
+
+ if (dc == null) {
+ // For SQL-based reports - value always string
+ String value = st.nextToken().trim();
+ if (value.startsWith("'"))
+ fmtValue.append(value);
+ else
+ fmtValue.append("'" + value + "'");
+ } else
+ fmtValue.append(formatValue(st.nextToken().trim(), dc, useDefaultDateFormat,
+ ds, null));
+
+ } // while
+
+ if (fmtValue.length() == 0) {
+ if (nvl(fieldDisplay).length() > 0) {
+ fmtValue.append("");
+ } else {
+ fmtValue.append("(");
+ fmtValue.append(nvl(listBaseSQL, "NULL"));
+ fmtValue.append(")");
+ }
+ } else if (fmtValue.charAt(0) != '(') {
+ fmtValue.insert(0, '(');
+ fmtValue.append(')');
+ }
+ /*
+ * } else { fmtValue = new StringBuffer("()"); }
+ */
+ return fmtValue.toString();
+ } // formatListValue
+
+ private String getColumnSelectStr(DataColumnType dc, ReportParamValues paramValues) {
+ String colName = dc.isCalculated() ? dc.getColName()
+ : ((nvl(dc.getTableId()).length() > 0) ? (dc.getTableId() + "." + dc
+ .getColName()) : dc.getColName());
+ String paramValue = null;
+ if (dc.isCalculated())
+ if (getFormFieldList() != null)
+ for (Iterator iter2 = getFormFieldList().getFormField().iterator(); iter2
+ .hasNext();) {
+ FormFieldType fft = (FormFieldType) iter2.next();
+ String fieldId = fft.getFieldId();
+ String fieldDisplay = getFormFieldDisplayName(fft);
+ if (!paramValues.isParameterMultiValue(fieldId)) {
+ paramValue = paramValues.getParamValue(fieldId);
+ if (paramValue != null && paramValue.length() > 0) {
+ colName = Utils.replaceInString(colName, fieldDisplay, Utils
+ .oracleSafe(nvl(paramValue, "NULL")));
+ } else {
+ colName = Utils.replaceInString(colName, "'" + fieldDisplay + "'", nvl(
+ paramValue, "NULL"));
+ colName = Utils.replaceInString(colName, fieldDisplay, nvl(
+ paramValue, "NULL"));
+ }
+ }
+ } // for
+
+ return colName;
+ } // getColumnSelectStr
+
+ private void addExtraIdSelect(StringBuffer selectExtraIdCl, String drillDownParams,
+ boolean includeSelectExpr) {
+ // drillDownParams - example value "c_master=[bo1.RECID$]"
+ drillDownParams = drillDownParams.substring(10, drillDownParams.length() - 1); // i.e.
+ // "bo1.RECID$"
+
+ selectExtraIdCl.append(", ");
+ if (includeSelectExpr) {
+ selectExtraIdCl.append(drillDownParams);
+ selectExtraIdCl.append(" ");
+ } // if
+ selectExtraIdCl.append(drillDownParams.replace('.', '_')); // i.e.
+ // "bo1_RECID$"
+ } // addExtraIdSelect
+
+ private void addExtraDateSelect(StringBuffer selectExtraDateCl, String drillDownParams,
+ ReportParamValues paramValues, boolean includeSelectExpr) {
+ // drillDownParams - example value "ff1=[dl1]&fc2=[mo3]"
+ String colId = "";
+ while (drillDownParams.indexOf('[') >= 0) {
+ int startIdx = drillDownParams.indexOf('[');
+ int endIdx = drillDownParams.indexOf(']');
+
+ if (startIdx <= endIdx) {
+ colId = drillDownParams.substring(startIdx + 1, endIdx); // i.e.
+ } else {
+ drillDownParams = drillDownParams.substring(endIdx + 1);
+ continue;
+ }
+ // "dl1"
+
+ DataColumnType column = getColumnById(colId);
+ if (column != null)
+ if (column.getColType().equals(AppConstants.CT_DATE))
+ if (!nvl(column.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT).equals(
+ AppConstants.DEFAULT_DATE_FORMAT))
+ if (selectExtraDateCl.toString().indexOf(
+ " " + colId + AppConstants.DD_COL_EXTENSION) < 0) {
+ selectExtraDateCl.append(", ");
+ if (includeSelectExpr) {
+ selectExtraDateCl.append("TO_CHAR("
+ + getColumnSelectStr(column, paramValues) + ", '"
+ + AppConstants.DEFAULT_DATE_FORMAT + "')");
+ selectExtraDateCl.append(" ");
+ } // if
+ selectExtraDateCl.append(colId + AppConstants.DD_COL_EXTENSION); // i.e.
+ // "dl1_dde"
+ } // if
+
+ drillDownParams = drillDownParams.substring(endIdx + 1);
+ } // while
+ } // addExtraDateSelect
+
+ /*
+ * public String generateSQL() { return generateSQL(null); } // generateSQL
+ */
+ public String generateSQL(String userId, HttpServletRequest request) throws RaptorException {
+ return generateSQL(new ReportParamValues(), userId, request);
+ } // generateSQL
+
+ public String generateSQL(ReportParamValues paramValues, String userId, HttpServletRequest request)
+ throws RaptorException {
+ return generateSQL(paramValues, null, AppConstants.SO_ASC, userId, request);
+ } // generateSQL
+
+ public String generateSQL(ReportParamValues paramValues, String overrideSortByColId,
+ String overrideSortByAscDesc, String userId, HttpServletRequest request) throws RaptorException {
+ if (cr == null)
+ throw new NullPointerException("CustomReport not initialized");
+ if (nvl(getWholeSQL()).length() > 0)
+ return getWholeSQL();
+ if (paramValues.size() > 0)
+ resetCache(true);
+ // resetCache(true);
+ if (generatedSQL == null) {
+ if (getReportDefType().equals(AppConstants.RD_SQL_BASED)
+ || getReportDefType().equals(AppConstants.RD_SQL_BASED_DATAMIN)) {
+ generatedSQL = generateSQLSQLBased(paramValues, overrideSortByColId,
+ overrideSortByAscDesc, userId, request);
+ generatedChartSQL = generateSQLSQLBased(paramValues, null,
+ AppConstants.SO_ASC, userId, request);
+ } else if (getReportDefType().equals(AppConstants.RD_VISUAL)
+ && !getReportType().equals(AppConstants.RT_CROSSTAB)) {
+ generatedSQL = generateSQLVisual(paramValues, overrideSortByColId,
+ overrideSortByAscDesc, userId, request);
+ generatedChartSQL = generateSQLVisual(paramValues, null,
+ AppConstants.SO_ASC, userId, request);
+ } else {
+ generatedSQL = generateSQLCrossTabVisual(paramValues, overrideSortByColId,
+ overrideSortByAscDesc, userId, request);
+ }
+
+ // debugLogger.debug("******************");
+ // debugLogger.debug("SQL Before Changing new line \n" + generatedSQL);
+ // debugLogger.debug("******************");
+ generatedSQL = replaceNewLine(generatedSQL, "" + '\n', " " + '\n' + " ");
+ // chart sql should not be null
+ if (nvl(generatedChartSQL).trim().length() > 0)
+ generatedChartSQL = replaceNewLine(generatedChartSQL, "" + '\n', " " + '\n' + " ");
+ // (generatedSQL, "\n", " \n ");
+ // debugLogger.debug("******************");
+ // debugLogger.debug("SQL After Changing new line \n" + generatedSQL);
+ // debugLogger.debug("******************");
+ // generatedSQL = replaceNewLine(generatedSQL, "SELECT", "SELECT ");
+ // generatedSQL = replaceNewLine(generatedSQL, "select", "select ");
+ // debugLogger.debug("SQL After Changing new line \n" + generatedSQL);
+ // debugLogger.debug("[[[[[[[[[[[[[[[[[[");
+ // generatedSQL = Utils.replaceInString(generatedSQL, "\n", " ");
+ // generatedSQL = Utils.replaceInString(generatedSQL, "\t", " ");
+ } // if
+
+ return generatedSQL;
+ } // generateSQL
+
+ public String generateSQLSQLBased(ReportParamValues paramValues,
+ String overrideSortByColId, String overrideSortByAscDesc, String userId, HttpServletRequest request)
+ throws RaptorException {
+ String sql = getReportSQL();
DataSet ds = null;
- //debugLogger.debug(" generateSQLSQLBased " + sql);
+ // debugLogger.debug(" generateSQLSQLBased " + sql);
String[] reqParameters = Globals.getRequestParams().split(",");
String[] sessionParameters = Globals.getSessionParams().split(",");
String[] scheduleSessionParameters = Globals.getSessionParamsForScheduling().split(",");
javax.servlet.http.HttpSession session = request.getSession();
String dbType = "";
String dbInfo = getDBInfo();
- int fieldCount = 0;
+ int fieldCount = 0;
// For Daytona removing all formfields which has null param value
Pattern re1 = null;
Matcher matcher = null;
int index = 0;
int posFormField = 0;
int posAnd = 0;
- if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) {
- try {
- org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo();
- dbType = remDbInfo.getDBType(dbInfo);
- } catch (Exception ex) {
- throw new RaptorException(ex);
- }
- }
-
- sql = sql + " ";
- sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ss][Ee][Ll][Ee][Cc][Tt]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" SELECT ");
- //sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ff][Rr][Oo][Mm]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" FROM ");
- sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Rr][Ee]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" WHERE ");
- sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Nn]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" WHEN ");
- sql = Pattern.compile("(^[\r\n]*|([\\s]))[Aa][Nn][Dd]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" AND ");
-
- if (getFormFieldList() != null) {
- for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) {
-
- FormFieldType fft = (FormFieldType) iter.next();
- String fieldId = fft.getFieldId();
- String fieldDisplay = getFormFieldDisplayName(fft);
- if(!fft.getFieldType().equals(FormField.FFT_BLANK)) {
- if (paramValues.isParameterMultiValue(fieldId)) {
- String replaceValue = formatListValue(fieldDisplay, Utils
- .oracleSafe(nvl(paramValues.getParamValue(fieldId))), null, false,
- true, null, paramValues.getParamBaseSQL(fieldId));
- if(replaceValue.length() > 0) {
- sql = Utils.replaceInString(sql, fieldDisplay, replaceValue);
- } else {
- fieldCount++;
- if(fieldCount == 1) {
- //sql = sql + " ";
- //sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ss][Ee][Ll][Ee][Cc][Tt]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" SELECT ");
- //sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Rr][Ee]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" WHERE ");
- //sql = Pattern.compile("(^[\r\n]*|([\\s]))[Aa][Nn][Dd]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" AND ");
- }
- //sql = getReportSQL();
- while(sql.indexOf(fieldDisplay) > 0) {
-/* sql = Utils.replaceInString(sql, "SELECT ", "select ");
- sql = Utils.replaceInString(sql, "WHERE", "where");
- sql = Utils.replaceInString(sql, " AND ", " and ");
-*/
- re1 = Pattern.compile("(^[\r\n]|[\\s])AND(.*?[^\r\n]*)"+ "\\["+fft.getFieldName()+ "\\](.*?)\\s", Pattern.DOTALL);
- //re1 = Pattern.compile("(^[\r\n]|[\\s])AND(.*?[^\r\n]*)"+ "\\["+fft.getFieldName()+ "\\]", Pattern.DOTALL);
-/* posFormField = sql.indexOf(fieldDisplay);
- posAnd = sql.lastIndexOf("and", posFormField);
- if(posAnd < 0) posAnd = 0;
- else if (posAnd > 2) posAnd = posAnd - 2;
- matcher = re1.matcher(sql);
-*/
- posFormField = sql.indexOf(fieldDisplay);
- int posSelectField = sql.lastIndexOf("SELECT ", posFormField);
- int andField = 0;
- int whereField = 0, whenField = 0;
- andField = sql.lastIndexOf(" AND ", posFormField);
- whereField = sql.indexOf(" WHERE" , posSelectField);
- whenField = sql.indexOf(" WHEN" , posSelectField);
-
- if(posFormField > whereField)
- andField = sql.lastIndexOf(" AND ", posFormField);
- if (posFormField > andField && (andField > whereField || andField > whenField))
- posAnd = andField;
- else
- posAnd = 0;
- matcher = re1.matcher(sql);
-
-
- if (posAnd > 0 && matcher.find(posAnd-1)) {
- //sql = Utils.replaceInString(sql, matcher.group(), " ");
- matcher = re1.matcher(sql);
- index = sql!=null?sql.lastIndexOf("["+fft.getFieldName()+"]"):-1;
-
- if(andField>0)
- index = andField;
- else
- index = whereField;
- if(index >= 0 && matcher.find(index-1)) {
- sql = sql.replace(matcher.group(), " ");
- }
- } else {
-
- //sql = sql.replace
- re1 = Pattern.compile("(^[\r\n]|[\\s])WHERE(.*?[^\r\n]*)\\["+fft.getFieldName()+ "\\](.*?)\\s", Pattern.DOTALL);
- matcher = re1.matcher(sql);
- if(whereField != -1) {
- if(matcher.find(whereField-1)) {
- matcher = re1.matcher(sql);
- index = sql!=null?sql.lastIndexOf("["+fft.getFieldName()+"]"):-1;
- if(index >= 0 && matcher.find(index-30)) {
- sql = sql.replace(matcher.group(), " WHERE 1=1 ");
- }
- //sql = Utils.replaceInString(sql, matcher.group(), " where 1=1 ");
- } /*else {
- replaceValue = formatListValue("", Utils
- .oracleSafe(nvl(paramValues.getParamValue(fieldId))), null, false,
- true, null, paramValues.getParamBaseSQL(fieldId));
- sql = Utils.replaceInString(sql, fieldDisplay, replaceValue);
- }*/
- } else {
- sql = Utils.replaceInString(sql, fieldDisplay, replaceValue);
- }
-
- }
- }
- }
-
- //sql = Utils.replaceInString(sql, " select ", " SELECT ");
- //sql = Utils.replaceInString(sql, " where ", " WHERE ");
- //sql = Utils.replaceInString(sql, " and ", " AND ");
+ if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) {
+ try {
+ org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo =
+ new org.onap.portalsdk.analytics.util.RemDbInfo();
+ dbType = remDbInfo.getDBType(dbInfo);
+ } catch (Exception ex) {
+ throw new RaptorException(ex);
+ }
+ }
+ sql = sql + " ";
+ sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ss][Ee][Ll][Ee][Cc][Tt]([\r\n]*|[\\s]*)", Pattern.DOTALL).matcher(sql)
+ .replaceAll(" SELECT ");
+ // sql =
+ // Pattern.compile("(^[\r\n]*|([\\s]))[Ff][Rr][Oo][Mm]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll("
+ // FROM ");
+ sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Rr][Ee]([\r\n]*|[\\s]*)", Pattern.DOTALL).matcher(sql)
+ .replaceAll(" WHERE ");
+ sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Nn]([\r\n]*|[\\s]*)", Pattern.DOTALL).matcher(sql)
+ .replaceAll(" WHEN ");
+ sql = Pattern.compile("(^[\r\n]*|([\\s]))[Aa][Nn][Dd]([\r\n]*|[\\s]*)", Pattern.DOTALL).matcher(sql)
+ .replaceAll(" AND ");
+
+ if (getFormFieldList() != null) {
+ for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) {
+
+ FormFieldType fft = (FormFieldType) iter.next();
+ String fieldId = fft.getFieldId();
+ String fieldDisplay = getFormFieldDisplayName(fft);
+ if (!fft.getFieldType().equals(FormField.FFT_BLANK)) {
+ if (paramValues.isParameterMultiValue(fieldId)) {
+ String replaceValue = formatListValue(fieldDisplay, Utils
+ .oracleSafe(nvl(paramValues.getParamValue(fieldId))), null, false,
+ true, null, paramValues.getParamBaseSQL(fieldId));
+ if (replaceValue.length() > 0) {
+ sql = Utils.replaceInString(sql, fieldDisplay, replaceValue);
+ } else {
+ fieldCount++;
+ if (fieldCount == 1) {
+ // sql = sql + " ";
+ // sql =
+ // Pattern.compile("(^[\r\n]*|([\\s]))[Ss][Ee][Ll][Ee][Cc][Tt]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll("
+ // SELECT ");
+ // sql =
+ // Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Rr][Ee]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll("
+ // WHERE ");
+ // sql =
+ // Pattern.compile("(^[\r\n]*|([\\s]))[Aa][Nn][Dd]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll("
+ // AND ");
+ }
+ // sql = getReportSQL();
+ while (sql.indexOf(fieldDisplay) > 0) {
+ /*
+ * sql = Utils.replaceInString(sql, "SELECT ", "select "); sql =
+ * Utils.replaceInString(sql, "WHERE", "where"); sql = Utils.replaceInString(sql,
+ * " AND ", " and ");
+ */
+ re1 = Pattern.compile(
+ "(^[\r\n]|[\\s])AND(.*?[^\r\n]*)" + "\\[" + fft.getFieldName() + "\\](.*?)\\s",
+ Pattern.DOTALL);
+ // re1 = Pattern.compile("(^[\r\n]|[\\s])AND(.*?[^\r\n]*)"+ "\\["+fft.getFieldName()+
+ // "\\]", Pattern.DOTALL);
+ /*
+ * posFormField = sql.indexOf(fieldDisplay); posAnd = sql.lastIndexOf("and",
+ * posFormField); if(posAnd < 0) posAnd = 0; else if (posAnd > 2) posAnd = posAnd - 2;
+ * matcher = re1.matcher(sql);
+ */
+ posFormField = sql.indexOf(fieldDisplay);
+ int posSelectField = sql.lastIndexOf("SELECT ", posFormField);
+ int andField = 0;
+ int whereField = 0, whenField = 0;
+ andField = sql.lastIndexOf(" AND ", posFormField);
+ whereField = sql.indexOf(" WHERE", posSelectField);
+ whenField = sql.indexOf(" WHEN", posSelectField);
+
+ if (posFormField > whereField)
+ andField = sql.lastIndexOf(" AND ", posFormField);
+ if (posFormField > andField && (andField > whereField || andField > whenField))
+ posAnd = andField;
+ else
+ posAnd = 0;
+ matcher = re1.matcher(sql);
+
+ if (posAnd > 0 && matcher.find(posAnd - 1)) {
+ // sql = Utils.replaceInString(sql, matcher.group(), " ");
+ matcher = re1.matcher(sql);
+ index = sql != null ? sql.lastIndexOf("[" + fft.getFieldName() + "]") : -1;
+
+ if (andField > 0)
+ index = andField;
+ else
+ index = whereField;
+ if (index >= 0 && matcher.find(index - 1)) {
+ sql = sql.replace(matcher.group(), " ");
+ }
} else {
- String paramValue = "";
- if(paramValues.isParameterTextAreaValueAndModified(fieldId)) {
- String value = "";
- value = nvl(paramValues
- .getParamValue(fieldId));
-// value = Utils.oracleSafe(nvl(value));
-// if (!(dbType.equals("DAYTONA") && sql.trim().toUpperCase().startsWith("SELECT"))) {
-// value = "('" + Utils.replaceInString(value, ",", "'|'") + "')";
-// value = Utils.replaceInString(value, "|", ",");
-// paramValue = XSSFilter.filterRequestOnlyScript(value);
-// } else if (nvl(value.trim()).length()>0) {
-// value = "('" + Utils.replaceInString(value, ",", "'|'") + "')";
-// value = Utils.replaceInString(value, "|", ",");
-// paramValue = XSSFilter.filterRequestOnlyScript(value);
-// }
- paramValue = value;
- } else
- paramValue = Utils.oracleSafe(nvl(paramValues
- .getParamValue(fieldId)));
-
- if (paramValue!=null && paramValue.length() > 0) {
- if(paramValue.toLowerCase().trim().startsWith("select ")) {
- paramValue = Utils.replaceInString(paramValue, "[LOGGED_USERID]", userId);
- paramValue = Utils.replaceInString(paramValue, "[USERID]", userId);
- paramValue = Utils.replaceInString(paramValue, "[USER_ID]", userId);
-
- paramValue = Utils.replaceInString(paramValue, "''", "'");
- ds = ConnectionUtils.getDataSet(paramValue, dbInfo);
- if (ds.getRowCount() > 0) paramValue = ds.getString(0, 0);
+
+ // sql = sql.replace
+ re1 = Pattern.compile(
+ "(^[\r\n]|[\\s])WHERE(.*?[^\r\n]*)\\[" + fft.getFieldName() + "\\](.*?)\\s",
+ Pattern.DOTALL);
+ matcher = re1.matcher(sql);
+ if (whereField != -1) {
+ if (matcher.find(whereField - 1)) {
+ matcher = re1.matcher(sql);
+ index = sql != null ? sql.lastIndexOf("[" + fft.getFieldName() + "]") : -1;
+ if (index >= 0 && matcher.find(index - 30)) {
+ sql = sql.replace(matcher.group(), " WHERE 1=1 ");
+ }
+ // sql = Utils.replaceInString(sql, matcher.group(), " where 1=1 ");
+ } /*
+ * else { replaceValue = formatListValue("", Utils
+ * .oracleSafe(nvl(paramValues.getParamValue(fieldId))), null, false, true,
+ * null, paramValues.getParamBaseSQL(fieldId)); sql =
+ * Utils.replaceInString(sql, fieldDisplay, replaceValue); }
+ */
+ } else {
+ sql = Utils.replaceInString(sql, fieldDisplay, replaceValue);
+ }
+
+ }
+ }
}
- //debugLogger.debug("SQLSQLBASED B4^^^^^^^^^ " + sql + " " + fft.getValidationType() + " " + fft.getFieldName() + " " + fft.getFieldId());
- if(fft!=null && (fft.getValidationType()!=null && (fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) ||fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC) ||fft.getValidationType().equals(FormField.VT_DATE) ))) {
- //System.out.println("paramValues.getParamValue(fieldId_Hr) Inside if " + fft.getValidationType() + " " + fieldDisplay);
- if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)) {
- sql = Utils.replaceInString(sql, fieldDisplay, nvl(
- paramValue) +((nvl(paramValues
- .getParamValue(fieldId+"_Hr") ).length()>0)?" "+addZero(Utils.oracleSafe(nvl(paramValues
- .getParamValue(fieldId+"_Hr") ) ) ):""));
- }
- else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)) {
-/* System.out.println("paramValues.getParamValue(fieldId_Hr)" + paramValues
- .getParamValue(fieldId+"_Hr") + " " + paramValues
- .getParamValue(fieldId+"_Min")) ;
-*/ sql = Utils.replaceInString(sql, fieldDisplay, nvl(
- paramValue) + ((nvl(paramValues
- .getParamValue(fieldId+"_Hr") ).length()>0)?" "+addZero(Utils.oracleSafe(nvl(paramValues
- .getParamValue(fieldId+"_Hr") ) ) ):"") + ((nvl(paramValues
- .getParamValue(fieldId+"_Min") ).length()>0)?":" + addZero(Utils.oracleSafe(nvl(paramValues
- .getParamValue(fieldId+"_Min") ) ) ) : "") ) ;
- }
- else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
- sql = Utils.replaceInString(sql, fieldDisplay, nvl(
- paramValue) + ((nvl(paramValues
- .getParamValue(fieldId+"_Hr") ).length()>0)?" "+addZero(Utils.oracleSafe(nvl(paramValues
- .getParamValue(fieldId+"_Hr") ) ) ):"") + ((nvl(paramValues
- .getParamValue(fieldId+"_Min") ).length()>0)?":" + addZero(Utils.oracleSafe(nvl(paramValues
- .getParamValue(fieldId+"_Min") ) ) ) : "") + ((nvl(paramValues
- .getParamValue(fieldId+"_Sec") ).length()>0)?":"+addZero(Utils.oracleSafe(nvl(paramValues
- .getParamValue(fieldId+"_Sec") ) ) ) : "" ) ) ;
- } else {
- sql = Utils.replaceInString(sql, fieldDisplay, nvl(
- paramValue, "NULL"));
- }
-
- } else {
- if(paramValue!=null && paramValue.length() > 0) {
- if(sql.indexOf("'"+fieldDisplay+"'")!=-1 || sql.indexOf("'"+fieldDisplay)!=-1 || sql.indexOf(fieldDisplay+"'")!=-1
- || sql.indexOf("'%"+fieldDisplay+"%'")!=-1 || sql.indexOf("'%"+fieldDisplay)!=-1 || sql.indexOf(fieldDisplay+"%'")!=-1
- || sql.indexOf("'_"+fieldDisplay+"_'")!=-1 || sql.indexOf("'_"+fieldDisplay)!=-1 || sql.indexOf(fieldDisplay+"_'")!=-1
- || sql.indexOf("'%_"+fieldDisplay+"_%'")!=-1 || sql.indexOf("^"+fieldDisplay+"^")!=-1 || sql.indexOf("'%_"+fieldDisplay)!=-1 || sql.indexOf(fieldDisplay+"_%'")!=-1) {
- sql = Utils.replaceInString(sql, fieldDisplay, nvl(
- paramValue, "NULL"));
- } else {
- if(sql.indexOf(fieldDisplay)!=-1) {
- if(nvl(paramValue).length()>0) {
- try {
- double vD = Double.parseDouble(paramValue);
- sql = Utils.replaceInString(sql, fieldDisplay, nvl(
- paramValue, "NULL"));
-
- } catch (NumberFormatException ex) {
- if (/*dbType.equals("DAYTONA") &&*/ sql.trim().toUpperCase().startsWith("SELECT")) {
- sql = Utils.replaceInString(sql, fieldDisplay, nvl(
- paramValue, "NULL"));
- } else
- throw new UserDefinedException("Expected number, Given String for the form field \"" + fieldDisplay+"\"");
- }
- /*sql = Utils.replaceInString(sql, fieldDisplay, nvl(
- paramValue, "NULL"));*/
- } else
- sql = Utils.replaceInString(sql, fieldDisplay, nvl(
- paramValue, "NULL"));
-
- }
- }
+ // sql = Utils.replaceInString(sql, " select ", " SELECT ");
+ // sql = Utils.replaceInString(sql, " where ", " WHERE ");
+ // sql = Utils.replaceInString(sql, " and ", " AND ");
+
+ } else {
+ String paramValue = "";
+ if (paramValues.isParameterTextAreaValueAndModified(fieldId)) {
+ String value = "";
+ value = nvl(paramValues
+ .getParamValue(fieldId));
+ // value = Utils.oracleSafe(nvl(value));
+ // if (!(dbType.equals("DAYTONA") && sql.trim().toUpperCase().startsWith("SELECT"))) {
+ // value = "('" + Utils.replaceInString(value, ",", "'|'") + "')";
+ // value = Utils.replaceInString(value, "|", ",");
+ // paramValue = XSSFilter.filterRequestOnlyScript(value);
+ // } else if (nvl(value.trim()).length()>0) {
+ // value = "('" + Utils.replaceInString(value, ",", "'|'") + "')";
+ // value = Utils.replaceInString(value, "|", ",");
+ // paramValue = XSSFilter.filterRequestOnlyScript(value);
+ // }
+ paramValue = value;
+ } else
+ paramValue = Utils.oracleSafe(nvl(paramValues
+ .getParamValue(fieldId)));
+
+ if (paramValue != null && paramValue.length() > 0) {
+ if (paramValue.toLowerCase().trim().startsWith("select ")) {
+ paramValue = Utils.replaceInString(paramValue, "[LOGGED_USERID]", userId);
+ paramValue = Utils.replaceInString(paramValue, "[USERID]", userId);
+ paramValue = Utils.replaceInString(paramValue, "[USER_ID]", userId);
+
+ paramValue = Utils.replaceInString(paramValue, "''", "'");
+ ds = ConnectionUtils.getDataSet(paramValue, dbInfo);
+ if (ds.getRowCount() > 0)
+ paramValue = ds.getString(0, 0);
+ }
+ // debugLogger.debug("SQLSQLBASED B4^^^^^^^^^ " + sql + " " + fft.getValidationType() + " "
+ // + fft.getFieldName() + " " + fft.getFieldId());
+ if (fft != null && (fft.getValidationType() != null
+ && (fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)
+ || fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)
+ || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)
+ || fft.getValidationType().equals(FormField.VT_DATE)))) {
+ // System.out.println("paramValues.getParamValue(fieldId_Hr) Inside if " +
+ // fft.getValidationType() + " " + fieldDisplay);
+ if (fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)) {
+ sql = Utils.replaceInString(sql, fieldDisplay, nvl(
+ paramValue)
+ + ((nvl(paramValues
+ .getParamValue(fieldId + "_Hr")).length() > 0)
+ ? " " + addZero(Utils.oracleSafe(nvl(paramValues
+ .getParamValue(fieldId + "_Hr"))))
+ : ""));
+ } else if (fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)) {
+ /*
+ * System.out.println("paramValues.getParamValue(fieldId_Hr)" + paramValues
+ * .getParamValue(fieldId+"_Hr") + " " + paramValues .getParamValue(fieldId+"_Min"))
+ * ;
+ */ sql = Utils.replaceInString(sql, fieldDisplay, nvl(
+ paramValue)
+ + ((nvl(paramValues
+ .getParamValue(fieldId + "_Hr")).length() > 0)
+ ? " " + addZero(Utils.oracleSafe(nvl(paramValues
+ .getParamValue(fieldId + "_Hr"))))
+ : "")
+ + ((nvl(paramValues
+ .getParamValue(fieldId + "_Min")).length() > 0)
+ ? ":" + addZero(Utils.oracleSafe(nvl(paramValues
+ .getParamValue(fieldId + "_Min"))))
+ : ""));
+ } else if (fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
+ sql = Utils.replaceInString(sql, fieldDisplay, nvl(
+ paramValue)
+ + ((nvl(paramValues
+ .getParamValue(fieldId + "_Hr")).length() > 0)
+ ? " " + addZero(Utils.oracleSafe(nvl(paramValues
+ .getParamValue(fieldId + "_Hr"))))
+ : "")
+ + ((nvl(paramValues
+ .getParamValue(fieldId + "_Min")).length() > 0)
+ ? ":" + addZero(Utils.oracleSafe(nvl(paramValues
+ .getParamValue(fieldId + "_Min"))))
+ : "")
+ + ((nvl(paramValues
+ .getParamValue(fieldId + "_Sec")).length() > 0)
+ ? ":" + addZero(Utils.oracleSafe(nvl(paramValues
+ .getParamValue(fieldId + "_Sec"))))
+ : ""));
+ } else {
+ sql = Utils.replaceInString(sql, fieldDisplay, nvl(
+ paramValue, "NULL"));
+ }
+
+ } else {
+ if (paramValue != null && paramValue.length() > 0) {
+ if (sql.indexOf("'" + fieldDisplay + "'") != -1
+ || sql.indexOf("'" + fieldDisplay) != -1
+ || sql.indexOf(fieldDisplay + "'") != -1
+ || sql.indexOf("'%" + fieldDisplay + "%'") != -1
+ || sql.indexOf("'%" + fieldDisplay) != -1
+ || sql.indexOf(fieldDisplay + "%'") != -1
+ || sql.indexOf("'_" + fieldDisplay + "_'") != -1
+ || sql.indexOf("'_" + fieldDisplay) != -1
+ || sql.indexOf(fieldDisplay + "_'") != -1
+ || sql.indexOf("'%_" + fieldDisplay + "_%'") != -1
+ || sql.indexOf("^" + fieldDisplay + "^") != -1
+ || sql.indexOf("'%_" + fieldDisplay) != -1
+ || sql.indexOf(fieldDisplay + "_%'") != -1) {
+ sql = Utils.replaceInString(sql, fieldDisplay, nvl(
+ paramValue, "NULL"));
+ } else {
+ if (sql.indexOf(fieldDisplay) != -1) {
+ if (nvl(paramValue).length() > 0) {
+ try {
+ double vD = Double.parseDouble(paramValue);
+ sql = Utils.replaceInString(sql, fieldDisplay, nvl(
+ paramValue, "NULL"));
+
+ } catch (NumberFormatException ex) {
+ if (/* dbType.equals("DAYTONA") && */ sql.trim().toUpperCase()
+ .startsWith("SELECT")) {
+ sql = Utils.replaceInString(sql, fieldDisplay, nvl(
+ paramValue, "NULL"));
+ } else
+ throw new UserDefinedException(
+ "Expected number, Given String for the form field \""
+ + fieldDisplay + "\"");
+ }
+ /*
+ * sql = Utils.replaceInString(sql, fieldDisplay, nvl( paramValue,
+ * "NULL"));
+ */
+ } else
+ sql = Utils.replaceInString(sql, fieldDisplay, nvl(
+ paramValue, "NULL"));
+
+ }
+ }
+ } else {
+ if ("DAYTONA".equals(dbType) && sql.trim().toUpperCase().startsWith("SELECT")) {
+ sql = sql + " ";
+ re1 = Pattern.compile("(^[\r\n]|[\\s]|[^0-9a-zA-Z])AND(.*?[^\r\n]*)" + "\\["
+ + fft.getFieldName() + "\\](.*?)\\s", Pattern.DOTALL);
+ posFormField = sql.indexOf(fieldDisplay);
+ posAnd = sql.lastIndexOf(" AND ", posFormField);
+ if (posAnd < 0)
+ posAnd = 0;
+ else if (posAnd > 2)
+ posAnd = posAnd - 2;
+ matcher = re1.matcher(sql);
+ if (matcher.find(posAnd)) {
+ sql = sql.replace(matcher.group(), "");
+ }
+ } else {
+ sql = Utils.replaceInString(sql, "'" + fieldDisplay + "'", nvl(
+ paramValue, "NULL"));
+ sql = Utils.replaceInString(sql, fieldDisplay, nvl(
+ paramValue, "NULL"));
+ }
+ }
+ }
+
}
- else {
- if (dbType.equals("DAYTONA") && sql.trim().toUpperCase().startsWith("SELECT")) {
- sql = sql + " ";
- re1 = Pattern.compile("(^[\r\n]|[\\s]|[^0-9a-zA-Z])AND(.*?[^\r\n]*)"+ "\\["+fft.getFieldName()+ "\\](.*?)\\s", Pattern.DOTALL);
- posFormField = sql.indexOf(fieldDisplay);
- posAnd = sql.lastIndexOf(" AND ", posFormField);
- if(posAnd < 0) posAnd = 0;
- else if (posAnd > 2) posAnd = posAnd - 2;
- matcher = re1.matcher(sql);
- if (matcher.find(posAnd)) {
- sql = sql.replace(matcher.group(), "");
- }
- } else {
- sql = Utils.replaceInString(sql, "'" + fieldDisplay + "'", nvl(
- paramValue, "NULL"));
- sql = Utils.replaceInString(sql, fieldDisplay, nvl(
- paramValue, "NULL"));
- }
+
+ if ("DAYTONA".equals(dbType) && sql.trim().toUpperCase().startsWith("SELECT")) {
+ sql = sql + " ";
+ re1 = Pattern.compile("(^[\r\n]|[\\s]|[^0-9a-zA-Z])AND(.*?[^\r\n]*)" + "\\["
+ + fft.getFieldName() + "\\](.*?)\\s", Pattern.DOTALL); // +[\'\\)|\'|\\s]
+ posFormField = sql.indexOf(fieldDisplay);
+ posAnd = sql.lastIndexOf(" AND ", posFormField);
+ if (posAnd < 0)
+ posAnd = 0;
+ else if (posAnd > 2)
+ posAnd = posAnd - 2;
+ matcher = re1.matcher(sql);
+ if (matcher.find(posAnd)) {
+ sql = sql.replace(matcher.group(), " ");
+ }
+ } else {
+ if (fft.isGroupFormField() != null && fft.isGroupFormField().booleanValue()) {
+ sql = Pattern.compile("[[\\s*][,]]\\[" + fft.getFieldName() + "\\](.*?)[,]",
+ Pattern.MULTILINE).matcher(sql).replaceAll(" ");
+ // sql =
+ // Pattern.compile("[,][\\s*]\\["+fft.getFieldName()+"\\][\\s]",Pattern.MULTILINE).matcher(sql).replaceAll("
+ // ");
+ sql = Pattern
+ .compile("(,.+?)[\\s*]\\[" + fft.getFieldName() + "\\][\\s]", Pattern.MULTILINE)
+ .matcher(sql).replaceAll(" ");
+ // sql =
+ // Pattern.compile("(?:,?)[\\s*]\\["+fft.getFieldName()+"\\]",Pattern.MULTILINE).matcher(sql).replaceAll("");
+ // sql =
+ // Pattern.compile("[,][\\s*]\\["+fft.getFieldName()+"\\]",Pattern.MULTILINE).matcher(sql).replaceAll("
+ // ");
+ // sql = Pattern.compile(
+ // "\\["+fft.getFieldName()+"\\](.*?[^\r\n]*)[,]",Pattern.DOTALL).matcher(sql).replaceAll("");
+
+ // sql =
+ // Pattern.compile("[,]|(.*?[^\r\n]*)"+fieldDisplay+"(.*?)\\s",Pattern.DOTALL).matcher(sql).replaceAll("");
+ // sql =
+ // Pattern.compile("(.*?[^\r\n]*)"+fieldDisplay+"(.*?)\\s|[,]",Pattern.DOTALL).matcher(sql).replaceAll("");
+ /*
+ * sql = Utils.replaceInString(sql, "," + fieldDisplay , nvl( paramValue, "")); sql =
+ * Utils.replaceInString(sql, fieldDisplay + "," , nvl( paramValue, ""));
+ */ } else {
+ // debugLogger.debug("ParamValue |" + paramValue + "| Sql |" + sql + "| Multi Value |" +
+ // paramValues.isParameterMultiValue(fieldId));
+ sql = Utils.replaceInString(sql, "'" + fieldDisplay + "'", nvl(
+ paramValue, "NULL"));
+ sql = Utils.replaceInString(sql, fieldDisplay, nvl(
+ paramValue, "NULL"));
+ // debugLogger.debug("SQLSQLBASED AFTER^^^^^^^^^ " + sql);
+ }
}
- }
-
- }
-
- if (dbType.equals("DAYTONA") && sql.trim().toUpperCase().startsWith("SELECT")) {
- sql = sql + " ";
- re1 = Pattern.compile("(^[\r\n]|[\\s]|[^0-9a-zA-Z])AND(.*?[^\r\n]*)"+ "\\["+fft.getFieldName()+ "\\](.*?)\\s", Pattern.DOTALL); //+[\'\\)|\'|\\s]
- posFormField = sql.indexOf(fieldDisplay);
- posAnd = sql.lastIndexOf(" AND ", posFormField);
- if(posAnd < 0) posAnd = 0;
- else if (posAnd > 2) posAnd = posAnd - 2;
- matcher = re1.matcher(sql);
- if (matcher.find(posAnd)) {
- sql = sql.replace(matcher.group(), " ");
- }
- } else {
- if( fft.isGroupFormField()!=null && fft.isGroupFormField().booleanValue()) {
- sql = Pattern.compile("[[\\s*][,]]\\["+fft.getFieldName()+"\\](.*?)[,]",Pattern.MULTILINE).matcher(sql).replaceAll(" ");
- //sql = Pattern.compile("[,][\\s*]\\["+fft.getFieldName()+"\\][\\s]",Pattern.MULTILINE).matcher(sql).replaceAll(" ");
- sql = Pattern.compile("(,.+?)[\\s*]\\["+fft.getFieldName()+"\\][\\s]",Pattern.MULTILINE).matcher(sql).replaceAll(" ");
- //sql = Pattern.compile("(?:,?)[\\s*]\\["+fft.getFieldName()+"\\]",Pattern.MULTILINE).matcher(sql).replaceAll("");
- //sql = Pattern.compile("[,][\\s*]\\["+fft.getFieldName()+"\\]",Pattern.MULTILINE).matcher(sql).replaceAll(" ");
- //sql = Pattern.compile( "\\["+fft.getFieldName()+"\\](.*?[^\r\n]*)[,]",Pattern.DOTALL).matcher(sql).replaceAll("");
-
- //sql = Pattern.compile("[,]|(.*?[^\r\n]*)"+fieldDisplay+"(.*?)\\s",Pattern.DOTALL).matcher(sql).replaceAll("");
- //sql = Pattern.compile("(.*?[^\r\n]*)"+fieldDisplay+"(.*?)\\s|[,]",Pattern.DOTALL).matcher(sql).replaceAll("");
-/* sql = Utils.replaceInString(sql, "," + fieldDisplay , nvl(
- paramValue, ""));
- sql = Utils.replaceInString(sql, fieldDisplay + "," , nvl(
- paramValue, ""));
-*/ } else {
- //debugLogger.debug("ParamValue |" + paramValue + "| Sql |" + sql + "| Multi Value |" + paramValues.isParameterMultiValue(fieldId));
- sql = Utils.replaceInString(sql, "'" + fieldDisplay + "'", nvl(
- paramValue, "NULL"));
- sql = Utils.replaceInString(sql, fieldDisplay , nvl(
- paramValue, "NULL"));
- //debugLogger.debug("SQLSQLBASED AFTER^^^^^^^^^ " + sql);
- }
- }
-
- } // else
- } // if BLANK
- } // for
- if(request != null ) {
+
+ } // else
+ } // if BLANK
+ } // for
+ if (request != null) {
for (int i = 0; i < reqParameters.length; i++) {
- if(!reqParameters[i].startsWith("ff")) {
- if (nvl(request.getParameter(reqParameters[i].toUpperCase())).length() > 0)
- sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase()+"]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), request.getParameter(reqParameters[i].toUpperCase()) ));
- }
- else
- sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase()+"]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), request.getParameter(reqParameters[i]) ));
+ if (!reqParameters[i].startsWith("ff")) {
+ if (nvl(request.getParameter(reqParameters[i].toUpperCase())).length() > 0)
+ sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase() + "]",
+ ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(),
+ request.getParameter(reqParameters[i].toUpperCase())));
+ } else
+ sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase() + "]", ESAPI.encoder()
+ .encodeForSQL(SecurityCodecUtil.getCodec(), request.getParameter(reqParameters[i])));
}
-
+
for (int i = 0; i < scheduleSessionParameters.length; i++) {
- if(nvl(request.getParameter(scheduleSessionParameters[i])).trim().length()>0 )
- sql = Utils.replaceInString(sql, "[" + scheduleSessionParameters[i].toUpperCase()+"]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), request.getParameter(scheduleSessionParameters[i]) ));
- }
- }
- if(session != null ) {
+ if (nvl(request.getParameter(scheduleSessionParameters[i])).trim().length() > 0)
+ sql = Utils.replaceInString(sql, "[" + scheduleSessionParameters[i].toUpperCase() + "]",
+ ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(),
+ request.getParameter(scheduleSessionParameters[i])));
+ }
+ }
+ if (session != null) {
for (int i = 0; i < sessionParameters.length; i++) {
- //if(!sessionParameters[i].startsWith("ff"))
- // paramValue = Utils.replaceInString(paramValue, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i].toUpperCase()) );
- // else {
- //debugLogger.debug(" Session " + " sessionParameters[i] " + sessionParameters[i] + " " + (String)session.getAttribute(sessionParameters[i]));
- sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) );
- //}
+ // if(!sessionParameters[i].startsWith("ff"))
+ // paramValue = Utils.replaceInString(paramValue, "[" + sessionParameters[i].toUpperCase()+"]",
+ // (String)session.getAttribute(sessionParameters[i].toUpperCase()) );
+ // else {
+ // debugLogger.debug(" Session " + " sessionParameters[i] " + sessionParameters[i] + " " +
+ // (String)session.getAttribute(sessionParameters[i]));
+ sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase() + "]",
+ (String) session.getAttribute(sessionParameters[i]));
+ // }
}
- }
- } else {
- //debugLogger.debug("BEFORE LOGGED USERID REPLACE " + sql);
- //sql = Utils.replaceInString(sql, "'[logged_userId]'", "'"+userId+"'");
- //debugLogger.debug("Replacing string 2 " + sql);
- sql = Utils.replaceInString(sql, "[LOGGED_USERID]", userId);
- sql = Utils.replaceInString(sql, "[USERID]", userId);
- sql = Utils.replaceInString(sql, "[USER_ID]", userId);
- //debugLogger.debug("AFTER LOGGED USERID REPLACE " + sql);
- // Added for Simon's GM Project where they need to get page_id in their query
- //debugLogger.debug("SQLSQLBASED no formfields " + sql);
- if(request != null ) {
- for (int i = 0; i < reqParameters.length; i++) {
- sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase()+"]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), request.getParameter(reqParameters[i]) ));
- }
- }
- if(session != null ) {
- for (int i = 0; i < sessionParameters.length; i++) {
- //debugLogger.debug(" Session " + " sessionParameters[i] " + sessionParameters[i] + " " + (String)session.getAttribute(sessionParameters[i]));
- sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) );
}
- }
- }
- // if it is not multiple select and ParamValue is empty this is the place it can be replaced.
- sql = Utils.replaceInString(sql, "[LOGGED_USERID]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), userId));
- sql = Utils.replaceInString(sql, "[USERID]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), userId));
- sql = Utils.replaceInString(sql, "[USER_ID]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), userId));
- //debugLogger.debug("SQLSQLBASED no formfields after" + sql);
- //debugLogger.debug("Replacing String 2 "+ sql);
- //debugLogger.debug("Replaced String " + sql);
-
+ } else {
+ // debugLogger.debug("BEFORE LOGGED USERID REPLACE " + sql);
+ // sql = Utils.replaceInString(sql, "'[logged_userId]'", "'"+userId+"'");
+ // debugLogger.debug("Replacing string 2 " + sql);
+ sql = Utils.replaceInString(sql, "[LOGGED_USERID]", userId);
+ sql = Utils.replaceInString(sql, "[USERID]", userId);
+ sql = Utils.replaceInString(sql, "[USER_ID]", userId);
+ // debugLogger.debug("AFTER LOGGED USERID REPLACE " + sql);
+ // Added for Simon's GM Project where they need to get page_id in their query
+ // debugLogger.debug("SQLSQLBASED no formfields " + sql);
+ if (request != null) {
+ for (int i = 0; i < reqParameters.length; i++) {
+ sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase() + "]", ESAPI.encoder()
+ .encodeForSQL(SecurityCodecUtil.getCodec(), request.getParameter(reqParameters[i])));
+ }
+ }
+ if (session != null) {
+ for (int i = 0; i < sessionParameters.length; i++) {
+ // debugLogger.debug(" Session " + " sessionParameters[i] " + sessionParameters[i] + " " +
+ // (String)session.getAttribute(sessionParameters[i]));
+ sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase() + "]",
+ (String) session.getAttribute(sessionParameters[i]));
+ }
+ }
+ }
+ // if it is not multiple select and ParamValue is empty this is the place it can be replaced.
+ sql = Utils.replaceInString(sql, "[LOGGED_USERID]",
+ ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), userId));
+ sql = Utils.replaceInString(sql, "[USERID]",
+ ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), userId));
+ sql = Utils.replaceInString(sql, "[USER_ID]",
+ ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), userId));
+ // debugLogger.debug("SQLSQLBASED no formfields after" + sql);
+ // debugLogger.debug("Replacing String 2 "+ sql);
+ // debugLogger.debug("Replaced String " + sql);
+
int closeBracketPos = 0;
- if (nvl(overrideSortByColId).length() > 0) {
- if(sql.lastIndexOf(")")!= -1) closeBracketPos = sql.lastIndexOf(")");
- int idxOrderBy = (closeBracketPos>0)?sql.toUpperCase().indexOf("ORDER BY", closeBracketPos):sql.toUpperCase().lastIndexOf("ORDER BY");
- DataColumnType dct = getColumnById(overrideSortByColId+"_sort");
- if(dct!=null && dct.getColName().length()>0) {
- overrideSortByColId = overrideSortByColId+"_sort";
- }
- if (idxOrderBy < 0)
- sql += " ORDER BY " + overrideSortByColId + " " + overrideSortByAscDesc;
- else {
- int braketCount = 0;
- int idxOrderByClauseEnd = 0;
- for (idxOrderByClauseEnd = idxOrderBy; idxOrderByClauseEnd < sql.length(); idxOrderByClauseEnd++) {
- char ch = sql.charAt(idxOrderByClauseEnd);
-
- if (ch == '(')
- braketCount++;
- else if (ch == ')') {
- if (braketCount == 0)
- break;
- braketCount--;
- }
- } // for
-
- sql = sql.substring(0, idxOrderBy) + " ORDER BY " + overrideSortByColId + " "
- + overrideSortByAscDesc + sql.substring(idxOrderByClauseEnd);
- } // else
- } // if
- sql = Pattern.compile("([\n][\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" ");
- return sql;
- } // generateSQLSQLBased
-
- public String generateSQLVisual(ReportParamValues paramValues, String overrideSortByColId,
- String overrideSortByAscDesc, String userId, HttpServletRequest request)throws RaptorException {
- StringBuffer selectCl = new StringBuffer();
- StringBuffer fromCl = new StringBuffer();
- StringBuffer whereCl = new StringBuffer();
- StringBuffer groupByCl = new StringBuffer();
- StringBuffer havingCl = new StringBuffer();
- StringBuffer orderByCl = new StringBuffer();
- StringBuffer selectExtraIdCl = new StringBuffer();
- StringBuffer selectExtraDateCl = new StringBuffer();
-
- int whereClBracketCount = 0;
- int havingClBracketCount = 0;
- int whereClCarryoverBrackets = 0;
- int havingClCarryoverBrackets = 0;
-
- // Identifying FROM clause tables and WHERE clause joins
- List dsList = getDataSourceList().getDataSource();
- for (Iterator iter = dsList.iterator(); iter.hasNext();) {
- DataSourceType ds = (DataSourceType) iter.next();
-
- if (fromCl.length() > 0)
- fromCl.append(", ");
- fromCl.append(ds.getTableName());
- fromCl.append(" ");
- fromCl.append(ds.getTableId());
-
- if (nvl(ds.getRefTableId()).length() > 0) {
- if (whereCl.length() > 0)
- whereCl.append(" AND ");
- whereCl.append(ds.getRefDefinition());
- } // if
- // Add the condition.
- TableSource tableSource = null;
- String dBInfo = this.cr.getDbInfo();
- Vector userRoles = AppUtils.getUserRoles(request);
- tableSource = DataCache.getTableSource(ds.getTableName(), dBInfo,userRoles,userId, request);
- if (userId != null && (!AppUtils.isSuperUser(request))
- && (!AppUtils.isAdminUser(request)) && tableSource != null
- && nvl(tableSource.getFilterSql()).length() > 0) {
- if (whereCl.length() > 0)
- whereCl.append(" AND ");
- whereCl.append(Utils.replaceInString(Utils.replaceInString(tableSource
- .getFilterSql(), "[" + ds.getTableName() + "]", ds.getTableId()),
- "[USER_ID]", userId));
- } // if
- } // for
-
- List reportCols = getAllColumns();
-
- boolean isGroupStmt = false;
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if (dc.isGroupBreak()) {
- isGroupStmt = true;
- break;
- } // if
- } // for
-
- // Identifying SELECT and GROUP BY clause fields and WHERE and HAVING
- // clause filters
- // Collections.sort(reportCols, new OrderSeqComparator());
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- String colName = getColumnSelectStr(dc, paramValues);
-
- // SELECT clause fields
- //TODO: Uncomment if it's not working -- if (dc.isVisible()) {
- if (selectCl.length() > 0)
- selectCl.append(", ");
- selectCl.append(getSelectExpr(dc, colName));
- selectCl.append(" ");
- selectCl.append(dc.getColId());
- //TODO } // if
-
- // Checking for extra fields necessary for drill-down
- if (nvl(dc.getDrillDownURL()).length() > 0)
- if (isViewAction(dc.getDrillDownURL()))
- addExtraIdSelect(selectExtraIdCl, nvl(dc.getDrillDownParams()), true);
- else
- addExtraDateSelect(selectExtraDateCl, nvl(dc.getDrillDownParams()),
- paramValues, true);
-
- // GROUP BY clause fields
- if (dc.isGroupBreak()) {
- if (groupByCl.length() > 0)
- groupByCl.append(", ");
- groupByCl.append(colName);
- } // if
-
- // WHERE/HAVING clause fields
- //boolean isHavingCl = isGroupStmt && dc.isVisible() && (!dc.isGroupBreak());
+ if (nvl(overrideSortByColId).length() > 0) {
+ if (sql.lastIndexOf(")") != -1)
+ closeBracketPos = sql.lastIndexOf(")");
+ int idxOrderBy = (closeBracketPos > 0) ? sql.toUpperCase().indexOf("ORDER BY", closeBracketPos)
+ : sql.toUpperCase().lastIndexOf("ORDER BY");
+ DataColumnType dct = getColumnById(overrideSortByColId + "_sort");
+ if (dct != null && dct.getColName().length() > 0) {
+ overrideSortByColId = overrideSortByColId + "_sort";
+ }
+ if (idxOrderBy < 0)
+ sql += " ORDER BY " + overrideSortByColId + " " + overrideSortByAscDesc;
+ else {
+ int braketCount = 0;
+ int idxOrderByClauseEnd = 0;
+ for (idxOrderByClauseEnd = idxOrderBy; idxOrderByClauseEnd < sql.length(); idxOrderByClauseEnd++) {
+ char ch = sql.charAt(idxOrderByClauseEnd);
+
+ if (ch == '(')
+ braketCount++;
+ else if (ch == ')') {
+ if (braketCount == 0)
+ break;
+ braketCount--;
+ }
+ } // for
+
+ sql = sql.substring(0, idxOrderBy) + " ORDER BY " + overrideSortByColId + " "
+ + overrideSortByAscDesc + sql.substring(idxOrderByClauseEnd);
+ } // else
+ } // if
+ sql = Pattern.compile("([\n][\\s]*)", Pattern.DOTALL).matcher(sql).replaceAll(" ");
+ return sql;
+ } // generateSQLSQLBased
+
+ public String generateSQLVisual(ReportParamValues paramValues, String overrideSortByColId,
+ String overrideSortByAscDesc, String userId, HttpServletRequest request) throws RaptorException {
+ StringBuffer selectCl = new StringBuffer();
+ StringBuffer fromCl = new StringBuffer();
+ StringBuffer whereCl = new StringBuffer();
+ StringBuffer groupByCl = new StringBuffer();
+ StringBuffer havingCl = new StringBuffer();
+ StringBuffer orderByCl = new StringBuffer();
+ StringBuffer selectExtraIdCl = new StringBuffer();
+ StringBuffer selectExtraDateCl = new StringBuffer();
+
+ int whereClBracketCount = 0;
+ int havingClBracketCount = 0;
+ int whereClCarryoverBrackets = 0;
+ int havingClCarryoverBrackets = 0;
+
+ // Identifying FROM clause tables and WHERE clause joins
+ List dsList = getDataSourceList().getDataSource();
+ for (Iterator iter = dsList.iterator(); iter.hasNext();) {
+ DataSourceType ds = (DataSourceType) iter.next();
+
+ if (fromCl.length() > 0)
+ fromCl.append(", ");
+ fromCl.append(ds.getTableName());
+ fromCl.append(" ");
+ fromCl.append(ds.getTableId());
+
+ if (nvl(ds.getRefTableId()).length() > 0) {
+ if (whereCl.length() > 0)
+ whereCl.append(" AND ");
+ whereCl.append(ds.getRefDefinition());
+ } // if
+ // Add the condition.
+ TableSource tableSource = null;
+ String dBInfo = this.cr.getDbInfo();
+ Vector userRoles = AppUtils.getUserRoles(request);
+ tableSource = DataCache.getTableSource(ds.getTableName(), dBInfo, userRoles, userId, request);
+ if (userId != null && (!AppUtils.isSuperUser(request))
+ && (!AppUtils.isAdminUser(request)) && tableSource != null
+ && nvl(tableSource.getFilterSql()).length() > 0) {
+ if (whereCl.length() > 0)
+ whereCl.append(" AND ");
+ whereCl.append(Utils.replaceInString(Utils.replaceInString(tableSource
+ .getFilterSql(), "[" + ds.getTableName() + "]", ds.getTableId()),
+ "[USER_ID]", userId));
+ } // if
+ } // for
+
+ List reportCols = getAllColumns();
+
+ boolean isGroupStmt = false;
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (dc.isGroupBreak()) {
+ isGroupStmt = true;
+ break;
+ } // if
+ } // for
+
+ // Identifying SELECT and GROUP BY clause fields and WHERE and HAVING
+ // clause filters
+ // Collections.sort(reportCols, new OrderSeqComparator());
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ String colName = getColumnSelectStr(dc, paramValues);
+
+ // SELECT clause fields
+ // TODO: Uncomment if it's not working -- if (dc.isVisible()) {
+ if (selectCl.length() > 0)
+ selectCl.append(", ");
+ selectCl.append(getSelectExpr(dc, colName));
+ selectCl.append(" ");
+ selectCl.append(dc.getColId());
+ // TODO } // if
+
+ // Checking for extra fields necessary for drill-down
+ if (nvl(dc.getDrillDownURL()).length() > 0)
+ if (isViewAction(dc.getDrillDownURL()))
+ addExtraIdSelect(selectExtraIdCl, nvl(dc.getDrillDownParams()), true);
+ else
+ addExtraDateSelect(selectExtraDateCl, nvl(dc.getDrillDownParams()),
+ paramValues, true);
+
+ // GROUP BY clause fields
+ if (dc.isGroupBreak()) {
+ if (groupByCl.length() > 0)
+ groupByCl.append(", ");
+ groupByCl.append(colName);
+ } // if
+
+ // WHERE/HAVING clause fields
+ // boolean isHavingCl = isGroupStmt && dc.isVisible() && (!dc.isGroupBreak());
boolean isHavingCl = isGroupStmt && (!dc.isGroupBreak());
- StringBuffer filterCl = isHavingCl ? havingCl : whereCl;
- // StringBuffer filterCl =
- // isGroupStmt?(dc.isVisible()?(dc.isGroupBreak()?whereCl:havingCl):whereCl):whereCl;
- if (dc.getColFilterList() != null) {
- int fNo = 0;
- List fList = dc.getColFilterList().getColFilter();
- for (Iterator iterF = fList.iterator(); iterF.hasNext(); fNo++) {
- ColFilterType cf = (ColFilterType) iterF.next();
-
- StringBuffer curFilter = new StringBuffer();
- if (filterCl.length() > 0)
- curFilter.append(" " + cf.getJoinCondition() + " ");
- if ((isHavingCl ? havingClCarryoverBrackets : whereClCarryoverBrackets) > 0)
- for (int b = 0; b < (isHavingCl ? havingClCarryoverBrackets
- : whereClCarryoverBrackets); b++)
- filterCl.append('(');
- curFilter.append(nvl(cf.getOpenBrackets()));
- curFilter.append(colName + " ");
- curFilter.append(cf.getExpression() + " ");
-
- boolean applyFilter = true;
- if ((nvl(cf.getArgValue()).length() > 0)
- || (nvl(cf.getArgType()).equals(AppConstants.AT_FORM)))
- if (nvl(cf.getArgType()).equals(AppConstants.AT_FORMULA))
- curFilter.append(cf.getArgValue());
- else if (nvl(cf.getArgType()).equals(AppConstants.AT_VALUE))
- curFilter.append(formatValue(cf.getArgValue(), dc, false));
- else if (nvl(cf.getArgType()).equals(AppConstants.AT_LIST))
- curFilter.append(formatListValue(cf.getArgValue(), dc, false,
- false));
- else if (nvl(cf.getArgType()).equals(AppConstants.AT_COLUMN))
- curFilter.append(getColumnNameById(cf.getArgValue()));
- else if (nvl(cf.getArgType()).equals(AppConstants.AT_FORM)) {
- String fieldName = getFormFieldName(cf);
- String fieldValue = Utils.oracleSafe(paramValues
- .getParamValue(fieldName));
- boolean isMultiValue = paramValues
- .isParameterMultiValue(fieldName);
- boolean usePipeDelimiterOnly = false;
-
- FormFieldType fft = getFormFieldByDisplayValue(cf.getArgValue());
- if (fft == null)
- // If not FormField => applying default value
- fieldValue = nvl(fieldValue, Utils
- .oracleSafe(cf.getArgValue()));
- else
- usePipeDelimiterOnly = fft.getFieldType().equals(
- FormField.FFT_CHECK_BOX)
- || fft.getFieldType().equals(FormField.FFT_LIST_MULTI);
- //Added for TimeStamp validation
- String fieldId = fft.getFieldId();
- if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)||fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)||fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
- fieldValue = nvl(
- fieldValue + " " + addZero(Utils.oracleSafe(nvl(paramValues
- .getParamValue(fieldId+"_Hr") ) ) ) ) ;
- if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
- fieldValue = fieldValue + (nvl(paramValues
- .getParamValue(fieldId+"_Min")).length()>0 ? ":" + addZero(Utils.oracleSafe(nvl(paramValues
- .getParamValue(fieldId+"_Min")))): "") ;
- }
- if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
- fieldValue = fieldValue + (nvl(paramValues
- .getParamValue(fieldId+"_Sec")).length()>0 ? ":"+ addZero(Utils.oracleSafe(nvl(paramValues
- .getParamValue(fieldId+"_Sec")))) : "");
- }
- }
-
- // End
- if (nvl(fieldValue).length() == 0)
- // Does not append filter with missing form
- // field argument
- applyFilter = false;
- else if (isMultiValue || nvl(cf.getExpression()).equals("IN")
- || nvl(cf.getExpression()).equals("NOT IN"))
- curFilter.append(formatListValue(fieldValue, dc, true,
- usePipeDelimiterOnly));
- else
- curFilter.append(formatValue(fieldValue, dc, true, null, fft));
- } // else
- curFilter.append(nvl(cf.getCloseBrackets()));
-
- if (applyFilter) {
- filterCl.append(curFilter.toString());
-
- if (isHavingCl) {
- havingClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl(
- cf.getCloseBrackets()).length());
- havingClCarryoverBrackets = 0;
- } else {
- whereClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl(
- cf.getCloseBrackets()).length());
- whereClCarryoverBrackets = 0;
- }
- } else if (nvl(cf.getOpenBrackets()).length() != nvl(cf.getCloseBrackets())
- .length())
- if (nvl(cf.getOpenBrackets()).length() > nvl(cf.getCloseBrackets())
- .length()) {
- // Carry over opening brackets
- if (isHavingCl)
- havingClCarryoverBrackets += (nvl(cf.getOpenBrackets())
- .length() - nvl(cf.getCloseBrackets()).length());
- else
- whereClCarryoverBrackets += (nvl(cf.getOpenBrackets())
- .length() - nvl(cf.getCloseBrackets()).length());
-
- if (isHavingCl)
- havingClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl(
- cf.getCloseBrackets()).length());
- else
- whereClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl(
- cf.getCloseBrackets()).length());
- } else {
- // Adding closing brackets
- if (filterCl.length() > 0) {
- for (int b = 0; b < nvl(cf.getCloseBrackets()).length()
- - nvl(cf.getOpenBrackets()).length(); b++)
- filterCl.append(')');
-
- if (isHavingCl)
- havingClBracketCount += (nvl(cf.getOpenBrackets())
- .length() - nvl(cf.getCloseBrackets()).length());
- else
- whereClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl(
- cf.getCloseBrackets()).length());
- } // if
- } // else
- } // for
- } // if
- } // for
-
- // Identifying ORDER BY clause fields
- DataColumnType overrideSortByCol = null;
- if (overrideSortByColId != null)
- overrideSortByCol = getColumnById(overrideSortByColId);
-
- if (overrideSortByCol != null) {
- orderByCl.append(getColumnSelectStr(overrideSortByCol, paramValues));
- orderByCl.append(" ");
- orderByCl.append(nvl(overrideSortByAscDesc, AppConstants.SO_ASC));
- } else if (getReportType().equals(AppConstants.RT_CROSSTAB)) {
- /*
- * for(Iterator iter=reportCols.iterator(); iter.hasNext(); ) {
- * DataColumnType dc = (DataColumnType) iter.next();
- *
- * if(nvl(dc.getCrossTabValue()).equals(AppConstants.CV_ROW)||nvl(dc.getCrossTabValue()).equals(AppConstants.CV_COLUMN)) {
- * if(orderByCl.length()>0) orderByCl.append(", ");
- * orderByCl.append(getColumnSelectStr(dc, paramValues));
- * orderByCl.append(" ");
- * if(dc.getColType().equals(AppConstants.CT_DATE))
- * orderByCl.append(AppConstants.SO_DESC); else
- * orderByCl.append(AppConstants.SO_ASC); } // if } // for
- */
- } else {
- Collections.sort(reportCols, new OrderBySeqComparator());
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
-
- if (dc.getOrderBySeq() > 0) {
- if (orderByCl.length() > 0)
- orderByCl.append(", ");
- orderByCl.append(getColumnSelectStr(dc, paramValues));
- orderByCl.append(" ");
- orderByCl.append(dc.getOrderByAscDesc());
- } // if
- } // for
- Collections.sort(reportCols, new OrderSeqComparator());
- } // else
-
- // Adding up the actual statement
- StringBuffer sql = new StringBuffer();
- //sql.append("SELECT "); // Need to add PK for /*+ FIRST_ROWS */ ");
- sql.append(Globals.getGenerateSqlVisualSelect());
- //sql.append((selectCl.length() == 0) ? "COUNT(*) cnt" : selectCl.toString());
- sql.append((selectCl.length() == 0) ? Globals.getGenerateSqlVisualCount() : selectCl.toString());
- if (groupByCl.length() == 0)
- sql.append(selectExtraIdCl.toString());
- sql.append(selectExtraDateCl.toString());
- // sql.append(" FROM ");
- sql.append((fromCl.length() == 0) ? Globals.getGenerateSqlVisualDual() : "FROM "+fromCl.toString());
- if (whereCl.length() > 0) {
- if (whereClBracketCount > 0) {
- for (int b = 0; b < whereClBracketCount; b++)
- whereCl.append(')');
- } else if (whereClBracketCount < 0) {
- for (int b = 0; b < Math.abs(whereClBracketCount); b++)
- whereCl.insert(0, '(');
- } // else
-
- sql.append(" WHERE ");
- sql.append(whereCl.toString());
- } // if
- if (groupByCl.length() > 0) {
- sql.append(" GROUP BY ");
- sql.append(groupByCl.toString());
-
- if (havingCl.length() > 0) {
- if (havingClBracketCount > 0) {
- for (int b = 0; b < havingClBracketCount; b++)
- havingCl.append(')');
- } else if (havingClBracketCount < 0) {
- for (int b = 0; b < Math.abs(havingClBracketCount); b++)
- havingCl.insert(0, '(');
- } // else
-
- sql.append(" HAVING ");
- sql.append(havingCl.toString());
- }
- }
- if (orderByCl.length() > 0) {
- sql.append(" ORDER BY ");
- sql.append(orderByCl.toString());
- }
- //String sqlStr = Utils.replaceInString(sql.toString(), "[LOGGED_USERID]", userId);
- //return sqlStr;
+ StringBuffer filterCl = isHavingCl ? havingCl : whereCl;
+ // StringBuffer filterCl =
+ // isGroupStmt?(dc.isVisible()?(dc.isGroupBreak()?whereCl:havingCl):whereCl):whereCl;
+ if (dc.getColFilterList() != null) {
+ int fNo = 0;
+ List fList = dc.getColFilterList().getColFilter();
+ for (Iterator iterF = fList.iterator(); iterF.hasNext(); fNo++) {
+ ColFilterType cf = (ColFilterType) iterF.next();
+
+ StringBuffer curFilter = new StringBuffer();
+ if (filterCl.length() > 0)
+ curFilter.append(" " + cf.getJoinCondition() + " ");
+ if ((isHavingCl ? havingClCarryoverBrackets : whereClCarryoverBrackets) > 0)
+ for (int b = 0; b < (isHavingCl ? havingClCarryoverBrackets
+ : whereClCarryoverBrackets); b++)
+ filterCl.append('(');
+ curFilter.append(nvl(cf.getOpenBrackets()));
+ curFilter.append(colName + " ");
+ curFilter.append(cf.getExpression() + " ");
+
+ boolean applyFilter = true;
+ if ((nvl(cf.getArgValue()).length() > 0)
+ || (nvl(cf.getArgType()).equals(AppConstants.AT_FORM)))
+ if (nvl(cf.getArgType()).equals(AppConstants.AT_FORMULA))
+ curFilter.append(cf.getArgValue());
+ else if (nvl(cf.getArgType()).equals(AppConstants.AT_VALUE))
+ curFilter.append(formatValue(cf.getArgValue(), dc, false));
+ else if (nvl(cf.getArgType()).equals(AppConstants.AT_LIST))
+ curFilter.append(formatListValue(cf.getArgValue(), dc, false,
+ false));
+ else if (nvl(cf.getArgType()).equals(AppConstants.AT_COLUMN))
+ curFilter.append(getColumnNameById(cf.getArgValue()));
+ else if (nvl(cf.getArgType()).equals(AppConstants.AT_FORM)) {
+ String fieldName = getFormFieldName(cf);
+ String fieldValue = Utils.oracleSafe(paramValues
+ .getParamValue(fieldName));
+ boolean isMultiValue = paramValues
+ .isParameterMultiValue(fieldName);
+ boolean usePipeDelimiterOnly = false;
+
+ FormFieldType fft = getFormFieldByDisplayValue(cf.getArgValue());
+ if (fft == null)
+ // If not FormField => applying default value
+ fieldValue = nvl(fieldValue, Utils
+ .oracleSafe(cf.getArgValue()));
+ else
+ usePipeDelimiterOnly = fft.getFieldType().equals(
+ FormField.FFT_CHECK_BOX)
+ || fft.getFieldType().equals(FormField.FFT_LIST_MULTI);
+ if (fft != null) {
+ // Added for TimeStamp validation
+ String fieldId = fft.getFieldId();
+ if (fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)
+ || fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)
+ || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
+ fieldValue = nvl(
+ fieldValue + " " + addZero(Utils.oracleSafe(nvl(paramValues
+ .getParamValue(fieldId + "_Hr")))));
+ if (fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)
+ || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
+ fieldValue = fieldValue + (nvl(paramValues
+ .getParamValue(fieldId + "_Min")).length() > 0
+ ? ":" + addZero(Utils.oracleSafe(nvl(paramValues
+ .getParamValue(fieldId + "_Min"))))
+ : "");
+ }
+ if (fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) {
+ fieldValue = fieldValue + (nvl(paramValues
+ .getParamValue(fieldId + "_Sec")).length() > 0
+ ? ":" + addZero(Utils.oracleSafe(nvl(paramValues
+ .getParamValue(fieldId + "_Sec"))))
+ : "");
+ }
+ }
+ }
+
+ // End
+ if (nvl(fieldValue).length() == 0)
+ // Does not append filter with missing form
+ // field argument
+ applyFilter = false;
+ else if (isMultiValue || "IN".equals(nvl(cf.getExpression()))
+ || "NOT IN".equals(nvl(cf.getExpression())))
+ curFilter.append(formatListValue(fieldValue, dc, true,
+ usePipeDelimiterOnly));
+ else
+ curFilter.append(formatValue(fieldValue, dc, true, null, fft));
+ } // else
+ curFilter.append(nvl(cf.getCloseBrackets()));
+
+ if (applyFilter) {
+ filterCl.append(curFilter.toString());
+
+ if (isHavingCl) {
+ havingClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl(
+ cf.getCloseBrackets()).length());
+ havingClCarryoverBrackets = 0;
+ } else {
+ whereClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl(
+ cf.getCloseBrackets()).length());
+ whereClCarryoverBrackets = 0;
+ }
+ } else if (nvl(cf.getOpenBrackets()).length() != nvl(cf.getCloseBrackets())
+ .length())
+ if (nvl(cf.getOpenBrackets()).length() > nvl(cf.getCloseBrackets())
+ .length()) {
+ // Carry over opening brackets
+ if (isHavingCl)
+ havingClCarryoverBrackets += (nvl(cf.getOpenBrackets())
+ .length() - nvl(cf.getCloseBrackets()).length());
+ else
+ whereClCarryoverBrackets += (nvl(cf.getOpenBrackets())
+ .length() - nvl(cf.getCloseBrackets()).length());
+
+ if (isHavingCl)
+ havingClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl(
+ cf.getCloseBrackets()).length());
+ else
+ whereClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl(
+ cf.getCloseBrackets()).length());
+ } else {
+ // Adding closing brackets
+ if (filterCl.length() > 0) {
+ for (int b = 0; b < nvl(cf.getCloseBrackets()).length()
+ - nvl(cf.getOpenBrackets()).length(); b++)
+ filterCl.append(')');
+
+ if (isHavingCl)
+ havingClBracketCount += (nvl(cf.getOpenBrackets())
+ .length() - nvl(cf.getCloseBrackets()).length());
+ else
+ whereClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl(
+ cf.getCloseBrackets()).length());
+ } // if
+ } // else
+ } // for
+ } // if
+ } // for
+
+ // Identifying ORDER BY clause fields
+ DataColumnType overrideSortByCol = null;
+ if (overrideSortByColId != null)
+ overrideSortByCol = getColumnById(overrideSortByColId);
+
+ if (overrideSortByCol != null) {
+ orderByCl.append(getColumnSelectStr(overrideSortByCol, paramValues));
+ orderByCl.append(" ");
+ orderByCl.append(nvl(overrideSortByAscDesc, AppConstants.SO_ASC));
+ } else if (getReportType().equals(AppConstants.RT_CROSSTAB)) {
+ /*
+ * for(Iterator iter=reportCols.iterator(); iter.hasNext(); ) { DataColumnType dc = (DataColumnType)
+ * iter.next();
+ *
+ * if(nvl(dc.getCrossTabValue()).equals(AppConstants.CV_ROW)||nvl(dc.getCrossTabValue()).equals(
+ * AppConstants.CV_COLUMN)) { if(orderByCl.length()>0) orderByCl.append(", ");
+ * orderByCl.append(getColumnSelectStr(dc, paramValues)); orderByCl.append(" ");
+ * if(dc.getColType().equals(AppConstants.CT_DATE)) orderByCl.append(AppConstants.SO_DESC); else
+ * orderByCl.append(AppConstants.SO_ASC); } // if } // for
+ */
+ } else {
+ Collections.sort(reportCols, new OrderBySeqComparator());
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+
+ if (dc.getOrderBySeq() > 0) {
+ if (orderByCl.length() > 0)
+ orderByCl.append(", ");
+ orderByCl.append(getColumnSelectStr(dc, paramValues));
+ orderByCl.append(" ");
+ orderByCl.append(dc.getOrderByAscDesc());
+ } // if
+ } // for
+ Collections.sort(reportCols, new OrderSeqComparator());
+ } // else
+
+ // Adding up the actual statement
+ StringBuffer sql = new StringBuffer();
+ // sql.append("SELECT "); // Need to add PK for /*+ FIRST_ROWS */ ");
+ sql.append(Globals.getGenerateSqlVisualSelect());
+ // sql.append((selectCl.length() == 0) ? "COUNT(*) cnt" : selectCl.toString());
+ sql.append((selectCl.length() == 0) ? Globals.getGenerateSqlVisualCount() : selectCl.toString());
+ if (groupByCl.length() == 0)
+ sql.append(selectExtraIdCl.toString());
+ sql.append(selectExtraDateCl.toString());
+ // sql.append(" FROM ");
+ sql.append((fromCl.length() == 0) ? Globals.getGenerateSqlVisualDual() : "FROM " + fromCl.toString());
+ if (whereCl.length() > 0) {
+ if (whereClBracketCount > 0) {
+ for (int b = 0; b < whereClBracketCount; b++)
+ whereCl.append(')');
+ } else if (whereClBracketCount < 0) {
+ for (int b = 0; b < Math.abs(whereClBracketCount); b++)
+ whereCl.insert(0, '(');
+ } // else
+
+ sql.append(" WHERE ");
+ sql.append(whereCl.toString());
+ } // if
+ if (groupByCl.length() > 0) {
+ sql.append(" GROUP BY ");
+ sql.append(groupByCl.toString());
+
+ if (havingCl.length() > 0) {
+ if (havingClBracketCount > 0) {
+ for (int b = 0; b < havingClBracketCount; b++)
+ havingCl.append(')');
+ } else if (havingClBracketCount < 0) {
+ for (int b = 0; b < Math.abs(havingClBracketCount); b++)
+ havingCl.insert(0, '(');
+ } // else
+
+ sql.append(" HAVING ");
+ sql.append(havingCl.toString());
+ }
+ }
+ if (orderByCl.length() > 0) {
+ sql.append(" ORDER BY ");
+ sql.append(orderByCl.toString());
+ }
+ // String sqlStr = Utils.replaceInString(sql.toString(), "[LOGGED_USERID]", userId);
+ // return sqlStr;
return sql.toString();
- } // generateSQLVisual
+ } // generateSQLVisual
public String generateSQLCrossTabVisual(ReportParamValues paramValues, String overrideSortByColId,
- String overrideSortByAscDesc, String userId, HttpServletRequest request) throws RaptorException {
+ String overrideSortByAscDesc, String userId, HttpServletRequest request) throws RaptorException {
StringBuffer selectCl = new StringBuffer();
StringBuffer fromCl = new StringBuffer();
StringBuffer whereCl = new StringBuffer();
@@ -3393,11 +3610,11 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject {
whereCl.append(" AND ");
whereCl.append(ds.getRefDefinition());
} // if
- // Add the condition.
+ // Add the condition.
TableSource tableSource = null;
String dBInfo = this.cr.getDbInfo();
Vector userRoles = AppUtils.getUserRoles(request);
- tableSource = DataCache.getTableSource(ds.getTableName(), dBInfo,userRoles,userId, request);
+ tableSource = DataCache.getTableSource(ds.getTableName(), dBInfo, userRoles, userId, request);
if (userId != null && (!AppUtils.isSuperUser(request))
&& (!AppUtils.isAdminUser(request)) && tableSource != null
&& nvl(tableSource.getFilterSql()).length() > 0) {
@@ -3408,7 +3625,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject {
"[USER_ID]", userId));
} // if
} // for
-
+
List reportCols = getAllColumns();
boolean isGroupStmt = false;
@@ -3434,7 +3651,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject {
selectCl.append(getSelectExpr(dc, colName));
selectCl.append(" ");
selectCl.append(dc.getColId());
- } // if
+ } // if
// Checking for extra fields necessary for drill-down
if (nvl(dc.getDrillDownURL()).length() > 0)
@@ -3453,10 +3670,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject {
// WHERE/HAVING clause fields
boolean isHavingCl = isGroupStmt && dc.isVisible() && (!dc.isGroupBreak());
- //boolean isHavingCl = isGroupStmt && (!dc.isGroupBreak());
- //StringBuffer filterCl = isHavingCl ? havingCl : whereCl;
- StringBuffer filterCl =
- isGroupStmt?(dc.isVisible()?(dc.isGroupBreak()?whereCl:havingCl):whereCl):whereCl;
+ // boolean isHavingCl = isGroupStmt && (!dc.isGroupBreak());
+ // StringBuffer filterCl = isHavingCl ? havingCl : whereCl;
+ StringBuffer filterCl =
+ isGroupStmt ? (dc.isVisible() ? (dc.isGroupBreak() ? whereCl : havingCl) : whereCl) : whereCl;
if (dc.getColFilterList() != null) {
int fNo = 0;
List fList = dc.getColFilterList().getColFilter();
@@ -3508,8 +3725,8 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject {
// Does not append filter with missing form
// field argument
applyFilter = false;
- else if (isMultiValue || nvl(cf.getExpression()).equals("IN")
- || nvl(cf.getExpression()).equals("NOT IN"))
+ else if (isMultiValue || "IN".equals(nvl(cf.getExpression()))
+ || "NOT IN".equals(nvl(cf.getExpression())))
curFilter.append(formatListValue(fieldValue, dc, true,
usePipeDelimiterOnly));
else
@@ -3577,15 +3794,13 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject {
orderByCl.append(nvl(overrideSortByAscDesc, AppConstants.SO_ASC));
} else if (getReportType().equals(AppConstants.RT_CROSSTAB)) {
/*
- * for(Iterator iter=reportCols.iterator(); iter.hasNext(); ) {
- * DataColumnType dc = (DataColumnType) iter.next();
- *
- * if(nvl(dc.getCrossTabValue()).equals(AppConstants.CV_ROW)||nvl(dc.getCrossTabValue()).equals(AppConstants.CV_COLUMN)) {
- * if(orderByCl.length()>0) orderByCl.append(", ");
- * orderByCl.append(getColumnSelectStr(dc, paramValues));
- * orderByCl.append(" ");
- * if(dc.getColType().equals(AppConstants.CT_DATE))
- * orderByCl.append(AppConstants.SO_DESC); else
+ * for(Iterator iter=reportCols.iterator(); iter.hasNext(); ) { DataColumnType dc = (DataColumnType)
+ * iter.next();
+ *
+ * if(nvl(dc.getCrossTabValue()).equals(AppConstants.CV_ROW)||nvl(dc.getCrossTabValue()).equals(
+ * AppConstants.CV_COLUMN)) { if(orderByCl.length()>0) orderByCl.append(", ");
+ * orderByCl.append(getColumnSelectStr(dc, paramValues)); orderByCl.append(" ");
+ * if(dc.getColType().equals(AppConstants.CT_DATE)) orderByCl.append(AppConstants.SO_DESC); else
* orderByCl.append(AppConstants.SO_ASC); } // if } // for
*/
} else {
@@ -3606,15 +3821,15 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject {
// Adding up the actual statement
StringBuffer sql = new StringBuffer();
- //sql.append("SELECT "); // Need to add PK for /*+ FIRST_ROWS */ ");
+ // sql.append("SELECT "); // Need to add PK for /*+ FIRST_ROWS */ ");
sql.append(Globals.getGenerateSqlVisualSelect());
- // sql.append((selectCl.length() == 0) ? "COUNT(*) cnt" : selectCl.toString());
+ // sql.append((selectCl.length() == 0) ? "COUNT(*) cnt" : selectCl.toString());
sql.append((selectCl.length() == 0) ? Globals.getGenerateSqlVisualCount() : selectCl.toString());
if (groupByCl.length() == 0)
sql.append(selectExtraIdCl.toString());
sql.append(selectExtraDateCl.toString());
- // sql.append(" FROM ");
- sql.append((fromCl.length() == 0) ? Globals.getGenerateSqlVisualDual() : "FROM "+fromCl.toString());
+ // sql.append(" FROM ");
+ sql.append((fromCl.length() == 0) ? Globals.getGenerateSqlVisualDual() : "FROM " + fromCl.toString());
if (whereCl.length() > 0) {
if (whereClBracketCount > 0) {
for (int b = 0; b < whereClBracketCount; b++)
@@ -3648,1779 +3863,1815 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject {
sql.append(" ORDER BY ");
sql.append(orderByCl.toString());
}
-
- System.out.println("Created SQL statement: "+sql);
-
- //String sqlStr = Utils.replaceInString(sql.toString(), "[LOGGED_USERID]", userId);
- //return sqlStr;
+
+ logger.debug(EELFLoggerDelegate.debugLogger, "Created SQL statement: {}", sql);
+
+ // String sqlStr = Utils.replaceInString(sql.toString(), "[LOGGED_USERID]", userId);
+ // return sqlStr;
return sql.toString();
} // generateSQLCrossTabVisual
+ public String generatePagedSQL(int pageNo, String userId, HttpServletRequest request,
+ boolean getColumnNamesFromReportSQL, ReportParamValues paramValues) throws RaptorException {
+ int counter = 0;
+ if (!Globals.isMySQL())
+ counter = 1;
+ return generateSubsetSQL(pageNo * getPageSize() + counter, ((pageNo + 1) * getPageSize())
+ + ((pageNo == 0) ? 1 : 0), userId, request, getColumnNamesFromReportSQL, paramValues);
+ } // generatePagedSQL
+
+ public String generateSubsetSQL(int startRow, int endRow, String userId, HttpServletRequest request,
+ boolean getColumnNamesFromReportSQL, ReportParamValues paramValues) throws RaptorException {
+ // debugLogger.debug(" ******** End Row ********* " + endRow);
+ String dbInfo = getDBInfo();
+ String dbType = "";
+ if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) {
+ try {
+ org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo =
+ new org.onap.portalsdk.analytics.util.RemDbInfo();
+ dbType = remDbInfo.getDBType(dbInfo);
+ } catch (Exception ex) {
+ throw new RaptorException(ex);
+ }
+ }
+ List reportCols = getAllColumns();
+ String wholeSQL_OrderBy = getWholeSQL();
+ String reportSQL = getWholeSQL();
+ reportSQL = reportSQL.replace(";", "");
+ setWholeSQL(reportSQL);
+ if (nvl(reportSQL).length() > 0)
+ reportSQL = generateSQL(userId, request);
+ if (nvl(reportSQL).toUpperCase().indexOf("ORDER BY ") < 0) {
+ StringBuffer sortBy = null;
+
+ if (nvl(reportSQL).toUpperCase().indexOf("GROUP BY ") < 0)
+ if (getDataSourceList().getDataSource().size() > 0) {
+ DataSourceType dst = (DataSourceType) getDataSourceList().getDataSource()
+ .get(0);
+ String tId = dst.getTableId();
+ String tPK = dst.getTablePK();
+ if (nvl(tPK).length() > 0) {
+ sortBy = new StringBuffer();
+ StringTokenizer st = new StringTokenizer(tPK, ", ");
+ while (st.hasMoreTokens()) {
+ if (sortBy.length() > 0)
+ sortBy.append(",");
+ sortBy.append(tId);
+ sortBy.append(".");
+ sortBy.append(st.nextToken());
+ } // while
+ }
+ } // if
+ if (nvl(reportSQL).trim().toUpperCase().startsWith("SELECT")) {
+ // if (!(dbType.equals("DAYTONA") && reportSQL.trim().toUpperCase().startsWith("SELECT")))
+ // reportSQL += " ORDER BY " + ((sortBy == null) ? "1" : sortBy.toString());
+ }
+ }
+ StringBuffer colNames = new StringBuffer();
+ StringBuffer colExtraIdNames = new StringBuffer();
+ StringBuffer colExtraDateNames = new StringBuffer();
+ if (getDBType() != null && getDBType().equals(AppConstants.ORACLE)) {
+ colNames.append("rownum rnum");
+ }
+
+ if (getColumnNamesFromReportSQL) {
+ DataSet ds = ConnectionUtils.getDataSet(reportSQL, dbInfo);
+ List reportCols1 = getAllColumns();
+ reportCols = new Vector();
+ outer: for (Iterator iter = reportCols1.iterator(); iter.hasNext();) {
+ DataColumnType dct = (DataColumnType) iter.next();
+ for (int k = 0; k < ds.getColumnCount(); k++) {
+ if (dct.getColId().toUpperCase().trim().equals(ds.getColumnName(k).trim())) {
+ reportCols.add(dct);
+ continue outer;
+ }
+ }
+ }
+
+ if (getFormFieldList() != null) {
+ String paramValue = "";
+ for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) {
+ FormFieldType fft = (FormFieldType) iter.next();
+ if (fft.isGroupFormField() != null && fft.isGroupFormField().booleanValue()) {
+ paramValue = Utils.oracleSafe(nvl(paramValues
+ .getParamValue(fft.getFieldId())));
+ outer: for (Iterator iter1 = reportCols1.iterator(); iter1.hasNext();) {
+ DataColumnType dct = (DataColumnType) iter1.next();
+ if (("[" + fft.getFieldName() + "]").equals(dct.getColName().trim())) {
+ dct.setDisplayName(paramValue);
+ continue outer;
+ }
+ }
+
+ }
+ }
+ }
+
+ }
+
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ // TODO: commented if (dc.isVisible()) {
+ if (colNames.length() > 0)
+ colNames.append(", ");
+ colNames.append(dc.getColId());
+ // TODO uncomment if it's not working} // if
+
+ // Checking for extra fields necessary for drill-down
+ if (nvl(dc.getDrillDownURL()).length() > 0)
+ if (isViewAction(dc.getDrillDownURL()))
+ addExtraIdSelect(colExtraIdNames, nvl(dc.getDrillDownParams()), false);
+ else
+ addExtraDateSelect(colExtraDateNames, nvl(dc.getDrillDownParams()), null,
+ false);
+ } // for
+
+ if (reportSQL.toUpperCase().indexOf("GROUP BY ") < 0)
+ colNames.append(colExtraIdNames.toString());
+ // commented to avoid coldId_dde
+ // colNames.append(colExtraDateNames.toString());
+
+ /*
+ * if(pageNo==0) if(reportSQL.toUpperCase().indexOf(" WHERE ")<0)
+ * if(reportSQL.toUpperCase().indexOf(" GROUP BY ")<0) reportSQL = reportSQL.substring(0,
+ * reportSQL.toUpperCase().indexOf(" ORDER BY "))+" WHERE ROWNUM <=
+ * "+getPageSize()+reportSQL.substring(reportSQL.toUpperCase().indexOf(" ORDER BY
+ * ")); else reportSQL = "SELECT "+colNames.toString()+" FROM (SELECT ROWNUM rnum,
+ * "+colNames.toString()+" FROM ("+reportSQL+") x) y WHERE rnum <= "+getPageSize()+" ORDER BY rnum";
+ * else reportSQL = reportSQL.substring(0, reportSQL.toUpperCase().indexOf(" WHERE "))+" WHERE
+ * ROWNUM <= "+getPageSize()+" AND "+reportSQL.substring(reportSQL.toUpperCase().indexOf(" WHERE
+ * ")+7); else reportSQL = "SELECT "+colNames.toString()+" FROM (SELECT ROWNUM rnum,
+ * "+colNames.toString()+" FROM ("+reportSQL+") x) y WHERE rnum >= "+(pageNo*getPageSize()+1)+" AND
+ * rnum <= "+((pageNo+1)*getPageSize())+" ORDER BY rnum";
+ */
+ if ("DAYTONA".equals(dbType) && reportSQL.trim().toUpperCase().startsWith("SELECT")) {
+ if (endRow == -1)
+ endRow = (getMaxRowsInExcelDownload() > 0) ? getMaxRowsInExcelDownload() : Globals.getDownloadLimit();
+ reportSQL = reportSQL + " LIMIT TO " + (startRow == 0 ? startRow + 1 : startRow) + "->" + endRow;
+ return reportSQL;
+ } else if ("DAYTONA".equals(dbType)) {
+ return reportSQL;
+ }
+
+ // reportSQL = "SELECT " + colNames.toString() + " FROM (SELECT ROWNUM rnum, "
+ // + colNames.toString() + " FROM (" + reportSQL + ") x ";
+
+ String rSQL = Globals.getGenerateSubsetSql();
+ rSQL = rSQL.replace("[colNames.toString()]", colNames.toString());
+ rSQL = rSQL.replace("[reportSQL]", reportSQL);
- public String generatePagedSQL(int pageNo, String userId, HttpServletRequest request, boolean getColumnNamesFromReportSQL, ReportParamValues paramValues) throws RaptorException {
- int counter = 0;
- if(!Globals.isMySQL())
- counter = 1;
- return generateSubsetSQL(pageNo * getPageSize() + counter, ((pageNo + 1) * getPageSize())
- + ((pageNo == 0) ? 1 : 0), userId, request, getColumnNamesFromReportSQL, paramValues);
- } // generatePagedSQL
-
- public String generateSubsetSQL(int startRow, int endRow, String userId, HttpServletRequest request, boolean getColumnNamesFromReportSQL, ReportParamValues paramValues) throws RaptorException {
- //debugLogger.debug(" ******** End Row ********* " + endRow);
- String dbInfo = getDBInfo();
- String dbType = "";
- if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) {
- try {
- org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo();
- dbType = remDbInfo.getDBType(dbInfo);
- } catch (Exception ex) {
- throw new RaptorException(ex);
- }
- }
- List reportCols = getAllColumns();
- String wholeSQL_OrderBy = getWholeSQL();
- String reportSQL = getWholeSQL();
- reportSQL = reportSQL.replace(";", "");
- setWholeSQL(reportSQL);
- if(nvl(reportSQL).length()>0)
- reportSQL = generateSQL(userId, request);
- if (nvl(reportSQL).toUpperCase().indexOf("ORDER BY ") < 0) {
- StringBuffer sortBy = null;
-
- if (nvl(reportSQL).toUpperCase().indexOf("GROUP BY ") < 0)
- if (getDataSourceList().getDataSource().size() > 0) {
- DataSourceType dst = (DataSourceType) getDataSourceList().getDataSource()
- .get(0);
- String tId = dst.getTableId();
- String tPK = dst.getTablePK();
- if (nvl(tPK).length() > 0) {
- sortBy = new StringBuffer();
- StringTokenizer st = new StringTokenizer(tPK, ", ");
- while (st.hasMoreTokens()) {
- if (sortBy.length() > 0)
- sortBy.append(",");
- sortBy.append(tId);
- sortBy.append(".");
- sortBy.append(st.nextToken());
- } // while
- }
- } // if
- if (nvl(reportSQL).trim().toUpperCase().startsWith("SELECT")) {
- //if (!(dbType.equals("DAYTONA") && reportSQL.trim().toUpperCase().startsWith("SELECT")))
- // reportSQL += " ORDER BY " + ((sortBy == null) ? "1" : sortBy.toString());
- }
- }
- StringBuffer colNames = new StringBuffer();
- StringBuffer colExtraIdNames = new StringBuffer();
- StringBuffer colExtraDateNames = new StringBuffer();
- if(getDBType()!=null && getDBType().equals(AppConstants.ORACLE)) {
- colNames.append("rownum rnum");
- }
-
- if(getColumnNamesFromReportSQL) {
- DataSet ds = ConnectionUtils.getDataSet(reportSQL, dbInfo);
- List reportCols1 = getAllColumns();
- reportCols = new Vector();
- outer:
- for (Iterator iter = reportCols1.iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
- for (int k=0; k<ds.getColumnCount(); k++) {
- if(dct.getColId().toUpperCase().trim().equals(ds.getColumnName(k).trim())) {
- reportCols.add(dct);
- continue outer;
- }
- }
- }
-
- if (getFormFieldList() != null) {
- String paramValue = "";
- for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) {
- FormFieldType fft = (FormFieldType) iter.next();
- if(fft.isGroupFormField()!=null && fft.isGroupFormField().booleanValue()) {
- paramValue = Utils.oracleSafe(nvl(paramValues
- .getParamValue(fft.getFieldId())));
- outer:
- for (Iterator iter1 = reportCols1.iterator(); iter1.hasNext();) {
- DataColumnType dct = (DataColumnType) iter1.next();
- if(("["+fft.getFieldName()+ "]").equals(dct.getColName().trim())) {
- dct.setDisplayName(paramValue);
- continue outer;
- }
- }
-
-
- }
- }
- }
-
- }
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- //TODO: commented if (dc.isVisible()) {
- if (colNames.length() > 0)
- colNames.append(", ");
- colNames.append(dc.getColId());
- //TODO uncomment if it's not working} // if
-
- // Checking for extra fields necessary for drill-down
- if (nvl(dc.getDrillDownURL()).length() > 0)
- if (isViewAction(dc.getDrillDownURL()))
- addExtraIdSelect(colExtraIdNames, nvl(dc.getDrillDownParams()), false);
- else
- addExtraDateSelect(colExtraDateNames, nvl(dc.getDrillDownParams()), null,
- false);
- } // for
-
- if (reportSQL.toUpperCase().indexOf("GROUP BY ") < 0)
- colNames.append(colExtraIdNames.toString());
- //commented to avoid coldId_dde
- //colNames.append(colExtraDateNames.toString());
-
- /*
- * if(pageNo==0) if(reportSQL.toUpperCase().indexOf(" WHERE ")<0)
- * if(reportSQL.toUpperCase().indexOf(" GROUP BY ")<0) reportSQL =
- * reportSQL.substring(0, reportSQL.toUpperCase().indexOf(" ORDER BY
- * "))+" WHERE ROWNUM <=
- * "+getPageSize()+reportSQL.substring(reportSQL.toUpperCase().indexOf("
- * ORDER BY ")); else reportSQL = "SELECT "+colNames.toString()+" FROM
- * (SELECT ROWNUM rnum, "+colNames.toString()+" FROM ("+reportSQL+") x)
- * y WHERE rnum <= "+getPageSize()+" ORDER BY rnum"; else reportSQL =
- * reportSQL.substring(0, reportSQL.toUpperCase().indexOf(" WHERE "))+"
- * WHERE ROWNUM <= "+getPageSize()+" AND
- * "+reportSQL.substring(reportSQL.toUpperCase().indexOf(" WHERE ")+7);
- * else reportSQL = "SELECT "+colNames.toString()+" FROM (SELECT ROWNUM
- * rnum, "+colNames.toString()+" FROM ("+reportSQL+") x) y WHERE rnum >=
- * "+(pageNo*getPageSize()+1)+" AND rnum <=
- * "+((pageNo+1)*getPageSize())+" ORDER BY rnum";
- */
- if (dbType.equals("DAYTONA") && reportSQL.trim().toUpperCase().startsWith("SELECT")) {
- if(endRow == -1) endRow = (getMaxRowsInExcelDownload()>0)?getMaxRowsInExcelDownload():Globals.getDownloadLimit();
- reportSQL = reportSQL + " LIMIT TO " +(startRow==0?startRow+1:startRow)+"->"+endRow;
- return reportSQL;
- } else if (dbType.equals("DAYTONA")) {
- return reportSQL;
- }
-
- //reportSQL = "SELECT " + colNames.toString() + " FROM (SELECT ROWNUM rnum, "
- // + colNames.toString() + " FROM (" + reportSQL + ") x ";
-
- String rSQL = Globals.getGenerateSubsetSql();
- rSQL = rSQL.replace("[colNames.toString()]", colNames.toString());
- rSQL = rSQL.replace("[reportSQL]", reportSQL);
-
- reportSQL=rSQL;
- //added rownum for total report where row header need to be shown
- //reportSQLOnlyFirstPart = "SELECT rnum," + colNames.toString() + " FROM (SELECT ROWNUM rnum, "
- //+ colNames.toString() + " FROM (" ;
-
- reportSQLOnlyFirstPart = Globals.getReportSqlOnlyFirstPart();
- reportSQLOnlyFirstPart = reportSQLOnlyFirstPart.replace("[colNames.toString()]", colNames.toString());
-
-
- reportSQLWithRowNum = reportSQL;
-
- /* if( endRow != -1)
- reportSQL += " WHERE ROWNUM <= " + endRow;
- reportSQL += " ) y WHERE rnum >= " + startRow + " ORDER BY rnum";
- return reportSQL;*/
- String parta = Globals.getReportSqlOnlySecondPartA();
- String partb = Globals.getReportSqlOnlySecondPartB();
-
- String partSql = "";
- if(!AppUtils.isNotEmpty(getDBType())){
- setDBType(Globals.getDBType());
- }
-
- int closeBracketPos = 0;
- if(wholeSQL_OrderBy.lastIndexOf(")")!= -1) closeBracketPos = wholeSQL_OrderBy.lastIndexOf(")");
- int idxOrderBy = (closeBracketPos>0)?wholeSQL_OrderBy.toUpperCase().indexOf("ORDER BY", closeBracketPos):wholeSQL_OrderBy.toUpperCase().lastIndexOf("ORDER BY");
- String orderbyclause = "";
- if (idxOrderBy < 0) {
- orderbyclause = " ORDER BY 1 ";
- partSql += " "+ orderbyclause+ " ";
- }
- else {
- orderbyclause = wholeSQL_OrderBy.substring(idxOrderBy);
- partSql += " "+ orderbyclause+ " ";
- }
-
- if(getDBType().equals(AppConstants.MYSQL)) {
- partSql = partSql+ " LIMIT "+ String.valueOf(startRow)+" , "+ String.valueOf(endRow);
- } else if(getDBType().equals(AppConstants.ORACLE)) {
- reportSQL = reportSQL.replace(" AS ", " ");
- partSql = "where rnum >= "+ String.valueOf(startRow)+" and rnum <= "+(Integer.parseInt(String.valueOf(startRow)) + Integer.parseInt(String.valueOf(endRow)));
- } else if(getDBType().equals(AppConstants.POSTGRESQL)) {
- partSql = partSql + " LIMIT "+ String.valueOf(endRow)+" , "+ String.valueOf(startRow);//limit [pageSize] offset [startRow]
- }
-
- // Limit only to MYSQL or MariaDB
- //if (reportSQL.toUpperCase().indexOf("ORDER BY ") < 0)
- //partSql += " ORDER BY 1";
- //else {
-
-
-
- /*if(!Globals.isMySQL())
- parta = parta.replace("[endRow]", String.valueOf(endRow));
- else
- parta = parta.replace("[startRow]", String.valueOf(startRow));
-
- //String partb = Globals.getReportSqlOnlySecondPartB();
- if(!Globals.isMySQL())
- partb = partb.replace("[startRow]", String.valueOf(startRow));
- else
- partb = partb.replace("[pageSize]", String.valueOf(getPageSize()));
-
- if( endRow != -1)
- reportSQL += parta;*/
- reportSQL += partSql;
-
- return reportSQL;
-
- } // generateSubsetSQL
-
- public String generateChartSQL(ReportParamValues paramValues, String userId, HttpServletRequest request ) throws RaptorException {
- List reportCols = getAllColumns();
- List chartValueCols = getChartValueColumnsList(AppConstants.CHART_ALL_COLUMNS, null); // parameter is 0 has this requires all columns.
- String reportSQL = generateSQL(userId, request);
- //if(nvl(reportSQL).length()>0) reportSQL = generatedChartSQL;
+ reportSQL = rSQL;
+ // added rownum for total report where row header need to be shown
+ // reportSQLOnlyFirstPart = "SELECT rnum," + colNames.toString() + " FROM (SELECT ROWNUM rnum, "
+ // + colNames.toString() + " FROM (" ;
+
+ reportSQLOnlyFirstPart = Globals.getReportSqlOnlyFirstPart();
+ reportSQLOnlyFirstPart = reportSQLOnlyFirstPart.replace("[colNames.toString()]", colNames.toString());
+
+ reportSQLWithRowNum = reportSQL;
+
+ /*
+ * if( endRow != -1) reportSQL += " WHERE ROWNUM <= " + endRow; reportSQL += " ) y WHERE rnum >= " +
+ * startRow + " ORDER BY rnum"; return reportSQL;
+ */
+ String parta = Globals.getReportSqlOnlySecondPartA();
+ String partb = Globals.getReportSqlOnlySecondPartB();
+
+ String partSql = "";
+ if (!AppUtils.isNotEmpty(getDBType())) {
+ setDBType(Globals.getDBType());
+ }
+
+ int closeBracketPos = 0;
+ if (wholeSQL_OrderBy.lastIndexOf(")") != -1)
+ closeBracketPos = wholeSQL_OrderBy.lastIndexOf(")");
+ int idxOrderBy = (closeBracketPos > 0) ? wholeSQL_OrderBy.toUpperCase().indexOf("ORDER BY", closeBracketPos)
+ : wholeSQL_OrderBy.toUpperCase().lastIndexOf("ORDER BY");
+ String orderbyclause = "";
+ if (idxOrderBy < 0) {
+ orderbyclause = " ORDER BY 1 ";
+ partSql += " " + orderbyclause + " ";
+ } else {
+ orderbyclause = wholeSQL_OrderBy.substring(idxOrderBy);
+ partSql += " " + orderbyclause + " ";
+ }
+
+ if (getDBType().equals(AppConstants.MYSQL)) {
+ partSql = partSql + " LIMIT " + String.valueOf(startRow) + " , " + String.valueOf(endRow);
+ } else if (getDBType().equals(AppConstants.ORACLE)) {
+ reportSQL = reportSQL.replace(" AS ", " ");
+ partSql = "where rnum >= " + String.valueOf(startRow) + " and rnum <= "
+ + (Integer.parseInt(String.valueOf(startRow)) + Integer.parseInt(String.valueOf(endRow)));
+ } else if (getDBType().equals(AppConstants.POSTGRESQL)) {
+ partSql = partSql + " LIMIT " + String.valueOf(endRow) + " , " + String.valueOf(startRow);// limit
+ // [pageSize]
+ // offset
+ // [startRow]
+ }
+
+ // Limit only to MYSQL or MariaDB
+ // if (reportSQL.toUpperCase().indexOf("ORDER BY ") < 0)
+ // partSql += " ORDER BY 1";
+ // else {
+
+ /*
+ * if(!Globals.isMySQL()) parta = parta.replace("[endRow]", String.valueOf(endRow)); else parta =
+ * parta.replace("[startRow]", String.valueOf(startRow));
+ *
+ * //String partb = Globals.getReportSqlOnlySecondPartB(); if(!Globals.isMySQL()) partb =
+ * partb.replace("[startRow]", String.valueOf(startRow)); else partb = partb.replace("[pageSize]",
+ * String.valueOf(getPageSize()));
+ *
+ * if( endRow != -1) reportSQL += parta;
+ */
+ reportSQL += partSql;
+
+ return reportSQL;
+
+ } // generateSubsetSQL
+
+ public String generateChartSQL(ReportParamValues paramValues, String userId, HttpServletRequest request)
+ throws RaptorException {
+ List reportCols = getAllColumns();
+ List chartValueCols = getChartValueColumnsList(AppConstants.CHART_ALL_COLUMNS, null); // parameter is 0 has this
+ // requires all columns.
+ String reportSQL = generateSQL(userId, request);
+ // if(nvl(reportSQL).length()>0) reportSQL = generatedChartSQL;
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, paramValues);
- 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() <= 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, paramValues))+ " " + 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, paramValues);
- //valueCols.append(", NVL(" + formatChartColumn(colName) + ",0) " + dc.getColId());
- seriesCol.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))
- seriesCol.append(", " + AppConstants.RI_CHART_TOTAL_COL + " " + AppConstants.RI_CHART_TOTAL_COL );
- if (colName.equals(AppConstants.RI_CHART_COLOR))
- seriesCol.append(", " + AppConstants.RI_CHART_COLOR + " " + 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 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, paramValues);
+ 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() <= 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, paramValues)) + " " + 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, paramValues);
+ // valueCols.append(", NVL(" + formatChartColumn(colName) + ",0) " + dc.getColId());
+ seriesCol.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))
+ seriesCol.append(", " + AppConstants.RI_CHART_TOTAL_COL + " " + AppConstants.RI_CHART_TOTAL_COL);
+ if (colName.equals(AppConstants.RI_CHART_COLOR))
+ seriesCol.append(", " + AppConstants.RI_CHART_COLOR + " " + 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, " 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 "));
-// }
+ // 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) {
+ 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);
+ 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) {
+ if (pos_dup_select > pos_first_select) {
logger.debug(EELFLoggerDelegate.debugLogger, ("********pos_dup_select ********" + pos_dup_select));
- //pos_dup_select1 = 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);
+ 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);
+ 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));
+ }
+
+ }
+ 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
+ } // generateChartSQL
private String formatChartColumn(String colName) {
-
+
logger.debug(EELFLoggerDelegate.debugLogger, ("Format Chart Column Input colName" + colName));
- colName = colName.trim();
+ colName = colName.trim();
colName = Utils.replaceInString(colName, "TO_CHAR", "to_char");
colName = Utils.replaceInString(colName, "to_number", "TO_NUMBER");
- //reportSQL = reportSQL.replaceAll("[\\s]*\\(", "(");
+ // 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()));
+ 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) {
+ 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.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 ");
+ 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));
+ // 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 + ")");
+ // 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 String generateTotalSQLLinear(ReportParamValues paramValues, String userId, HttpServletRequest request) throws RaptorException {
- List reportCols = getAllColumns();
- String reportSQL = generateSQL(userId,request);
- //debugLogger.debug("After GenerateSQL " + reportSQL);
-
- StringBuffer sbSelect = new StringBuffer();
- StringBuffer sbTotal = new StringBuffer();
- StringBuffer colNames = new StringBuffer();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
-
- DataColumnType dc = (DataColumnType) iter.next();
- if (colNames.length() > 0)
- colNames.append(", ");
- colNames.append(dc.getColId());
- }
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
-
- //if (!dct.isVisible())
- // continue;
-
- String colName = getColumnSelectStr(dct, paramValues);
-
- sbSelect.append((sbSelect.length() == 0) ? "SELECT " : ", ");
-
- sbSelect.append(colName);
- sbSelect.append(" ");
- sbSelect.append(dct.getColId());
-
-
+
+ public String generateTotalSQLLinear(ReportParamValues paramValues, String userId, HttpServletRequest request)
+ throws RaptorException {
+ List reportCols = getAllColumns();
+ String reportSQL = generateSQL(userId, request);
+ // debugLogger.debug("After GenerateSQL " + reportSQL);
+
+ StringBuffer sbSelect = new StringBuffer();
+ StringBuffer sbTotal = new StringBuffer();
+ StringBuffer colNames = new StringBuffer();
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (colNames.length() > 0)
+ colNames.append(", ");
+ colNames.append(dc.getColId());
+ }
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dct = (DataColumnType) iter.next();
+
+ // if (!dct.isVisible())
+ // continue;
+
+ String colName = getColumnSelectStr(dct, paramValues);
+
+ sbSelect.append((sbSelect.length() == 0) ? "SELECT " : ", ");
+
+ sbSelect.append(colName);
+ sbSelect.append(" ");
+ sbSelect.append(dct.getColId());
+
sbTotal.append((sbTotal.length() == 0) ? "SELECT " : ", ");
- if (nvl(dct.getDisplayTotal()).length() > 0) {
- // sbTotal.append(getSelectExpr(dct,
- // dct.getDisplayTotal()+dct.getColId()+")"));
- String displayTotal = dct.getDisplayTotal();
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < displayTotal.length(); i++) {
- char ch = displayTotal.charAt(i);
- if (ch == '+' || ch == '-')
- sb.append(dct.getColId() + ")");
- sb.append(ch);
- } // for
- sb.append(dct.getColId() + ")");
-
- //debugLogger.debug("SB " + sb.toString() + "\n " + getSelectExpr(dct, sb.toString()));
- sbTotal.append(getSelectExpr(dct, sb.toString()));
- //debugLogger.debug("SBTOTAL " + sbTotal.toString());
- } else
- sbTotal.append("NULL");
- sbTotal.append(" total_");
- sbTotal.append(dct.getColId());
- } // for
-
- //debugLogger.debug(" ****** " + sbTotal.toString());
+ if (nvl(dct.getDisplayTotal()).length() > 0) {
+ // sbTotal.append(getSelectExpr(dct,
+ // dct.getDisplayTotal()+dct.getColId()+")"));
+ String displayTotal = dct.getDisplayTotal();
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < displayTotal.length(); i++) {
+ char ch = displayTotal.charAt(i);
+ if (ch == '+' || ch == '-')
+ sb.append(dct.getColId() + ")");
+ sb.append(ch);
+ } // for
+ sb.append(dct.getColId() + ")");
+
+ // debugLogger.debug("SB " + sb.toString() + "\n " + getSelectExpr(dct, sb.toString()));
+ sbTotal.append(getSelectExpr(dct, sb.toString()));
+ // debugLogger.debug("SBTOTAL " + sbTotal.toString());
+ } else
+ sbTotal.append("NULL");
+ sbTotal.append(" total_");
+ sbTotal.append(dct.getColId());
+ } // for
+
+ // debugLogger.debug(" ****** " + sbTotal.toString());
logger.debug(EELFLoggerDelegate.debugLogger, ("REPORTWRAPPER " + reportSQL));
int pos = 0;
int pos_first_select = 0;
int pos_dup_select = 0;
int pos_prev_select = 0;
int pos_last_select = 0;
-
- //reportSQL = Utils.replaceInString(reportSQL, " from ", " FROM ");
- //reportSQL = Utils.replaceInString(reportSQL, "select ", "SELECT ");
+
+ // reportSQL = Utils.replaceInString(reportSQL, " from ", " FROM ");
+ // reportSQL = Utils.replaceInString(reportSQL, "select ", "SELECT ");
reportSQL = replaceNewLine(reportSQL, " from ", " FROM ");
reportSQL = replaceNewLine(reportSQL, "from ", " FROM ");
reportSQL = replaceNewLine(reportSQL, "FROM ", " FROM ");
-
- reportSQL = " "+reportSQL;
+
+ reportSQL = " " + reportSQL;
reportSQL = replaceNewLine(reportSQL, "select ", " SELECT ");
- reportSQL = replaceNewLine(reportSQL, "SELECT ", " SELECT ");
- if (reportSQL.indexOf("FROM", pos)!=-1) {
+ reportSQL = replaceNewLine(reportSQL, "SELECT ", " SELECT ");
+ 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);
+ 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) {
+ if (pos_dup_select > pos_first_select) {
logger.debug(EELFLoggerDelegate.debugLogger, ("********pos_dup_select ********" + pos_dup_select));
- //pos_dup_select1 = 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);
+ 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);
+ pos_last_select = reportSQL.lastIndexOf("SELECT", pos);
logger.debug(EELFLoggerDelegate.debugLogger, ("in WHILE LOOP LAST " + pos_last_select));
}
- }
-
- }
-
+ }
+
+ }
+
+ // sbSelect.append(reportSQL.substring(reportSQL.toUpperCase().indexOf(" FROM ")));
- //sbSelect.append(reportSQL.substring(reportSQL.toUpperCase().indexOf(" FROM ")));
-
logger.debug(EELFLoggerDelegate.debugLogger, (" *************** " + pos + " " + reportSQL));
- //sbSelect.append(" "+ reportSQL.substring(pos));
- sbSelect.append(" "+reportSQL.substring(pos));
+ // sbSelect.append(" "+ reportSQL.substring(pos));
+ sbSelect.append(" " + reportSQL.substring(pos));
logger.debug(EELFLoggerDelegate.debugLogger, (" **************** " + sbSelect.toString()));
sbTotal.append(" FROM (");
- sbTotal.append(sbSelect.toString());
- sbTotal.append(") totalSQL");
-
- String dbType = "";
- String dbInfo = getDBInfo();
- if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) {
- try {
- org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo();
- dbType = remDbInfo.getDBType(dbInfo);
- } catch (Exception ex) {
- throw new RaptorException(ex);
- }
- }
- if (dbType.equals("DAYTONA")) {
- sbTotal.append("("+ colNames+ ")");
- }
+ sbTotal.append(sbSelect.toString());
+ sbTotal.append(") totalSQL");
+
+ String dbType = "";
+ String dbInfo = getDBInfo();
+ if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) {
+ try {
+ org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo =
+ new org.onap.portalsdk.analytics.util.RemDbInfo();
+ dbType = remDbInfo.getDBType(dbInfo);
+ } catch (Exception ex) {
+ throw new RaptorException(ex);
+ }
+ }
+ if ("DAYTONA".equals(dbType)) {
+ sbTotal.append("(" + colNames + ")");
+ }
String sql = sbTotal.toString();
sql = Utils.replaceInString(sql, " from ", " FROM ");
sql = Utils.replaceInString(sql, "select ", "SELECT ");
- //sql = Utils.replaceInString(sql, " select ", " SELECT ");
- logger.debug(EELFLoggerDelegate.debugLogger, ("Before SQL Corrector " + sql));
+ // sql = Utils.replaceInString(sql, " select ", " SELECT ");
+ logger.debug(EELFLoggerDelegate.debugLogger, ("Before SQL Corrector " + sql));
String corrected_SQL = new SQLCorrector().fixSQL(new StringBuffer(sql));
logger.debug(EELFLoggerDelegate.debugLogger, ("************"));
logger.debug(EELFLoggerDelegate.debugLogger, ("Corrected SQL " + corrected_SQL));
- return corrected_SQL;
- //return sbTotal.toString();
- } // generateTotalSQLLinear
-
- public String generateTotalSQLCrossTab(String sql, String rowColPos,
- String userId, HttpServletRequest request, ReportParamValues paramValues) throws RaptorException {
- List reportCols = getAllColumns();
- String reportSQL = sql;
-
- StringBuffer sbSelect = new StringBuffer();
- StringBuffer sbGroup = new StringBuffer();
- // StringBuffer sbOrder = new StringBuffer();
- StringBuffer sbTotal = new StringBuffer();
- StringBuffer colNames = new StringBuffer();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
-
- DataColumnType dc = (DataColumnType) iter.next();
- if (colNames.length() > 0)
- colNames.append(", ");
- colNames.append(dc.getColId());
- }
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
-
- if (!dct.isVisible())
- continue;
-
-
- String colName = getColumnSelectStr(dct, paramValues);
- String colExpr = getSelectExpr(dct, colName);
-
- sbSelect.append((sbSelect.length() == 0) ? "SELECT " : ", ");
-
- if (nvl(dct.getCrossTabValue()).equals(rowColPos)) {
- //sbSelect.append(colExpr);
- sbSelect.append(dct.getColId());
- sbGroup.append((sbGroup.length() == 0) ? " GROUP BY " : ", ");
- sbGroup.append(dct.getColId());
-
- /*
- * sbOrder.append((sbOrder.length()==0)?" ORDER BY ":", ");
- * sbOrder.append(dct.getColId());
- * if(dct.getColType().equals(AppConstants.CT_DATE))
- * sbOrder.append(" DESC");
- */
-
- sbTotal.append((sbTotal.length() == 0) ? "SELECT " : ", ");
- sbTotal.append(dct.getColId());
- } else if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_VALUE)) {
- //sbSelect.append(colName);
- sbSelect.append(dct.getColId());
-
- String displayTotal = getCrossTabDisplayTotal(rowColPos);
- if (displayTotal.length() > 0) {
- // displayTotal += dct.getColId()+")";
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < displayTotal.length(); i++) {
- char ch = displayTotal.charAt(i);
- if (ch == '+' || ch == '-')
- sb.append(dct.getColId() + ")");
- sb.append(ch);
- } // for
- sb.append(dct.getColId() + ")");
-
- displayTotal = sb.toString();
- } else
- displayTotal = "COUNT(*)";
-
- sbTotal.append((sbTotal.length() == 0) ? "SELECT " : ", ");
- sbTotal.append(getSelectExpr(dct, displayTotal));
- sbTotal.append(" total_");
- sbTotal.append(dct.getColId());
- } else {
- //sbSelect.append(colExpr);
- sbSelect.append(dct.getColId());
- } // if
-
- sbSelect.append(" ");
- sbSelect.append(dct.getColId());
- } // for
-
- sbSelect.append(reportSQL.substring(reportSQL.toUpperCase().indexOf(" FROM ")));
-
- sbTotal.append(" FROM (");
- sbTotal.append(sbSelect.toString());
- sbTotal.append(") totalSQL");
- sbTotal.append(sbGroup.toString());
- String dbType = "";
- String dbInfo = getDBInfo();
- if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) {
- try {
- org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo();
- dbType = remDbInfo.getDBType(dbInfo);
- } catch (Exception ex) {
- throw new RaptorException(ex);
- }
- }
- if (dbType.equals("DAYTONA")) {
- sbTotal.append("("+ colNames+ ")");
- }
-
- // sbTotal.append(sbOrder.toString());
-
- //debugLogger.debug(getReportDefType() + " " + AppConstants.RD_SQL_BASED);
- //debugLogger.debug("SQL To Delete " + sbTotal.toString());
+ return corrected_SQL;
+ // return sbTotal.toString();
+ } // generateTotalSQLLinear
+
+ public String generateTotalSQLCrossTab(String sql, String rowColPos,
+ String userId, HttpServletRequest request, ReportParamValues paramValues) throws RaptorException {
+ List reportCols = getAllColumns();
+ String reportSQL = sql;
+
+ StringBuffer sbSelect = new StringBuffer();
+ StringBuffer sbGroup = new StringBuffer();
+ // StringBuffer sbOrder = new StringBuffer();
+ StringBuffer sbTotal = new StringBuffer();
+ StringBuffer colNames = new StringBuffer();
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (colNames.length() > 0)
+ colNames.append(", ");
+ colNames.append(dc.getColId());
+ }
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dct = (DataColumnType) iter.next();
+
+ if (!dct.isVisible())
+ continue;
+
+ String colName = getColumnSelectStr(dct, paramValues);
+ String colExpr = getSelectExpr(dct, colName);
+
+ sbSelect.append((sbSelect.length() == 0) ? "SELECT " : ", ");
+
+ if (nvl(dct.getCrossTabValue()).equals(rowColPos)) {
+ // sbSelect.append(colExpr);
+ sbSelect.append(dct.getColId());
+ sbGroup.append((sbGroup.length() == 0) ? " GROUP BY " : ", ");
+ sbGroup.append(dct.getColId());
+
+ /*
+ * sbOrder.append((sbOrder.length()==0)?" ORDER BY ":", "); sbOrder.append(dct.getColId());
+ * if(dct.getColType().equals(AppConstants.CT_DATE)) sbOrder.append(" DESC");
+ */
+
+ sbTotal.append((sbTotal.length() == 0) ? "SELECT " : ", ");
+ sbTotal.append(dct.getColId());
+ } else if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_VALUE)) {
+ // sbSelect.append(colName);
+ sbSelect.append(dct.getColId());
+
+ String displayTotal = getCrossTabDisplayTotal(rowColPos);
+ if (displayTotal.length() > 0) {
+ // displayTotal += dct.getColId()+")";
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < displayTotal.length(); i++) {
+ char ch = displayTotal.charAt(i);
+ if (ch == '+' || ch == '-')
+ sb.append(dct.getColId() + ")");
+ sb.append(ch);
+ } // for
+ sb.append(dct.getColId() + ")");
+
+ displayTotal = sb.toString();
+ } else
+ displayTotal = "COUNT(*)";
+
+ sbTotal.append((sbTotal.length() == 0) ? "SELECT " : ", ");
+ sbTotal.append(getSelectExpr(dct, displayTotal));
+ sbTotal.append(" total_");
+ sbTotal.append(dct.getColId());
+ } else {
+ // sbSelect.append(colExpr);
+ sbSelect.append(dct.getColId());
+ } // if
+
+ sbSelect.append(" ");
+ sbSelect.append(dct.getColId());
+ } // for
+
+ sbSelect.append(reportSQL.substring(reportSQL.toUpperCase().indexOf(" FROM ")));
+
+ sbTotal.append(" FROM (");
+ sbTotal.append(sbSelect.toString());
+ sbTotal.append(") totalSQL");
+ sbTotal.append(sbGroup.toString());
+ String dbType = "";
+ String dbInfo = getDBInfo();
+ if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) {
+ try {
+ org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo =
+ new org.onap.portalsdk.analytics.util.RemDbInfo();
+ dbType = remDbInfo.getDBType(dbInfo);
+ } catch (Exception ex) {
+ throw new RaptorException(ex);
+ }
+ }
+ if ("DAYTONA".equals(dbType)) {
+ sbTotal.append("(" + colNames + ")");
+ }
+
+ // sbTotal.append(sbOrder.toString());
+
+ // debugLogger.debug(getReportDefType() + " " + AppConstants.RD_SQL_BASED);
+ // debugLogger.debug("SQL To Delete " + sbTotal.toString());
sql = "";
if (getReportDefType().equals(AppConstants.RD_SQL_BASED)) {
sql = Utils.replaceInString(sbTotal.toString(), " from ", " FROM ");
sql = Utils.replaceInString(sql, "select ", "SELECT ");
return new SQLCorrector().fixSQL(new StringBuffer(sql));
}
-
+
return sbTotal.toString();
-
- } // generateTotalSQLCrossTab
-
-
- public String generateTotalSQLCrossTab(ReportParamValues paramValues, String rowColPos,
- String userId, HttpServletRequest request) throws RaptorException {
- List reportCols = getAllColumns();
- String reportSQL = generateSQL(userId, request);
-
- StringBuffer sbSelect = new StringBuffer();
- StringBuffer sbGroup = new StringBuffer();
- // StringBuffer sbOrder = new StringBuffer();
- StringBuffer sbTotal = new StringBuffer();
- StringBuffer colNames = new StringBuffer();
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
-
- DataColumnType dc = (DataColumnType) iter.next();
- if (colNames.length() > 0)
- colNames.append(", ");
- colNames.append(dc.getColId());
- }
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
-
- if (!dct.isVisible())
- continue;
-
- String colName = getColumnSelectStr(dct, paramValues);
- String colExpr = getSelectExpr(dct, colName);
-
- sbSelect.append((sbSelect.length() == 0) ? "SELECT " : ", ");
-
- if (nvl(dct.getCrossTabValue()).equals(rowColPos)) {
- sbSelect.append(colExpr);
-
- sbGroup.append((sbGroup.length() == 0) ? " GROUP BY " : ", ");
- sbGroup.append(dct.getColId());
-
- /*
- * sbOrder.append((sbOrder.length()==0)?" ORDER BY ":", ");
- * sbOrder.append(dct.getColId());
- * if(dct.getColType().equals(AppConstants.CT_DATE))
- * sbOrder.append(" DESC");
- */
-
- sbTotal.append((sbTotal.length() == 0) ? "SELECT " : ", ");
- sbTotal.append(dct.getColId());
- } else if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_VALUE)) {
- sbSelect.append(colName);
-
- String displayTotal = getCrossTabDisplayTotal(rowColPos);
- if (displayTotal.length() > 0) {
- // displayTotal += dct.getColId()+")";
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < displayTotal.length(); i++) {
- char ch = displayTotal.charAt(i);
- if (ch == '+' || ch == '-')
- sb.append(dct.getColId() + ")");
- sb.append(ch);
- } // for
- sb.append(dct.getColId() + ")");
-
- displayTotal = sb.toString();
- } else
- displayTotal = "COUNT(*)";
-
- sbTotal.append((sbTotal.length() == 0) ? "SELECT " : ", ");
- sbTotal.append(getSelectExpr(dct, displayTotal));
- sbTotal.append(" total_");
- sbTotal.append(dct.getColId());
- } else {
- sbSelect.append(colExpr);
- } // if
-
- sbSelect.append(" ");
- sbSelect.append(dct.getColId());
- } // for
-
- sbSelect.append(reportSQL.substring(reportSQL.toUpperCase().indexOf(" FROM ")));
-
- sbTotal.append(" FROM (");
- sbTotal.append(sbSelect.toString());
- sbTotal.append(") totalSQL");
- sbTotal.append(sbGroup.toString());
- String dbType = "";
- String dbInfo = getDBInfo();
- if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) {
- try {
- org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo();
- dbType = remDbInfo.getDBType(dbInfo);
- } catch (Exception ex) {
- throw new RaptorException(ex);
- }
- }
- if (dbType.equals("DAYTONA")) {
- sbTotal.append("("+ colNames+ ")");
- }
-
- // sbTotal.append(sbOrder.toString());
-
- //debugLogger.debug(getReportDefType() + " " + AppConstants.RD_SQL_BASED);
- //debugLogger.debug("SQL To Delete " + sbTotal.toString());
+
+ } // generateTotalSQLCrossTab
+
+ public String generateTotalSQLCrossTab(ReportParamValues paramValues, String rowColPos,
+ String userId, HttpServletRequest request) throws RaptorException {
+ List reportCols = getAllColumns();
+ String reportSQL = generateSQL(userId, request);
+
+ StringBuffer sbSelect = new StringBuffer();
+ StringBuffer sbGroup = new StringBuffer();
+ // StringBuffer sbOrder = new StringBuffer();
+ StringBuffer sbTotal = new StringBuffer();
+ StringBuffer colNames = new StringBuffer();
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (colNames.length() > 0)
+ colNames.append(", ");
+ colNames.append(dc.getColId());
+ }
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dct = (DataColumnType) iter.next();
+
+ if (!dct.isVisible())
+ continue;
+
+ String colName = getColumnSelectStr(dct, paramValues);
+ String colExpr = getSelectExpr(dct, colName);
+
+ sbSelect.append((sbSelect.length() == 0) ? "SELECT " : ", ");
+
+ if (nvl(dct.getCrossTabValue()).equals(rowColPos)) {
+ sbSelect.append(colExpr);
+
+ sbGroup.append((sbGroup.length() == 0) ? " GROUP BY " : ", ");
+ sbGroup.append(dct.getColId());
+
+ /*
+ * sbOrder.append((sbOrder.length()==0)?" ORDER BY ":", "); sbOrder.append(dct.getColId());
+ * if(dct.getColType().equals(AppConstants.CT_DATE)) sbOrder.append(" DESC");
+ */
+
+ sbTotal.append((sbTotal.length() == 0) ? "SELECT " : ", ");
+ sbTotal.append(dct.getColId());
+ } else if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_VALUE)) {
+ sbSelect.append(colName);
+
+ String displayTotal = getCrossTabDisplayTotal(rowColPos);
+ if (displayTotal.length() > 0) {
+ // displayTotal += dct.getColId()+")";
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < displayTotal.length(); i++) {
+ char ch = displayTotal.charAt(i);
+ if (ch == '+' || ch == '-')
+ sb.append(dct.getColId() + ")");
+ sb.append(ch);
+ } // for
+ sb.append(dct.getColId() + ")");
+
+ displayTotal = sb.toString();
+ } else
+ displayTotal = "COUNT(*)";
+
+ sbTotal.append((sbTotal.length() == 0) ? "SELECT " : ", ");
+ sbTotal.append(getSelectExpr(dct, displayTotal));
+ sbTotal.append(" total_");
+ sbTotal.append(dct.getColId());
+ } else {
+ sbSelect.append(colExpr);
+ } // if
+
+ sbSelect.append(" ");
+ sbSelect.append(dct.getColId());
+ } // for
+
+ sbSelect.append(reportSQL.substring(reportSQL.toUpperCase().indexOf(" FROM ")));
+
+ sbTotal.append(" FROM (");
+ sbTotal.append(sbSelect.toString());
+ sbTotal.append(") totalSQL");
+ sbTotal.append(sbGroup.toString());
+ String dbType = "";
+ String dbInfo = getDBInfo();
+ if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) {
+ try {
+ org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo =
+ new org.onap.portalsdk.analytics.util.RemDbInfo();
+ dbType = remDbInfo.getDBType(dbInfo);
+ } catch (Exception ex) {
+ throw new RaptorException(ex);
+ }
+ }
+ if ("DAYTONA".equals(dbType)) {
+ sbTotal.append("(" + colNames + ")");
+ }
+
+ // sbTotal.append(sbOrder.toString());
+
+ // debugLogger.debug(getReportDefType() + " " + AppConstants.RD_SQL_BASED);
+ // debugLogger.debug("SQL To Delete " + sbTotal.toString());
String sql = "";
if (getReportDefType().equals(AppConstants.RD_SQL_BASED)) {
sql = Utils.replaceInString(sbTotal.toString(), " from ", " FROM ");
sql = Utils.replaceInString(sql, "select ", "SELECT ");
return new SQLCorrector().fixSQL(new StringBuffer(sql));
}
-
+
return sbTotal.toString();
-
- } // generateTotalSQLCrossTab
-
- public String generateDistinctValuesSQL(ReportParamValues paramValues, DataColumnType dct,
- String userId, HttpServletRequest request) throws RaptorException {
- DataSourceType dst = getColumnTableById(dct.getColId());
- String colName = getColumnSelectStr(dct, paramValues);
- String colExpr = getSelectExpr(dct, colName);
- ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
- StringBuffer sb = new StringBuffer();
- sb.append("SELECT DISTINCT ");
- if (getReportDefType().equals(AppConstants.RD_SQL_BASED)) {
- sb.append(dct.getColId());
- sb.append(" FROM (");
- //paramvalues added below to filter distinct values based on formfields.
- //sb.append(generateSQL(paramValues, userId, request));
- sb.append(rr.getWholeSQL());
- sb.append(") " + (Globals.isPostgreSQL() || Globals.isMySQL() ?" AS ":"") + " report_sql ORDER BY 1");
- } else {
- sb.append(colExpr);
- sb.append(" ");
- sb.append(dct.getColId());
- if (!colExpr.equals(colName)) {
- sb.append(", ");
- sb.append(colName);
- } // if
- sb.append(" FROM ");
- sb.append(dst.getTableName());
- sb.append(" ");
- sb.append(dst.getTableId());
- sb.append(" ORDER BY ");
- sb.append(colName);
- if (dct.getColType().equals(AppConstants.CT_DATE))
- sb.append(" DESC");
- } // else
-
- return sb.toString();
- } // generateDistinctValuesSQL
-
- /** ************************************************************************************************* */
-
- public DataSourceType getTableWithoutColumns() {
- List dsList = getDataSourceList().getDataSource();
- for (Iterator iter = dsList.iterator(); iter.hasNext();) {
- DataSourceType ds = (DataSourceType) iter.next();
-
- if (ds.getDataColumnList().getDataColumn().size() == 0)
- return ds;
- } // for
-
- return null;
- } // getTableWithoutColumns
-
- public CustomReportType cloneCustomReportClearTables() throws RaptorException {
- ReportWrapper nrw = new ReportWrapper(cloneCustomReport(), reportID, getOwnerID(),
- getCreateID(), getCreateDate(), getUpdateID(), getUpdateDate(), getMenuID(),
- isMenuApproved());
-
- DataSourceType ndst = null;
- while ((ndst = nrw.getTableWithoutColumns()) != null)
- nrw.deleteDataSourceType(ndst.getTableId());
-
- return nrw.getCustomReport();
- } // cloneCustomReportClearTables
-
- public String marshal() throws RaptorException {
- StringWriter sw = new StringWriter();
- ObjectFactory objFactory = new ObjectFactory();
-
- try {
- JAXBContext jc = JAXBContext.newInstance("org.onap.portalsdk.analytics.xmlobj");
- Marshaller m = jc.createMarshaller();
- m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
- //JAXBElement jaxbElement = new JAXBElement(new QName("customReport"), Object.class, "");
- //m.marshal( System.out );
- //m.marshal(jaxbElement, new StreamResult(sw));
- m.marshal((getTableWithoutColumns() == null) ? objFactory.createCustomReport(cr) : objFactory.createCustomReport(cloneCustomReportClearTables()),
- new StreamResult(sw));
- } catch (JAXBException ex) {
- throw new RaptorException (ex.getMessage(), ex.getCause());
- }
- return sw.toString();
- } // marshal
-
- public static CustomReportType unmarshalCR(String reportXML) throws RaptorException {
- //CustomReport cr = null;
- try {
- JAXBContext jc = JAXBContext.newInstance("org.onap.portalsdk.analytics.xmlobj");
- Unmarshaller u = jc.createUnmarshaller();
- javax.xml.bind.JAXBElement<CustomReportType> doc = (javax.xml.bind.JAXBElement<CustomReportType>) u.unmarshal(new java.io.StringReader(
- reportXML));
- return doc.getValue();
- } catch (JAXBException ex) {
- ex.printStackTrace();
- throw new RaptorException (ex.getMessage(), ex.getCause());
- }
-
-
- } // unmarshal
-
- protected static CustomReportType createBlankCR() throws RaptorException {
- return createBlankCR("N/A");
- } // createBlank
-
- protected static CustomReportType createBlankCR(String createID) throws RaptorException {
- ObjectFactory objFactory = new ObjectFactory();
- CustomReportType cr = objFactory.createCustomReportType();
- //CustomReport cr = null;
- try {
- //cr = (CustomReport) objFactory.createCustomReport(customReportType);
-
- cr.setReportName("");
- cr.setReportDescr("");
- cr.setChartType("");
- cr.setPublic(false);
- cr.setCreateId(createID);
- cr.setCreateDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar()));
- // cr.setReportSQL("");
- cr.setReportType("");
- cr.setPageSize(50);
-
- DataSourceList dataSourceList = objFactory.createDataSourceList();
- cr.setDataSourceList(dataSourceList);
- } catch (DatatypeConfigurationException ex) {
- throw new RaptorException (ex.getMessage(), ex.getCause());
- }
- return cr;
- } // createBlank
-
- protected void replaceCustomReportWithClone() throws RaptorException {
- try {
- CustomReportType clone = cloneCustomReport();
- this.cr = clone;
- } catch (Exception e) {
- e.printStackTrace();
- logger.debug(EELFLoggerDelegate.debugLogger, ("[SYSTEM ERROR] ReportWrapper.replaceCustomReportWithClone generated exception for report ["
- + reportID + "]. Exception: " + e.getMessage()));
- throw new RaptorException("[SYSTEM ERROR] ReportWrapper.replaceCustomReportWithClone generated exception for report ["
- + reportID + "]. Exception: " + e.getMessage(), e.getCause());
- }
- } // replaceCustomReportWithClone
-
- /** ************************************************************************************************* */
-
- public FormatType cloneFormatType(ObjectFactory objFactory, FormatType ft)
- throws JAXBException {
- FormatType nft = objFactory.createFormatType();
-
- nft.setLessThanValue(ft.getLessThanValue());
- nft.setExpression(ft.getExpression());
- nft.setBold(ft.isBold());
- nft.setItalic(ft.isItalic());
- nft.setUnderline(ft.isUnderline());
- if (nvl(ft.getBgColor()).length() > 0)
- nft.setBgColor(ft.getBgColor());
- if (nvl(ft.getFontColor()).length() > 0)
- nft.setFontColor(ft.getFontColor());
- if (nvl(ft.getFontFace()).length() > 0)
- nft.setFontFace(ft.getFontFace());
- if (nvl(ft.getFontSize()).length() > 0)
- nft.setFontSize(ft.getFontSize());
- if (nvl(ft.getAlignment()).length() > 0)
- nft.setAlignment(ft.getAlignment());
- if (nvl(ft.getComment()).length() > 0)
- nft.setComment(ft.getComment());
-
- nft.setFormatId(ft.getFormatId());
-
- return nft;
- } // cloneFormatType
-
- public SemaphoreType cloneSemaphoreType(ObjectFactory objFactory, SemaphoreType st)
- throws JAXBException {
- SemaphoreType nst = objFactory.createSemaphoreType();
-
- nst.setSemaphoreName(st.getSemaphoreName());
- nst.setSemaphoreType(st.getSemaphoreType());
- nst.setSemaphoreId(st.getSemaphoreId());
- if (nvl(st.getComment()).length() > 0)
- nst.setComment(st.getComment());
-
- if (st.getFormatList() != null) {
- FormatList formatList = objFactory.createFormatList();
- nst.setFormatList(formatList);
-
- for (Iterator iter = st.getFormatList().getFormat().iterator(); iter.hasNext();)
- formatList.getFormat().add(
- cloneFormatType(objFactory, (FormatType) iter.next()));
- } // if
-
- return nst;
- } // cloneSemaphoreType
-
- public Reports cloneDashboardType(ObjectFactory objFactory, Reports rpt)
- throws JAXBException {
- Reports nrpt = objFactory.createReports();
-
- nrpt.setReportId(rpt.getReportId());
- nrpt.setBgcolor(rpt.getBgcolor());
- return nrpt;
- } // cloneDashboardType
-
- public Marker cloneMarkerType(ObjectFactory objFactory, Marker marker)
- throws JAXBException {
- Marker nMarker = objFactory.createMarker();
- nMarker.setAddressColumn(marker.getAddressColumn());
- nMarker.setDataColumn(marker.getDataColumn());
- nMarker.setDataHeader(marker.getDataHeader());
- nMarker.setMarkerColor(marker.getMarkerColor());
- return nMarker;
- } // cloneDashboardType
-
- public ChartDrillFormfield cloneChartDrillFormfield(ObjectFactory objFactory, ChartDrillFormfield chartDrillFormfield)
- throws JAXBException {
- ChartDrillFormfield nChartDrillFormfield = objFactory.createChartDrillFormfield();
- nChartDrillFormfield.setFormfield(chartDrillFormfield.getFormfield());
- return nChartDrillFormfield;
- } // cloneDashboardType
-
- public boolean isChartDrillDownContainsName(String name) {
- for (Iterator iter = getChartDrillOptions().getTargetFormfield().iterator(); iter
- .hasNext();) {
- org.onap.portalsdk.analytics.xmlobj.ChartDrillFormfield cdf = (org.onap.portalsdk.analytics.xmlobj.ChartDrillFormfield) iter.next();
- if(cdf.getFormfield().equals(name)) {
- return true;
- }
- }
- return false;
- }
- public FormFieldType cloneFormFieldType(ObjectFactory objFactory, FormFieldType fft)
- throws JAXBException {
- FormFieldType nfft = objFactory.createFormFieldType();
-
- nfft.setColId(fft.getColId());
- nfft.setFieldName(fft.getFieldName());
- nfft.setFieldType(fft.getFieldType());
- if (nvl(fft.getVisible()).length() > 0)
- nfft.setVisible(fft.getVisible());
- if (nvl(fft.getValidationType()).length() > 0)
- nfft.setValidationType(fft.getValidationType());
- if (nvl(fft.getMandatory()).length() > 0)
- nfft.setMandatory(fft.getMandatory());
- if (nvl(fft.getDefaultValue()).length() > 0)
- nfft.setDefaultValue(fft.getDefaultValue());
- nfft.setOrderBySeq(fft.getOrderBySeq());
- if (nvl(fft.getFieldSQL()).length() > 0)
- nfft.setFieldSQL(fft.getFieldSQL());
- if (nvl(fft.getFieldDefaultSQL()).length() > 0)
- nfft.setFieldDefaultSQL(fft.getFieldDefaultSQL());
- if(fft.getRangeStartDate()!=null)
- nfft.setRangeStartDate(fft.getRangeStartDate());
- if(fft.getRangeEndDate()!=null)
- nfft.setRangeEndDate(fft.getRangeEndDate());
- if(fft.getRangeStartDateSQL()!=null)
- nfft.setRangeStartDateSQL(fft.getRangeStartDateSQL());
- if(fft.getRangeEndDateSQL()!=null)
- nfft.setRangeEndDateSQL(fft.getRangeEndDateSQL());
-
- if (nvl(fft.getComment()).length() > 0)
- nfft.setComment(fft.getComment());
-
- if (fft.getPredefinedValueList() != null) {
- PredefinedValueList predefinedValueList = objFactory.createPredefinedValueList();
- nfft.setPredefinedValueList(predefinedValueList);
-
- for (Iterator iter = fft.getPredefinedValueList().getPredefinedValue().iterator(); iter
- .hasNext();)
- predefinedValueList.getPredefinedValue().add(new String((String) iter.next()));
- } // if
- if (nvl(fft.getDependsOn()).length() > 0)
- nfft.setDependsOn(fft.getDependsOn());
-
- nfft.setGroupFormField((fft.isGroupFormField()!=null && fft.isGroupFormField().booleanValue())?true:false);
- if (nvl(fft.getMultiSelectListSize()).length() > 0)
- nfft.setMultiSelectListSize(fft.getMultiSelectListSize());
-
- nfft.setFieldId(fft.getFieldId());
- return nfft;
- } // cloneFormFieldType
-
- public JavascriptItemType cloneJavascriptType(ObjectFactory objFactory, JavascriptItemType jit)
- throws JAXBException {
- JavascriptItemType njit = objFactory.createJavascriptItemType();
-
- njit.setId(jit.getId());
- njit.setFieldId(jit.getFieldId());
- njit.setCallText(jit.getCallText());
- return njit;
- } // cloneJavascriptType
-
- public ColFilterType cloneColFilterType(ObjectFactory objFactory, ColFilterType cft)
- throws JAXBException {
- ColFilterType ncft = objFactory.createColFilterType();
-
- ncft.setColId(cft.getColId());
- ncft.setFilterSeq(cft.getFilterSeq());
- ncft.setJoinCondition(cft.getJoinCondition());
- if (nvl(cft.getOpenBrackets()).length() > 0)
- ncft.setOpenBrackets(cft.getOpenBrackets());
- ncft.setExpression(cft.getExpression());
- if (nvl(cft.getArgType()).length() > 0)
- ncft.setArgType(cft.getArgType());
- if (nvl(cft.getArgValue()).length() > 0)
- ncft.setArgValue(cft.getArgValue());
- if (nvl(cft.getCloseBrackets()).length() > 0)
- ncft.setCloseBrackets(cft.getCloseBrackets());
- if (nvl(cft.getComment()).length() > 0)
- ncft.setComment(cft.getComment());
-
- return ncft;
- } // cloneColFilterType
-
- public DataColumnType cloneDataColumnType(ObjectFactory objFactory, DataColumnType dct)
- throws JAXBException {
- DataColumnType ndct = objFactory.createDataColumnType();
-
- ndct.setTableId(dct.getTableId());
- ndct.setDbColName(dct.getDbColName());
- if (nvl(dct.getCrossTabValue()).length() > 0)
- ndct.setCrossTabValue(dct.getCrossTabValue());
- ndct.setColName(dct.getColName());
- ndct.setDisplayName(dct.getDisplayName());
- if (dct.getDisplayWidth() > 0)
- ndct.setDisplayWidth(dct.getDisplayWidth());
- if (nvl(dct.getDisplayWidthInPxls()).length()>0)
- ndct.setDisplayWidthInPxls(dct.getDisplayWidthInPxls());
- if (nvl(dct.getDisplayAlignment()).length() > 0)
- ndct.setDisplayAlignment(dct.getDisplayAlignment());
- if (nvl(dct.getDisplayHeaderAlignment()).length() > 0)
- ndct.setDisplayHeaderAlignment(dct.getDisplayHeaderAlignment());
- ndct.setOrderSeq(dct.getOrderSeq());
- ndct.setVisible(dct.isVisible());
- ndct.setCalculated(dct.isCalculated());
- ndct.setColType(dct.getColType());
- if(dct.getColType().equals(AppConstants.CT_HYPERLINK)) {
- ndct.setHyperlinkURL(dct.getHyperlinkURL());
- ndct.setHyperlinkType(dct.getHyperlinkType());
- if(dct.getHyperlinkType().equals("IMAGE")) {
- ndct.setActionImg(dct.getActionImg());
- }
- }
-
- if(dct.getIndentation()!=null) {
- ndct.setIndentation(dct.getIndentation());
- }
-
- if (nvl(dct.getColFormat()).length() > 0)
- ndct.setColFormat(dct.getColFormat());
- ndct.setGroupBreak(dct.isGroupBreak());
- ndct.setNowrap(dct.getNowrap());
- if (nvl(dct.getYAxis()).length() > 0)
- ndct.setYAxis(dct.getYAxis());
- if (dct.getOrderBySeq()!=null && dct.getOrderBySeq() > 0)
- ndct.setOrderBySeq(dct.getOrderBySeq());
- if (nvl(dct.getOrderByAscDesc()).length() > 0)
- ndct.setOrderByAscDesc(dct.getOrderByAscDesc());
- if (nvl(dct.getDisplayTotal()).length() > 0)
- ndct.setDisplayTotal(dct.getDisplayTotal());
- if (nvl(dct.getColOnChart()).length() > 0)
- ndct.setColOnChart(dct.getColOnChart());
- if (dct.getChartSeq() !=null)
- ndct.setChartSeq(dct.getChartSeq());
- if (nvl(dct.getChartColor()).length() > 0)
- ndct.setChartColor(dct.getChartColor());
- if (nvl(dct.getChartLineType()).length() > 0)
- ndct.setChartLineType(dct.getChartLineType());
- ndct.setChartSeries((dct.isChartSeries()!=null && dct.isChartSeries().booleanValue())?true:false);
- ndct.setIsRangeAxisFilled((dct.isIsRangeAxisFilled()!=null && dct.isIsRangeAxisFilled().booleanValue())?true:false);
-
- if (dct.isCreateInNewChart()!=null)
- ndct.setCreateInNewChart(dct.isCreateInNewChart());
- if (nvl(dct.getDrillDownType()).length() > 0)
- ndct.setDrillDownType(dct.getDrillDownType());
- ndct.setDrillinPoPUp(dct.isDrillinPoPUp()!=null?dct.isDrillinPoPUp():false);
- if (nvl(dct.getDrillDownURL()).length() > 0)
- ndct.setDrillDownURL(dct.getDrillDownURL());
- if (nvl(dct.getDrillDownParams()).length() > 0)
- ndct.setDrillDownParams(dct.getDrillDownParams());
- if (nvl(dct.getComment()).length() > 0)
- ndct.setComment(dct.getComment());
- if (nvl(dct.getDependsOnFormField()).length() > 0)
- ndct.setDependsOnFormField(dct.getDependsOnFormField());
- if (dct.getColFilterList() != null) {
- ColFilterList colFilterList = objFactory.createColFilterList();
- ndct.setColFilterList(colFilterList);
-
- for (Iterator iter = dct.getColFilterList().getColFilter().iterator(); iter
- .hasNext();)
- colFilterList.getColFilter().add(
- cloneColFilterType(objFactory, (ColFilterType) iter.next()));
- } // if
-
- if (nvl(dct.getSemaphoreId()).length() > 0)
- ndct.setSemaphoreId(dct.getSemaphoreId());
- if (nvl(dct.getDbColType()).length() > 0)
- ndct.setDbColType(dct.getDbColType());
- else {
- ndct.setDbColType(dct.getColType());
- adjustColumnType(ndct);
- }
- if (nvl(dct.getChartGroup()).length() > 0)
- ndct.setChartGroup(dct.getChartGroup());
-
- if (nvl(dct.getYAxis()).length() > 0)
- ndct.setYAxis(dct.getYAxis());
-
- if (nvl(dct.getDependsOnFormField()).length() > 0)
- ndct.setDependsOnFormField(dct.getDependsOnFormField());
-
-
-
- if(nvl(dct.getNowrap()).length() > 0)
- ndct.setNowrap(dct.getNowrap());
-
- if(dct.getIndentation()!=null) {
- ndct.setIndentation(dct.getIndentation());
- }
-
- ndct.setEnhancedPagination((dct.isEnhancedPagination()!=null && dct.isEnhancedPagination().booleanValue())?true:false);
- if(nvl(dct.getDataMiningCol()).length() > 0)
- ndct.setDataMiningCol(dct.getDataMiningCol());
-
- ndct.setColId(dct.getColId());
-
- // ndct.setSemaphoreId(nvl(dct.getSemaphoreId()));
- // if(nvl(dct.getDbColType()).length()>0)
- // ndct.setDbColType(dct.getDbColType());
- return ndct;
- } // cloneDataColumnType
-
- public DataSourceType cloneDataSourceType(ObjectFactory objFactory, DataSourceType dst)
- throws JAXBException {
- DataSourceType ndst = objFactory.createDataSourceType();
-
- ndst.setTableName(dst.getTableName());
- ndst.setTablePK(dst.getTablePK());
- ndst.setDisplayName(dst.getDisplayName());
- if (nvl(dst.getRefTableId()).length() > 0)
- ndst.setRefTableId(dst.getRefTableId());
- if (nvl(dst.getRefDefinition()).length() > 0)
- ndst.setRefDefinition(dst.getRefDefinition());
- if (nvl(dst.getComment()).length() > 0)
- ndst.setComment(dst.getComment());
- DataColumnList dataColumnList = objFactory.createDataColumnList();
- ndst.setDataColumnList(dataColumnList);
-
- for (Iterator iter = dst.getDataColumnList().getDataColumn().iterator(); iter
- .hasNext();)
- dataColumnList.getDataColumn().add(
- cloneDataColumnType(objFactory, (DataColumnType) iter.next()));
- ndst.setTableId(dst.getTableId());
-
-
- return ndst;
- } // cloneDataSourceType
-
- public CustomReportType cloneCustomReport() throws RaptorException {
- ObjectFactory objFactory = new ObjectFactory();
- CustomReportType ncr = objFactory.createCustomReportType();
-
- //CustomReport ncr = null;
- try {
- //ncr = (CustomReport) objFactory.createCustomReport(customReportType);
- ncr.setReportName(cr.getReportName());
- ncr.setReportDescr(cr.getReportDescr());
- if (nvl(cr.getNumDashCols()).length() > 0)
- ncr.setNumDashCols(cr.getNumDashCols());
- if (nvl(cr.getDashboardLayoutHTML()).length() > 0)
- ncr.setDashboardLayoutHTML(cr.getDashboardLayoutHTML());
- if (nvl(cr.getDbInfo()).length() > 0)
- ncr.setDbInfo(cr.getDbInfo());
- ncr.setChartType(cr.getChartType());
- if (nvl(cr.getChartTypeFixed()).length() > 0)
- ncr.setChartTypeFixed(cr.getChartTypeFixed());
- if (nvl(cr.getChartMultiSeries()).length() > 0)
- ncr.setChartMultiSeries(cr.getChartMultiSeries());
- if (nvl(cr.getChartLeftAxisLabel()).length() > 0)
- ncr.setChartLeftAxisLabel(cr.getChartLeftAxisLabel());
- if (nvl(cr.getChartRightAxisLabel()).length() > 0)
- ncr.setChartRightAxisLabel(cr.getChartRightAxisLabel());
- if (nvl(cr.getChartWidth()).length() > 0)
- ncr.setChartWidth(cr.getChartWidth());
- if (nvl(cr.getChartHeight()).length() > 0)
- ncr.setChartHeight(cr.getChartHeight());
- ncr.setShowChartTitle(cr.isShowChartTitle());
- ncr.setPublic(cr.isPublic());
- ncr.setHideFormFieldAfterRun(cr.isHideFormFieldAfterRun());
- ncr.setCreateId(cr.getCreateId());
- ncr.setCreateDate(cr.getCreateDate());
- if (nvl(cr.getReportSQL()).length() > 0)
- ncr.setReportSQL(cr.getReportSQL());
- if (nvl(cr.getReportTitle()).length() > 0)
- ncr.setReportTitle(cr.getReportTitle());
- if (nvl(cr.getReportSubTitle()).length() > 0)
- ncr.setReportSubTitle(cr.getReportSubTitle());
- if (nvl(cr.getReportHeader()).length() > 0)
- ncr.setReportHeader(cr.getReportHeader());
- if (cr.getFrozenColumns()!=null)
- ncr.setFrozenColumns(cr.getFrozenColumns());
- if (nvl(cr.getPdfImgLogo()).length()>0)
- ncr.setPdfImgLogo(cr.getPdfImgLogo());
- if (nvl(cr.getEmptyMessage()).length()>0)
- ncr.setEmptyMessage(cr.getEmptyMessage());
- if (nvl(cr.getWidthNoColumn()).length()>0)
- ncr.setWidthNoColumn(cr.getWidthNoColumn());
- if (nvl(cr.getDataGridAlign()).length()>0)
- ncr.setDataGridAlign(cr.getDataGridAlign());
-
- if (nvl(cr.getReportFooter()).length() > 0)
- ncr.setReportFooter(cr.getReportFooter());
- if (nvl(cr.getNumFormCols()).length() > 0)
- ncr.setNumFormCols(cr.getNumFormCols());
- if (nvl(cr.getDisplayOptions()).length() > 0)
- ncr.setDisplayOptions(cr.getDisplayOptions());
- if (nvl(cr.getDataContainerHeight()).length() > 0)
- ncr.setDataContainerHeight(cr.getDataContainerHeight());
- if (nvl(cr.getDataContainerWidth()).length() > 0)
- ncr.setDataContainerWidth(cr.getDataContainerWidth());
- if (nvl(cr.getAllowSchedule()).length() > 0)
- ncr.setAllowSchedule(cr.getAllowSchedule());
- if (nvl(cr.getTopDown()).length() > 0)
- ncr.setTopDown(cr.getTopDown());
- if (nvl(cr.getSizedByContent()).length() > 0)
- ncr.setSizedByContent(cr.getSizedByContent());
- if (nvl(cr.getComment()).length() > 0)
- ncr.setComment(cr.getComment());
- if (nvl(cr.getDashboardOptions()).length()>0)
- ncr.setDashboardOptions(cr.getDashboardOptions());
-
- if(cr.isDashboardType()!=null)
- ncr.setDashboardType(cr.isDashboardType());
- if(cr.isReportInNewWindow()!=null)
- ncr.setReportInNewWindow(cr.isReportInNewWindow());
- ncr.setDisplayFolderTree(cr.isDisplayFolderTree());
- if (cr.getDashBoardReports() == null) {
- if (cr.getMaxRowsInExcelDownload()!=null && cr.getMaxRowsInExcelDownload()>0)
- ncr.setMaxRowsInExcelDownload(cr.getMaxRowsInExcelDownload());
- }
-
- if (nvl(cr.getJavascriptElement()).length()>0)
- ncr.setJavascriptElement(cr.getJavascriptElement());
- if (nvl(cr.getFolderId()).length()>0)
- ncr.setFolderId(cr.getFolderId());
- ncr.setDrillURLInPoPUpPresent((cr.isDrillURLInPoPUpPresent()!=null && cr.isDrillURLInPoPUpPresent().booleanValue())?true:false);
-
- if (nvl(cr.getIsOneTimeScheduleAllowed()).length()>0)
- ncr.setIsOneTimeScheduleAllowed(cr.getIsOneTimeScheduleAllowed());
- if (nvl(cr.getIsHourlyScheduleAllowed()).length()>0)
- ncr.setIsHourlyScheduleAllowed(cr.getIsHourlyScheduleAllowed());
- if (nvl(cr.getIsDailyScheduleAllowed()).length()>0)
- ncr.setIsDailyScheduleAllowed(cr.getIsDailyScheduleAllowed());
- if (nvl(cr.getIsDailyMFScheduleAllowed()).length()>0)
- ncr.setIsDailyMFScheduleAllowed(cr.getIsDailyMFScheduleAllowed());
- if (nvl(cr.getIsWeeklyScheduleAllowed()).length()>0)
- ncr.setIsWeeklyScheduleAllowed(cr.getIsWeeklyScheduleAllowed());
- if (nvl(cr.getIsMonthlyScheduleAllowed()).length()>0)
- ncr.setIsMonthlyScheduleAllowed(cr.getIsMonthlyScheduleAllowed());
-
- ncr.setPageSize(cr.getPageSize());
- ncr.setReportType(cr.getReportType());
-
-
- DataSourceList dataSourceList = objFactory.createDataSourceList();
- ncr.setDataSourceList(dataSourceList);
-
- for (Iterator iter = cr.getDataSourceList().getDataSource().iterator(); iter.hasNext();) {
- dataSourceList.getDataSource().add(
- cloneDataSourceType(objFactory, (DataSourceType) iter.next()));
- }
-
- if (cr.getFormFieldList() != null) {
- FormFieldList formFieldList = objFactory.createFormFieldList();
- ncr.setFormFieldList(formFieldList);
- ncr.getFormFieldList().setComment(formFieldList.getComment());
-
- for (Iterator iter = cr.getFormFieldList().getFormField().iterator(); iter
- .hasNext();)
- formFieldList.getFormField().add(
- cloneFormFieldType(objFactory, (FormFieldType) iter.next()));
- formFieldList.setComment(cr.getFormFieldList().getComment());
- } // if
-
- if (cr.getJavascriptList() != null) {
- JavascriptList javascriptList = objFactory.createJavascriptList();
- ncr.setJavascriptList(javascriptList);
-
- for (Iterator iter = cr.getJavascriptList().getJavascriptItem().iterator(); iter
- .hasNext();)
- javascriptList.getJavascriptItem().add(
- cloneJavascriptType(objFactory, (JavascriptItemType) iter.next()));
- } // if
-
- if (cr.getSemaphoreList() != null) {
- SemaphoreList semaphoreList = objFactory.createSemaphoreList();
- ncr.setSemaphoreList(semaphoreList);
-
- for (Iterator iter = cr.getSemaphoreList().getSemaphore().iterator(); iter
- .hasNext();) {
- semaphoreList.getSemaphore().add(
- cloneSemaphoreType(objFactory, (SemaphoreType) iter.next()));
- }
- } // if
-
- if (nvl(cr.getDashboardOptions()).length()>0)
- ncr.setDashboardOptions(cr.getDashboardOptions());
- if(cr.isDashboardType()!=null)
- ncr.setDashboardType(cr.isDashboardType());
- if(cr.isReportInNewWindow()!=null)
- ncr.setReportInNewWindow(cr.isReportInNewWindow());
- ncr.setDisplayFolderTree(cr.isDisplayFolderTree());
- if (cr.getDashBoardReports() == null) {
- if (cr.getMaxRowsInExcelDownload()!=null && cr.getMaxRowsInExcelDownload()>0)
- ncr.setMaxRowsInExcelDownload(cr.getMaxRowsInExcelDownload());
- }
-
- if (cr.getDashBoardReports() != null) {
- DashboardReports dashboardReports = objFactory.createDashboardReports();
- ncr.setDashBoardReports(dashboardReports);
-
- for (Iterator iter = cr.getDashBoardReports().getReportsList().iterator(); iter
- .hasNext();) {
- dashboardReports.getReportsList().add(
- cloneDashboardType(objFactory, (Reports) iter.next()));
- }
- } // if
-
- if (cr.getChartAdditionalOptions() != null) {
- ChartAdditionalOptions chartAdditionalOptions = objFactory.createChartAdditionalOptions();
- if(nvl(cr.getChartAdditionalOptions().getChartMultiplePieOrder()).length()>0)
- chartAdditionalOptions.setChartMultiplePieOrder(cr.getChartAdditionalOptions().getChartMultiplePieOrder());
- if(nvl(cr.getChartAdditionalOptions().getChartMultiplePieLabelDisplay()).length()>0)
- chartAdditionalOptions.setChartMultiplePieLabelDisplay(cr.getChartAdditionalOptions().getChartMultiplePieLabelDisplay());
-
- if(nvl(cr.getChartAdditionalOptions().getChartOrientation()).length()>0)
- chartAdditionalOptions.setChartOrientation(cr.getChartAdditionalOptions().getChartOrientation());
- if(nvl(cr.getChartAdditionalOptions().getSecondaryChartRenderer()).length()>0)
- chartAdditionalOptions.setSecondaryChartRenderer(cr.getChartAdditionalOptions().getSecondaryChartRenderer());
-
- if(nvl(cr.getChartAdditionalOptions().getChartDisplay()).length()>0)
- chartAdditionalOptions.setChartDisplay(cr.getChartAdditionalOptions().getChartDisplay());
- if(nvl(cr.getChartAdditionalOptions().getHideToolTips()).length()>0)
- chartAdditionalOptions.setHideToolTips(cr.getChartAdditionalOptions().getHideToolTips());
- if(nvl(cr.getChartAdditionalOptions().getHidechartLegend()).length()>0)
- chartAdditionalOptions.setHidechartLegend(cr.getChartAdditionalOptions().getHidechartLegend());
- if(nvl(cr.getChartAdditionalOptions().getLegendPosition()).length()>0)
- chartAdditionalOptions.setLegendPosition(cr.getChartAdditionalOptions().getLegendPosition());
- if(nvl(cr.getChartAdditionalOptions().getLabelAngle()).length()>0)
- chartAdditionalOptions.setLabelAngle(cr.getChartAdditionalOptions().getLabelAngle());
-
- if(nvl(cr.getChartAdditionalOptions().getIntervalFromdate()).length()>0)
- chartAdditionalOptions.setIntervalFromdate(cr.getChartAdditionalOptions().getIntervalFromdate());
- if(nvl(cr.getChartAdditionalOptions().getIntervalTodate()).length()>0)
- chartAdditionalOptions.setIntervalTodate(cr.getChartAdditionalOptions().getIntervalTodate());
- if(nvl(cr.getChartAdditionalOptions().getIntervalLabel()).length()>0)
- chartAdditionalOptions.setIntervalLabel(cr.getChartAdditionalOptions().getIntervalLabel());
-
- if(nvl(cr.getChartAdditionalOptions().getLastSeriesALineChart()).length()>0)
- chartAdditionalOptions.setLastSeriesALineChart(cr.getChartAdditionalOptions().getLastSeriesALineChart());
- if(nvl(cr.getChartAdditionalOptions().getLastSeriesABarChart()).length()>0)
- chartAdditionalOptions.setLastSeriesABarChart(cr.getChartAdditionalOptions().getLastSeriesABarChart());
-
- if(nvl(cr.getChartAdditionalOptions().getMaxLabelsInDomainAxis()).length()>0)
- chartAdditionalOptions.setMaxLabelsInDomainAxis(cr.getChartAdditionalOptions().getMaxLabelsInDomainAxis());
- if(nvl(cr.getChartAdditionalOptions().getLinearRegression()).length()>0)
- chartAdditionalOptions.setLinearRegression(cr.getChartAdditionalOptions().getLinearRegression());
- if(nvl(cr.getChartAdditionalOptions().getLinearRegressionColor()).length()>0)
- chartAdditionalOptions.setLinearRegressionColor(cr.getChartAdditionalOptions().getLinearRegressionColor());
- if(nvl(cr.getChartAdditionalOptions().getExponentialRegressionColor()).length()>0)
- chartAdditionalOptions.setExponentialRegressionColor(cr.getChartAdditionalOptions().getExponentialRegressionColor());
- if(nvl(cr.getChartAdditionalOptions().getMaxRegression()).length()>0)
- chartAdditionalOptions.setMaxRegression(cr.getChartAdditionalOptions().getMaxRegression());
- if(nvl(cr.getChartAdditionalOptions().getRangeAxisUpperLimit()).length()>0)
- chartAdditionalOptions.setRangeAxisUpperLimit(cr.getChartAdditionalOptions().getRangeAxisUpperLimit());
- if(nvl(cr.getChartAdditionalOptions().getRangeAxisLowerLimit()).length()>0)
- chartAdditionalOptions.setRangeAxisLowerLimit(cr.getChartAdditionalOptions().getRangeAxisLowerLimit());
- if(nvl(cr.getChartAdditionalOptions().getOverlayItemValueOnStackBar()).length()>0)
- chartAdditionalOptions.setOverlayItemValueOnStackBar(cr.getChartAdditionalOptions().getOverlayItemValueOnStackBar());
- chartAdditionalOptions.setAnimate((cr.getChartAdditionalOptions().isAnimate()!=null && cr.getChartAdditionalOptions().isAnimate().booleanValue())?true:false);
-
- if(nvl(cr.getChartAdditionalOptions().getKeepDomainAxisValueAsString()).length()>0)
- chartAdditionalOptions.setKeepDomainAxisValueAsString(cr.getChartAdditionalOptions().getKeepDomainAxisValueAsString());
-
-
- // Animate
- chartAdditionalOptions.setAnimateAnimatedChart((cr.getChartAdditionalOptions().isAnimateAnimatedChart()!=null && cr.getChartAdditionalOptions().isAnimateAnimatedChart().booleanValue())?true:false);
- chartAdditionalOptions.setStacked((cr.getChartAdditionalOptions().isStacked()!=null && cr.getChartAdditionalOptions().isStacked().booleanValue())?true:false);
- chartAdditionalOptions.setBarControls((cr.getChartAdditionalOptions().isBarControls()!=null && cr.getChartAdditionalOptions().isBarControls().booleanValue())?true:false);
- chartAdditionalOptions.setXAxisDateType((cr.getChartAdditionalOptions().isXAxisDateType()!=null && cr.getChartAdditionalOptions().isXAxisDateType().booleanValue())?true:false);
- chartAdditionalOptions.setLessXaxisTickers((cr.getChartAdditionalOptions().isLessXaxisTickers()!=null && cr.getChartAdditionalOptions().isLessXaxisTickers().booleanValue())?true:false);
- chartAdditionalOptions.setTimeAxis((cr.getChartAdditionalOptions().isTimeAxis()!=null && cr.getChartAdditionalOptions().isTimeAxis().booleanValue())?true:false);
-
- if(nvl(cr.getChartAdditionalOptions().getTimeSeriesRender()).length()>0)
- chartAdditionalOptions.setTimeSeriesRender(cr.getChartAdditionalOptions().getTimeSeriesRender());
-
- chartAdditionalOptions.setMultiSeries((cr.getChartAdditionalOptions().isMultiSeries()!=null && cr.getChartAdditionalOptions().isMultiSeries().booleanValue())?true:false);
-
- chartAdditionalOptions.setTopMargin(cr.getChartAdditionalOptions().getTopMargin()!=null?cr.getChartAdditionalOptions().getTopMargin():new Integer(30));
- chartAdditionalOptions.setBottomMargin(cr.getChartAdditionalOptions().getBottomMargin()!=null?cr.getChartAdditionalOptions().getBottomMargin():new Integer(50));
- chartAdditionalOptions.setLeftMargin(cr.getChartAdditionalOptions().getLeftMargin()!=null?cr.getChartAdditionalOptions().getLeftMargin():new Integer(100));
- chartAdditionalOptions.setRightMargin(cr.getChartAdditionalOptions().getRightMargin()!=null?cr.getChartAdditionalOptions().getRightMargin():new Integer(60));
-
-
- ncr.setChartAdditionalOptions(chartAdditionalOptions);
- } // if
-
- if (nvl(cr.getJavascriptElement()).length()>0)
- ncr.setJavascriptElement(cr.getJavascriptElement());
- if (nvl(cr.getFolderId()).length()>0)
- ncr.setFolderId(cr.getFolderId());
-
- if (cr.getChartDrillOptions() != null) {
- ChartDrillOptions chartDrillOptions = objFactory.createChartDrillOptions();
-
- if(nvl(cr.getChartDrillOptions().getDrillReportId()).length()>0)
- chartDrillOptions.setDrillReportId(cr.getChartDrillOptions().getDrillReportId());
-
- for (Iterator iter = cr.getChartDrillOptions().getTargetFormfield().iterator(); iter
- .hasNext();) {
- chartDrillOptions.getTargetFormfield().add(
- cloneChartDrillFormfield(objFactory, (ChartDrillFormfield)iter.next()));
-
- }
-
- if(nvl(cr.getChartDrillOptions().getDrillXAxisFormField()).length()>0)
- chartDrillOptions.setDrillXAxisFormField(cr.getChartDrillOptions().getDrillXAxisFormField());
- if(nvl(cr.getChartDrillOptions().getDrillYAxisFormField()).length()>0)
- chartDrillOptions.setDrillYAxisFormField(cr.getChartDrillOptions().getDrillYAxisFormField());
- if(nvl(cr.getChartDrillOptions().getDrillSeriesFormField()).length()>0)
- chartDrillOptions.setDrillSeriesFormField(cr.getChartDrillOptions().getDrillSeriesFormField());
-
-
- ncr.setChartDrillOptions(chartDrillOptions);
- }
-
- if (nvl(cr.getIsOneTimeScheduleAllowed()).length()>0)
- ncr.setIsOneTimeScheduleAllowed(cr.getIsOneTimeScheduleAllowed());
- if (nvl(cr.getIsHourlyScheduleAllowed()).length()>0)
- ncr.setIsHourlyScheduleAllowed(cr.getIsHourlyScheduleAllowed());
- if (nvl(cr.getIsDailyScheduleAllowed()).length()>0)
- ncr.setIsDailyScheduleAllowed(cr.getIsDailyScheduleAllowed());
- if (nvl(cr.getIsDailyMFScheduleAllowed()).length()>0)
- ncr.setIsDailyMFScheduleAllowed(cr.getIsDailyMFScheduleAllowed());
- if (nvl(cr.getIsWeeklyScheduleAllowed()).length()>0)
- ncr.setIsWeeklyScheduleAllowed(cr.getIsWeeklyScheduleAllowed());
- if (nvl(cr.getIsMonthlyScheduleAllowed()).length()>0)
- ncr.setIsMonthlyScheduleAllowed(cr.getIsMonthlyScheduleAllowed());
-
- ncr.setPageSize(cr.getPageSize());
- ncr.setReportType(cr.getReportType());
-
- if (cr.getReportMap() != null){
- ReportMap repMap = objFactory.createReportMap();
- if(nvl(cr.getReportMap().getMarkerColor()).length()>0)
- repMap.setMarkerColor(cr.getReportMap().getMarkerColor());
- if(nvl(cr.getReportMap().getUseDefaultSize()).length()>0)
- repMap.setUseDefaultSize(cr.getReportMap().getUseDefaultSize());
- if(nvl(cr.getReportMap().getHeight()).length()>0)
- repMap.setHeight(cr.getReportMap().getHeight());
- if(nvl(cr.getReportMap().getWidth()).length()>0)
- repMap.setWidth(cr.getReportMap().getWidth());
- if(nvl(cr.getReportMap().getIsMapAllowedYN()).length()>0)
- repMap.setIsMapAllowedYN(cr.getReportMap().getIsMapAllowedYN());
- if(nvl(cr.getReportMap().getAddAddressInDataYN()).length()>0)
- repMap.setAddAddressInDataYN(cr.getReportMap().getAddAddressInDataYN());
- if(nvl(cr.getReportMap().getAddressColumn()).length()>0)
- repMap.setAddressColumn(cr.getReportMap().getAddressColumn());
- if(nvl(cr.getReportMap().getDataColumn()).length()>0)
- repMap.setDataColumn(cr.getReportMap().getDataColumn());
- if(nvl(cr.getReportMap().getDefaultMapType()).length()>0)
- repMap.setDefaultMapType(cr.getReportMap().getDefaultMapType());
- if(nvl(cr.getReportMap().getLatColumn()).length()>0)
- repMap.setLatColumn(cr.getReportMap().getLatColumn());
- if(nvl(cr.getReportMap().getLongColumn()).length()>0)
- repMap.setLongColumn(cr.getReportMap().getLongColumn());
- if(nvl(cr.getReportMap().getColorColumn()).length()>0)
- repMap.setColorColumn(cr.getReportMap().getColorColumn());
- if(nvl(cr.getReportMap().getLegendColumn()).length()>0)
- repMap.setLegendColumn(cr.getReportMap().getLegendColumn());
-
-
- for (Iterator iter = cr.getReportMap().getMarkers().iterator(); iter
- .hasNext();) {
- repMap.getMarkers().add(
- cloneMarkerType(objFactory, (Marker)iter.next()));
-
- }
-
- ncr.setReportMap(repMap);
- }
-
-
-
- } catch (JAXBException ex) { // try
- throw new RaptorException(ex.getMessage(), ex.getCause());
- }
-
- return ncr;
- } // cloneCustomReport
-
- /** ************************************************************************************************* */
-
-// public void printFormatType(FormatType ft) {
-// System.out.println("------------------------------------------------");
-// System.out.println("Semaphore Col Format");
-// System.out.println("------------------------------------------------");
-// System.out.println("FormatId: [" + ft.getFormatId() + "]");
-// System.out.println("LessThanValue: [" + ft.getLessThanValue() + "]");
-// System.out.println("Expression: [" + ft.getExpression() + "]");
-// System.out.println("Bold: [" + ft.isBold() + "]");
-// System.out.println("Italic: [" + ft.isItalic() + "]");
-// System.out.println("Underline: [" + ft.isUnderline() + "]");
-// System.out.println("BgColor: [" + ft.getBgColor() + "]");
-// System.out.println("FontColor: [" + ft.getFontColor() + "]");
-// System.out.println("FontFace: [" + ft.getFontFace() + "]");
-// System.out.println("FontSize: [" + ft.getFontSize() + "]");
-// System.out.println("Alignment: [" + ft.getAlignment() + "]");
-// System.out.println("Comment: [" + ft.getComment() + "]");
-// System.out.println("------------------------------------------------");
-// } // printFormatType
-
-// public void printSemaphoreType(SemaphoreType st) {
-// System.out.println("------------------------------------------------");
-// System.out.println("Semaphore");
-// System.out.println("------------------------------------------------");
-// System.out.println("SemaphoreId: [" + st.getSemaphoreId() + "]");
-// System.out.println("SemaphoreName: [" + st.getSemaphoreName() + "]");
-// System.out.println("SemaphoreType: [" + st.getSemaphoreType() + "]");
-// System.out.println("Comment: [" + st.getComment() + "]");
-//
-// if (st.getFormatList() != null)
-// for (Iterator iter = st.getFormatList().getFormat().iterator(); iter.hasNext();)
-// printFormatType((FormatType) iter.next());
-//
-// System.out.println("------------------------------------------------");
-// } // printSemaphoreType
-
-// public void printFormFieldType(FormFieldType fft) {
-// System.out.println("------------------------------------------------");
-// System.out.println("Form Field");
-// System.out.println("------------------------------------------------");
-// System.out.println("FieldId: [" + fft.getFieldId() + "]");
-// System.out.println("ColId: [" + fft.getColId() + "]");
-// System.out.println("FieldName: [" + fft.getFieldName() + "]");
-// System.out.println("FieldType: [" + fft.getFieldType() + "]");
-// System.out.println("ValidationType: [" + fft.getValidationType() + "]");
-// System.out.println("Mandatory: [" + fft.getMandatory() + "]");
-// System.out.println("DefaultValue: [" + fft.getDefaultValue() + "]");
-// System.out.println("OrderBySeq: [" + fft.getOrderBySeq() + "]");
-// System.out.println("FieldSQL: [" + fft.getFieldSQL() + "]");
-// System.out.println("Comment: [" + fft.getComment() + "]");
-// if (fft.getPredefinedValueList() != null)
-// for (Iterator iter = fft.getPredefinedValueList().getPredefinedValue().iterator(); iter
-// .hasNext();)
-// System.out.println("PredefinedValues: [" + ((String) iter.next()) + "]");
-//
-// System.out.println("------------------------------------------------");
-// } // printFormFieldType
-
-// public void printColFilterType(ColFilterType cft) {
-// System.out.println("------------------------------------------------");
-// System.out.println("Col Filter");
-// System.out.println("------------------------------------------------");
-// System.out.println("ColId: [" + cft.getColId() + "]");
-// System.out.println("FilterSeq: [" + cft.getFilterSeq() + "]");
-// System.out.println("JoinCondition: [" + cft.getJoinCondition() + "]");
-// System.out.println("OpenBrackets: [" + cft.getOpenBrackets() + "]");
-// System.out.println("Expression: [" + cft.getExpression() + "]");
-// System.out.println("ArgType: [" + cft.getArgType() + "]");
-// System.out.println("ArgValue: [" + cft.getArgValue() + "]");
-// System.out.println("CloseBrackets: [" + cft.getCloseBrackets() + "]");
-// System.out.println("Comment: [" + cft.getComment() + "]");
-// System.out.println("------------------------------------------------");
-// } // printColFilterType
-
-// public void printDataColumnType(DataColumnType dct) {
-// System.out.println("------------------------------------------------");
-// System.out.println("Data Column");
-// System.out.println("------------------------------------------------");
-// System.out.println("ColId: [" + dct.getColId() + "]");
-// System.out.println("TableId: [" + dct.getTableId() + "]");
-// System.out.println("DbColName: [" + dct.getDbColName() + "]");
-// System.out.println("CrossTabValue: [" + dct.getCrossTabValue() + "]");
-// System.out.println("ColName: [" + dct.getColName() + "]");
-// System.out.println("DisplayName: [" + dct.getDisplayName() + "]");
-// System.out.println("DisplayWidth: [" + dct.getDisplayWidth() + "]");
-// System.out.println("DisplayAlignment: [" + dct.getDisplayAlignment() + "]");
-// System.out.println("DisplayHeaderAlignment: [" + dct.getDisplayHeaderAlignment() + "]");
-// System.out.println("OrderSeq(): [" + dct.getOrderSeq() + "]");
-// System.out.println("Visible: [" + dct.isVisible() + "]");
-// System.out.println("Calculated: [" + dct.isCalculated() + "]");
-// System.out.println("ColType: [" + dct.getColType() + "]");
-// System.out.println("ColFormat: [" + dct.getColFormat() + "]");
-// System.out.println("GroupBreak: [" + dct.isGroupBreak() + "]");
-// System.out.println("OrderBySeq: [" + dct.getOrderBySeq() + "]");
-// System.out.println("OrderByAscDesc: [" + dct.getOrderByAscDesc() + "]");
-// System.out.println("DisplayTotal: [" + dct.getDisplayTotal() + "]");
-// System.out.println("ColOnChart: [" + dct.getColOnChart() + "]");
-// System.out.println("ChartSeq: [" + dct.getChartSeq() + "]");
-// System.out.println("ChartColor: [" + dct.getChartColor() + "]");
-// System.out.println("DrillDownType: [" + dct.getDrillDownType() + "]");
-// System.out.println("DrillDownURL: [" + dct.getDrillDownURL() + "]");
-// System.out.println("DrillDownParams: [" + dct.getDrillDownParams() + "]");
-// System.out.println("Comment: [" + dct.getComment() + "]");
-//
-// if (dct.getColFilterList() != null)
-// for (Iterator iter = dct.getColFilterList().getColFilter().iterator(); iter
-// .hasNext();)
-// printColFilterType((ColFilterType) iter.next());
-//
-// System.out.println("SemaphoreId: [" + dct.getSemaphoreId() + "]");
-// System.out.println("DbColType: [" + dct.getDbColType() + "]");
-// System.out.println("------------------------------------------------");
-// } // printDataColumnType
-
-// public void printDataSourceType(DataSourceType dst) {
-// System.out.println("------------------------------------------------");
-// System.out.println("Data Source");
-// System.out.println("------------------------------------------------");
-// System.out.println("TableId: [" + dst.getTableId() + "]");
-// System.out.println("TableName: [" + dst.getTableName() + "]");
-// System.out.println("TablePK: [" + dst.getTablePK() + "]");
-// System.out.println("DisplayName: [" + dst.getDisplayName() + "]");
-// System.out.println("RefTableId: [" + dst.getRefTableId() + "]");
-// System.out.println("RefDefinition: [" + dst.getRefDefinition() + "]");
-// System.out.println("Comment: [" + dst.getComment() + "]");
-//
-// for (Iterator iter = dst.getDataColumnList().getDataColumn().iterator(); iter
-// .hasNext();)
-// printDataColumnType((DataColumnType) iter.next());
-//
-// System.out.println("------------------------------------------------");
-// } // printDataSourceType
-
-// public void print() {
-// System.out.println("------------------------------------------------");
-// System.out.println("ReportWrapper object");
-// System.out.println("------------------------------------------------");
-// System.out.println("PageSize: [" + getPageSize() + "]");
-// System.out.println("ReportType: [" + getReportType() + "]");
-// System.out.println("ReportName: [" + getReportName() + "]");
-// System.out.println("ReportDescr: [" + getReportDescr() + "]");
-// System.out.println("ChartType: [" + getChartType() + "]");
-// System.out.println("ChartTypeFixed: [" + getChartTypeFixed() + "]");
-// //System.out.println("ChartLeftAxisLabel: [" + getChartLeftAxisLabel() + "]");
-// //System.out.println("ChartRightAxisLabel: [" + getChartRightAxisLabel() + "]");
-// System.out.println("ChartWidth: [" + getChartWidth() + "]");
-// System.out.println("ChartHeight: [" + getChartHeight() + "]");
-// System.out.println("Public: [" + isPublic() + "]");
-// System.out.println("CreateId: NOT USED ANYMORE[" + /* getCreateId()+ */"]");
-// System.out.println("CreateDate: NOT USED ANYMORE[" + /* getCreateDate()+ */"]");
-// System.out.println("ReportSQL: [" + getReportSQL() + "]");
-// System.out.println("ReportTitle: [" + getReportTitle() + "]");
-// System.out.println("DbInfo: [" + getDBInfo() + "]");
-// System.out.println("ReportSubTitle: [" + getReportSubTitle() + "]");
-// System.out.println("ReportHeader: [" + getReportHeader() + "]");
-// System.out.println("ReportFooter: [" + getReportFooter() + "]");
-// System.out.println("NumFormCols: [" + getNumFormCols() + "]");
-// System.out.println("DisplayOptions: [" + getDisplayOptions() + "]");
-// System.out.println("Comment: [" + getComment() + "]");
-//
-// for (Iterator iter = cr.getDataSourceList().getDataSource().iterator(); iter.hasNext();)
-// printDataSourceType((DataSourceType) iter.next());
-//
-// if (cr.getFormFieldList() != null)
-// for (Iterator iter = cr.getFormFieldList().getFormField().iterator(); iter
-// .hasNext();)
-// printFormFieldType((FormFieldType) iter.next());
-//
-// if (cr.getSemaphoreList() != null)
-// for (Iterator iter = cr.getSemaphoreList().getSemaphore().iterator(); iter
-// .hasNext();)
-// printSemaphoreType((SemaphoreType) iter.next());
-//
-// System.out.println("------------------------------------------------");
-// System.out.println("ReportWrapper object end");
-// System.out.println("------------------------------------------------");
-// } // print
-
- private int getIntValue(String value, int defaultValue) {
- int iValue = defaultValue;
- try {
- iValue = Integer.parseInt(value);
- } catch (Exception e) {
- }
-
- return iValue;
- } // getIntValue
- public static String replaceNewLine( String strSource, String strFind, String chrReplace )
- {
+
+ } // generateTotalSQLCrossTab
+
+ public String generateDistinctValuesSQL(ReportParamValues paramValues, DataColumnType dct,
+ String userId, HttpServletRequest request) throws RaptorException {
+ DataSourceType dst = getColumnTableById(dct.getColId());
+ String colName = getColumnSelectStr(dct, paramValues);
+ String colExpr = getSelectExpr(dct, colName);
+ ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
+ StringBuffer sb = new StringBuffer();
+ sb.append("SELECT DISTINCT ");
+ if (getReportDefType().equals(AppConstants.RD_SQL_BASED)) {
+ sb.append(dct.getColId());
+ sb.append(" FROM (");
+ // paramvalues added below to filter distinct values based on formfields.
+ // sb.append(generateSQL(paramValues, userId, request));
+ sb.append(rr.getWholeSQL());
+ sb.append(") " + (Globals.isPostgreSQL() || Globals.isMySQL() ? " AS " : "") + " report_sql ORDER BY 1");
+ } else {
+ sb.append(colExpr);
+ sb.append(" ");
+ sb.append(dct.getColId());
+ if (!colExpr.equals(colName)) {
+ sb.append(", ");
+ sb.append(colName);
+ } // if
+ sb.append(" FROM ");
+ sb.append(dst.getTableName());
+ sb.append(" ");
+ sb.append(dst.getTableId());
+ sb.append(" ORDER BY ");
+ sb.append(colName);
+ if (dct.getColType().equals(AppConstants.CT_DATE))
+ sb.append(" DESC");
+ } // else
+
+ return sb.toString();
+ } // generateDistinctValuesSQL
+
+ /**
+ * *************************************************************************************************
+ */
+
+ public DataSourceType getTableWithoutColumns() {
+ List dsList = getDataSourceList().getDataSource();
+ for (Iterator iter = dsList.iterator(); iter.hasNext();) {
+ DataSourceType ds = (DataSourceType) iter.next();
+
+ if (ds.getDataColumnList().getDataColumn().isEmpty())
+ return ds;
+ } // for
+
+ return null;
+ } // getTableWithoutColumns
+
+ public CustomReportType cloneCustomReportClearTables() throws RaptorException {
+ ReportWrapper nrw = new ReportWrapper(cloneCustomReport(), reportID, getOwnerID(),
+ getCreateID(), getCreateDate(), getUpdateID(), getUpdateDate(), getMenuID(),
+ isMenuApproved());
+
+ DataSourceType ndst = null;
+ while ((ndst = nrw.getTableWithoutColumns()) != null)
+ nrw.deleteDataSourceType(ndst.getTableId());
+
+ return nrw.getCustomReport();
+ } // cloneCustomReportClearTables
+
+ public String marshal() throws RaptorException {
+ StringWriter sw = new StringWriter();
+ ObjectFactory objFactory = new ObjectFactory();
+
+ try {
+ JAXBContext jc = JAXBContext.newInstance("org.onap.portalsdk.analytics.xmlobj");
+ Marshaller m = jc.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+ // JAXBElement jaxbElement = new JAXBElement(new QName("customReport"), Object.class, "");
+ // m.marshal( System.out );
+ // m.marshal(jaxbElement, new StreamResult(sw));
+ m.marshal(
+ (getTableWithoutColumns() == null) ? objFactory.createCustomReport(cr)
+ : objFactory.createCustomReport(cloneCustomReportClearTables()),
+ new StreamResult(sw));
+ } catch (JAXBException ex) {
+ logger.error(EELFLoggerDelegate.debugLogger, "Exception occured in marshal ", ex);
+ throw new RaptorException(ex.getMessage(), ex.getCause());
+ }
+ return sw.toString();
+ } // marshal
+
+ public static CustomReportType unmarshalCR(String reportXML) throws RaptorException {
+ // CustomReport cr = null;
+ try {
+ JAXBContext jc = JAXBContext.newInstance("org.onap.portalsdk.analytics.xmlobj");
+ Unmarshaller u = jc.createUnmarshaller();
+ javax.xml.bind.JAXBElement<CustomReportType> doc =
+ (javax.xml.bind.JAXBElement<CustomReportType>) u.unmarshal(new java.io.StringReader(
+ reportXML));
+ return doc.getValue();
+ } catch (JAXBException ex) {
+ logger.error(EELFLoggerDelegate.debugLogger, "Exception occured in unmarshalCR ", ex);
+ throw new RaptorException(ex.getMessage(), ex.getCause());
+ }
+
+ } // unmarshal
+
+ protected static CustomReportType createBlankCR() throws RaptorException {
+ return createBlankCR("N/A");
+ } // createBlank
+
+ protected static CustomReportType createBlankCR(String createID) throws RaptorException {
+ ObjectFactory objFactory = new ObjectFactory();
+ CustomReportType cr = objFactory.createCustomReportType();
+ // CustomReport cr = null;
+ try {
+ // cr = (CustomReport) objFactory.createCustomReport(customReportType);
+
+ cr.setReportName("");
+ cr.setReportDescr("");
+ cr.setChartType("");
+ cr.setPublic(false);
+ cr.setCreateId(createID);
+ cr.setCreateDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar()));
+ // cr.setReportSQL("");
+ cr.setReportType("");
+ cr.setPageSize(50);
+
+ DataSourceList dataSourceList = objFactory.createDataSourceList();
+ cr.setDataSourceList(dataSourceList);
+ } catch (DatatypeConfigurationException ex) {
+ throw new RaptorException(ex.getMessage(), ex.getCause());
+ }
+ return cr;
+ } // createBlank
+
+ protected void replaceCustomReportWithClone() throws RaptorException {
+ try {
+ CustomReportType clone = cloneCustomReport();
+ this.cr = clone;
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ ("[SYSTEM ERROR] ReportWrapper.replaceCustomReportWithClone generated exception for report ["
+ + reportID + "]. Exception: "),
+ e);
+ throw new RaptorException(
+ "[SYSTEM ERROR] ReportWrapper.replaceCustomReportWithClone generated exception for report ["
+ + reportID + "]. Exception: " + e.getMessage(),
+ e.getCause());
+ }
+ } // replaceCustomReportWithClone
+
+ /**
+ * *************************************************************************************************
+ */
+
+ public FormatType cloneFormatType(ObjectFactory objFactory, FormatType ft)
+ throws JAXBException {
+ FormatType nft = objFactory.createFormatType();
+
+ nft.setLessThanValue(ft.getLessThanValue());
+ nft.setExpression(ft.getExpression());
+ nft.setBold(ft.isBold());
+ nft.setItalic(ft.isItalic());
+ nft.setUnderline(ft.isUnderline());
+ if (nvl(ft.getBgColor()).length() > 0)
+ nft.setBgColor(ft.getBgColor());
+ if (nvl(ft.getFontColor()).length() > 0)
+ nft.setFontColor(ft.getFontColor());
+ if (nvl(ft.getFontFace()).length() > 0)
+ nft.setFontFace(ft.getFontFace());
+ if (nvl(ft.getFontSize()).length() > 0)
+ nft.setFontSize(ft.getFontSize());
+ if (nvl(ft.getAlignment()).length() > 0)
+ nft.setAlignment(ft.getAlignment());
+ if (nvl(ft.getComment()).length() > 0)
+ nft.setComment(ft.getComment());
+
+ nft.setFormatId(ft.getFormatId());
+
+ return nft;
+ } // cloneFormatType
+
+ public SemaphoreType cloneSemaphoreType(ObjectFactory objFactory, SemaphoreType st)
+ throws JAXBException {
+ SemaphoreType nst = objFactory.createSemaphoreType();
+
+ nst.setSemaphoreName(st.getSemaphoreName());
+ nst.setSemaphoreType(st.getSemaphoreType());
+ nst.setSemaphoreId(st.getSemaphoreId());
+ if (nvl(st.getComment()).length() > 0)
+ nst.setComment(st.getComment());
+
+ if (st.getFormatList() != null) {
+ FormatList formatList = objFactory.createFormatList();
+ nst.setFormatList(formatList);
+
+ for (Iterator iter = st.getFormatList().getFormat().iterator(); iter.hasNext();)
+ formatList.getFormat().add(
+ cloneFormatType(objFactory, (FormatType) iter.next()));
+ } // if
+
+ return nst;
+ } // cloneSemaphoreType
+
+ public Reports cloneDashboardType(ObjectFactory objFactory, Reports rpt)
+ throws JAXBException {
+ Reports nrpt = objFactory.createReports();
+
+ nrpt.setReportId(rpt.getReportId());
+ nrpt.setBgcolor(rpt.getBgcolor());
+ return nrpt;
+ } // cloneDashboardType
+
+ public Marker cloneMarkerType(ObjectFactory objFactory, Marker marker)
+ throws JAXBException {
+ Marker nMarker = objFactory.createMarker();
+ nMarker.setAddressColumn(marker.getAddressColumn());
+ nMarker.setDataColumn(marker.getDataColumn());
+ nMarker.setDataHeader(marker.getDataHeader());
+ nMarker.setMarkerColor(marker.getMarkerColor());
+ return nMarker;
+ } // cloneDashboardType
+
+ public ChartDrillFormfield cloneChartDrillFormfield(ObjectFactory objFactory,
+ ChartDrillFormfield chartDrillFormfield)
+ throws JAXBException {
+ ChartDrillFormfield nChartDrillFormfield = objFactory.createChartDrillFormfield();
+ nChartDrillFormfield.setFormfield(chartDrillFormfield.getFormfield());
+ return nChartDrillFormfield;
+ } // cloneDashboardType
+
+ public boolean isChartDrillDownContainsName(String name) {
+ for (Iterator iter = getChartDrillOptions().getTargetFormfield().iterator(); iter
+ .hasNext();) {
+ org.onap.portalsdk.analytics.xmlobj.ChartDrillFormfield cdf =
+ (org.onap.portalsdk.analytics.xmlobj.ChartDrillFormfield) iter.next();
+ if (cdf.getFormfield().equals(name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public FormFieldType cloneFormFieldType(ObjectFactory objFactory, FormFieldType fft)
+ throws JAXBException {
+ FormFieldType nfft = objFactory.createFormFieldType();
+
+ nfft.setColId(fft.getColId());
+ nfft.setFieldName(fft.getFieldName());
+ nfft.setFieldType(fft.getFieldType());
+ if (nvl(fft.getVisible()).length() > 0)
+ nfft.setVisible(fft.getVisible());
+ if (nvl(fft.getValidationType()).length() > 0)
+ nfft.setValidationType(fft.getValidationType());
+ if (nvl(fft.getMandatory()).length() > 0)
+ nfft.setMandatory(fft.getMandatory());
+ if (nvl(fft.getDefaultValue()).length() > 0)
+ nfft.setDefaultValue(fft.getDefaultValue());
+ nfft.setOrderBySeq(fft.getOrderBySeq());
+ if (nvl(fft.getFieldSQL()).length() > 0)
+ nfft.setFieldSQL(fft.getFieldSQL());
+ if (nvl(fft.getFieldDefaultSQL()).length() > 0)
+ nfft.setFieldDefaultSQL(fft.getFieldDefaultSQL());
+ if (fft.getRangeStartDate() != null)
+ nfft.setRangeStartDate(fft.getRangeStartDate());
+ if (fft.getRangeEndDate() != null)
+ nfft.setRangeEndDate(fft.getRangeEndDate());
+ if (fft.getRangeStartDateSQL() != null)
+ nfft.setRangeStartDateSQL(fft.getRangeStartDateSQL());
+ if (fft.getRangeEndDateSQL() != null)
+ nfft.setRangeEndDateSQL(fft.getRangeEndDateSQL());
+
+ if (nvl(fft.getComment()).length() > 0)
+ nfft.setComment(fft.getComment());
+
+ if (fft.getPredefinedValueList() != null) {
+ PredefinedValueList predefinedValueList = objFactory.createPredefinedValueList();
+ nfft.setPredefinedValueList(predefinedValueList);
+
+ for (Iterator iter = fft.getPredefinedValueList().getPredefinedValue().iterator(); iter
+ .hasNext();)
+ predefinedValueList.getPredefinedValue().add(new String((String) iter.next()));
+ } // if
+ if (nvl(fft.getDependsOn()).length() > 0)
+ nfft.setDependsOn(fft.getDependsOn());
+
+ nfft.setGroupFormField(
+ (fft.isGroupFormField() != null && fft.isGroupFormField().booleanValue()) ? true : false);
+ if (nvl(fft.getMultiSelectListSize()).length() > 0)
+ nfft.setMultiSelectListSize(fft.getMultiSelectListSize());
+
+ nfft.setFieldId(fft.getFieldId());
+ return nfft;
+ } // cloneFormFieldType
+
+ public JavascriptItemType cloneJavascriptType(ObjectFactory objFactory, JavascriptItemType jit)
+ throws JAXBException {
+ JavascriptItemType njit = objFactory.createJavascriptItemType();
+
+ njit.setId(jit.getId());
+ njit.setFieldId(jit.getFieldId());
+ njit.setCallText(jit.getCallText());
+ return njit;
+ } // cloneJavascriptType
+
+ public ColFilterType cloneColFilterType(ObjectFactory objFactory, ColFilterType cft)
+ throws JAXBException {
+ ColFilterType ncft = objFactory.createColFilterType();
+
+ ncft.setColId(cft.getColId());
+ ncft.setFilterSeq(cft.getFilterSeq());
+ ncft.setJoinCondition(cft.getJoinCondition());
+ if (nvl(cft.getOpenBrackets()).length() > 0)
+ ncft.setOpenBrackets(cft.getOpenBrackets());
+ ncft.setExpression(cft.getExpression());
+ if (nvl(cft.getArgType()).length() > 0)
+ ncft.setArgType(cft.getArgType());
+ if (nvl(cft.getArgValue()).length() > 0)
+ ncft.setArgValue(cft.getArgValue());
+ if (nvl(cft.getCloseBrackets()).length() > 0)
+ ncft.setCloseBrackets(cft.getCloseBrackets());
+ if (nvl(cft.getComment()).length() > 0)
+ ncft.setComment(cft.getComment());
+
+ return ncft;
+ } // cloneColFilterType
+
+ public DataColumnType cloneDataColumnType(ObjectFactory objFactory, DataColumnType dct)
+ throws JAXBException {
+ DataColumnType ndct = objFactory.createDataColumnType();
+
+ ndct.setTableId(dct.getTableId());
+ ndct.setDbColName(dct.getDbColName());
+ if (nvl(dct.getCrossTabValue()).length() > 0)
+ ndct.setCrossTabValue(dct.getCrossTabValue());
+ ndct.setColName(dct.getColName());
+ ndct.setDisplayName(dct.getDisplayName());
+ if (dct.getDisplayWidth() > 0)
+ ndct.setDisplayWidth(dct.getDisplayWidth());
+ if (nvl(dct.getDisplayWidthInPxls()).length() > 0)
+ ndct.setDisplayWidthInPxls(dct.getDisplayWidthInPxls());
+ if (nvl(dct.getDisplayAlignment()).length() > 0)
+ ndct.setDisplayAlignment(dct.getDisplayAlignment());
+ if (nvl(dct.getDisplayHeaderAlignment()).length() > 0)
+ ndct.setDisplayHeaderAlignment(dct.getDisplayHeaderAlignment());
+ ndct.setOrderSeq(dct.getOrderSeq());
+ ndct.setVisible(dct.isVisible());
+ ndct.setCalculated(dct.isCalculated());
+ ndct.setColType(dct.getColType());
+ if (dct.getColType().equals(AppConstants.CT_HYPERLINK)) {
+ ndct.setHyperlinkURL(dct.getHyperlinkURL());
+ ndct.setHyperlinkType(dct.getHyperlinkType());
+ if ("IMAGE".equals(dct.getHyperlinkType())) {
+ ndct.setActionImg(dct.getActionImg());
+ }
+ }
+
+ if (dct.getIndentation() != null) {
+ ndct.setIndentation(dct.getIndentation());
+ }
+
+ if (nvl(dct.getColFormat()).length() > 0)
+ ndct.setColFormat(dct.getColFormat());
+ ndct.setGroupBreak(dct.isGroupBreak());
+ ndct.setNowrap(dct.getNowrap());
+ if (nvl(dct.getYAxis()).length() > 0)
+ ndct.setYAxis(dct.getYAxis());
+ if (dct.getOrderBySeq() != null && dct.getOrderBySeq() > 0)
+ ndct.setOrderBySeq(dct.getOrderBySeq());
+ if (nvl(dct.getOrderByAscDesc()).length() > 0)
+ ndct.setOrderByAscDesc(dct.getOrderByAscDesc());
+ if (nvl(dct.getDisplayTotal()).length() > 0)
+ ndct.setDisplayTotal(dct.getDisplayTotal());
+ if (nvl(dct.getColOnChart()).length() > 0)
+ ndct.setColOnChart(dct.getColOnChart());
+ if (dct.getChartSeq() != null)
+ ndct.setChartSeq(dct.getChartSeq());
+ if (nvl(dct.getChartColor()).length() > 0)
+ ndct.setChartColor(dct.getChartColor());
+ if (nvl(dct.getChartLineType()).length() > 0)
+ ndct.setChartLineType(dct.getChartLineType());
+ ndct.setChartSeries((dct.isChartSeries() != null && dct.isChartSeries().booleanValue()) ? true : false);
+ ndct.setIsRangeAxisFilled(
+ (dct.isIsRangeAxisFilled() != null && dct.isIsRangeAxisFilled().booleanValue()) ? true : false);
+
+ if (dct.isCreateInNewChart() != null)
+ ndct.setCreateInNewChart(dct.isCreateInNewChart());
+ if (nvl(dct.getDrillDownType()).length() > 0)
+ ndct.setDrillDownType(dct.getDrillDownType());
+ ndct.setDrillinPoPUp(dct.isDrillinPoPUp() != null ? dct.isDrillinPoPUp() : false);
+ if (nvl(dct.getDrillDownURL()).length() > 0)
+ ndct.setDrillDownURL(dct.getDrillDownURL());
+ if (nvl(dct.getDrillDownParams()).length() > 0)
+ ndct.setDrillDownParams(dct.getDrillDownParams());
+ if (nvl(dct.getComment()).length() > 0)
+ ndct.setComment(dct.getComment());
+ if (nvl(dct.getDependsOnFormField()).length() > 0)
+ ndct.setDependsOnFormField(dct.getDependsOnFormField());
+ if (dct.getColFilterList() != null) {
+ ColFilterList colFilterList = objFactory.createColFilterList();
+ ndct.setColFilterList(colFilterList);
+
+ for (Iterator iter = dct.getColFilterList().getColFilter().iterator(); iter
+ .hasNext();)
+ colFilterList.getColFilter().add(
+ cloneColFilterType(objFactory, (ColFilterType) iter.next()));
+ } // if
+
+ if (nvl(dct.getSemaphoreId()).length() > 0)
+ ndct.setSemaphoreId(dct.getSemaphoreId());
+ if (nvl(dct.getDbColType()).length() > 0)
+ ndct.setDbColType(dct.getDbColType());
+ else {
+ ndct.setDbColType(dct.getColType());
+ adjustColumnType(ndct);
+ }
+ if (nvl(dct.getChartGroup()).length() > 0)
+ ndct.setChartGroup(dct.getChartGroup());
+
+ if (nvl(dct.getYAxis()).length() > 0)
+ ndct.setYAxis(dct.getYAxis());
+
+ if (nvl(dct.getDependsOnFormField()).length() > 0)
+ ndct.setDependsOnFormField(dct.getDependsOnFormField());
+
+ if (nvl(dct.getNowrap()).length() > 0)
+ ndct.setNowrap(dct.getNowrap());
+
+ if (dct.getIndentation() != null) {
+ ndct.setIndentation(dct.getIndentation());
+ }
+
+ ndct.setEnhancedPagination(
+ (dct.isEnhancedPagination() != null && dct.isEnhancedPagination().booleanValue()) ? true : false);
+ if (nvl(dct.getDataMiningCol()).length() > 0)
+ ndct.setDataMiningCol(dct.getDataMiningCol());
+
+ ndct.setColId(dct.getColId());
+
+ // ndct.setSemaphoreId(nvl(dct.getSemaphoreId()));
+ // if(nvl(dct.getDbColType()).length()>0)
+ // ndct.setDbColType(dct.getDbColType());
+ return ndct;
+ } // cloneDataColumnType
+
+ public DataSourceType cloneDataSourceType(ObjectFactory objFactory, DataSourceType dst)
+ throws JAXBException {
+ DataSourceType ndst = objFactory.createDataSourceType();
+
+ ndst.setTableName(dst.getTableName());
+ ndst.setTablePK(dst.getTablePK());
+ ndst.setDisplayName(dst.getDisplayName());
+ if (nvl(dst.getRefTableId()).length() > 0)
+ ndst.setRefTableId(dst.getRefTableId());
+ if (nvl(dst.getRefDefinition()).length() > 0)
+ ndst.setRefDefinition(dst.getRefDefinition());
+ if (nvl(dst.getComment()).length() > 0)
+ ndst.setComment(dst.getComment());
+ DataColumnList dataColumnList = objFactory.createDataColumnList();
+ ndst.setDataColumnList(dataColumnList);
+
+ for (Iterator iter = dst.getDataColumnList().getDataColumn().iterator(); iter
+ .hasNext();)
+ dataColumnList.getDataColumn().add(
+ cloneDataColumnType(objFactory, (DataColumnType) iter.next()));
+ ndst.setTableId(dst.getTableId());
+
+ return ndst;
+ } // cloneDataSourceType
+
+ public CustomReportType cloneCustomReport() throws RaptorException {
+ ObjectFactory objFactory = new ObjectFactory();
+ CustomReportType ncr = objFactory.createCustomReportType();
+
+ // CustomReport ncr = null;
+ try {
+ // ncr = (CustomReport) objFactory.createCustomReport(customReportType);
+ ncr.setReportName(cr.getReportName());
+ ncr.setReportDescr(cr.getReportDescr());
+ if (nvl(cr.getNumDashCols()).length() > 0)
+ ncr.setNumDashCols(cr.getNumDashCols());
+ if (nvl(cr.getDashboardLayoutHTML()).length() > 0)
+ ncr.setDashboardLayoutHTML(cr.getDashboardLayoutHTML());
+ if (nvl(cr.getDbInfo()).length() > 0)
+ ncr.setDbInfo(cr.getDbInfo());
+ ncr.setChartType(cr.getChartType());
+ if (nvl(cr.getChartTypeFixed()).length() > 0)
+ ncr.setChartTypeFixed(cr.getChartTypeFixed());
+ if (nvl(cr.getChartMultiSeries()).length() > 0)
+ ncr.setChartMultiSeries(cr.getChartMultiSeries());
+ if (nvl(cr.getChartLeftAxisLabel()).length() > 0)
+ ncr.setChartLeftAxisLabel(cr.getChartLeftAxisLabel());
+ if (nvl(cr.getChartRightAxisLabel()).length() > 0)
+ ncr.setChartRightAxisLabel(cr.getChartRightAxisLabel());
+ if (nvl(cr.getChartWidth()).length() > 0)
+ ncr.setChartWidth(cr.getChartWidth());
+ if (nvl(cr.getChartHeight()).length() > 0)
+ ncr.setChartHeight(cr.getChartHeight());
+ ncr.setShowChartTitle(cr.isShowChartTitle());
+ ncr.setPublic(cr.isPublic());
+ ncr.setHideFormFieldAfterRun(cr.isHideFormFieldAfterRun());
+ ncr.setCreateId(cr.getCreateId());
+ ncr.setCreateDate(cr.getCreateDate());
+ if (nvl(cr.getReportSQL()).length() > 0)
+ ncr.setReportSQL(cr.getReportSQL());
+ if (nvl(cr.getReportTitle()).length() > 0)
+ ncr.setReportTitle(cr.getReportTitle());
+ if (nvl(cr.getReportSubTitle()).length() > 0)
+ ncr.setReportSubTitle(cr.getReportSubTitle());
+ if (nvl(cr.getReportHeader()).length() > 0)
+ ncr.setReportHeader(cr.getReportHeader());
+ if (cr.getFrozenColumns() != null)
+ ncr.setFrozenColumns(cr.getFrozenColumns());
+ if (nvl(cr.getPdfImgLogo()).length() > 0)
+ ncr.setPdfImgLogo(cr.getPdfImgLogo());
+ if (nvl(cr.getEmptyMessage()).length() > 0)
+ ncr.setEmptyMessage(cr.getEmptyMessage());
+ if (nvl(cr.getWidthNoColumn()).length() > 0)
+ ncr.setWidthNoColumn(cr.getWidthNoColumn());
+ if (nvl(cr.getDataGridAlign()).length() > 0)
+ ncr.setDataGridAlign(cr.getDataGridAlign());
+
+ if (nvl(cr.getReportFooter()).length() > 0)
+ ncr.setReportFooter(cr.getReportFooter());
+ if (nvl(cr.getNumFormCols()).length() > 0)
+ ncr.setNumFormCols(cr.getNumFormCols());
+ if (nvl(cr.getDisplayOptions()).length() > 0)
+ ncr.setDisplayOptions(cr.getDisplayOptions());
+ if (nvl(cr.getDataContainerHeight()).length() > 0)
+ ncr.setDataContainerHeight(cr.getDataContainerHeight());
+ if (nvl(cr.getDataContainerWidth()).length() > 0)
+ ncr.setDataContainerWidth(cr.getDataContainerWidth());
+ if (nvl(cr.getAllowSchedule()).length() > 0)
+ ncr.setAllowSchedule(cr.getAllowSchedule());
+ if (nvl(cr.getTopDown()).length() > 0)
+ ncr.setTopDown(cr.getTopDown());
+ if (nvl(cr.getSizedByContent()).length() > 0)
+ ncr.setSizedByContent(cr.getSizedByContent());
+ if (nvl(cr.getComment()).length() > 0)
+ ncr.setComment(cr.getComment());
+ if (nvl(cr.getDashboardOptions()).length() > 0)
+ ncr.setDashboardOptions(cr.getDashboardOptions());
+
+ if (cr.isDashboardType() != null)
+ ncr.setDashboardType(cr.isDashboardType());
+ if (cr.isReportInNewWindow() != null)
+ ncr.setReportInNewWindow(cr.isReportInNewWindow());
+ ncr.setDisplayFolderTree(cr.isDisplayFolderTree());
+ if (cr.getDashBoardReports() == null) {
+ if (cr.getMaxRowsInExcelDownload() != null && cr.getMaxRowsInExcelDownload() > 0)
+ ncr.setMaxRowsInExcelDownload(cr.getMaxRowsInExcelDownload());
+ }
+
+ if (nvl(cr.getJavascriptElement()).length() > 0)
+ ncr.setJavascriptElement(cr.getJavascriptElement());
+ if (nvl(cr.getFolderId()).length() > 0)
+ ncr.setFolderId(cr.getFolderId());
+ ncr.setDrillURLInPoPUpPresent(
+ (cr.isDrillURLInPoPUpPresent() != null && cr.isDrillURLInPoPUpPresent().booleanValue()) ? true
+ : false);
+
+ if (nvl(cr.getIsOneTimeScheduleAllowed()).length() > 0)
+ ncr.setIsOneTimeScheduleAllowed(cr.getIsOneTimeScheduleAllowed());
+ if (nvl(cr.getIsHourlyScheduleAllowed()).length() > 0)
+ ncr.setIsHourlyScheduleAllowed(cr.getIsHourlyScheduleAllowed());
+ if (nvl(cr.getIsDailyScheduleAllowed()).length() > 0)
+ ncr.setIsDailyScheduleAllowed(cr.getIsDailyScheduleAllowed());
+ if (nvl(cr.getIsDailyMFScheduleAllowed()).length() > 0)
+ ncr.setIsDailyMFScheduleAllowed(cr.getIsDailyMFScheduleAllowed());
+ if (nvl(cr.getIsWeeklyScheduleAllowed()).length() > 0)
+ ncr.setIsWeeklyScheduleAllowed(cr.getIsWeeklyScheduleAllowed());
+ if (nvl(cr.getIsMonthlyScheduleAllowed()).length() > 0)
+ ncr.setIsMonthlyScheduleAllowed(cr.getIsMonthlyScheduleAllowed());
+
+ ncr.setPageSize(cr.getPageSize());
+ ncr.setReportType(cr.getReportType());
+
+ DataSourceList dataSourceList = objFactory.createDataSourceList();
+ ncr.setDataSourceList(dataSourceList);
+
+ for (Iterator iter = cr.getDataSourceList().getDataSource().iterator(); iter.hasNext();) {
+ dataSourceList.getDataSource().add(
+ cloneDataSourceType(objFactory, (DataSourceType) iter.next()));
+ }
+
+ if (cr.getFormFieldList() != null) {
+ FormFieldList formFieldList = objFactory.createFormFieldList();
+ ncr.setFormFieldList(formFieldList);
+ ncr.getFormFieldList().setComment(formFieldList.getComment());
+
+ for (Iterator iter = cr.getFormFieldList().getFormField().iterator(); iter
+ .hasNext();)
+ formFieldList.getFormField().add(
+ cloneFormFieldType(objFactory, (FormFieldType) iter.next()));
+ formFieldList.setComment(cr.getFormFieldList().getComment());
+ } // if
+
+ if (cr.getJavascriptList() != null) {
+ JavascriptList javascriptList = objFactory.createJavascriptList();
+ ncr.setJavascriptList(javascriptList);
+
+ for (Iterator iter = cr.getJavascriptList().getJavascriptItem().iterator(); iter
+ .hasNext();)
+ javascriptList.getJavascriptItem().add(
+ cloneJavascriptType(objFactory, (JavascriptItemType) iter.next()));
+ } // if
+
+ if (cr.getSemaphoreList() != null) {
+ SemaphoreList semaphoreList = objFactory.createSemaphoreList();
+ ncr.setSemaphoreList(semaphoreList);
+
+ for (Iterator iter = cr.getSemaphoreList().getSemaphore().iterator(); iter
+ .hasNext();) {
+ semaphoreList.getSemaphore().add(
+ cloneSemaphoreType(objFactory, (SemaphoreType) iter.next()));
+ }
+ } // if
+
+ if (nvl(cr.getDashboardOptions()).length() > 0)
+ ncr.setDashboardOptions(cr.getDashboardOptions());
+ if (cr.isDashboardType() != null)
+ ncr.setDashboardType(cr.isDashboardType());
+ if (cr.isReportInNewWindow() != null)
+ ncr.setReportInNewWindow(cr.isReportInNewWindow());
+ ncr.setDisplayFolderTree(cr.isDisplayFolderTree());
+ if (cr.getDashBoardReports() == null) {
+ if (cr.getMaxRowsInExcelDownload() != null && cr.getMaxRowsInExcelDownload() > 0)
+ ncr.setMaxRowsInExcelDownload(cr.getMaxRowsInExcelDownload());
+ }
+
+ if (cr.getDashBoardReports() != null) {
+ DashboardReports dashboardReports = objFactory.createDashboardReports();
+ ncr.setDashBoardReports(dashboardReports);
+
+ for (Iterator iter = cr.getDashBoardReports().getReportsList().iterator(); iter
+ .hasNext();) {
+ dashboardReports.getReportsList().add(
+ cloneDashboardType(objFactory, (Reports) iter.next()));
+ }
+ } // if
+
+ if (cr.getChartAdditionalOptions() != null) {
+ ChartAdditionalOptions chartAdditionalOptions = objFactory.createChartAdditionalOptions();
+ if (nvl(cr.getChartAdditionalOptions().getChartMultiplePieOrder()).length() > 0)
+ chartAdditionalOptions
+ .setChartMultiplePieOrder(cr.getChartAdditionalOptions().getChartMultiplePieOrder());
+ if (nvl(cr.getChartAdditionalOptions().getChartMultiplePieLabelDisplay()).length() > 0)
+ chartAdditionalOptions.setChartMultiplePieLabelDisplay(
+ cr.getChartAdditionalOptions().getChartMultiplePieLabelDisplay());
+
+ if (nvl(cr.getChartAdditionalOptions().getChartOrientation()).length() > 0)
+ chartAdditionalOptions.setChartOrientation(cr.getChartAdditionalOptions().getChartOrientation());
+ if (nvl(cr.getChartAdditionalOptions().getSecondaryChartRenderer()).length() > 0)
+ chartAdditionalOptions
+ .setSecondaryChartRenderer(cr.getChartAdditionalOptions().getSecondaryChartRenderer());
+
+ if (nvl(cr.getChartAdditionalOptions().getChartDisplay()).length() > 0)
+ chartAdditionalOptions.setChartDisplay(cr.getChartAdditionalOptions().getChartDisplay());
+ if (nvl(cr.getChartAdditionalOptions().getHideToolTips()).length() > 0)
+ chartAdditionalOptions.setHideToolTips(cr.getChartAdditionalOptions().getHideToolTips());
+ if (nvl(cr.getChartAdditionalOptions().getHidechartLegend()).length() > 0)
+ chartAdditionalOptions.setHidechartLegend(cr.getChartAdditionalOptions().getHidechartLegend());
+ if (nvl(cr.getChartAdditionalOptions().getLegendPosition()).length() > 0)
+ chartAdditionalOptions.setLegendPosition(cr.getChartAdditionalOptions().getLegendPosition());
+ if (nvl(cr.getChartAdditionalOptions().getLabelAngle()).length() > 0)
+ chartAdditionalOptions.setLabelAngle(cr.getChartAdditionalOptions().getLabelAngle());
+
+ if (nvl(cr.getChartAdditionalOptions().getIntervalFromdate()).length() > 0)
+ chartAdditionalOptions.setIntervalFromdate(cr.getChartAdditionalOptions().getIntervalFromdate());
+ if (nvl(cr.getChartAdditionalOptions().getIntervalTodate()).length() > 0)
+ chartAdditionalOptions.setIntervalTodate(cr.getChartAdditionalOptions().getIntervalTodate());
+ if (nvl(cr.getChartAdditionalOptions().getIntervalLabel()).length() > 0)
+ chartAdditionalOptions.setIntervalLabel(cr.getChartAdditionalOptions().getIntervalLabel());
+
+ if (nvl(cr.getChartAdditionalOptions().getLastSeriesALineChart()).length() > 0)
+ chartAdditionalOptions
+ .setLastSeriesALineChart(cr.getChartAdditionalOptions().getLastSeriesALineChart());
+ if (nvl(cr.getChartAdditionalOptions().getLastSeriesABarChart()).length() > 0)
+ chartAdditionalOptions
+ .setLastSeriesABarChart(cr.getChartAdditionalOptions().getLastSeriesABarChart());
+
+ if (nvl(cr.getChartAdditionalOptions().getMaxLabelsInDomainAxis()).length() > 0)
+ chartAdditionalOptions
+ .setMaxLabelsInDomainAxis(cr.getChartAdditionalOptions().getMaxLabelsInDomainAxis());
+ if (nvl(cr.getChartAdditionalOptions().getLinearRegression()).length() > 0)
+ chartAdditionalOptions.setLinearRegression(cr.getChartAdditionalOptions().getLinearRegression());
+ if (nvl(cr.getChartAdditionalOptions().getLinearRegressionColor()).length() > 0)
+ chartAdditionalOptions
+ .setLinearRegressionColor(cr.getChartAdditionalOptions().getLinearRegressionColor());
+ if (nvl(cr.getChartAdditionalOptions().getExponentialRegressionColor()).length() > 0)
+ chartAdditionalOptions.setExponentialRegressionColor(
+ cr.getChartAdditionalOptions().getExponentialRegressionColor());
+ if (nvl(cr.getChartAdditionalOptions().getMaxRegression()).length() > 0)
+ chartAdditionalOptions.setMaxRegression(cr.getChartAdditionalOptions().getMaxRegression());
+ if (nvl(cr.getChartAdditionalOptions().getRangeAxisUpperLimit()).length() > 0)
+ chartAdditionalOptions
+ .setRangeAxisUpperLimit(cr.getChartAdditionalOptions().getRangeAxisUpperLimit());
+ if (nvl(cr.getChartAdditionalOptions().getRangeAxisLowerLimit()).length() > 0)
+ chartAdditionalOptions
+ .setRangeAxisLowerLimit(cr.getChartAdditionalOptions().getRangeAxisLowerLimit());
+ if (nvl(cr.getChartAdditionalOptions().getOverlayItemValueOnStackBar()).length() > 0)
+ chartAdditionalOptions.setOverlayItemValueOnStackBar(
+ cr.getChartAdditionalOptions().getOverlayItemValueOnStackBar());
+ chartAdditionalOptions.setAnimate((cr.getChartAdditionalOptions().isAnimate() != null
+ && cr.getChartAdditionalOptions().isAnimate().booleanValue()) ? true : false);
+
+ if (nvl(cr.getChartAdditionalOptions().getKeepDomainAxisValueAsString()).length() > 0)
+ chartAdditionalOptions.setKeepDomainAxisValueAsString(
+ cr.getChartAdditionalOptions().getKeepDomainAxisValueAsString());
+
+ // Animate
+ chartAdditionalOptions
+ .setAnimateAnimatedChart((cr.getChartAdditionalOptions().isAnimateAnimatedChart() != null
+ && cr.getChartAdditionalOptions().isAnimateAnimatedChart().booleanValue()) ? true
+ : false);
+ chartAdditionalOptions.setStacked((cr.getChartAdditionalOptions().isStacked() != null
+ && cr.getChartAdditionalOptions().isStacked().booleanValue()) ? true : false);
+ chartAdditionalOptions.setBarControls((cr.getChartAdditionalOptions().isBarControls() != null
+ && cr.getChartAdditionalOptions().isBarControls().booleanValue()) ? true : false);
+ chartAdditionalOptions.setXAxisDateType((cr.getChartAdditionalOptions().isXAxisDateType() != null
+ && cr.getChartAdditionalOptions().isXAxisDateType().booleanValue()) ? true : false);
+ chartAdditionalOptions.setLessXaxisTickers((cr.getChartAdditionalOptions().isLessXaxisTickers() != null
+ && cr.getChartAdditionalOptions().isLessXaxisTickers().booleanValue()) ? true : false);
+ chartAdditionalOptions.setTimeAxis((cr.getChartAdditionalOptions().isTimeAxis() != null
+ && cr.getChartAdditionalOptions().isTimeAxis().booleanValue()) ? true : false);
+
+ if (nvl(cr.getChartAdditionalOptions().getTimeSeriesRender()).length() > 0)
+ chartAdditionalOptions.setTimeSeriesRender(cr.getChartAdditionalOptions().getTimeSeriesRender());
+
+ chartAdditionalOptions.setMultiSeries((cr.getChartAdditionalOptions().isMultiSeries() != null
+ && cr.getChartAdditionalOptions().isMultiSeries().booleanValue()) ? true : false);
+
+ chartAdditionalOptions.setTopMargin(cr.getChartAdditionalOptions().getTopMargin() != null
+ ? cr.getChartAdditionalOptions().getTopMargin()
+ : new Integer(30));
+ chartAdditionalOptions.setBottomMargin(cr.getChartAdditionalOptions().getBottomMargin() != null
+ ? cr.getChartAdditionalOptions().getBottomMargin()
+ : new Integer(50));
+ chartAdditionalOptions.setLeftMargin(cr.getChartAdditionalOptions().getLeftMargin() != null
+ ? cr.getChartAdditionalOptions().getLeftMargin()
+ : new Integer(100));
+ chartAdditionalOptions.setRightMargin(cr.getChartAdditionalOptions().getRightMargin() != null
+ ? cr.getChartAdditionalOptions().getRightMargin()
+ : new Integer(60));
+
+ ncr.setChartAdditionalOptions(chartAdditionalOptions);
+ } // if
+
+ if (nvl(cr.getJavascriptElement()).length() > 0)
+ ncr.setJavascriptElement(cr.getJavascriptElement());
+ if (nvl(cr.getFolderId()).length() > 0)
+ ncr.setFolderId(cr.getFolderId());
+
+ if (cr.getChartDrillOptions() != null) {
+ ChartDrillOptions chartDrillOptions = objFactory.createChartDrillOptions();
+
+ if (nvl(cr.getChartDrillOptions().getDrillReportId()).length() > 0)
+ chartDrillOptions.setDrillReportId(cr.getChartDrillOptions().getDrillReportId());
+
+ for (Iterator iter = cr.getChartDrillOptions().getTargetFormfield().iterator(); iter
+ .hasNext();) {
+ chartDrillOptions.getTargetFormfield().add(
+ cloneChartDrillFormfield(objFactory, (ChartDrillFormfield) iter.next()));
+
+ }
+
+ if (nvl(cr.getChartDrillOptions().getDrillXAxisFormField()).length() > 0)
+ chartDrillOptions.setDrillXAxisFormField(cr.getChartDrillOptions().getDrillXAxisFormField());
+ if (nvl(cr.getChartDrillOptions().getDrillYAxisFormField()).length() > 0)
+ chartDrillOptions.setDrillYAxisFormField(cr.getChartDrillOptions().getDrillYAxisFormField());
+ if (nvl(cr.getChartDrillOptions().getDrillSeriesFormField()).length() > 0)
+ chartDrillOptions.setDrillSeriesFormField(cr.getChartDrillOptions().getDrillSeriesFormField());
+
+ ncr.setChartDrillOptions(chartDrillOptions);
+ }
+
+ if (nvl(cr.getIsOneTimeScheduleAllowed()).length() > 0)
+ ncr.setIsOneTimeScheduleAllowed(cr.getIsOneTimeScheduleAllowed());
+ if (nvl(cr.getIsHourlyScheduleAllowed()).length() > 0)
+ ncr.setIsHourlyScheduleAllowed(cr.getIsHourlyScheduleAllowed());
+ if (nvl(cr.getIsDailyScheduleAllowed()).length() > 0)
+ ncr.setIsDailyScheduleAllowed(cr.getIsDailyScheduleAllowed());
+ if (nvl(cr.getIsDailyMFScheduleAllowed()).length() > 0)
+ ncr.setIsDailyMFScheduleAllowed(cr.getIsDailyMFScheduleAllowed());
+ if (nvl(cr.getIsWeeklyScheduleAllowed()).length() > 0)
+ ncr.setIsWeeklyScheduleAllowed(cr.getIsWeeklyScheduleAllowed());
+ if (nvl(cr.getIsMonthlyScheduleAllowed()).length() > 0)
+ ncr.setIsMonthlyScheduleAllowed(cr.getIsMonthlyScheduleAllowed());
+
+ ncr.setPageSize(cr.getPageSize());
+ ncr.setReportType(cr.getReportType());
+
+ if (cr.getReportMap() != null) {
+ ReportMap repMap = objFactory.createReportMap();
+ if (nvl(cr.getReportMap().getMarkerColor()).length() > 0)
+ repMap.setMarkerColor(cr.getReportMap().getMarkerColor());
+ if (nvl(cr.getReportMap().getUseDefaultSize()).length() > 0)
+ repMap.setUseDefaultSize(cr.getReportMap().getUseDefaultSize());
+ if (nvl(cr.getReportMap().getHeight()).length() > 0)
+ repMap.setHeight(cr.getReportMap().getHeight());
+ if (nvl(cr.getReportMap().getWidth()).length() > 0)
+ repMap.setWidth(cr.getReportMap().getWidth());
+ if (nvl(cr.getReportMap().getIsMapAllowedYN()).length() > 0)
+ repMap.setIsMapAllowedYN(cr.getReportMap().getIsMapAllowedYN());
+ if (nvl(cr.getReportMap().getAddAddressInDataYN()).length() > 0)
+ repMap.setAddAddressInDataYN(cr.getReportMap().getAddAddressInDataYN());
+ if (nvl(cr.getReportMap().getAddressColumn()).length() > 0)
+ repMap.setAddressColumn(cr.getReportMap().getAddressColumn());
+ if (nvl(cr.getReportMap().getDataColumn()).length() > 0)
+ repMap.setDataColumn(cr.getReportMap().getDataColumn());
+ if (nvl(cr.getReportMap().getDefaultMapType()).length() > 0)
+ repMap.setDefaultMapType(cr.getReportMap().getDefaultMapType());
+ if (nvl(cr.getReportMap().getLatColumn()).length() > 0)
+ repMap.setLatColumn(cr.getReportMap().getLatColumn());
+ if (nvl(cr.getReportMap().getLongColumn()).length() > 0)
+ repMap.setLongColumn(cr.getReportMap().getLongColumn());
+ if (nvl(cr.getReportMap().getColorColumn()).length() > 0)
+ repMap.setColorColumn(cr.getReportMap().getColorColumn());
+ if (nvl(cr.getReportMap().getLegendColumn()).length() > 0)
+ repMap.setLegendColumn(cr.getReportMap().getLegendColumn());
+
+ for (Iterator iter = cr.getReportMap().getMarkers().iterator(); iter
+ .hasNext();) {
+ repMap.getMarkers().add(
+ cloneMarkerType(objFactory, (Marker) iter.next()));
+
+ }
+
+ ncr.setReportMap(repMap);
+ }
+
+ } catch (JAXBException ex) { // try
+ logger.error(EELFLoggerDelegate.debugLogger, "Exception occured in cloneCustomReport ", ex);
+ throw new RaptorException(ex.getMessage(), ex.getCause());
+ }
+
+ return ncr;
+ } // cloneCustomReport
+
+ /**
+ * *************************************************************************************************
+ */
+
+ // public void printFormatType(FormatType ft) {
+ // System.out.println("------------------------------------------------");
+ // System.out.println("Semaphore Col Format");
+ // System.out.println("------------------------------------------------");
+ // System.out.println("FormatId: [" + ft.getFormatId() + "]");
+ // System.out.println("LessThanValue: [" + ft.getLessThanValue() + "]");
+ // System.out.println("Expression: [" + ft.getExpression() + "]");
+ // System.out.println("Bold: [" + ft.isBold() + "]");
+ // System.out.println("Italic: [" + ft.isItalic() + "]");
+ // System.out.println("Underline: [" + ft.isUnderline() + "]");
+ // System.out.println("BgColor: [" + ft.getBgColor() + "]");
+ // System.out.println("FontColor: [" + ft.getFontColor() + "]");
+ // System.out.println("FontFace: [" + ft.getFontFace() + "]");
+ // System.out.println("FontSize: [" + ft.getFontSize() + "]");
+ // System.out.println("Alignment: [" + ft.getAlignment() + "]");
+ // System.out.println("Comment: [" + ft.getComment() + "]");
+ // System.out.println("------------------------------------------------");
+ // } // printFormatType
+
+ // public void printSemaphoreType(SemaphoreType st) {
+ // System.out.println("------------------------------------------------");
+ // System.out.println("Semaphore");
+ // System.out.println("------------------------------------------------");
+ // System.out.println("SemaphoreId: [" + st.getSemaphoreId() + "]");
+ // System.out.println("SemaphoreName: [" + st.getSemaphoreName() + "]");
+ // System.out.println("SemaphoreType: [" + st.getSemaphoreType() + "]");
+ // System.out.println("Comment: [" + st.getComment() + "]");
+ //
+ // if (st.getFormatList() != null)
+ // for (Iterator iter = st.getFormatList().getFormat().iterator(); iter.hasNext();)
+ // printFormatType((FormatType) iter.next());
+ //
+ // System.out.println("------------------------------------------------");
+ // } // printSemaphoreType
+
+ // public void printFormFieldType(FormFieldType fft) {
+ // System.out.println("------------------------------------------------");
+ // System.out.println("Form Field");
+ // System.out.println("------------------------------------------------");
+ // System.out.println("FieldId: [" + fft.getFieldId() + "]");
+ // System.out.println("ColId: [" + fft.getColId() + "]");
+ // System.out.println("FieldName: [" + fft.getFieldName() + "]");
+ // System.out.println("FieldType: [" + fft.getFieldType() + "]");
+ // System.out.println("ValidationType: [" + fft.getValidationType() + "]");
+ // System.out.println("Mandatory: [" + fft.getMandatory() + "]");
+ // System.out.println("DefaultValue: [" + fft.getDefaultValue() + "]");
+ // System.out.println("OrderBySeq: [" + fft.getOrderBySeq() + "]");
+ // System.out.println("FieldSQL: [" + fft.getFieldSQL() + "]");
+ // System.out.println("Comment: [" + fft.getComment() + "]");
+ // if (fft.getPredefinedValueList() != null)
+ // for (Iterator iter = fft.getPredefinedValueList().getPredefinedValue().iterator(); iter
+ // .hasNext();)
+ // System.out.println("PredefinedValues: [" + ((String) iter.next()) + "]");
+ //
+ // System.out.println("------------------------------------------------");
+ // } // printFormFieldType
+
+ // public void printColFilterType(ColFilterType cft) {
+ // System.out.println("------------------------------------------------");
+ // System.out.println("Col Filter");
+ // System.out.println("------------------------------------------------");
+ // System.out.println("ColId: [" + cft.getColId() + "]");
+ // System.out.println("FilterSeq: [" + cft.getFilterSeq() + "]");
+ // System.out.println("JoinCondition: [" + cft.getJoinCondition() + "]");
+ // System.out.println("OpenBrackets: [" + cft.getOpenBrackets() + "]");
+ // System.out.println("Expression: [" + cft.getExpression() + "]");
+ // System.out.println("ArgType: [" + cft.getArgType() + "]");
+ // System.out.println("ArgValue: [" + cft.getArgValue() + "]");
+ // System.out.println("CloseBrackets: [" + cft.getCloseBrackets() + "]");
+ // System.out.println("Comment: [" + cft.getComment() + "]");
+ // System.out.println("------------------------------------------------");
+ // } // printColFilterType
+
+ // public void printDataColumnType(DataColumnType dct) {
+ // System.out.println("------------------------------------------------");
+ // System.out.println("Data Column");
+ // System.out.println("------------------------------------------------");
+ // System.out.println("ColId: [" + dct.getColId() + "]");
+ // System.out.println("TableId: [" + dct.getTableId() + "]");
+ // System.out.println("DbColName: [" + dct.getDbColName() + "]");
+ // System.out.println("CrossTabValue: [" + dct.getCrossTabValue() + "]");
+ // System.out.println("ColName: [" + dct.getColName() + "]");
+ // System.out.println("DisplayName: [" + dct.getDisplayName() + "]");
+ // System.out.println("DisplayWidth: [" + dct.getDisplayWidth() + "]");
+ // System.out.println("DisplayAlignment: [" + dct.getDisplayAlignment() + "]");
+ // System.out.println("DisplayHeaderAlignment: [" + dct.getDisplayHeaderAlignment() + "]");
+ // System.out.println("OrderSeq(): [" + dct.getOrderSeq() + "]");
+ // System.out.println("Visible: [" + dct.isVisible() + "]");
+ // System.out.println("Calculated: [" + dct.isCalculated() + "]");
+ // System.out.println("ColType: [" + dct.getColType() + "]");
+ // System.out.println("ColFormat: [" + dct.getColFormat() + "]");
+ // System.out.println("GroupBreak: [" + dct.isGroupBreak() + "]");
+ // System.out.println("OrderBySeq: [" + dct.getOrderBySeq() + "]");
+ // System.out.println("OrderByAscDesc: [" + dct.getOrderByAscDesc() + "]");
+ // System.out.println("DisplayTotal: [" + dct.getDisplayTotal() + "]");
+ // System.out.println("ColOnChart: [" + dct.getColOnChart() + "]");
+ // System.out.println("ChartSeq: [" + dct.getChartSeq() + "]");
+ // System.out.println("ChartColor: [" + dct.getChartColor() + "]");
+ // System.out.println("DrillDownType: [" + dct.getDrillDownType() + "]");
+ // System.out.println("DrillDownURL: [" + dct.getDrillDownURL() + "]");
+ // System.out.println("DrillDownParams: [" + dct.getDrillDownParams() + "]");
+ // System.out.println("Comment: [" + dct.getComment() + "]");
+ //
+ // if (dct.getColFilterList() != null)
+ // for (Iterator iter = dct.getColFilterList().getColFilter().iterator(); iter
+ // .hasNext();)
+ // printColFilterType((ColFilterType) iter.next());
+ //
+ // System.out.println("SemaphoreId: [" + dct.getSemaphoreId() + "]");
+ // System.out.println("DbColType: [" + dct.getDbColType() + "]");
+ // System.out.println("------------------------------------------------");
+ // } // printDataColumnType
+
+ // public void printDataSourceType(DataSourceType dst) {
+ // System.out.println("------------------------------------------------");
+ // System.out.println("Data Source");
+ // System.out.println("------------------------------------------------");
+ // System.out.println("TableId: [" + dst.getTableId() + "]");
+ // System.out.println("TableName: [" + dst.getTableName() + "]");
+ // System.out.println("TablePK: [" + dst.getTablePK() + "]");
+ // System.out.println("DisplayName: [" + dst.getDisplayName() + "]");
+ // System.out.println("RefTableId: [" + dst.getRefTableId() + "]");
+ // System.out.println("RefDefinition: [" + dst.getRefDefinition() + "]");
+ // System.out.println("Comment: [" + dst.getComment() + "]");
+ //
+ // for (Iterator iter = dst.getDataColumnList().getDataColumn().iterator(); iter
+ // .hasNext();)
+ // printDataColumnType((DataColumnType) iter.next());
+ //
+ // System.out.println("------------------------------------------------");
+ // } // printDataSourceType
+
+ // public void print() {
+ // System.out.println("------------------------------------------------");
+ // System.out.println("ReportWrapper object");
+ // System.out.println("------------------------------------------------");
+ // System.out.println("PageSize: [" + getPageSize() + "]");
+ // System.out.println("ReportType: [" + getReportType() + "]");
+ // System.out.println("ReportName: [" + getReportName() + "]");
+ // System.out.println("ReportDescr: [" + getReportDescr() + "]");
+ // System.out.println("ChartType: [" + getChartType() + "]");
+ // System.out.println("ChartTypeFixed: [" + getChartTypeFixed() + "]");
+ // //System.out.println("ChartLeftAxisLabel: [" + getChartLeftAxisLabel() + "]");
+ // //System.out.println("ChartRightAxisLabel: [" + getChartRightAxisLabel() + "]");
+ // System.out.println("ChartWidth: [" + getChartWidth() + "]");
+ // System.out.println("ChartHeight: [" + getChartHeight() + "]");
+ // System.out.println("Public: [" + isPublic() + "]");
+ // System.out.println("CreateId: NOT USED ANYMORE[" + /* getCreateId()+ */"]");
+ // System.out.println("CreateDate: NOT USED ANYMORE[" + /* getCreateDate()+ */"]");
+ // System.out.println("ReportSQL: [" + getReportSQL() + "]");
+ // System.out.println("ReportTitle: [" + getReportTitle() + "]");
+ // System.out.println("DbInfo: [" + getDBInfo() + "]");
+ // System.out.println("ReportSubTitle: [" + getReportSubTitle() + "]");
+ // System.out.println("ReportHeader: [" + getReportHeader() + "]");
+ // System.out.println("ReportFooter: [" + getReportFooter() + "]");
+ // System.out.println("NumFormCols: [" + getNumFormCols() + "]");
+ // System.out.println("DisplayOptions: [" + getDisplayOptions() + "]");
+ // System.out.println("Comment: [" + getComment() + "]");
+ //
+ // for (Iterator iter = cr.getDataSourceList().getDataSource().iterator(); iter.hasNext();)
+ // printDataSourceType((DataSourceType) iter.next());
+ //
+ // if (cr.getFormFieldList() != null)
+ // for (Iterator iter = cr.getFormFieldList().getFormField().iterator(); iter
+ // .hasNext();)
+ // printFormFieldType((FormFieldType) iter.next());
+ //
+ // if (cr.getSemaphoreList() != null)
+ // for (Iterator iter = cr.getSemaphoreList().getSemaphore().iterator(); iter
+ // .hasNext();)
+ // printSemaphoreType((SemaphoreType) iter.next());
+ //
+ // System.out.println("------------------------------------------------");
+ // System.out.println("ReportWrapper object end");
+ // System.out.println("------------------------------------------------");
+ // } // print
+
+ private int getIntValue(String value, int defaultValue) {
+ int iValue = defaultValue;
+ try {
+ iValue = Integer.parseInt(value);
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.debugLogger, "Exception occured in getIntValue ", e);
+ }
+
+ return iValue;
+ } // getIntValue
+
+ public static String replaceNewLine(String strSource, String strFind, String chrReplace) {
// buffer to hold the target string after replacement is done.
StringBuffer sbfTemp = new StringBuffer();
- try
- {
+ try {
// for each occurrence of strFind in strSource, replace it with chrReplace.
- int intIndex = strSource.indexOf( strFind, 0 );
+ int intIndex = strSource.indexOf(strFind, 0);
// check if there is any instace of strFind in strSource
- if( intIndex >= 0 )
- {
+ if (intIndex >= 0) {
// holds the index from where the search is supposed to happen.
int intStart = 0;
// size of the source string
int intTotalSize = strSource.length();
- while( intStart < intTotalSize &&
- ( ( intIndex = strSource.indexOf( strFind, intStart ) ) >= 0 ) )
- {
+ while (intStart < intTotalSize &&
+ ((intIndex = strSource.indexOf(strFind, intStart)) >= 0)) {
// check if strFind is at the beginning... i.e., at index intStart
- if( intIndex == intStart )
- {
+ if (intIndex == intStart) {
/*
- * starts with strFind...just append chrReplace
- * to the target
+ * starts with strFind...just append chrReplace to the target
*/
- sbfTemp.append( chrReplace );
- }
- else
- {
+ sbfTemp.append(chrReplace);
+ } else {
// append the sub-string...plus chrReplace
- sbfTemp.append( strSource.substring( intStart, intIndex ) );
- sbfTemp.append( chrReplace );
+ sbfTemp.append(strSource.substring(intStart, intIndex));
+ sbfTemp.append(chrReplace);
}
// advance string index
@@ -5428,314 +5679,315 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject {
}
// append the last portion of the source string.
- sbfTemp.append( strSource.substring( intStart ) );
- }
- else
- {
+ sbfTemp.append(strSource.substring(intStart));
+ } else {
// strFind not found... just copy the text as it is.
- sbfTemp.append( strSource );
+ sbfTemp.append(strSource);
}
- }
- catch( Exception expGeneral )
- {
+ } catch (Exception expGeneral) {
+ logger.error(EELFLoggerDelegate.debugLogger, "Exception occured in replaceNewLine ", expGeneral);
// in case of any exception, return the source string as it is.
- sbfTemp = new StringBuffer( strSource );
+ sbfTemp = new StringBuffer(strSource);
}
return sbfTemp.toString();
}
-
- /*folder id*/
+
+ /* folder id */
public String getFolderId() {
- return nvl(cr.getFolderId()).length()>0?cr.getFolderId():"NULL";
- }
- public void setFolderId(String folderId ) {
- cr.setFolderId(folderId);
- }
-
+ return nvl(cr.getFolderId()).length() > 0 ? cr.getFolderId() : "NULL";
+ }
+
+ public void setFolderId(String folderId) {
+ cr.setFolderId(folderId);
+ }
+
public String addZero(String num) {
- int numInt = 0;
- try {
- numInt = Integer.parseInt(num);
- }catch(NumberFormatException ex){
- numInt = 0;
- }
- if(numInt < 10) return "0"+numInt;
- else return ""+numInt;
- }
-
- public String getIsDailyMFScheduleAllowed() {
- return cr.getIsDailyMFScheduleAllowed();
- }
-
- public void setIsDailyMFScheduleAllowed(String isDailyMFScheduleAllowed) {
- cr.setIsDailyMFScheduleAllowed(isDailyMFScheduleAllowed);
- }
-
- public String getIsDailyScheduleAllowed() {
- return cr.getIsDailyScheduleAllowed();
- }
-
- public void setIsDailyScheduleAllowed(String isDailyScheduleAllowed) {
- cr.setIsDailyScheduleAllowed(isDailyScheduleAllowed);
- }
-
- public String getIsHourlyScheduleAllowed() {
- return cr.getIsHourlyScheduleAllowed();
- }
-
- public void setIsHourlyScheduleAllowed(String isHourlyScheduleAllowed) {
- cr.setIsHourlyScheduleAllowed(isHourlyScheduleAllowed);
- }
-
- public String getIsMonthlyScheduleAllowed() {
- return cr.getIsMonthlyScheduleAllowed();
- }
-
- public void setIsMonthlyScheduleAllowed(String isMonthlyScheduleAllowed) {
- cr.setIsMonthlyScheduleAllowed(isMonthlyScheduleAllowed);
- }
-
- public String getIsOneTimeScheduleAllowed() {
- return cr.getIsOneTimeScheduleAllowed();
- }
-
- public void setIsOneTimeScheduleAllowed(String isOneTimeScheduleAllowed) {
- cr.setIsOneTimeScheduleAllowed(isOneTimeScheduleAllowed);
- }
-
- public String getIsWeeklyScheduleAllowed() {
- return cr.getIsWeeklyScheduleAllowed();
- }
-
- public void setIsWeeklyScheduleAllowed(String isWeeklyScheduleAllowed) {
- cr.setIsWeeklyScheduleAllowed(isWeeklyScheduleAllowed);
-
- }
-
- public static boolean isNull(String a) {
- if ((a == null) || (a.length() == 0) || a.equalsIgnoreCase("null"))
- return true;
- else
- return false;
- }
-
- public int getDependsOnFormFieldFlag(DataColumnType dc, HashMap formValues) {
- int flag = 0;
- String fieldValue = "";
- if(nvl(dc.getDependsOnFormField()).length()>0 && nvl(dc.getDependsOnFormField()).indexOf("[")!=-1) {
- if(formValues != null) {
- Set set = formValues.entrySet();
- String value = "";
- for(Iterator iter1 = set.iterator(); iter1.hasNext(); ) {
- Map.Entry entry = (Entry) iter1.next();
- value = (String) entry.getValue();
- if (dc.getDependsOnFormField().equals("["+entry.getKey()+"]")) {
- fieldValue = nvl(value);
-
- if (fieldValue.length()>0 && !fieldValue.equals("NULL")) {
- flag = 0;
- } else {
- flag = 1;
- }
-
- }
- }
- }
- }
-
- return flag;
- }
-
- /* Datamining Getter Setter */
-
- public String getClassifier() {
- return (cr.getDataminingOptions()!=null?cr.getDataminingOptions().getClassifier():"");
- }
-
- public void setClassifier( String classifier) {
- cr.getDataminingOptions().setClassifier(classifier);
- }
-
-
- public int getForecastingPeriod() {
- return (cr.getDataminingOptions()!=null? new Integer(cr.getDataminingOptions().getForecastingUnits()).intValue():-1);
- }
-
- public void setForecastingPeriod( String period) {
- cr.getDataminingOptions().setForecastingUnits(period);
- }
-
- public String getForecastingTimeFormat() {
- return (cr.getDataminingOptions()!=null?cr.getDataminingOptions().getTimeformat():"");
- }
-
- public void setForecastingTimeFormat( String format) {
- cr.getDataminingOptions().setTimeformat(format);
- }
-
- /**
- * Get Number of Columns to Frozen in Data Grid
- */
-
- public int getFrozenColumns() {
- return cr.getFrozenColumns()==null?0:cr.getFrozenColumns();
- }
-
- public String getFrozenColumnId() {
- int noOfColumns = cr.getFrozenColumns()==null?0:cr.getFrozenColumns();
- if(noOfColumns != 0) {
- List reportCols = getOnlyVisibleColumns();
- int colIdx = 0;
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- ++colIdx;
- DataColumnType dc = (DataColumnType) iter.next();
- if(colIdx == noOfColumns) {
-
- return dc.getColId();
- } else continue;
- } // for
- return "";
- } else return "";
-
- }
-
- /**
- * Set Number of Columns to Frozen in Data Grid
- */
-
- public void setFrozenColumns( int frozenColumns) {
- cr.setFrozenColumns(frozenColumns);
- }
-
- /**
- * @return the reportSQLWithRowNum for ZK Support
- */
- public String getReportSQLWithRowNum() {
- return reportSQLWithRowNum;
- }
-
- /**
- * @param reportSQLWithRowNum the reportSQLWithRowNum to set for ZK Support
- */
- public void setReportSQLWithRowNum(String reportSQLWithRowNum) {
- this.reportSQLWithRowNum = reportSQLWithRowNum;
- }
-
- //used for Zk sort
- public void setReportSQLOnlyFirstPart(String reportSQLOnlyFirstPart) {
- this.reportSQLOnlyFirstPart = reportSQLOnlyFirstPart;
- }
-
- public String getReportSQLOnlyFirstPart() {
- return this.reportSQLOnlyFirstPart;
- }
-
- public String getTemplateFile() throws RaptorException {
- return ReportLoader.getTemplateFile(getReportID());
- }
-
- public String getPdfImg() {
- return cr.getPdfImgLogo();
- }
-
-
- public String getEmptyMessage() {
- String emptyMessage = cr.getEmptyMessage();
- if(nvl(emptyMessage).length()<=0)
- emptyMessage = Globals.getReportEmptyMessage();
- return emptyMessage;
- }
-
- public void setPdfImg(String img_loc) {
- cr.setPdfImgLogo(img_loc);
- }
-
- public void setEmptyMessage(String emptyMessage) {
- cr.setEmptyMessage(emptyMessage);
- }
-
- public void setDrillReportIdForChart(String reportId) {
- //(cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().setDrillReportId():"";
- cr.getChartDrillOptions().setDrillReportId(reportId);
- }
-
- public String getDrillReportIdForChart() {
- return (cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().getDrillReportId():"";
- }
-
- public void setDrillXAxisFormField(String formField) {
- //(cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().setDrillReportId():"";
- cr.getChartDrillOptions().setDrillXAxisFormField(formField);
- }
-
- public String getDrillXAxisFormField() {
- return (cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().getDrillXAxisFormField():"";
- }
-
- public void setDrillYAxisFormField(String formField) {
- //(cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().setDrillReportId():"";
- cr.getChartDrillOptions().setDrillYAxisFormField(formField);
- }
-
- public String getDrillYAxisFormField() {
- return (cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().getDrillYAxisFormField():"";
- }
-
- public void setDrillSeriesFormField(String formField) {
- //(cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().setDrillReportId():"";
- cr.getChartDrillOptions().setDrillSeriesFormField(formField);
- }
-
- public String getDrillSeriesFormField() {
- return (cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().getDrillSeriesFormField():"";
- }
-
- public boolean isEnhancedPaginationNeeded() {
- List reportCols = getAllColumns();
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if (dc.isEnhancedPagination()!=null && dc.isEnhancedPagination().booleanValue())
- return true;
- } // for
- return false;
- }
-
- public DataColumnType getColumnWhichNeedEnhancedPagination() {
- List reportCols = getAllColumns();
-
- for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dc = (DataColumnType) iter.next();
- if (dc.isEnhancedPagination()!=null && dc.isEnhancedPagination().booleanValue())
- return dc;
- } // for
- return null;
- }
-
- public void setDataGridAlign(String align) {
- cr.setDataGridAlign(align);
- }
-
-
- public String getDataGridAlign() {
- return (cr.getDataGridAlign()!=null)?cr.getDataGridAlign():"left";
- }
-
- public void setWidthNoColumn(String width) {
- cr.setWidthNoColumn(width);
- }
-
-
- public String getWidthNoColumn() {
- return (cr.getWidthNoColumn()!=null)?cr.getWidthNoColumn():"30px";
- }
-
+ int numInt = 0;
+ try {
+ numInt = Integer.parseInt(num);
+ } catch (NumberFormatException ex) {
+ numInt = 0;
+ }
+ if (numInt < 10)
+ return "0" + numInt;
+ else
+ return "" + numInt;
+ }
+
+ public String getIsDailyMFScheduleAllowed() {
+ return cr.getIsDailyMFScheduleAllowed();
+ }
+
+ public void setIsDailyMFScheduleAllowed(String isDailyMFScheduleAllowed) {
+ cr.setIsDailyMFScheduleAllowed(isDailyMFScheduleAllowed);
+ }
+
+ public String getIsDailyScheduleAllowed() {
+ return cr.getIsDailyScheduleAllowed();
+ }
+
+ public void setIsDailyScheduleAllowed(String isDailyScheduleAllowed) {
+ cr.setIsDailyScheduleAllowed(isDailyScheduleAllowed);
+ }
+
+ public String getIsHourlyScheduleAllowed() {
+ return cr.getIsHourlyScheduleAllowed();
+ }
+
+ public void setIsHourlyScheduleAllowed(String isHourlyScheduleAllowed) {
+ cr.setIsHourlyScheduleAllowed(isHourlyScheduleAllowed);
+ }
+
+ public String getIsMonthlyScheduleAllowed() {
+ return cr.getIsMonthlyScheduleAllowed();
+ }
+
+ public void setIsMonthlyScheduleAllowed(String isMonthlyScheduleAllowed) {
+ cr.setIsMonthlyScheduleAllowed(isMonthlyScheduleAllowed);
+ }
+
+ public String getIsOneTimeScheduleAllowed() {
+ return cr.getIsOneTimeScheduleAllowed();
+ }
+
+ public void setIsOneTimeScheduleAllowed(String isOneTimeScheduleAllowed) {
+ cr.setIsOneTimeScheduleAllowed(isOneTimeScheduleAllowed);
+ }
+
+ public String getIsWeeklyScheduleAllowed() {
+ return cr.getIsWeeklyScheduleAllowed();
+ }
+
+ public void setIsWeeklyScheduleAllowed(String isWeeklyScheduleAllowed) {
+ cr.setIsWeeklyScheduleAllowed(isWeeklyScheduleAllowed);
+
+ }
+
+ public static boolean isNull(String a) {
+ if ((a == null) || (a.length() == 0) || "null".equalsIgnoreCase(a))
+ return true;
+ else
+ return false;
+ }
+
+ public int getDependsOnFormFieldFlag(DataColumnType dc, HashMap formValues) {
+ int flag = 0;
+ String fieldValue = "";
+ if (nvl(dc.getDependsOnFormField()).length() > 0 && nvl(dc.getDependsOnFormField()).indexOf("[") != -1) {
+ if (formValues != null) {
+ Set set = formValues.entrySet();
+ String value = "";
+ for (Iterator iter1 = set.iterator(); iter1.hasNext();) {
+ Map.Entry entry = (Entry) iter1.next();
+ value = (String) entry.getValue();
+ if (dc.getDependsOnFormField().equals("[" + entry.getKey() + "]")) {
+ fieldValue = nvl(value);
+
+ if (fieldValue.length() > 0 && !"NULL".equals(fieldValue)) {
+ flag = 0;
+ } else {
+ flag = 1;
+ }
+
+ }
+ }
+ }
+ }
+
+ return flag;
+ }
+
+ /* Datamining Getter Setter */
+
+ public String getClassifier() {
+ return (cr.getDataminingOptions() != null ? cr.getDataminingOptions().getClassifier() : "");
+ }
+
+ public void setClassifier(String classifier) {
+ cr.getDataminingOptions().setClassifier(classifier);
+ }
+
+ public int getForecastingPeriod() {
+ return (cr.getDataminingOptions() != null
+ ? new Integer(cr.getDataminingOptions().getForecastingUnits()).intValue()
+ : -1);
+ }
+
+ public void setForecastingPeriod(String period) {
+ cr.getDataminingOptions().setForecastingUnits(period);
+ }
+
+ public String getForecastingTimeFormat() {
+ return (cr.getDataminingOptions() != null ? cr.getDataminingOptions().getTimeformat() : "");
+ }
+
+ public void setForecastingTimeFormat(String format) {
+ cr.getDataminingOptions().setTimeformat(format);
+ }
+
+ /**
+ * Get Number of Columns to Frozen in Data Grid
+ */
+
+ public int getFrozenColumns() {
+ return cr.getFrozenColumns() == null ? 0 : cr.getFrozenColumns();
+ }
+
+ public String getFrozenColumnId() {
+ int noOfColumns = cr.getFrozenColumns() == null ? 0 : cr.getFrozenColumns();
+ if (noOfColumns != 0) {
+ List reportCols = getOnlyVisibleColumns();
+ int colIdx = 0;
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ ++colIdx;
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (colIdx == noOfColumns) {
+
+ return dc.getColId();
+ } else
+ continue;
+ } // for
+ return "";
+ } else
+ return "";
+
+ }
+
+ /**
+ * Set Number of Columns to Frozen in Data Grid
+ */
+
+ public void setFrozenColumns(int frozenColumns) {
+ cr.setFrozenColumns(frozenColumns);
+ }
+
+ /**
+ * @return the reportSQLWithRowNum for ZK Support
+ */
+ public String getReportSQLWithRowNum() {
+ return reportSQLWithRowNum;
+ }
+
+ /**
+ * @param reportSQLWithRowNum the reportSQLWithRowNum to set for ZK Support
+ */
+ public void setReportSQLWithRowNum(String reportSQLWithRowNum) {
+ this.reportSQLWithRowNum = reportSQLWithRowNum;
+ }
+
+ // used for Zk sort
+ public void setReportSQLOnlyFirstPart(String reportSQLOnlyFirstPart) {
+ this.reportSQLOnlyFirstPart = reportSQLOnlyFirstPart;
+ }
+
+ public String getReportSQLOnlyFirstPart() {
+ return this.reportSQLOnlyFirstPart;
+ }
+
+ public String getTemplateFile() throws RaptorException {
+ return ReportLoader.getTemplateFile(getReportID());
+ }
+
+ public String getPdfImg() {
+ return cr.getPdfImgLogo();
+ }
+
+ public String getEmptyMessage() {
+ String emptyMessage = cr.getEmptyMessage();
+ if (nvl(emptyMessage).length() <= 0)
+ emptyMessage = Globals.getReportEmptyMessage();
+ return emptyMessage;
+ }
+
+ public void setPdfImg(String img_loc) {
+ cr.setPdfImgLogo(img_loc);
+ }
+
+ public void setEmptyMessage(String emptyMessage) {
+ cr.setEmptyMessage(emptyMessage);
+ }
+
+ public void setDrillReportIdForChart(String reportId) {
+ // (cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().setDrillReportId():"";
+ cr.getChartDrillOptions().setDrillReportId(reportId);
+ }
+
+ public String getDrillReportIdForChart() {
+ return (cr.getChartDrillOptions() != null) ? cr.getChartDrillOptions().getDrillReportId() : "";
+ }
+
+ public void setDrillXAxisFormField(String formField) {
+ // (cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().setDrillReportId():"";
+ cr.getChartDrillOptions().setDrillXAxisFormField(formField);
+ }
+
+ public String getDrillXAxisFormField() {
+ return (cr.getChartDrillOptions() != null) ? cr.getChartDrillOptions().getDrillXAxisFormField() : "";
+ }
+
+ public void setDrillYAxisFormField(String formField) {
+ // (cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().setDrillReportId():"";
+ cr.getChartDrillOptions().setDrillYAxisFormField(formField);
+ }
+
+ public String getDrillYAxisFormField() {
+ return (cr.getChartDrillOptions() != null) ? cr.getChartDrillOptions().getDrillYAxisFormField() : "";
+ }
+
+ public void setDrillSeriesFormField(String formField) {
+ // (cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().setDrillReportId():"";
+ cr.getChartDrillOptions().setDrillSeriesFormField(formField);
+ }
+
+ public String getDrillSeriesFormField() {
+ return (cr.getChartDrillOptions() != null) ? cr.getChartDrillOptions().getDrillSeriesFormField() : "";
+ }
+
+ public boolean isEnhancedPaginationNeeded() {
+ List reportCols = getAllColumns();
+
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (dc.isEnhancedPagination() != null && dc.isEnhancedPagination().booleanValue())
+ return true;
+ } // for
+ return false;
+ }
+
+ public DataColumnType getColumnWhichNeedEnhancedPagination() {
+ List reportCols = getAllColumns();
+
+ for (Iterator iter = reportCols.iterator(); iter.hasNext();) {
+ DataColumnType dc = (DataColumnType) iter.next();
+ if (dc.isEnhancedPagination() != null && dc.isEnhancedPagination().booleanValue())
+ return dc;
+ } // for
+ return null;
+ }
+
+ public void setDataGridAlign(String align) {
+ cr.setDataGridAlign(align);
+ }
+
+ public String getDataGridAlign() {
+ return (cr.getDataGridAlign() != null) ? cr.getDataGridAlign() : "left";
+ }
+
+ public void setWidthNoColumn(String width) {
+ cr.setWidthNoColumn(width);
+ }
+
+ public String getWidthNoColumn() {
+ return (cr.getWidthNoColumn() != null) ? cr.getWidthNoColumn() : "30px";
+ }
+
public void setWholeSQL(String sql) {
wholeSQL = sql;
- }
- public String getWholeSQL() {
- return wholeSQL;
- }
-
+ }
+
+ public String getWholeSQL() {
+ return wholeSQL;
+ }
+
} // ReportWrapper
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResultJSON.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResultJSON.java
index c3fc0a7b..2bd278e4 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResultJSON.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResultJSON.java
@@ -38,12 +38,12 @@
package org.onap.portalsdk.analytics.model.search;
import java.util.ArrayList;
+import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.onap.portalsdk.analytics.error.RaptorException;
import org.onap.portalsdk.analytics.system.AppUtils;
-import org.onap.portalsdk.analytics.system.DbUtils;
import org.onap.portalsdk.analytics.system.Globals;
import org.onap.portalsdk.analytics.util.AppConstants;
import org.onap.portalsdk.analytics.util.DataSet;
@@ -102,22 +102,22 @@ class SearchReport {
this.metaReport = metaReport;
}
- private ArrayList<ArrayList<SearchResultColumn>> columns = new ArrayList<>();
- private ArrayList<ArrayList<SearchResultRow>> rows = new ArrayList<>();
+ private List<ArrayList<SearchResultColumn>> columns = new ArrayList<>();
+ private List<ArrayList<SearchResultRow>> rows = new ArrayList<>();
- public ArrayList<ArrayList<SearchResultColumn>> getColumns() {
+ public List<ArrayList<SearchResultColumn>> getColumns() {
return columns;
}
- public void setColumns(ArrayList<ArrayList<SearchResultColumn>> columns) {
+ public void setColumns(List<ArrayList<SearchResultColumn>> columns) {
this.columns = columns;
}
- public ArrayList<ArrayList<SearchResultRow>> getRows() {
+ public List<ArrayList<SearchResultRow>> getRows() {
return rows;
}
- public void setRows(ArrayList<ArrayList<SearchResultRow>> rows) {
+ public void setRows(List<ArrayList<SearchResultRow>> rows) {
this.rows = rows;
}
@@ -130,9 +130,7 @@ public class ReportSearchResultJSON extends SearchResultJSON {
private static final String HTML_FORM = "forma";
private String jsonString = "";
private SearchReport searchReport;
- // private ArrayList<ArrayList<SearchResultColumn>> columns = new
- // ArrayList<ArrayList<SearchResultColumn>>();
- // private ArrayList<ArrayList<SearchResultRow>> rows = new ArrayList<ArrayList<SearchResultRow>>();
+
public ReportSearchResultJSON(int pageNo) {
this(pageNo, Globals.getDefaultPageSize(), -1, -1);
@@ -147,7 +145,6 @@ public class ReportSearchResultJSON extends SearchResultJSON {
searchReport = new SearchReport();
MetaReport metaReport = new MetaReport();
- // if(searchReport.getMetaReport()!=null)
searchReport.setMetaReport(metaReport);
metaReport.setPageNo(pageNo);
metaReport.setPageSize(pageSize);
@@ -166,12 +163,6 @@ public class ReportSearchResultJSON extends SearchResultJSON {
.getImgFolderURL()
+ "modify_icon.gif",
"13", "12", true, false, false));
- /*
- * addColumn(new SearchResultColumn("&nbsp;&nbsp;Schedule&nbsp;&nbsp;", "5%", "Center", "document."
- * + HTML_FORM + "." + AppConstants.RI_ACTION + ".value='report.schedule_only';", "Schedule report",
- * HTML_FORM, null, AppUtils .getImgFolderURL() + "calendar_icon.gif", "13", "12", true, false,
- * false));
- */
addColumn(new SearchResultColumn("edit", "Edit", "5%", "Center",
"document." + HTML_FORM + "." + AppConstants.RI_ACTION
@@ -202,21 +193,20 @@ public class ReportSearchResultJSON extends SearchResultJSON {
searchReport.getColumns().add(searchResultColumns);
} // ReportSearchResult
- public void parseData(DataSet ds, HttpServletRequest request, int pageNo, int pageSize, int writeAccessColIndex,
+ public void parseData(DataSet ds, HttpServletRequest request, int pageNumber, int pageSize, int writeAccessColIndex,
int ownerIndicatorColIndex) throws RaptorException {
// Presumes single ID field in the first column of the DataSet and row
// number in the first SearchResultColumn
- pageNo = AppUtils.getRequestNvlValue(request, "r_page").length() > 0
+ int pageNo = AppUtils.getRequestNvlValue(request, "r_page").length() > 0
? Integer.parseInt(AppUtils.getRequestNvlValue(request, "r_page"))
: 0;
- String userID = AppUtils.getUserID(request);
+
int dataSize = ds.getRowCount();
- // pageSize = 0;
+
if (searchReport.getMetaReport() != null) {
searchReport.getMetaReport().setPageNo(pageNo);
- // searchReport.getMetaReport().setPageSize(pageSize);
pageSize = searchReport.getMetaReport().getPageSize();
searchReport.getMetaReport().setTotalSize(dataSize);
}
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendNotifications.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendNotifications.java
index 3c871d87..3a761d84 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendNotifications.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendNotifications.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- *
+ *
*/
package org.onap.portalsdk.analytics.scheduler;
@@ -51,27 +51,27 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
public class SendNotifications {
- private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SendNotifications.class);
- SchedulerUtil schedulerUtil;
- public SendEmail sendEmail;
-
- public SendNotifications() throws Exception {
- schedulerUtil = new SchedulerUtil();
- sendEmail = new SendEmail();
- sendEmail.setSchedulerUtil(schedulerUtil);
- init();
- }
-
- public void deInit() throws SQLException {
- schedulerUtil.closeConnection();
- }
-
- public void init() throws SQLException, ReportSQLException {
- schedulerUtil.init();
- }
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SendNotifications.class);
+ SchedulerUtil schedulerUtil;
+ public SendEmail sendEmail;
+
+ public SendNotifications() throws Exception {
+ schedulerUtil = new SchedulerUtil();
+ sendEmail = new SendEmail();
+ sendEmail.setSchedulerUtil(schedulerUtil);
+ init();
+ }
+
+ public void deInit() throws SQLException {
+ schedulerUtil.closeConnection();
+ }
+
+ public void init() throws SQLException, ReportSQLException {
+ schedulerUtil.init();
+ }
public void send_notification(final String p_mail_server, final String p_sender, final String p_system_name,
- final String p_system_url, final int connectionTimeout) throws RaptorException, Exception {
+ final String p_system_url, final int connectionTimeout) throws RaptorException, Exception {
logger.info(p_mail_server + " " + p_sender + " " + p_system_name + " " + p_system_url);
final int p_time_interval = Globals.getSchedulerInterval();
@@ -80,7 +80,7 @@ public class SendNotifications {
String v_r_action = "report.download.pdf";
final String CNotificationsql = Globals.getAvailableSchedules()
- .replace("[currentDate]", Globals.getCurrentDateString());
+ .replace("[currentDate]", Globals.getCurrentDateString());
try (final ResultSet rs = schedulerUtil.getConnection().createStatement().executeQuery(CNotificationsql);) {
while (rs.next()) {
@@ -92,9 +92,10 @@ public class SendNotifications {
}
final Date v_touch_date = (Date) schedulerUtil.getSingleResult(
- "select touch_date from cr_report_email_sent_log where schedule_id = " + v_schedule_id
- + " and log_id = (select max(log_id) from cr_report_email_sent_log where schedule_id = "
- + v_schedule_id + ")", "touch_date");
+ "select touch_date from cr_report_email_sent_log where schedule_id = " + v_schedule_id
+ + " and log_id = (select max(log_id) from cr_report_email_sent_log where schedule_id = "
+ + v_schedule_id + ")",
+ "touch_date");
if (v_touch_date != null) {
if (Math.abs(System.currentTimeMillis() - v_touch_date.getTime()) / 1000 < (p_time_interval - 1)) {
return;
@@ -103,16 +104,18 @@ public class SendNotifications {
if ("Y".equals(rs.getString("conditional_yn"))) {
v_num_recs = (Integer) schedulerUtil
- .getSingleResult("select count(*) count from (" + rs.getString("condition_large_sql") + " )",
- "count");
+ .getSingleResult(
+ "select count(*) count from (" + rs.getString("condition_large_sql") + " )",
+ "count");
}
if (v_num_recs > 0 || "N".equals(rs.getString("conditional_yn"))) {
final String v_gen_key = ("Z" + UUID.randomUUID()).toString()
- .substring(0, 24); // 25 character string
+ .substring(0, 24); // 25 character string
final Object sequenceId =
- schedulerUtil.getSingleResult(
- Globals.getSequenceNextVal().replace("[sequenceName]", "seq_email_sent_log_id"), "id");
+ schedulerUtil.getSingleResult(
+ Globals.getSequenceNextVal().replace("[sequenceName]", "seq_email_sent_log_id"),
+ "id");
if (sequenceId instanceof Long) {
v_id = new BigDecimal((Long) sequenceId);
@@ -121,10 +124,11 @@ public class SendNotifications {
}
schedulerUtil.insertOrUpdate(
- "insert into cr_report_email_sent_log (log_id, gen_key, schedule_id, rep_id, user_id, touch_date) values ("
- + v_id + ",'" + v_gen_key + "'," + rs.getInt("schedule_id") + "," + rs.getInt("rep_id")
- + ","
- + rs.getInt("user_id") + ", " + Globals.getCurrentDateString() + " )");
+ "insert into cr_report_email_sent_log (log_id, gen_key, schedule_id, rep_id, user_id, touch_date) values ("
+ + v_id + ",'" + v_gen_key + "'," + rs.getInt("schedule_id") + ","
+ + rs.getInt("rep_id")
+ + ","
+ + rs.getInt("user_id") + ", " + Globals.getCurrentDateString() + " )");
final int notify_type = rs.getInt("notify_type");
if (notify_type == 4) {
@@ -147,52 +151,55 @@ public class SendNotifications {
}
final String v_url =
- p_system_url + "&r_action=" + v_r_action + "&log_id=" + v_id + "&user_id=" + rs
- .getString("user_id")
- + "&pdfAttachmentKey=" + v_gen_key + "&download_limit=" + rs.getInt("max_row")
- + v_formfields;
+ p_system_url + "&r_action=" + v_r_action + "&log_id=" + v_id + "&user_id=" + rs
+ .getString("user_id")
+ + "&pdfAttachmentKey=" + v_gen_key + "&download_limit=" + rs.getInt("max_row")
+ + v_formfields;
final boolean v_attach_email_yn = shouldSendAttachmentInEmail(v_schedule_id);
final String v_email_msg =
- "<html><body><p><b><u><i>" + p_system_name + " System Notification</i></u></b></p>"
- + "<p>Report <b>" + rs.getString("title")
- + "</b> is available for viewing.</p><p>You can view the report if it is attached. </br>"
- + "If it is not attached, or you have problem to open it, you can log into Business Direct and run the report.</p>"
- + "</body></html>";
+ "<html><body><p><b><u><i>" + p_system_name + " System Notification</i></u></b></p>"
+ + "<p>Report <b>" + rs.getString("title")
+ + "</b> is available for viewing.</p><p>You can view the report if it is attached. </br>"
+ + "If it is not attached, or you have problem to open it, you can log into Business Direct and run the report.</p>"
+ + "</body></html>";
if (rs.getInt("notify_type") != 6) {
sendEmail.sendEmail(p_mail_server, p_sender,
- p_system_name + " System Notification: Report " + rs.getString("title") + " generated",
- v_email_msg, v_url, rs.getInt("notify_type"), v_schedule_id, p_time_interval,
- v_attach_email_yn,
- connectionTimeout);
+ p_system_name + " System Notification: Report " + rs.getString("title") + " generated",
+ v_email_msg, v_url, rs.getInt("notify_type"), v_schedule_id, p_time_interval,
+ v_attach_email_yn,
+ connectionTimeout);
} else {
// may not necessary
schedulerUtil.insertOrUpdate(
- "insert into cr_schedule_activity_log (SCHEDULE_ID, url, notes, run_time) values ("
- + v_schedule_id + ",'" + v_url + "'," + "'Success: http request began.', " + Globals
- .getCurrentDateString() + " )");
+ "insert into cr_schedule_activity_log (SCHEDULE_ID, url, notes, run_time) values ("
+ + v_schedule_id + ",'" + v_url + "'," + "'Success: http request began.', "
+ + Globals
+ .getCurrentDateString()
+ + " )");
schedulerUtil.insertOrUpdate(
- "insert into cr_schedule_activity_log (SCHEDULE_ID, url, notes, run_time) values ("
- + v_schedule_id + ",'" + v_url + "',"
- + "'Success: http response recieved. Code resp.status_code '' desc '' resp.reason_phrase', "
- + Globals.getCurrentDateString() + " )");
+ "insert into cr_schedule_activity_log (SCHEDULE_ID, url, notes, run_time) values ("
+ + v_schedule_id + ",'" + v_url + "',"
+ + "'Success: http response recieved. Code resp.status_code '' desc '' resp.reason_phrase', "
+ + Globals.getCurrentDateString() + " )");
}
schedulerUtil.insertOrUpdate(
- "update cr_report_schedule set run_date = " + Globals.getCurrentDateString()
- + " where schedule_id="
- + v_schedule_id);
+ "update cr_report_schedule set run_date = " + Globals.getCurrentDateString()
+ + " where schedule_id="
+ + v_schedule_id);
schedulerUtil.insertOrUpdate(
- "update cr_report_email_sent_log set sent_date= " + Globals.getCurrentDateString()
- + " , access_flag='N' where log_id=" + v_id);
+ "update cr_report_email_sent_log set sent_date= " + Globals.getCurrentDateString()
+ + " , access_flag='N' where log_id=" + v_id);
schedulerUtil.insertOrUpdate(
- "insert into cr_schedule_activity_log (SCHEDULE_ID, url, notes, run_time) values ("
- + v_schedule_id
- + ",'" + v_url + "','Success: Email Sent', " + Globals.getCurrentDateString() + " )");
+ "insert into cr_schedule_activity_log (SCHEDULE_ID, url, notes, run_time) values ("
+ + v_schedule_id
+ + ",'" + v_url + "','Success: Email Sent', " + Globals.getCurrentDateString()
+ + " )");
}
}
} catch (final SQLException e) {
@@ -200,280 +207,322 @@ public class SendNotifications {
}
}
- private boolean shouldSendAttachmentInEmail(int v_schedule_id) throws SQLException, ReportSQLException {
-
- String l_boolean = (String) schedulerUtil.getSingleResult("SELECT ATTACHMENT_YN from cr_report_schedule where schedule_id = " + v_schedule_id, "ATTACHMENT_YN");
- if ("Y".equals(l_boolean))
- return true;
- return false;
- }
-
- private String strip_formfields(int v_schedule_id, String p_formfields) throws SQLException, ReportSQLException {
-
- String v_formfields_insert = "";
- String v_formfields_generate = "";
- String v_name = "";
- String v_value = "";
-
-
- String[] column_values = schedulerUtil.cr_dissecturl(p_formfields, "&");
-
- for(String column_value : column_values){
- if(column_value == null || column_value.isEmpty())
- continue;
-
- v_name = column_value.substring(0, column_value.indexOf('='));
- v_formfields_insert += column_value + "&";
- v_value = column_value.substring(column_value.indexOf('=') + 1);
- if (column_value.indexOf("_auto") > 0) {
- v_formfields_generate = v_formfields_generate + v_name.substring(0, v_name.indexOf("_auto")) + "=" + v_value + "&";
- } else {
- v_formfields_generate = v_formfields_generate + column_value + "&";
- }
- }
-
- schedulerUtil.insertOrUpdate("update CR_REPORT_SCHEDULE set processed_formfields ='" + v_formfields_insert + "' where schedule_id = " + v_schedule_id);
-
- return v_formfields_generate.substring(0, v_formfields_generate.length());
-
- }
-
- private String modify_formfields(int v_schedule_id, String p_formfields) throws SQLException, ReportSQLException {
-
- class Result {
-
- String v_formfields_insert = "";
- String v_formfields_generate = "";
- String v_name = "";
- String v_value = "";
- Date v_date;
- String v_hour = "";
- String v_hour_value = "";
- }
-
- final Result result = new Result();
-
- final String v_recurrence = (String) schedulerUtil.getSingleResult("select recurrence from cr_report_schedule where schedule_id = " + v_schedule_id, "recurrence");
-
- String[] column_values = schedulerUtil.cr_dissecturl(p_formfields, "&");
-
- for(String column_value : column_values){
- if (column_value == null)
- column_value = "";
-
- if ("MONTHLY".equals(v_recurrence)) {
- if (column_value.indexOf("_auto") > 0) {
- result.v_name = column_value.substring(0, column_value.indexOf('='));
- result.v_date = schedulerUtil.to_date(column_value.substring(column_value.indexOf('=') + 1), "mm/dd/yyyy");
- result.v_value = schedulerUtil.add_months(result.v_date, 1).toString();
-
- if (result.v_name.length() > 0) {
- result.v_formfields_insert = result.v_formfields_insert + result.v_name + "=" + result.v_value + "&";
- result.v_formfields_generate = result.v_formfields_generate + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "=" + result.v_value + "&";
- }
- } else {
- result.v_formfields_insert = result.v_formfields_insert + column_value + "&";
- result.v_formfields_generate = result.v_formfields_generate + column_value + "&";
- }
-
- } else if ("DAILY".equals(v_recurrence)) {
- if (column_value.indexOf("_auto") > 0) {
- result.v_name = column_value.substring(0, column_value.indexOf('='));
- result.v_date = schedulerUtil.to_date(column_value.substring(column_value.indexOf('=') + 1), "mm/dd/yyyy");
- result.v_value = schedulerUtil.add_months(result.v_date, 1).toString();
-
- if (result.v_name.length() > 0) {
- result.v_formfields_insert = result.v_formfields_insert + result.v_name + "=" + result.v_value + "&";
- result.v_formfields_generate = result.v_formfields_generate + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "=" + result.v_value + "&";
- }
- } else {
- result.v_formfields_insert = result.v_formfields_insert + column_value + "&";
- result.v_formfields_generate = result.v_formfields_generate + column_value + "&";
- }
-
- } else if ("DAILY_MO_FR".equals(v_recurrence)) {
- if (column_value.indexOf("_auto") > 0) {
- result.v_name = column_value.substring(0, column_value.indexOf('='));
- result.v_date = schedulerUtil.to_date(column_value.substring(column_value.indexOf('=') + 1), "mm/dd/yyyy");
- SimpleDateFormat sdf = new SimpleDateFormat("EEE");
- sdf.format(result.v_date);
- if ("FRI".equals(result.v_date.toString())) {
- result.v_date = schedulerUtil.add_days(result.v_date, 3);
- } else if ("SAT".equals(result.v_date.toString())) {
- result.v_date = schedulerUtil.add_days(result.v_date, 2);
- } else {
- result.v_date = schedulerUtil.add_days(result.v_date, 1);
- }
- result.v_value = result.v_date.toString();
- if (result.v_name.length() > 0) {
- result.v_formfields_insert = result.v_formfields_insert + result.v_name + "=" + result.v_value + "&";
- result.v_formfields_generate = result.v_formfields_generate + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "=" + result.v_value + "&";
- }
-
- } else {
- result.v_formfields_insert = result.v_formfields_insert + column_value + "&";
- result.v_formfields_generate = result.v_formfields_generate + column_value + "&";
- }
-
- } else if ("HOURLY".equals(v_recurrence)) {
-
- result.v_name = column_value.indexOf('=')>0?column_value.substring(0, column_value.indexOf('=')) : "";
- if (column_value.indexOf("_auto") > 0) {
-
-
- String[] column_values2 = schedulerUtil.cr_dissecturl(p_formfields, "&");
-
- for(String column_value2 : column_values2){
-
- String key = column_value2.substring(0, column_value2.indexOf("="));
- if(key.equals(result.v_name.substring(0, result.v_name.indexOf("_auto"))) || key.equals(result.v_name.substring(0, result.v_name.indexOf("_Hr")))){
- result.v_hour = column_value2;
- }
- }
-
-// schedulerUtil.getAndExecute("select c.column_value from table(CR_DISSECTURL(p_formfields)) c where substr(c.column_value, 1, instr(c.column_value, '=')-1) = substr(" + result.v_name + ",1,instr(" + result.v_name + ",'_auto')-1)||'_Hr'", new Executor() {
-//
-// @Override
-// public void execute(ResultSet rs) throws SQLException {
-//
-// result.v_hour = rs.getString("column_value");
-// }
-//
-// });
-
- if (result.v_hour.length() > 0) {
- result.v_hour_value = result.v_hour.substring(result.v_hour.indexOf('=') + 1);
- }
-
- result.v_date = schedulerUtil.to_date(column_value.substring(column_value.indexOf('=') + 1) + " " + result.v_hour_value, "mm/dd/yyyy HH24:MI:SS");
-
- result.v_value = schedulerUtil.to_date_str(schedulerUtil.add_hours(result.v_date, 1), "mm/dd/yyyy HH24");
-
- if (result.v_name.length() > 0) {
- if (result.v_hour.length() > 0) {
-
- result.v_formfields_insert = result.v_formfields_insert + result.v_name + "=" + result.v_value.substring(0, 10) + "&" + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "_Hr=" + result.v_value.substring(11, 13);
- result.v_formfields_generate = result.v_formfields_generate + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "=" + result.v_value.substring(0, 10) + "&" + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "_Hr="
- + result.v_value.substring(11, 13) + "&";
-
- } else {
- result.v_formfields_insert = result.v_formfields_insert + result.v_name + "=" + result.v_value + "&";
- result.v_formfields_generate = result.v_formfields_generate + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "=" + result.v_value + "&";
- }
- }
- }
- if (column_value.indexOf("_Hr") <= 0) {
- result.v_formfields_insert = result.v_formfields_insert + column_value + "&";
- result.v_formfields_generate = result.v_formfields_generate + column_value + "&";
- }
- } else if ("WEEKLY".equals(v_recurrence)) {
-
- if (column_value.indexOf("_auto") > 0) {
- result.v_name = column_value.substring(0, column_value.indexOf('='));
- result.v_date = schedulerUtil.to_date(column_value.substring(column_value.indexOf('=') + 1), "mm/dd/yyyy");
- result.v_value = schedulerUtil.add_days(result.v_date, 7).toString();
-
- if (result.v_name.length() > 0) {
- result.v_formfields_insert = result.v_formfields_insert + result.v_name + "=" + result.v_value + "&";
- result.v_formfields_generate = result.v_formfields_generate + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "=" + result.v_value + "&";
- }
-
- } else {
- result.v_formfields_insert = result.v_formfields_insert + column_value + "&";
- result.v_formfields_generate = result.v_formfields_generate + column_value + "&";
- }
-
- } else {
- if (column_value.indexOf("_auto") > 0) {
- result.v_name = column_value.substring(0, column_value.indexOf('='));
- result.v_date = schedulerUtil.to_date(column_value.substring(column_value.indexOf('=') + 1), "mm/dd/yyyy");
- result.v_value = schedulerUtil.add_days(result.v_date, 7).toString();
- if (result.v_name.length() > 0) {
- result.v_formfields_insert = result.v_formfields_insert + result.v_name + "=" + result.v_value + "&";
- result.v_formfields_generate = result.v_formfields_generate + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "=" + result.v_value + "&";
- }
-
- } else {
- result.v_formfields_insert = result.v_formfields_insert + column_value + "&";
- result.v_formfields_generate = result.v_formfields_generate + column_value + "&";
- }
- }
- }
-
- schedulerUtil.insertOrUpdate("update CR_REPORT_SCHEDULE set processed_formfields ='" + result.v_formfields_insert + "' where schedule_id =" + v_schedule_id);
- return "&" + result.v_formfields_generate.substring(0, result.v_formfields_generate.length());
- }
-
- private int get_report_sched_offset(int p_rep_id, int p_schedule_id) throws SQLException, ReportSQLException {
-
- class CrReportSchedule {
-
- Date run_date;
- String recurrence;
- }
- Date v_last_date = null;
- Date v_sysdate = new Date();
-
- final CrReportSchedule v_report_schedule_rec = new CrReportSchedule();
-
- schedulerUtil.getAndExecute("SELECT * FROM cr_report_schedule WHERE rep_id = " + p_rep_id + " and schedule_id = " + p_schedule_id, new Executor() {
-
- @Override
- public void execute(ResultSet rs) throws SQLException {
-
- v_report_schedule_rec.recurrence = rs.getString("recurrence");
- java.sql.Timestamp runDate = rs.getTimestamp("run_date");
- v_report_schedule_rec.run_date = new Date(runDate.getTime()) ;
- }
-
- });
-
- if (v_report_schedule_rec.run_date == null || v_report_schedule_rec.run_date.compareTo(v_sysdate) > 0) {
- return Integer.MAX_VALUE;
- }
-
- Date v_next_date = v_report_schedule_rec.run_date;
-
- while (v_next_date.compareTo(v_sysdate) < 0) {
-
- if ("HOURLY".equals(v_report_schedule_rec.recurrence)) {
- v_next_date = SchedulerUtil.add_hours(v_next_date, 1);
- } else if ("DAILY".equals(v_report_schedule_rec.recurrence)) {
- v_next_date = SchedulerUtil.add_days(v_next_date, 1);
- } else if ("DAILY_MO_FR".equals(v_report_schedule_rec.recurrence)) {
- SimpleDateFormat sdf = new SimpleDateFormat("EEE");
- sdf.format(v_next_date);
- if ("FRI".equals(v_next_date.toString())) {
- v_next_date = SchedulerUtil.add_days(v_next_date, 3);
- } else if ("SAT".equals(v_next_date.toString())) {
- v_next_date = SchedulerUtil.add_days(v_next_date, 2);
- } else {
- v_next_date = SchedulerUtil.add_days(v_next_date, 1);
- }
- } else if ("WEEKLY".equals(v_report_schedule_rec.recurrence)) {
- v_next_date = SchedulerUtil.add_days(v_next_date, 7);
- } else if ("MONTHLY".equals(v_report_schedule_rec.recurrence)) {
- v_next_date = SchedulerUtil.add_months(v_next_date, 1);
- } else {
- break;
- }
- v_last_date = v_next_date;
- }
-
- if (SchedulerUtil.trunc_hour(v_last_date).compareTo(SchedulerUtil.trunc_hour(v_sysdate)) == 0) {
- return (int)(Math.abs (v_sysdate.getTime() - v_last_date.getTime()) / 1000);
- } else {
- // More than an hour
- return 3601;
- }
- }
-
- public SchedulerUtil getSchedulerUtil() {
- return schedulerUtil;
- }
-
- public void setSchedulerUtil(SchedulerUtil schedulerUtil) {
- this.schedulerUtil = schedulerUtil;
- }
+ private boolean shouldSendAttachmentInEmail(int v_schedule_id) throws SQLException, ReportSQLException {
+
+ String l_boolean = (String) schedulerUtil.getSingleResult(
+ "SELECT ATTACHMENT_YN from cr_report_schedule where schedule_id = " + v_schedule_id, "ATTACHMENT_YN");
+ if ("Y".equals(l_boolean))
+ return true;
+ return false;
+ }
+
+ private String strip_formfields(int v_schedule_id, String p_formfields) throws SQLException, ReportSQLException {
+
+ String v_formfields_insert = "";
+ String v_formfields_generate = "";
+ String v_name = "";
+ String v_value = "";
+
+ String[] column_values = schedulerUtil.cr_dissecturl(p_formfields, "&");
+
+ for (String column_value : column_values) {
+ if (column_value == null || column_value.isEmpty())
+ continue;
+
+ v_name = column_value.substring(0, column_value.indexOf('='));
+ v_formfields_insert += column_value + "&";
+ v_value = column_value.substring(column_value.indexOf('=') + 1);
+ if (column_value.indexOf("_auto") > 0) {
+ v_formfields_generate =
+ v_formfields_generate + v_name.substring(0, v_name.indexOf("_auto")) + "=" + v_value + "&";
+ } else {
+ v_formfields_generate = v_formfields_generate + column_value + "&";
+ }
+ }
+
+ schedulerUtil.insertOrUpdate("update CR_REPORT_SCHEDULE set processed_formfields ='" + v_formfields_insert
+ + "' where schedule_id = " + v_schedule_id);
+
+ return v_formfields_generate.substring(0, v_formfields_generate.length());
+
+ }
+
+ private String modify_formfields(int v_schedule_id, String p_formfields) throws SQLException, ReportSQLException {
+
+ class Result {
+
+ String v_formfields_insert = "";
+ String v_formfields_generate = "";
+ String v_name = "";
+ String v_value = "";
+ Date v_date;
+ String v_hour = "";
+ String v_hour_value = "";
+ }
+
+ final Result result = new Result();
+
+ final String v_recurrence = (String) schedulerUtil.getSingleResult(
+ "select recurrence from cr_report_schedule where schedule_id = " + v_schedule_id, "recurrence");
+
+ String[] column_values = schedulerUtil.cr_dissecturl(p_formfields, "&");
+
+ for (String column_value : column_values) {
+ if (column_value == null)
+ column_value = "";
+
+ if ("MONTHLY".equals(v_recurrence)) {
+ if (column_value.indexOf("_auto") > 0) {
+ result.v_name = column_value.substring(0, column_value.indexOf('='));
+ result.v_date =
+ schedulerUtil.to_date(column_value.substring(column_value.indexOf('=') + 1), "mm/dd/yyyy");
+ result.v_value = schedulerUtil.add_months(result.v_date, 1).toString();
+
+ if (result.v_name.length() > 0) {
+ result.v_formfields_insert =
+ result.v_formfields_insert + result.v_name + "=" + result.v_value + "&";
+ result.v_formfields_generate = result.v_formfields_generate
+ + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "=" + result.v_value
+ + "&";
+ }
+ } else {
+ result.v_formfields_insert = result.v_formfields_insert + column_value + "&";
+ result.v_formfields_generate = result.v_formfields_generate + column_value + "&";
+ }
+
+ } else if ("DAILY".equals(v_recurrence)) {
+ if (column_value.indexOf("_auto") > 0) {
+ result.v_name = column_value.substring(0, column_value.indexOf('='));
+ result.v_date =
+ schedulerUtil.to_date(column_value.substring(column_value.indexOf('=') + 1), "mm/dd/yyyy");
+ result.v_value = schedulerUtil.add_months(result.v_date, 1).toString();
+
+ if (result.v_name.length() > 0) {
+ result.v_formfields_insert =
+ result.v_formfields_insert + result.v_name + "=" + result.v_value + "&";
+ result.v_formfields_generate = result.v_formfields_generate
+ + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "=" + result.v_value
+ + "&";
+ }
+ } else {
+ result.v_formfields_insert = result.v_formfields_insert + column_value + "&";
+ result.v_formfields_generate = result.v_formfields_generate + column_value + "&";
+ }
+
+ } else if ("DAILY_MO_FR".equals(v_recurrence)) {
+ if (column_value.indexOf("_auto") > 0) {
+ result.v_name = column_value.substring(0, column_value.indexOf('='));
+ result.v_date =
+ schedulerUtil.to_date(column_value.substring(column_value.indexOf('=') + 1), "mm/dd/yyyy");
+ SimpleDateFormat sdf = new SimpleDateFormat("EEE");
+ sdf.format(result.v_date);
+ if ("FRI".equals(result.v_date.toString())) {
+ result.v_date = schedulerUtil.add_days(result.v_date, 3);
+ } else if ("SAT".equals(result.v_date.toString())) {
+ result.v_date = schedulerUtil.add_days(result.v_date, 2);
+ } else {
+ result.v_date = schedulerUtil.add_days(result.v_date, 1);
+ }
+ result.v_value = result.v_date.toString();
+ if (result.v_name.length() > 0) {
+ result.v_formfields_insert =
+ result.v_formfields_insert + result.v_name + "=" + result.v_value + "&";
+ result.v_formfields_generate = result.v_formfields_generate
+ + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "=" + result.v_value
+ + "&";
+ }
+
+ } else {
+ result.v_formfields_insert = result.v_formfields_insert + column_value + "&";
+ result.v_formfields_generate = result.v_formfields_generate + column_value + "&";
+ }
+
+ } else if ("HOURLY".equals(v_recurrence)) {
+
+ result.v_name =
+ column_value.indexOf('=') > 0 ? column_value.substring(0, column_value.indexOf('=')) : "";
+ if (column_value.indexOf("_auto") > 0) {
+
+ String[] column_values2 = schedulerUtil.cr_dissecturl(p_formfields, "&");
+
+ for (String column_value2 : column_values2) {
+
+ String key = column_value2.substring(0, column_value2.indexOf("="));
+ if (key.equals(result.v_name.substring(0, result.v_name.indexOf("_auto")))
+ || key.equals(result.v_name.substring(0, result.v_name.indexOf("_Hr")))) {
+ result.v_hour = column_value2;
+ }
+ }
+
+ // schedulerUtil.getAndExecute("select c.column_value from table(CR_DISSECTURL(p_formfields)) c
+ // where substr(c.column_value, 1, instr(c.column_value, '=')-1) = substr(" + result.v_name +
+ // ",1,instr(" + result.v_name + ",'_auto')-1)||'_Hr'", new Executor() {
+ //
+ // @Override
+ // public void execute(ResultSet rs) throws SQLException {
+ //
+ // result.v_hour = rs.getString("column_value");
+ // }
+ //
+ // });
+
+ if (result.v_hour.length() > 0) {
+ result.v_hour_value = result.v_hour.substring(result.v_hour.indexOf('=') + 1);
+ }
+
+ result.v_date = schedulerUtil.to_date(
+ column_value.substring(column_value.indexOf('=') + 1) + " " + result.v_hour_value,
+ "mm/dd/yyyy HH24:MI:SS");
+
+ result.v_value =
+ schedulerUtil.to_date_str(schedulerUtil.add_hours(result.v_date, 1), "mm/dd/yyyy HH24");
+
+ if (result.v_name.length() > 0) {
+ if (result.v_hour.length() > 0) {
+
+ result.v_formfields_insert =
+ result.v_formfields_insert + result.v_name + "=" + result.v_value.substring(0, 10)
+ + "&" + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "_Hr="
+ + result.v_value.substring(11, 13);
+ result.v_formfields_generate = result.v_formfields_generate
+ + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "="
+ + result.v_value.substring(0, 10) + "&"
+ + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "_Hr="
+ + result.v_value.substring(11, 13) + "&";
+
+ } else {
+ result.v_formfields_insert =
+ result.v_formfields_insert + result.v_name + "=" + result.v_value + "&";
+ result.v_formfields_generate = result.v_formfields_generate
+ + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "=" + result.v_value
+ + "&";
+ }
+ }
+ }
+ if (column_value.indexOf("_Hr") <= 0) {
+ result.v_formfields_insert = result.v_formfields_insert + column_value + "&";
+ result.v_formfields_generate = result.v_formfields_generate + column_value + "&";
+ }
+ } else if ("WEEKLY".equals(v_recurrence)) {
+
+ if (column_value.indexOf("_auto") > 0) {
+ result.v_name = column_value.substring(0, column_value.indexOf('='));
+ result.v_date =
+ schedulerUtil.to_date(column_value.substring(column_value.indexOf('=') + 1), "mm/dd/yyyy");
+ result.v_value = schedulerUtil.add_days(result.v_date, 7).toString();
+
+ if (result.v_name.length() > 0) {
+ result.v_formfields_insert =
+ result.v_formfields_insert + result.v_name + "=" + result.v_value + "&";
+ result.v_formfields_generate = result.v_formfields_generate
+ + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "=" + result.v_value
+ + "&";
+ }
+
+ } else {
+ result.v_formfields_insert = result.v_formfields_insert + column_value + "&";
+ result.v_formfields_generate = result.v_formfields_generate + column_value + "&";
+ }
+
+ } else {
+ if (column_value.indexOf("_auto") > 0) {
+ result.v_name = column_value.substring(0, column_value.indexOf('='));
+ result.v_date =
+ schedulerUtil.to_date(column_value.substring(column_value.indexOf('=') + 1), "mm/dd/yyyy");
+ result.v_value = schedulerUtil.add_days(result.v_date, 7).toString();
+ if (result.v_name.length() > 0) {
+ result.v_formfields_insert =
+ result.v_formfields_insert + result.v_name + "=" + result.v_value + "&";
+ result.v_formfields_generate = result.v_formfields_generate
+ + result.v_name.substring(0, result.v_name.indexOf("_auto")) + "=" + result.v_value
+ + "&";
+ }
+
+ } else {
+ result.v_formfields_insert = result.v_formfields_insert + column_value + "&";
+ result.v_formfields_generate = result.v_formfields_generate + column_value + "&";
+ }
+ }
+ }
+
+ schedulerUtil.insertOrUpdate("update CR_REPORT_SCHEDULE set processed_formfields ='"
+ + result.v_formfields_insert + "' where schedule_id =" + v_schedule_id);
+ return "&" + result.v_formfields_generate.substring(0, result.v_formfields_generate.length());
+ }
+
+ private int get_report_sched_offset(int p_rep_id, int p_schedule_id) throws SQLException, ReportSQLException {
+
+ class CrReportSchedule {
+
+ Date run_date;
+ String recurrence;
+ }
+ Date v_last_date = null;
+ Date v_sysdate = new Date();
+
+ final CrReportSchedule v_report_schedule_rec = new CrReportSchedule();
+
+ schedulerUtil.getAndExecute(
+ "SELECT * FROM cr_report_schedule WHERE rep_id = " + p_rep_id + " and schedule_id = " + p_schedule_id,
+ new Executor() {
+
+ @Override
+ public void execute(ResultSet rs) throws SQLException {
+
+ v_report_schedule_rec.recurrence = rs.getString("recurrence");
+ java.sql.Timestamp runDate = rs.getTimestamp("run_date");
+ v_report_schedule_rec.run_date = new Date(runDate.getTime());
+ }
+
+ });
+
+ if (v_report_schedule_rec.run_date == null || v_report_schedule_rec.run_date.compareTo(v_sysdate) > 0) {
+ return Integer.MAX_VALUE;
+ }
+
+ Date v_next_date = v_report_schedule_rec.run_date;
+
+ while (v_next_date.compareTo(v_sysdate) < 0) {
+
+ if ("HOURLY".equals(v_report_schedule_rec.recurrence)) {
+ v_next_date = SchedulerUtil.add_hours(v_next_date, 1);
+ } else if ("DAILY".equals(v_report_schedule_rec.recurrence)) {
+ v_next_date = SchedulerUtil.add_days(v_next_date, 1);
+ } else if ("DAILY_MO_FR".equals(v_report_schedule_rec.recurrence)) {
+ SimpleDateFormat sdf = new SimpleDateFormat("EEE");
+ sdf.format(v_next_date);
+ if ("FRI".equals(v_next_date.toString())) {
+ v_next_date = SchedulerUtil.add_days(v_next_date, 3);
+ } else if ("SAT".equals(v_next_date.toString())) {
+ v_next_date = SchedulerUtil.add_days(v_next_date, 2);
+ } else {
+ v_next_date = SchedulerUtil.add_days(v_next_date, 1);
+ }
+ } else if ("WEEKLY".equals(v_report_schedule_rec.recurrence)) {
+ v_next_date = SchedulerUtil.add_days(v_next_date, 7);
+ } else if ("MONTHLY".equals(v_report_schedule_rec.recurrence)) {
+ v_next_date = SchedulerUtil.add_months(v_next_date, 1);
+ } else {
+ break;
+ }
+ v_last_date = v_next_date;
+ }
+
+ if (v_last_date != null
+ && SchedulerUtil.trunc_hour(v_last_date).compareTo(SchedulerUtil.trunc_hour(v_sysdate)) == 0) {
+ return (int) (Math.abs(v_sysdate.getTime() - v_last_date.getTime()) / 1000);
+ } else {
+ // More than an hour
+ return 3601;
+ }
+ }
+
+ public SchedulerUtil getSchedulerUtil() {
+ return schedulerUtil;
+ }
+
+ public void setSchedulerUtil(SchedulerUtil schedulerUtil) {
+ this.schedulerUtil = schedulerUtil;
+ }
}
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java
index 9e11affe..84649e06 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java
@@ -129,6 +129,8 @@ import com.fasterxml.jackson.databind.SerializationFeature;
public class RaptorControllerAsync extends RestrictedBaseController {
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RaptorControllerAsync.class);
+ private static final String INVALID_ACTION = "[Controller.processRequest]Invalid raptor action [";
+ private static final String UNABLE_INSTANTIATE = "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: ";
private String viewName;
@@ -143,9 +145,9 @@ public class RaptorControllerAsync extends RestrictedBaseController {
HttpSession session = request.getSession();
User user = UserUtils.getUserSession(request);
- if (actionKey.equals("report.download.excel2007.session") || actionKey.equals("report.download.csv.session")
- || actionKey.equals("report.download.excel.session")
- || actionKey.equals("report.download.pdf.session")) {
+ if ("report.download.excel2007.session".equals(actionKey) || "report.download.csv.session".equals(actionKey)
+ || "report.download.excel.session".equals(actionKey)
+ || "report.download.pdf.session".equals(actionKey)) {
if (session != null && user != null) {
ServletContext servletContext = request.getSession().getServletContext();
if (!Globals.isSystemInitialized()) {
@@ -155,7 +157,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
ReportData rd = null;
String parent = "";
int parentFlag = 0;
- if (!nvl(request.getParameter("parent"), "").equals("N"))
+ if (!"N".equals(nvl(request.getParameter("parent"), "")))
parent = nvl(request.getParameter("parent"), "");
if (parent.startsWith("parent_"))
parentFlag = 1;
@@ -183,33 +185,35 @@ public class RaptorControllerAsync extends RestrictedBaseController {
if (rd == null)
rd = (ReportData) request.getSession().getAttribute(AppConstants.RI_REPORT_DATA);
}
- String user_id = AppUtils.getUserID(request);
+ String userId = AppUtils.getUserID(request);
int downloadLimit = 0;
if (rr != null)
downloadLimit = (rr.getMaxRowsInExcelDownload() > 0) ? rr.getMaxRowsInExcelDownload()
: Globals.getDownloadLimit();
- if (actionKey.equals("report.csv.download"))
+ if ("report.csv.download".equals(actionKey))
downloadLimit = Globals.getCSVDownloadLimit();
- String sql_whole = rr.getReportDataSQL(user_id, downloadLimit, request);
- request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sql_whole);
+ if(rr != null) {
+ String sqlWhole = rr.getReportDataSQL(userId, downloadLimit, request);
+ request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sqlWhole);
+ }
try {
OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream());
- if (actionKey.equals("report.download.pdf.session")) {
+ if ("report.download.pdf.session".equals(actionKey)) {
new PdfReportHandler().createPdfFileContent(request, response, 3);
- } else if (actionKey.equals("report.download.csv.session")) {
+ } else if ("report.download.csv.session".equals(actionKey)) {
(new ReportHandler()).createCSVFileContent(out, rd, rr, request, response);
- } else if (actionKey.equals("report.download.excel.session")) {
- new ReportHandler().createExcelFileContent(out, rd, rr, request, response, user_id, 3); // 3
+ } else if ("report.download.excel.session".equals(actionKey)) {
+ new ReportHandler().createExcelFileContent(out, rd, rr, request, response, userId, 3); // 3
// whole
} else {
- new ReportHandler().createExcel2007FileContent(out, rd, rr, request, response, user_id, 3); // 3
+ new ReportHandler().createExcel2007FileContent(out, rd, rr, request, response, userId, 3); // 3
// whole
}
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,
- "[Controller.processRequest]Invalid raptor action [" + actionKey + "].", e);
+ INVALID_ACTION + actionKey + "].", e);
}
} else {
response.sendRedirect("login.htm");
@@ -227,10 +231,10 @@ public class RaptorControllerAsync extends RestrictedBaseController {
throw new RaptorRuntimeException("Action not found");
} catch (RaptorException e) {
logger.error(EELFLoggerDelegate.errorLogger,
- "[Controller.processRequest]Invalid raptor action [" + actionKey + "].", e);
+ INVALID_ACTION + actionKey + "].", e);
viewName = (new ErrorHandler()).processFatalErrorJSON(request,
- new RaptorRuntimeException("[Controller.processRequest]Invalid raptor action [" + actionKey
+ new RaptorRuntimeException(INVALID_ACTION + actionKey
+ "]. Exception: " + e.getMessage()));
}
@@ -249,46 +253,36 @@ public class RaptorControllerAsync extends RestrictedBaseController {
;
viewName = (String) handlerMethod.invoke(handler, paramValues);
- if (!actionKey.equals("chart.run"))
+ if (!"chart.run".equals(actionKey))
response.setContentType("application/json");
else
response.setContentType("text/html");
} catch (ClassNotFoundException e) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
+ logger.debug(EELFLoggerDelegate.debugLogger, (INVALID_ACTION
+ actionKey + "]. ClassNotFoundException: " + e.getMessage()));
viewName = (new ErrorHandler()).processFatalErrorJSON(request,
- new RaptorRuntimeException(
- "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
- + e.getMessage()));
+ new RaptorRuntimeException(UNABLE_INSTANTIATE + e.getMessage()));
} catch (IllegalAccessException e) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
+ logger.debug(EELFLoggerDelegate.debugLogger, (INVALID_ACTION
+ actionKey + "]. IllegalAccessException: " + e.getMessage()));
viewName = (new ErrorHandler()).processFatalErrorJSON(request,
- new RaptorRuntimeException(
- "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
- + e.getMessage()));
+ new RaptorRuntimeException(UNABLE_INSTANTIATE + e.getMessage()));
} catch (InstantiationException e) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
+ logger.debug(EELFLoggerDelegate.debugLogger, (INVALID_ACTION
+ actionKey + "]. InstantiationException: " + e.getMessage()));
viewName = (new ErrorHandler()).processFatalErrorJSON(request,
- new RaptorRuntimeException(
- "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
- + e.getMessage()));
+ new RaptorRuntimeException(UNABLE_INSTANTIATE + e.getMessage()));
} catch (NoSuchMethodException e) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
+ logger.debug(EELFLoggerDelegate.debugLogger, (INVALID_ACTION
+ actionKey + "]. NoSuchMethodException: " + e.getMessage()));
viewName = (new ErrorHandler()).processFatalErrorJSON(request,
- new RaptorRuntimeException(
- "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
- + e.getMessage()));
+ new RaptorRuntimeException(UNABLE_INSTANTIATE + e.getMessage()));
} catch (InvocationTargetException e) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
+ logger.debug(EELFLoggerDelegate.debugLogger, (INVALID_ACTION
+ actionKey + "]. InvocationTargetException: " + e.getMessage()));
viewName = (new ErrorHandler()).processFatalErrorJSON(request,
- new RaptorRuntimeException(
- "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
- + e.getMessage()));
+ new RaptorRuntimeException(UNABLE_INSTANTIATE + e.getMessage()));
} finally {
PrintWriter out = response.getWriter();
out.write(viewName);
@@ -303,7 +297,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "/report/wizard/drill_down_param/{parameter}", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody List<DrillDownParamDef> getDrillDownParamDef (@PathVariable("parameter") String parameter, HttpServletRequest request, HttpServletResponse response)
- throws IOException, RaptorException {
+ {
List<DrillDownParamDef> list = new ArrayList<>();
String[] tmepArray = null;
if(parameter!=null){
@@ -317,11 +311,11 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "/report/wizard/list_columns", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody ArrayList<ColumnJSON> listColumns(HttpServletRequest request, HttpServletResponse response)
- throws IOException, RaptorException {
+ {
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
List<DataColumnType> reportColumnList = rdef.getAllColumns();
- ArrayList<ColumnJSON> listJSON = new ArrayList<ColumnJSON>();
- ColumnJSON columnJSON = new ColumnJSON();
+ ArrayList<ColumnJSON> listJSON = new ArrayList<>();
+ ColumnJSON columnJSON;
for (DataColumnType reportColumnType : reportColumnList) {
columnJSON = new ColumnJSON();
@@ -334,7 +328,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "/report/wizard/list_drilldown_reports", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody ArrayList<ColumnJSON> list_drilldown_reports(HttpServletRequest request,
- HttpServletResponse response) throws IOException, RaptorException {
+ HttpServletResponse response) throws RaptorException {
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
Vector<IdNameValue> publicReportIdNames = DataCache.getPublicReportIdNames();
Vector groupReportIdNames = DataCache.getGroupAccessibleReportIdNames(AppUtils.getUserID(request),
@@ -342,8 +336,8 @@ public class RaptorControllerAsync extends RestrictedBaseController {
Vector privateReportIdNames = DataCache.getPrivateAccessibleReportIdNames(AppUtils.getUserID(request),
AppUtils.getUserRoles(request));
- ArrayList<ColumnJSON> listJSON = new ArrayList<ColumnJSON>();
- ColumnJSON columnJSON = new ColumnJSON();
+ ArrayList<ColumnJSON> listJSON = new ArrayList<>();
+ ColumnJSON columnJSON;
ServletContext servletContext = request.getSession().getServletContext();
if (!Globals.isSystemInitialized()) {
@@ -351,7 +345,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
}
for (int i = 0; i < publicReportIdNames.size(); i++) {
- IdNameValue reportIdName = (IdNameValue) publicReportIdNames.get(i);
+ IdNameValue reportIdName = publicReportIdNames.get(i);
columnJSON = new ColumnJSON();
columnJSON.setId(reportIdName.getId());
columnJSON.setName("Public Report: " + reportIdName.getName());
@@ -382,10 +376,10 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "/report/wizard/list_formfields", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody ArrayList<SearchFieldJSON> listFormFields(HttpServletRequest request,
- HttpServletResponse response) throws IOException, RaptorException {
+ HttpServletResponse response) {
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
- ArrayList<SearchFieldJSON> listJSON = new ArrayList<SearchFieldJSON>();
- SearchFieldJSON fieldJSON = new SearchFieldJSON();
+ ArrayList<SearchFieldJSON> listJSON = new ArrayList<>();
+ SearchFieldJSON fieldJSON;
if (rdef.getFormFieldList() != null) {
for (Iterator iter = rdef.getFormFieldList().getFormField().iterator(); iter.hasNext();) {
fieldJSON = new SearchFieldJSON();
@@ -404,12 +398,12 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "/report/wizard/list_child_report_col/{reportID}", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody ArrayList<ColumnJSON> listChildReportCols(@PathVariable("reportID") String reportID,
- HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
+ HttpServletRequest request, HttpServletResponse response) throws RaptorException {
ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, reportID, false);
List<DataColumnType> reportColumnList = ddRr.getAllColumns();
- ArrayList<ColumnJSON> listJSON = new ArrayList<ColumnJSON>();
- ColumnJSON columnJSON = new ColumnJSON();
+ ArrayList<ColumnJSON> listJSON = new ArrayList<>();
+ ColumnJSON columnJSON;
for (DataColumnType reportColumnType : reportColumnList) {
columnJSON = new ColumnJSON();
@@ -422,10 +416,10 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "/report/wizard/list_child_report_ff/{reportID}", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody ArrayList<SearchFieldJSON> listChildReportFormFields(@PathVariable("reportID") String reportID,
- HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
+ HttpServletRequest request, HttpServletResponse response) throws RaptorException {
ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, reportID, false);
- ArrayList<SearchFieldJSON> listJSON = new ArrayList<SearchFieldJSON>();
- SearchFieldJSON fieldJSON = new SearchFieldJSON();
+ ArrayList<SearchFieldJSON> listJSON = new ArrayList<>();
+ SearchFieldJSON fieldJSON;
ReportFormFields ddReportFormFields = ddRr.getReportFormFields();
if (ddReportFormFields != null) {
@@ -444,7 +438,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "report/wizard/copy_report/{reportID}", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody MessageJSON copyReport(@PathVariable("reportID") String reportID, HttpServletRequest request,
- HttpServletResponse response) throws IOException, RaptorException {
+ HttpServletResponse response){
MessageJSON messageJSON = new MessageJSON();
try {
@@ -471,7 +465,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "report/wizard/import_report", method = RequestMethod.POST, consumes = "application/json")
public @ResponseBody MessageJSON importReport(@RequestBody ImportJSON importJSON, HttpServletRequest request,
- HttpServletResponse response) throws IOException, RaptorException {
+ HttpServletResponse response) {
MessageJSON messageJSON = new MessageJSON();
try {
String reportXML = importJSON.getReportXML();
@@ -502,7 +496,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "report/wizard/save_formfield_tab_data", method = RequestMethod.POST)
public @ResponseBody MessageJSON saveFFTabWiseData(@RequestBody FormEditJSON formEditJSON,
- HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
+ HttpServletRequest request, HttpServletResponse response) {
ReportDefinition rdef = null;
rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
@@ -559,8 +553,8 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "report/wizard/add_formfield_tab_data", method = RequestMethod.POST)
public @ResponseBody MessageJSON addFFTabWiseData(@RequestBody FormEditJSON formEditJSON,
- HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
- ReportDefinition rdef = null;
+ HttpServletRequest request, HttpServletResponse response) {
+ ReportDefinition rdef;
rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
MessageJSON messageJSON = new MessageJSON();
@@ -605,8 +599,8 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "report/wizard/save_col_tab_data", method = RequestMethod.POST)
public @ResponseBody MessageJSON saveColTabWiseData(@RequestBody ColumnEditJSON columnEditJSON,
- HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
- ReportDefinition rdef = null;
+ HttpServletRequest request, HttpServletResponse response) {
+ ReportDefinition rdef;
rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
MessageJSON messageJSON = new MessageJSON();
@@ -617,7 +611,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
List<DataColumnType> reportColumnList = rdef.getAllColumns();
for (DataColumnType reportColumnType : reportColumnList) {
- // columnJSON = new ColumnJSON();
+
if (reportColumnType.getColId().equals(colId)) {
reportColumnType.setColName(columnEditJSON.getColName());
reportColumnType.setDependsOnFormField(columnEditJSON.getDepeondsOnForField()==null?"":columnEditJSON.getDepeondsOnForField());
@@ -667,10 +661,10 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "report/wizard/save_def_tab_data/{id}", method = RequestMethod.POST)
public @ResponseBody MessageJSON saveDefTabWiseData(@PathVariable("id") String id,
@RequestBody DefinitionJSON definitionJSON, HttpServletRequest request, HttpServletResponse response)
- throws IOException, RaptorException {
- ReportDefinition rdef = null;
- ReportRuntime rr = null;
- boolean newReport = false;
+ {
+ ReportDefinition rdef;
+ ReportRuntime rr;
+ boolean newReport;
MessageJSON messageJSON = new MessageJSON();
try {
String copyReportEvent = (String)request.getSession().getAttribute("COPY_REPORT_EVENT");
@@ -732,9 +726,6 @@ public class RaptorControllerAsync extends RestrictedBaseController {
catch (Exception e) {}
rdef.setDBType(dbType);
String reportName = definitionJSON.getReportName();
- String errorString = "";
- if (AppUtils.nvl(reportName).length() <= 0)
- errorString = "ReportName cannot be null;";
rdef.setReportName(reportName);
String reportDescr = definitionJSON.getReportDescr();
@@ -848,8 +839,8 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = { "/report/wizard/retrieve_form_tab_wise_data/{id}",
"/report/wizard/retrieve_form_tab_wise_data/{id}/{action}" }, method = RequestMethod.GET)
public @ResponseBody FormEditJSON retrieveFormTabWiseData(@PathVariable Map<String, String> pathVariables,
- HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
- ReportDefinition rdef = null;
+ HttpServletRequest request, HttpServletResponse response) {
+ ReportDefinition rdef;
String id = "";
String action = "";
String detailId = "";
@@ -906,8 +897,8 @@ public class RaptorControllerAsync extends RestrictedBaseController {
PredefinedValueList preDefined = fft.getPredefinedValueList();
if (preDefined != null) {
- List<IdNameBooleanJSON> preDefinedList = new ArrayList<IdNameBooleanJSON>();
- IdNameBooleanJSON idNameBooleanJSON = new IdNameBooleanJSON();
+ List<IdNameBooleanJSON> preDefinedList = new ArrayList<>();
+ IdNameBooleanJSON idNameBooleanJSON;
for (String v : preDefined.getPredefinedValue()) {
idNameBooleanJSON = new IdNameBooleanJSON();
@@ -936,8 +927,8 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = { "/report/wizard/retrieve_col_tab_wise_data/{id}" }, method = RequestMethod.GET)
public @ResponseBody ColumnEditJSON retrieveColTabWiseData(@PathVariable Map<String, String> pathVariables,
- HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
- ReportDefinition rdef = null;
+ HttpServletRequest request, HttpServletResponse response) {
+ ReportDefinition rdef;
String id = "";
ColumnEditJSON wizardJSON = new ColumnEditJSON();
rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
@@ -996,19 +987,15 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = { "/report/wizard/retrieve_sql_tab_wise_data/{id}",
"/report/wizard/retrieve_sql_tab_wise_data/" }, method = RequestMethod.GET)
public @ResponseBody QueryJSON retrieveSqlTabWiseData(@PathVariable Map<String, String> pathVariables,
- HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
+ HttpServletRequest request, HttpServletResponse response) throws RaptorException {
ReportDefinition rdef = null;
- ReportRuntime rr = null;
+ ReportRuntime rr;
String id = "";
- String detailId = "";
QueryJSON wizardJSON = new QueryJSON();
if (pathVariables.containsKey("id")) {
id = pathVariables.get("id");
}
- if (pathVariables.containsKey("detailId")) {
- detailId = pathVariables.get("detailId");
- }
ServletContext servletContext = request.getSession().getServletContext();
if (!Globals.isSystemInitialized()) {
Globals.initializeSystem(servletContext);
@@ -1043,7 +1030,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = { "/report/wizard/retrieveTotalForTheColList" }, method = RequestMethod.GET)
public @ResponseBody List<IdNameValue> getTotalForTheCol(HttpServletRequest request)
- throws IOException, RaptorException {
+ {
IdNameList idNameList = AppConstants.TOTAL_FUNCTIONS;
List<IdNameValue> list = new ArrayList<>();
for(int i=0; i<idNameList.getCount(); i++)
@@ -1054,8 +1041,8 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = { "/report/wizard/security/retrieveReportUserList" }, method = RequestMethod.GET)
public @ResponseBody List<SecurityEntry> getReportUserList(HttpServletRequest request)
- throws IOException, RaptorException {
- List<SecurityEntry> reportUserList = new ArrayList<SecurityEntry>();
+ throws RaptorException {
+ List<SecurityEntry> reportUserList = new ArrayList<>();
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
Vector reportUsers = rdef.getReportUsers(request);
for(Iterator iter=reportUsers.iterator(); iter.hasNext();) {
@@ -1067,8 +1054,8 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = { "/report/wizard/security/retrieveReportRoleList" }, method = RequestMethod.GET)
public @ResponseBody List<IdNameValue> getReportRoleList(HttpServletRequest request)
- throws IOException, RaptorException {
- List<IdNameValue> reportRoleList = new ArrayList<IdNameValue>();
+ throws RaptorException {
+ List<IdNameValue> reportRoleList = new ArrayList<>();
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
Vector reportRoles = rdef.getReportRoles(request);
Vector remainingRoles = Utils.getRolesNotInList(reportRoles,request);
@@ -1081,16 +1068,15 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = { "/report/wizard/security/retrieveReportUserList_query" }, method = RequestMethod.GET)
public @ResponseBody List<Map<String, String>> getReportUserListQuery(HttpServletRequest request)
- throws IOException, RaptorException {
+ {
List<Map<String, String>> reportUserList = new ArrayList();
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
String reportId = rdef.getReportID();
- Map<String, Object> params = new HashMap<String, Object>();
+ Map<String, Object> params = new HashMap<>();
params.put("report_id", new Long(reportId));
List<ReportUserRole> queriedUserList = getDataAccessService().executeNamedQuery("getReportSecurityUsers", params, null);
for (int i=0; i<queriedUserList.size();i++){
- Map<String, String> reportUser = new HashMap<String, String>();
- Object tmp = queriedUserList.get(i);
+ Map<String, String> reportUser = new HashMap<>();
reportUser.put("rep_id", queriedUserList.get(i).toString());
reportUser.put("order_no", queriedUserList.get(i).getOrderNo().toString());
reportUser.put("user_id", queriedUserList.get(i).getUserId().toString());
@@ -1106,8 +1092,8 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "/report/security/addReportUser", method = RequestMethod.POST)
public @ResponseBody Map<String,String> addSelectedReportUser(
@RequestBody String userIdToAdd, HttpServletRequest request, HttpServletResponse response)
- throws IOException, RaptorException {
- Map<String, String> JsonResponse = new HashMap<String, String>();
+ {
+ Map<String, String> JsonResponse = new HashMap<>();
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
try {
JsonResponse.put("status","success");
@@ -1127,8 +1113,8 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "/report/security/removeReportUser", method = RequestMethod.POST)
public @ResponseBody Map<String,String> removeSelectedReportUser(
@RequestBody String userIdToRemove, HttpServletRequest request, HttpServletResponse response)
- throws IOException, RaptorException {
- Map<String, String> JsonResponse = new HashMap<String, String>();
+ {
+ Map<String, String> JsonResponse = new HashMap<>();
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
try {
JsonResponse.put("status","success");
@@ -1148,9 +1134,8 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "/report/security/addReportRole", method = RequestMethod.POST)
public @ResponseBody Map<String,String> addSelectedReportRole(
- @RequestBody String roleIdToAdd, HttpServletRequest request, HttpServletResponse response)
- throws IOException, RaptorException {
- Map<String, String> JsonResponse = new HashMap<String, String>();
+ @RequestBody String roleIdToAdd, HttpServletRequest request, HttpServletResponse response) {
+ Map<String, String> JsonResponse = new HashMap<>();
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
try {
JsonResponse.put("status","success");
@@ -1170,7 +1155,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "/report/security/removeReportRole", method = RequestMethod.POST)
public @ResponseBody Map<String,String> removeSelectedReportRole(
@RequestBody String roleIdToRemove, HttpServletRequest request, HttpServletResponse response)
- throws IOException, RaptorException {
+ {
Map<String, String> JsonResponse = new HashMap<String, String>();
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
try {
@@ -1191,9 +1176,9 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "/report/security/updateReportSecurityInfo", method = RequestMethod.POST)
public @ResponseBody Map<String,String> updateReportSecurityInfo(
@RequestBody Map<String,String> securityInfo, HttpServletRequest request, HttpServletResponse response)
- throws IOException, RaptorException {
+ {
- Map<String, String> JsonResponse = new HashMap<String, String>();
+ Map<String, String> JsonResponse = new HashMap<>();
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
try {
JsonResponse.put("status","success");
@@ -1216,8 +1201,8 @@ public class RaptorControllerAsync extends RestrictedBaseController {
public @ResponseBody Map<String,String> toggleUserEditAccess(
@PathVariable("userID") String userId,
@RequestBody String readOnly, HttpServletRequest request, HttpServletResponse response)
- throws IOException, RaptorException {
- Map<String, String> JsonResponse = new HashMap<String, String>();
+ {
+ Map<String, String> JsonResponse = new HashMap<>();
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
try {
String action ="";
@@ -1243,7 +1228,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
public @ResponseBody Map<String,String> toggleRoleEditAccess(
@PathVariable("roleID") String roleId,
@RequestBody String readOnly, HttpServletRequest request, HttpServletResponse response)
- throws IOException, RaptorException {
+ {
Map<String, String> JsonResponse = new HashMap<String, String>();
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
try {
@@ -1268,10 +1253,10 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = { "/report/wizard/security/retrieveReportOwner" }, method = RequestMethod.GET)
public @ResponseBody List<IdNameValue> getReportOwnerInList(HttpServletRequest request)
- throws IOException, RaptorException {
+ throws RaptorException {
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
- List<IdNameValue> UserList = new ArrayList<IdNameValue>();
+ List<IdNameValue> UserList = new ArrayList<>();
List excludeValues = new java.util.ArrayList();
HttpSession session = request.getSession();
String query = Globals.getCustomizedScheduleQueryForUsers();
@@ -1287,7 +1272,6 @@ public class RaptorControllerAsync extends RestrictedBaseController {
}
boolean isAdmin = AppUtils.isAdminUser(request);
Vector allUsers = AppUtils.getAllUsers(query, param, isAdmin);
- Vector result = new Vector(allUsers.size());
for (Iterator iter = allUsers.iterator(); iter.hasNext();) {
IdNameValue value = (IdNameValue) iter.next();
@@ -1308,8 +1292,8 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = { "/report/wizard/security/getReportSecurityInfo" }, method = RequestMethod.GET)
public @ResponseBody Map<String,String> getReportSecurityInfo(HttpServletRequest request)
- throws IOException, RaptorException {
- Map<String, String> securityInfoMap = new HashMap<String,String>();
+ {
+ Map<String, String> securityInfoMap = new HashMap<>();
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
String isPublic = Boolean.toString(rdef.isPublic());
String createUser = AppUtils.getUserName(rdef.getCreateID());
@@ -1330,9 +1314,9 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = { "/report/wizard/security/getReportSecurityUsers" }, method = RequestMethod.GET)
public @ResponseBody List<SecurityEntry> getReportSecurityUsers(HttpServletRequest request)
- throws IOException, RaptorException {
+ throws RaptorException {
- List<SecurityEntry> reportUserMapList = new ArrayList<SecurityEntry>();
+ List<SecurityEntry> reportUserMapList = new ArrayList<>();
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
Vector reportUsers = rdef.getReportUsers(request);
int iCount = 0;
@@ -1349,14 +1333,13 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = { "/report/wizard/security/getReportSecurityRoles" }, method = RequestMethod.GET)
public @ResponseBody List<SecurityEntry> getReportSecurityRoles(HttpServletRequest request)
- throws IOException, RaptorException {
+ throws RaptorException {
- List<SecurityEntry> reportRoleList = new ArrayList<SecurityEntry>();
+ List<SecurityEntry> reportRoleList = new ArrayList<>();
ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
Vector reportRoles = rdef.getReportRoles(request);
- int iCount = 0;
- for(Iterator iter=reportRoles.iterator(); iter.hasNext(); iCount++) {
+ for(Iterator iter=reportRoles.iterator(); iter.hasNext(); ) {
SecurityEntry rRole = (SecurityEntry) iter.next();
reportRoleList.add(rRole);
}
@@ -1368,21 +1351,15 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = { "/report/wizard/retrieve_def_tab_wise_data/{id}",
"/report/wizard/retrieve_def_tab_wise_data/{id}/{detailId}" }, method = RequestMethod.GET)
public @ResponseBody DefinitionJSON retrieveDefTabWiseData(@PathVariable Map<String, String> pathVariables,
- HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
- ReportDefinition rdef = null;
- ReportRuntime rr = null;
- boolean newReport = false;
+ HttpServletRequest request, HttpServletResponse response) throws RaptorException {
+ ReportDefinition rdef;
+ ReportRuntime rr;
String tabId = "Def";
String id = "";
if (pathVariables.containsKey("id")) {
id = pathVariables.get("id");
}
-
- String detailId = "";
- if (pathVariables.containsKey("detailId")) {
- detailId = pathVariables.get("detailId");
- }
ServletContext servletContext = request.getSession().getServletContext();
if (!Globals.isSystemInitialized()) {
@@ -1391,13 +1368,11 @@ public class RaptorControllerAsync extends RestrictedBaseController {
String copyReportEvent = (String)request.getSession().getAttribute("COPY_REPORT_EVENT");
if (tabId.equals("Def") && id.equals("InSession") || "true".equals(copyReportEvent)) {
rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
- newReport = false;
} else if (tabId.equals("Def") && id.equals("Create")) {
removeVariablesFromSession(request);
rdef = (new ReportHandler()).loadReportDefinition(request, "-1");
rdef.setReportType(AppConstants.RT_LINEAR);
- newReport = true;
} else if (tabId.equals("Def") && AppUtils.nvl(id).length() > 0) {
rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
@@ -1417,7 +1392,6 @@ public class RaptorControllerAsync extends RestrictedBaseController {
rdef = (new ReportHandler()).loadReportDefinition(request, id);
request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
}
- newReport = false;
} else {
rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
@@ -1531,7 +1505,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "/report/wizard/retrieve_data/{validate}", method = RequestMethod.POST)
public @ResponseBody RaptorResponse retrieveDataForGivenQuery(@PathVariable("validate") boolean validate,
@RequestBody QueryJSON queryJSON, HttpServletRequest request, HttpServletResponse response)
- throws IOException, RaptorException {
+ throws RaptorException {
RaptorResponse raptorResponse = new RaptorResponse();
String sql = queryJSON.getQuery();
String jsonInString = "";
@@ -1584,7 +1558,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
String remoteDbPrefix = (remoteDb != null && !remoteDb.equalsIgnoreCase("null")) ? remoteDb
: rdef.getDBInfo();
String userId = AppUtils.getUserID(request);
- // String userId = "1";
+
sql = Utils.replaceInString(sql, "[LOGGED_USERID]", userId);
sql = Utils.replaceInString(sql, "[USERID]", userId);
String[] reqParameters = Globals.getRequestParams().split(",");
@@ -1621,25 +1595,20 @@ public class RaptorControllerAsync extends RestrictedBaseController {
rdef.parseReportSQL(query,validate);
queryResultJSON.setQuery(query);
- int numColumns = ds.getColumnCount();
queryResultJSON.setTotalRows(ds.getRowCount());
- int count = 0;
- Map<String, String> dvJSON = null;
- ArrayList<String> colList = new ArrayList<String>();
- ArrayList<Map<String, String>> reportDataRows = new ArrayList<Map<String, String>>();
+ Map<String, String> dvJSON;
+ ArrayList<String> colList = new ArrayList<>();
+ ArrayList<Map<String, String>> reportDataRows = new ArrayList<>();
if (!ds.isEmpty()) {
- count = 0;
for (int i = 0; i < ds.getColumnCount(); i++) {
colList.add(ds.getColumnName(i));
}
queryResultJSON.setReportDataColumns(colList);
if (queryResultJSON.getTotalRows() > 0) {
- count = 0;
- dvJSON = new HashMap<String, String>();
for (int r = 0; r < Math.min(ds.getRowCount(), 100); r++) {
- dvJSON = new HashMap<String, String>();
+ dvJSON = new HashMap<>();
for (int c = 0; c < ds.getColumnCount(); c++) {
try {
dvJSON.put(ds.getColumnName(c), ds.getString(r, c));
@@ -1730,7 +1699,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "/report/wizard/get_report_log/{reportID}", method = RequestMethod.GET)
public @ResponseBody ArrayList<ReportLogEntry> getLogs(@PathVariable("reportID") String reportId, HttpServletRequest request,
- HttpServletResponse ReportLogEntry) throws IOException {
+ HttpServletResponse ReportLogEntry) {
ArrayList<ReportLogEntry> arrayList = new ArrayList<>();
try {
Vector<ReportLogEntry> v = ReportLoader.loadReportLogEntries(reportId);
@@ -1746,7 +1715,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
@RequestMapping(value = "save_chart", method = RequestMethod.POST)
public void reportChartReceive(@RequestBody ChartJSON chartJSON, HttpServletRequest request,
- HttpServletResponse response) throws IOException {
+ HttpServletResponse response) {
ReportRuntime reportRuntime;
reportRuntime = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME); // changing
// session
@@ -1777,7 +1746,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
List<DataColumnType> reportCols = reportRuntime.getAllColumns();
for (Iterator<DataColumnType> iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
+ DataColumnType dct = iter.next();
if (dct.getColId().equals(domainAxis)) {
dct.setColOnChart(AppConstants.GC_LEGEND);
} else {
@@ -1786,14 +1755,14 @@ public class RaptorControllerAsync extends RestrictedBaseController {
}
CategoryAxisJSON categoryAxisJSON = chartJSON.getCategoryAxisJSON();
- String categoryAxis = null;
+ String categoryAxis;
categoryAxis = (categoryAxisJSON != null ? categoryAxisJSON.getValue() : "");
reportCols = reportRuntime.getAllColumns();
for (Iterator<DataColumnType> iter = reportCols.iterator(); iter.hasNext();) {
- DataColumnType dct = (DataColumnType) iter.next();
+ DataColumnType dct = iter.next();
if (dct.getColId().equals(categoryAxis)) {
dct.setChartSeries(true);
} else {
@@ -1816,7 +1785,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
String rangeLineType = AppUtils.nvl(rangeAxisJSON.getRangeLineType());
rangefor: for (Iterator<DataColumnType> iterator = reportCols.iterator(); iterator.hasNext();) {
- DataColumnType dct = (DataColumnType) iterator.next();
+ DataColumnType dct = iterator.next();
if (dct.getColId().equals(rangeAxis)) {
if(removeRangeAxisMap.contains(rangeAxis))
dct.setChartSeq(-1); // if we set it to -1, means this range axis will not be included
@@ -1896,7 +1865,7 @@ public class RaptorControllerAsync extends RestrictedBaseController {
reportRuntime.setRightMargin(chartJSON.getCommonChartOptions().getRightMargin());
for (Iterator<DataColumnType> iterator = reportCols.iterator(); iterator.hasNext();) {
- DataColumnType dct = (DataColumnType) iterator.next();
+ DataColumnType dct = iterator.next();
if (!(AppUtils.nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND)
|| (dct.getChartSeq() != null && dct.getChartSeq() > 0) || dct.isChartSeries())) {
dct.setChartSeq(-1);