summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-analytics/src
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportHandler.java10672
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportLoader.java1614
2 files changed, 6117 insertions, 6169 deletions
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 90f3e2e1..e22d2e23 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,27 +33,27 @@
*
* ============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;
@@ -173,69 +173,71 @@ 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 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(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("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("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("Tahoma");
- styleGreen.setFont(fontGreen);
-
-
+ 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);
+
ArrayList semColumnList = new ArrayList();
List dsList = rr.getDataSourceList().getDataSource();
for (Iterator iter = dsList.iterator(); iter.hasNext();) {
@@ -244,128 +246,128 @@ 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("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(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());
int cellNum = 0;
HSSFRow row = null;
- short s1 = 0, s2 = (short) 1;
- HtmlStripper strip = new HtmlStripper();
+ short s1 = 0;
+ short s2 = (short) 1;
// 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.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.setDataFormat((short) 0);
HSSFFont font = wb.createFont();
- font.setFontHeight((short) (font_size / 0.05));
- font.setFontName("Tahoma");
+ font.setFontHeight((short) (FONT_SIZE / 0.05));
+ font.setFontName(FONT_TAHOMA);
font.setColor(HSSFColor.BLACK.index);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
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("Tahoma");
+ fontDefault.setFontHeight((short) (FONT_SIZE / 0.05));
+ fontDefault.setFontName(FONT_TAHOMA);
fontDefault.setItalic(true);
// Style default will be normal with no background
HSSFCellStyle styleValue = wb.createCellStyle();
- styleValue.setDataFormat((short)0);
+ styleValue.setDataFormat((short) 0);
styleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
styleValue.setBorderBottom(HSSFCellStyle.BORDER_THIN);
styleValue.setBorderTop(HSSFCellStyle.BORDER_THIN);
@@ -377,453 +379,427 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
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.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+ // styleDescription.setBorderTop(HSSFCellStyle.BORDER_THIN);
+ // styleDescription.setBorderRight(HSSFCellStyle.BORDER_THIN);
+ // styleDescription.setBorderLeft(HSSFCellStyle.BORDER_THIN);
HSSFFont fontDescr = wb.createFont();
- fontDescr.setFontHeight((short) (font_size / 0.05)); //14
- fontDescr.setFontName("Tahoma");
+ fontDescr.setFontHeight((short) (FONT_SIZE / 0.05)); // 14
+ fontDescr.setFontName(FONT_TAHOMA);
fontDescr.setColor(HSSFColor.BLACK.index);
fontDescr.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
styleDescription.setFont(font);
HSSFCell cellDescr = null;
int paramSeq = 0;
HSSFHeader 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("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
+ 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
} 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("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
+ 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
Iterator iterCheck = paramsList.iterator();
- if(iterCheck.hasNext()) {
+ if (iterCheck.hasNext()) {
rowNum += 2;
row = sheet.createRow(rowNum);
}
- header.setCenter(HSSFHeader.font("Tahoma", "")+ HSSFHeader.fontSize((short) 9)+" " + strBuf.toString());
+ header.setCenter(HSSFHeader.font(FONT_TAHOMA, "") + HSSFHeader.fontSize((short) 9) + " " + strBuf.toString());
HSSFFooter footer = sheet.getFooter();
- 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());
-
+ 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());
+
}
- 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("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);
+ // 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
+
}
- }
-*/
- 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();
+
+ 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("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.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) {
-
- }
- //Decimal Number
+
+ // 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);
@@ -832,9 +808,9 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
// styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
styleDecimalNumber.setFillPattern(HSSFCellStyle.NO_FILL);
styleDecimalNumber.setFont(fontDefault);
- styleDecimalNumber.setDataFormat((short)0x27);//HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
+ styleDecimalNumber.setDataFormat((short) 0x27);// HSSFDataFormat.getBuiltinFormat("(#,##0.00_);[Red](#,##0.00)"));
- //Decimal Number
+ // Decimal Number
styleDecimalNumberTotal.setAlignment(HSSFCellStyle.ALIGN_CENTER);
styleDecimalNumberTotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
styleDecimalNumberTotal.setBorderTop(HSSFCellStyle.BORDER_THIN);
@@ -843,32 +819,31 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
// styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
styleDecimalNumberTotal.setFillPattern(HSSFCellStyle.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);
- // 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
+ 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);
+ // 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);
@@ -877,10 +852,9 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
// styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
styleCurrencyNumber.setFillPattern(HSSFCellStyle.NO_FILL);
styleCurrencyNumber.setFont(fontDefault);
- styleCurrencyNumber.setDataFormat((short) 6);//HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
-
+ styleCurrencyNumber.setDataFormat((short) 6);// HSSFDataFormat.getBuiltinFormat("($#,##0_);[Red]($#,##0)"));
- //CurrencyNumber
+ // CurrencyNumber
styleCurrencyNumberTotal.setAlignment(HSSFCellStyle.ALIGN_CENTER);
styleCurrencyNumberTotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
styleCurrencyNumberTotal.setBorderTop(HSSFCellStyle.BORDER_THIN);
@@ -889,29 +863,29 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
// styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
styleCurrencyNumberTotal.setFillPattern(HSSFCellStyle.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);
+ 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);
@@ -920,9 +894,9 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
styleCurrencyTotal.setBorderRight(HSSFCellStyle.BORDER_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);
-
+ 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);
@@ -930,1901 +904,1843 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
styleDefaultTotal.setBorderRight(HSSFCellStyle.BORDER_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.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);
+ 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);
+ } 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";
- //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);
+ 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);
} 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) { /*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] #####"));
+ 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;
-
- }
-
- 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(HSSFCellStyle.ALIGN_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(HSSFCellStyle.ALIGN_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(HSSFCellStyle.ALIGN_CENTER);
- HSSFFont fontDescr = wb.createFont();
- fontDescr.setFontHeight((short) (font_size / 0.05)); //14
- fontDescr.setFontName("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);
- }
+ + (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;
- rowNum += 1;
- 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("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);
+ 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 styleFooter = wb.createCellStyle();
- styleFooter.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+ HSSFCellStyle styleHeader = wb.createCellStyle();
+ styleHeader.setAlignment(HSSFCellStyle.ALIGN_CENTER);
HSSFFont font = wb.createFont();
- font.setFontHeight((short) (10 / 0.05));
- font.setFontName("Tahoma");
+ font.setFontHeight((short) (FONT_HEADER_TITLE_SIZE / 0.05)); // 14
+ font.setFontName(FONT_TAHOMA);
font.setColor(HSSFColor.BLACK.index);
- font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
- styleFooter.setFont(font);
+ styleHeader.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));
+ 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;
row = sheet.createRow(rowNum);
- cell = row.createCell((short) 0);
- debugLogger.debug(Globals.getFooterSecondLine());
- cell.setCellValue(Globals.getFooterSecondLine());
- cell.setCellStyle(styleFooter);
-*/
+ // 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);
+ */
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 {
- 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);
+ 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
rowNum = sheet.getLastRowNum();
- } 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);
+ // 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();
}
- //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
+ 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
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();
@@ -2834,7 +2750,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());
@@ -2843,22 +2759,23 @@ 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) {
- System.out.println("File not found in the specified path.");
+ logger.error(EELFLoggerDelegate.errorLogger, "File not found in the specified path.", e);
}
if (xlsIn != null) {
final POIFSFileSystem fileSystem = new POIFSFileSystem(xlsIn);
@@ -2873,8 +2790,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();
@@ -2886,7 +2803,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 {
@@ -2894,8 +2811,9 @@ 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) {
@@ -2910,23 +2828,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();
@@ -2934,9 +2852,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);
@@ -2948,15 +2866,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);
@@ -2983,7 +2901,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);
@@ -3004,7 +2922,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();
@@ -3013,10 +2931,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);
@@ -3033,32 +2951,34 @@ 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);
+
+ 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);
- }
+ returnValue = paintExcelData(wb, rowNum, rd, styles, rr, sheet, sql_whole, request);
+ }
}
if (returnValue == 0) {
if (Globals.getPrintFooterInDownload()) {
@@ -3066,15 +2986,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();
@@ -3085,466 +3005,475 @@ 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
-
-
-
- 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
+ // 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
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();
- }
- }
- }
- } 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;
+ 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 {
- filename = formattedReportName+formattedDate+user_id;
- }
+ // 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();
+ 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();
- }
- 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 #####"));
+ // 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 #####"));
}
- /**
- *
- * @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);
- }
- }
+ /**
+ *
+ * @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());
@@ -3560,13 +3489,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();
@@ -3588,12 +3517,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("\"" + "Run-time Parameters" + "\"");
+ csvOut.print("\"" + RUNTIME_PARAMETERS + "\"");
csvOut.println();
}
csvOut.print("\"" + value.getId() + ":" + "\",");
@@ -3603,14 +3532,15 @@ 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();
}
@@ -3633,8 +3563,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);
@@ -3644,9 +3574,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");
@@ -3667,15 +3597,16 @@ 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())))
+ "\",");
}
@@ -3684,12 +3615,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()) + "\",");
@@ -3732,9 +3663,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) {
@@ -3744,7 +3675,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() + "\",");
@@ -3759,7 +3690,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 + "\",");
@@ -3767,7 +3698,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();
@@ -3778,7 +3709,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()) + "\",");
@@ -3788,12 +3719,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()) + "\",");
@@ -3827,8 +3758,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];
@@ -3862,11 +3793,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();
@@ -3892,336 +3823,349 @@ 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) {
- (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) {
+ 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 {
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());
- }
-// 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);
+ // 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);
}
- 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();
+ 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);
+ } 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;
- }
-
- 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;
+ 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) {
+ sheetName = sheet_name;
}
-
+
public String getSheetName() {
- return SHEET_NAME;
+ return sheetName;
+ }
+
+ /**
+ * 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);
+ }
}
- /**
- * 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(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);
+ 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);
ArrayList semColumnList = new ArrayList();
List dsList = rr.getDataSourceList().getDataSource();
for (Iterator iter = dsList.iterator(); iter.hasNext();) {
@@ -4230,26 +4174,25 @@ 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(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);
+
XSSFCellStyle styleDate = wb.createCellStyle();
styleDate.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
styleDate.setDataFormat(xssffmt.getFormat("d-mmm-yy"));
@@ -4258,275 +4201,244 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
styleDate.setBorderTop(XSSFCellStyle.BORDER_THIN);
styleDate.setBorderLeft(XSSFCellStyle.BORDER_THIN);
styleDate.setBorderRight(XSSFCellStyle.BORDER_THIN);
- // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
+ // styleDefault.setFillForegroundColor(HSSFColor.YELLOW.index);
styleDate.setFillPattern(XSSFCellStyle.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("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(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 {
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("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(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");
@@ -4569,1385 +4481,1463 @@ 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"));
+ }
- 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());
+ 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());
- 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;
+ // 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();
- } // 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());
+ 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();
+ } // 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.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.setDataFormat((short) 0);
XSSFFont font = wb.createFont();
- font.setFontHeight((short) (font_size / 0.05));
- font.setFontName("Tahoma");
+ font.setFontHeight((short) (FONT_SIZE / 0.05));
+ font.setFontName(FONT_TAHOMA);
font.setColor(HSSFColor.BLACK.index);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
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("Tahoma");
+ fontDefault.setFontHeight((short) (FONT_SIZE / 0.05));
+ fontDefault.setFontName(FONT_TAHOMA);
fontDefault.setItalic(true);
// Style default will be normal with no background
XSSFCellStyle styleValue = wb.createCellStyle();
- styleValue.setDataFormat((short)0);
+ styleValue.setDataFormat((short) 0);
styleValue.setAlignment(HSSFCellStyle.ALIGN_CENTER);
styleValue.setBorderBottom(HSSFCellStyle.BORDER_THIN);
styleValue.setBorderTop(HSSFCellStyle.BORDER_THIN);
@@ -5959,423 +5949,411 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject {
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.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+ // styleDescription.setBorderTop(HSSFCellStyle.BORDER_THIN);
+ // styleDescription.setBorderRight(HSSFCellStyle.BORDER_THIN);
+ // styleDescription.setBorderLeft(HSSFCellStyle.BORDER_THIN);
XSSFFont fontDescr = wb.createFont();
- fontDescr.setFontHeight((short) (font_header_descr_size / 0.05));
- fontDescr.setFontName("Tahoma");
+ fontDescr.setFontHeight((short) (FONT_HEADER_DESCR_SIZE / 0.05));
+ fontDescr.setFontName(FONT_TAHOMA);
fontDescr.setColor(HSSFColor.BLACK.index);
fontDescr.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
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("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
+ 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
} 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("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
+ 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
Iterator iterCheck = paramsList.iterator();
- if(iterCheck.hasNext()) {
+ if (iterCheck.hasNext()) {
rowNum += 2;
row = sheet.createRow(rowNum);
}
- header.setCenter(HSSFHeader.font("Tahoma", "")+ HSSFHeader.fontSize((short) font_header_title_size)+strBuf.toString());
+ header.setCenter(HSSFHeader.font(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\">" + "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());
+ 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());
}
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) {
- 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();
+ 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();
} else {
- csvOut.println("<TR><TD COLSPAN=\""+ numberOfColumns + "\">No Data Found</TD></TR>");
+ 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);
-
- }
- }
-
- }
-
-
- }
+ 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/ReportLoader.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportLoader.java
index 03df7731..8072d730 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportLoader.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportLoader.java
@@ -33,10 +33,10 @@
*
* ============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
* ===========================================================================================
*
@@ -44,14 +44,14 @@
* ReportLoader.java - This class is used to call database interaction related to reports.
* -------------------------------------------------------------------------------------------
*
- *
+ *
*
* Changes
* -------
- * 28-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> isDashboardType is made to return false, as any report can be added to Dashboard. </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>Admin User is given the same privilege as Super User when the property
- * "admin_role_equiv_to_super_role" in raptor.properties is Y. A check is made in corresponding to that. </LI></UL>
+ * 28-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> isDashboardType is made to return false, as any report can be added to Dashboard. </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>Admin User is given the same privilege as Super User when the property
+ * "admin_role_equiv_to_super_role" in raptor.properties is Y. A check is made in corresponding to that. </LI></UL>
*
*/
package org.onap.portalsdk.analytics.model;
@@ -93,89 +93,86 @@ import org.owasp.esapi.ESAPI;
public class ReportLoader extends org.onap.portalsdk.analytics.RaptorObject {
- private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportLoader.class);
-
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportLoader.class);
+
+ public static final String NOT_FOUND_IN_DB = " not found in the database";
+
public static String loadCustomReportXML(String reportID) throws RaptorException {
- Connection connection = DbUtils.getConnection();
- try {
- return loadCustomReportXML(connection, reportID);
- } finally {
- DbUtils.clearConnection(connection);
- }
- } // loadCustomReportXML
-
- public static String loadCustomReportXML(Connection connection, String reportID)
- throws RaptorException {
-
- StringBuffer sb = new StringBuffer();
-
- String sql = Globals.getLoadCustomReportXml();
-
- try(PreparedStatement stmt = connection.prepareStatement(sql)) {
-
- stmt.setInt(1,Integer.parseInt(reportID));
-
- try(ResultSet rs = stmt.executeQuery()){
- if(Globals.isWeblogicServer()) {
- java.sql.Clob clob= null;
- Object obj = null;
- if (rs.next()) {
- clob = rs.getClob(1);
- }
- else
- throw new RaptorException("Report " + reportID + " not found in the database");
-
- int len = 0;
- char[] buffer = new char[512];
- Reader in = null;
- in = new InputStreamReader(clob.getAsciiStream());
- // if(obj instanceof oracle.sql.CLOB) {
- // in = ((oracle.sql.CLOB) obj).getCharacterStream();
- // } else if (obj instanceof weblogic.jdbc.wrapper.Clob) {
- // in = ((weblogic.jdbc.base.BaseClob) obj).getCharacterStream();
- // }
- while ((len = in.read(buffer)) != -1)
- sb.append(buffer, 0, len);
- in.close();
- } else if (Globals.isPostgreSQL() || Globals.isMySQL()) {
- String clob= null;
- Object obj = null;
- if (rs.next()) {
- sb.append(rs.getString(1));
- }
- else
- throw new RaptorException("Report " + reportID + " not found in the database");
- } else {
- /*oracle.sql.CLOB clob = null;
- if (rs.next())
- clob = (oracle.sql.CLOB) rs.getObject(1);
- else
- throw new RaptorException("Report " + reportID + " not found in the database");
- int len = 0;
- char[] buffer = new char[512];
- Reader in = clob.getCharacterStream();
- while ((len = in.read(buffer)) != -1)
- sb.append(buffer, 0, len);
- in.close();*/
- throw new RaptorException("only maria db support for this ");
- }
- }
- } catch (SQLException ex) {
- throw new ReportSQLException (ex.getMessage(), ex.getCause());
- } catch (IOException ex) {
- throw new RaptorException (ex.getMessage(), ex.getCause());
- }
- return sb.toString();
- } // loadCustomReportXML
-
- private static void dbUpdateReportXML(Connection connection, String reportID,
- String reportXML) throws RaptorException {
-
- String sql = "";
- if(!Globals.isMySQL())
- sql = Globals.getDBUpdateReportXml();
- else
- sql = Globals.getDBUpdateReportXmlMySqlSelect();
+ Connection connection = DbUtils.getConnection();
+ try {
+ return loadCustomReportXML(connection, reportID);
+ } finally {
+ DbUtils.clearConnection(connection);
+ }
+ } // loadCustomReportXML
+
+ public static String loadCustomReportXML(Connection connection, String reportID)
+ throws RaptorException {
+
+ StringBuffer sb = new StringBuffer();
+
+ String sql = Globals.getLoadCustomReportXml();
+
+ try (PreparedStatement stmt = connection.prepareStatement(sql)) {
+
+ stmt.setInt(1, Integer.parseInt(reportID));
+
+ try (ResultSet rs = stmt.executeQuery()) {
+ if (Globals.isWeblogicServer()) {
+ java.sql.Clob clob = null;
+ Object obj = null;
+ if (rs.next()) {
+ clob = rs.getClob(1);
+ } else
+ throw new RaptorException("Report " + reportID + NOT_FOUND_IN_DB);
+
+ int len = 0;
+ char[] buffer = new char[512];
+ Reader in = null;
+ in = new InputStreamReader(clob.getAsciiStream());
+ // if(obj instanceof oracle.sql.CLOB) {
+ // in = ((oracle.sql.CLOB) obj).getCharacterStream();
+ // } else if (obj instanceof weblogic.jdbc.wrapper.Clob) {
+ // in = ((weblogic.jdbc.base.BaseClob) obj).getCharacterStream();
+ // }
+ while ((len = in.read(buffer)) != -1)
+ sb.append(buffer, 0, len);
+ in.close();
+ } else if (Globals.isPostgreSQL() || Globals.isMySQL()) {
+ String clob = null;
+ Object obj = null;
+ if (rs.next()) {
+ sb.append(rs.getString(1));
+ } else
+ throw new RaptorException("Report " + reportID + NOT_FOUND_IN_DB);
+ } else {
+ /*
+ * oracle.sql.CLOB clob = null; if (rs.next()) clob = (oracle.sql.CLOB) rs.getObject(1); else throw
+ * new RaptorException("Report " + reportID + NOT_FOUND_IN_DB); int len = 0; char[] buffer = new
+ * char[512]; Reader in = clob.getCharacterStream(); while ((len = in.read(buffer)) != -1)
+ * sb.append(buffer, 0, len); in.close();
+ */
+ throw new RaptorException("only maria db support for this ");
+ }
+ }
+ } catch (SQLException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "SQLException occured in loadCustomReportXML", ex);
+ throw new ReportSQLException(ex.getMessage(), ex.getCause());
+ } catch (IOException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "IOException occured in loadCustomReportXML", ex);
+ throw new RaptorException(ex.getMessage(), ex.getCause());
+ }
+ return sb.toString();
+ } // loadCustomReportXML
+
+ private static void dbUpdateReportXML(Connection connection, String reportID,
+ String reportXML) throws RaptorException {
+
+ String sql = "";
+ if (!Globals.isMySQL())
+ sql = Globals.getDBUpdateReportXml();
+ else
+ sql = Globals.getDBUpdateReportXmlMySqlSelect();
try (PreparedStatement stmt = connection.prepareStatement(sql,
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE)) {
@@ -183,14 +180,11 @@ public class ReportLoader extends org.onap.portalsdk.analytics.RaptorObject {
try (ResultSet rs = stmt.executeQuery()) {
// Writer out = null;
/*
- * if(Globals.isWeblogicServer()) { java.sql.Clob clob = null; if (rs.next()) clob =
- * rs.getClob(1); else throw new RaptorException("Report " + reportID +
- * " not found in the database");
+ * if(Globals.isWeblogicServer()) { java.sql.Clob clob = null; if (rs.next()) clob = rs.getClob(1);
+ * else throw new RaptorException("Report " + reportID + NOT_FOUND_IN_DB);
*
- * if (clob.length() > reportXML.length()) clob.truncate(0);
- * //clob.trim(reportXML.length()); out =
- * ((weblogic.jdbc.vendor.oracle.OracleThinClob)clob).getCharacterOutputStream(); }
- * else
+ * if (clob.length() > reportXML.length()) clob.truncate(0); //clob.trim(reportXML.length()); out =
+ * ((weblogic.jdbc.vendor.oracle.OracleThinClob)clob).getCharacterOutputStream(); } else
*/
if (Globals.isPostgreSQL()) {
if (rs.next()) {
@@ -200,7 +194,7 @@ public class ReportLoader extends org.onap.portalsdk.analytics.RaptorObject {
// sb.append(rs.getString(1));
} else {
throw new RaptorException(
- "Report " + reportID + " not found in the database");
+ "Report " + reportID + NOT_FOUND_IN_DB);
}
} else if (Globals.isMySQL()) {
if (rs.next()) {
@@ -215,14 +209,13 @@ public class ReportLoader extends org.onap.portalsdk.analytics.RaptorObject {
}
} else {
throw new RaptorException(
- "Report " + reportID + " not found in the database");
+ "Report " + reportID + NOT_FOUND_IN_DB);
}
} else {
/*
- * oracle.sql.CLOB clob = null; if (rs.next()) clob = (oracle.sql.CLOB)
- * rs.getObject(2); else throw new RaptorException("Report " + reportID +
- * " not found in the database");
+ * oracle.sql.CLOB clob = null; if (rs.next()) clob = (oracle.sql.CLOB) rs.getObject(2); else throw
+ * new RaptorException("Report " + reportID + NOT_FOUND_IN_DB);
*
* if (clob.length() > reportXML.length()) clob.trim(reportXML.length()); out =
* clob.getCharacterOutputStream();
@@ -230,76 +223,67 @@ public class ReportLoader extends org.onap.portalsdk.analytics.RaptorObject {
throw new RaptorException("only maria db support for this ");
}
/*
- * if(!(Globals.isPostgreSQL() || Globals.isMySQL())) { out.write(reportXML);
- * out.flush(); out.close(); }
+ * if(!(Globals.isPostgreSQL() || Globals.isMySQL())) { out.write(reportXML); out.flush();
+ * out.close(); }
*/
}
} catch (SQLException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "SQLException occured in dbUpdateReportXML", ex);
throw new ReportSQLException(ex.getMessage(), ex.getCause());
} catch (IOException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "IOException occured in dbUpdateReportXML", ex);
throw new RaptorException(ex.getMessage(), ex.getCause());
}
} // dbUpdateReportXML
- public static void updateCustomReportRec(Connection connection, ReportWrapper rw,
- String reportXML) throws RaptorException {
- /* DbUtils.executeUpdate(connection,"UPDATE cr_report SET title='"
- + Utils.oracleSafe(rw.getReportName()) + "', descr='"
- + Utils.oracleSafe(rw.getReportDescr()) + "', public_yn='"
- + (rw.isPublic() ? "Y" : "N") + "', menu_id='" + rw.getMenuID()
- + "', menu_approved_yn='" + (rw.isMenuApproved() ? "Y" : "N") + "', owner_id="
- + rw.getOwnerID() + ", maint_id=" + rw.getUpdateID()
- + ", maint_date=TO_DATE('" + rw.getUpdateDate() + "', '"
- + Globals.getOracleTimeFormat() + "'), dashboard_type_yn='"+ (rw.isDashboardType()?"Y":"N")+"', dashboard_yn= '"
- + (rw.getReportType().equals(AppConstants.RT_DASHBOARD)?"Y":"N") + "' WHERE rep_id = " + rw.getReportID());*/
-
- String sql = Globals.getUpdateCustomReportRec();
-
- sql = sql.replace("[Utils.oracleSafe(rw.getReportName())]", Utils.oracleSafe(rw.getReportName()));
- sql = sql.replace("[Utils.oracleSafe(rw.getReportDescr())]", Utils.oracleSafe(rw.getReportDescr()));
- sql = sql.replace("[(rw.isPublic()]",(rw.isPublic() ? "Y" : "N"));
- sql = sql.replace("[rw.getMenuID()]", rw.getMenuID());
- sql = sql.replace("[(rw.isMenuApproved()]", (rw.isMenuApproved() ? "Y" : "N"));
- sql = sql.replace("[rw.getOwnerID()]",rw.getOwnerID());
- sql = sql.replace("[rw.getUpdateID()]",rw.getUpdateID());
- sql = sql.replace("[rw.getUpdateDate()]",rw.getUpdateDate());
- sql = sql.replace("[Globals.getTimeFormat()]", Globals.getTimeFormat());
- sql = sql.replace("[(rw.isDashboardType()]", (rw.isDashboardType()?"Y":"N"));
- sql = sql.replace("[(rw.getReportType().equals(AppConstants.RT_DASHBOARD)]", (rw.getReportType().equals(AppConstants.RT_DASHBOARD)?"Y":"N"));
- sql = sql.replace("[rw.getReportID()]", rw.getReportID());
-
- DbUtils.executeUpdate(connection, sql);
-
- dbUpdateReportXML(connection, rw.getReportID(), reportXML);
- } // updateCustomReportRec
-
- public static boolean isDashboardType ( String reportID ) throws RaptorException {
- return false;
-/* String sql = "select dashboard_type_yn from cr_report where rep_id = ?";
- Connection connection = DbUtils.getConnection();
- PreparedStatement stmt = null;
- ResultSet rs = null;
- boolean dashboardType= false;
- try {
- stmt = connection.prepareStatement(sql);
- stmt.setString(1, reportID);
- rs = stmt.executeQuery();
- if(rs.next()) {
- dashboardType = nvls(rs.getString(1),"N").trim().toUpperCase().startsWith("Y");
- }
- } catch (SQLException ex) {
- throw new ReportSQLException (ex.getMessage(), ex.getCause());
- } finally {
- try {
- rs.close();
- stmt.close();
- DbUtils.clearConnection(connection);
- } catch (SQLException ex) {
- throw new ReportSQLException (ex.getMessage(), ex.getCause());
- }
- }
- return dashboardType;*/
- }
+ public static void updateCustomReportRec(Connection connection, ReportWrapper rw,
+ String reportXML) throws RaptorException {
+ /*
+ * DbUtils.executeUpdate(connection,"UPDATE cr_report SET title='" +
+ * Utils.oracleSafe(rw.getReportName()) + "', descr='" + Utils.oracleSafe(rw.getReportDescr()) +
+ * "', public_yn='" + (rw.isPublic() ? "Y" : "N") + "', menu_id='" + rw.getMenuID() +
+ * "', menu_approved_yn='" + (rw.isMenuApproved() ? "Y" : "N") + "', owner_id=" + rw.getOwnerID() +
+ * ", maint_id=" + rw.getUpdateID() + ", maint_date=TO_DATE('" + rw.getUpdateDate() + "', '" +
+ * Globals.getOracleTimeFormat() + "'), dashboard_type_yn='"+
+ * (rw.isDashboardType()?"Y":"N")+"', dashboard_yn= '" +
+ * (rw.getReportType().equals(AppConstants.RT_DASHBOARD)?"Y":"N") + "' WHERE rep_id = " +
+ * rw.getReportID());
+ */
+
+ String sql = Globals.getUpdateCustomReportRec();
+
+ sql = sql.replace("[Utils.oracleSafe(rw.getReportName())]", Utils.oracleSafe(rw.getReportName()));
+ sql = sql.replace("[Utils.oracleSafe(rw.getReportDescr())]", Utils.oracleSafe(rw.getReportDescr()));
+ sql = sql.replace("[(rw.isPublic()]", (rw.isPublic() ? "Y" : "N"));
+ sql = sql.replace("[rw.getMenuID()]", rw.getMenuID());
+ sql = sql.replace("[(rw.isMenuApproved()]", (rw.isMenuApproved() ? "Y" : "N"));
+ sql = sql.replace("[rw.getOwnerID()]", rw.getOwnerID());
+ sql = sql.replace("[rw.getUpdateID()]", rw.getUpdateID());
+ sql = sql.replace("[rw.getUpdateDate()]", rw.getUpdateDate());
+ sql = sql.replace("[Globals.getTimeFormat()]", Globals.getTimeFormat());
+ sql = sql.replace("[(rw.isDashboardType()]", (rw.isDashboardType() ? "Y" : "N"));
+ sql = sql.replace("[(rw.getReportType().equals(AppConstants.RT_DASHBOARD)]",
+ (rw.getReportType().equals(AppConstants.RT_DASHBOARD) ? "Y" : "N"));
+ sql = sql.replace("[rw.getReportID()]", rw.getReportID());
+
+ DbUtils.executeUpdate(connection, sql);
+
+ dbUpdateReportXML(connection, rw.getReportID(), reportXML);
+ } // updateCustomReportRec
+
+ public static boolean isDashboardType(String reportID) throws RaptorException {
+ return false;
+ /*
+ * String sql = "select dashboard_type_yn from cr_report where rep_id = ?"; Connection connection =
+ * DbUtils.getConnection(); PreparedStatement stmt = null; ResultSet rs = null; boolean
+ * dashboardType= false; try { stmt = connection.prepareStatement(sql); stmt.setString(1, reportID);
+ * rs = stmt.executeQuery(); if(rs.next()) { dashboardType =
+ * nvls(rs.getString(1),"N").trim().toUpperCase().startsWith("Y"); } } catch (SQLException ex) {
+ * throw new ReportSQLException (ex.getMessage(), ex.getCause()); } finally { try { rs.close();
+ * stmt.close(); DbUtils.clearConnection(connection); } catch (SQLException ex) { throw new
+ * ReportSQLException (ex.getMessage(), ex.getCause()); } } return dashboardType;
+ */
+ }
public static boolean isReportsAlreadyScheduled(String reportID) throws RaptorException {
// String sql = "select rep_id from cr_report_schedule where rep_id = ?";
@@ -316,6 +300,7 @@ public class ReportLoader extends org.onap.portalsdk.analytics.RaptorObject {
}
}
} catch (SQLException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "SQLException occured in isReportsAlreadyScheduled", ex);
throw new ReportSQLException(ex.getMessage(), ex.getCause());
} finally {
DbUtils.clearConnection(connection);
@@ -323,93 +308,71 @@ public class ReportLoader extends org.onap.portalsdk.analytics.RaptorObject {
return isScheduled;
}
- public static void createCustomReportRec(Connection connection, ReportWrapper rw,
- String reportXML) throws RaptorException {
-
- /*DbUtils
- .executeUpdate(
- connection,
- "INSERT INTO cr_report(rep_id, title, descr, public_yn, menu_id, menu_approved_yn, report_xml, owner_id, create_id, create_date, maint_id, maint_date, dashboard_type_yn, dashboard_yn, folder_id) VALUES("
- + rw.getReportID()
- + ", '"
- + Utils.oracleSafe(rw.getReportName())
- + "', '"
- + Utils.oracleSafe(rw.getReportDescr())
- + "', '"
- + (rw.isPublic() ? "Y" : "N")
- + "', '"
- + rw.getMenuID()
- + "', '"
- + (rw.isMenuApproved() ? "Y" : "N")
- + "', '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>', "
- + rw.getOwnerID()
- + ", "
- + rw.getCreateID()
- + ", TO_DATE('"
- + rw.getCreateDate()
- + "', '"
- + Globals.getOracleTimeFormat()
- + "'), "
- + rw.getUpdateID()
- + ", TO_DATE('"
- + rw.getUpdateDate()
- + "', '"
- + Globals.getOracleTimeFormat()
- + "'), '"
- + (rw.isDashboardType()?"Y":"N")
- + "', '"
- + (rw.getReportType().equals(AppConstants.RT_DASHBOARD)?"Y":"N")
- + "', "
- + rw.getFolderId()
- + ")");*/
- String sql = Globals.getCreateCustomReportRec();
-
- sql = sql.replace("[rw.getReportID()]", rw.getReportID());
- sql = sql.replace("[Utils.oracleSafe(rw.getReportName())]", Utils.oracleSafe(rw.getReportName()));
- sql = sql.replace("[Utils.oracleSafe(rw.getReportDescr())]", Utils.oracleSafe(rw.getReportDescr()));
- sql = sql.replace("[rw.isPublic()]", (rw.isPublic() ? "Y" : "N"));
- sql = sql.replace("[rw.getMenuID()]", rw.getMenuID());
- sql = sql.replace("[rw.isMenuApproved()]", (rw.isMenuApproved() ? "Y" : "N"));
- sql = sql.replace("[rw.getOwnerID()]", rw.getOwnerID());
- sql = sql.replace("[rw.getCreateID()]", rw.getCreateID());
- sql = sql.replace("[rw.getCreateDate()]", rw.getCreateDate());
- sql = sql.replace("[Globals.getTimeFormat()]", Globals.getTimeFormat());
- sql = sql.replace("[rw.getUpdateID()]", rw.getUpdateID());
- sql = sql.replace("[rw.getUpdateDate()]", rw.getUpdateDate());
- sql = sql.replace("[rw.isDashboardType()]", (rw.isDashboardType()?"Y":"N"));
- sql = sql.replace("[rw.getReportType().equals(AppConstants.RT_DASHBOARD)]", (rw.getReportType().equals(AppConstants.RT_DASHBOARD)?"Y":"N"));
- sql = sql.replace("[rw.getFolderId()]", rw.getFolderId());
-
-
- DbUtils.executeUpdate(connection,sql);
-
- dbUpdateReportXML(connection, rw.getReportID(), reportXML);
- } // createCustomReportRec
-
- public static Vector getUserReportNames(HttpServletRequest request) {
- return getUserReportNames(AppUtils.getUserID(request));
- } // getUserReportNames
-
- public static Vector getUserReportNames(String userID) {
- Vector reportIdNames = new Vector();
-
- try {
-
- String sql = Globals.getTheUserReportNames();
- sql = sql.replace("[userID]", userID);
- DataSet ds = DbUtils.executeQuery(sql);
-
- //DataSet ds = DbUtils
- // .executeQuery("SELECT cr.rep_id, cr.title FROM cr_report cr WHERE nvl(cr.owner_id, cr.create_id) = "
- // + userID);
-
- for (int i = 0; i < ds.getRowCount(); i++)
- reportIdNames.add(new IdNameValue(ds.getString(i, 0), ds.getString(i, 1)));
- } catch (Exception e) {
- }
-
- return reportIdNames;
- } // getUserReportNames
+ public static void createCustomReportRec(Connection connection, ReportWrapper rw,
+ String reportXML) throws RaptorException {
+
+ /*
+ * DbUtils .executeUpdate( connection,
+ * "INSERT INTO cr_report(rep_id, title, descr, public_yn, menu_id, menu_approved_yn, report_xml, owner_id, create_id, create_date, maint_id, maint_date, dashboard_type_yn, dashboard_yn, folder_id) VALUES("
+ * + rw.getReportID() + ", '" + Utils.oracleSafe(rw.getReportName()) + "', '" +
+ * Utils.oracleSafe(rw.getReportDescr()) + "', '" + (rw.isPublic() ? "Y" : "N") + "', '" +
+ * rw.getMenuID() + "', '" + (rw.isMenuApproved() ? "Y" : "N") +
+ * "', '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>', " + rw.getOwnerID() + ", " +
+ * rw.getCreateID() + ", TO_DATE('" + rw.getCreateDate() + "', '" + Globals.getOracleTimeFormat() +
+ * "'), " + rw.getUpdateID() + ", TO_DATE('" + rw.getUpdateDate() + "', '" +
+ * Globals.getOracleTimeFormat() + "'), '" + (rw.isDashboardType()?"Y":"N") + "', '" +
+ * (rw.getReportType().equals(AppConstants.RT_DASHBOARD)?"Y":"N") + "', " + rw.getFolderId() + ")");
+ */
+ String sql = Globals.getCreateCustomReportRec();
+
+ sql = sql.replace("[rw.getReportID()]", rw.getReportID());
+ sql = sql.replace("[Utils.oracleSafe(rw.getReportName())]", Utils.oracleSafe(rw.getReportName()));
+ sql = sql.replace("[Utils.oracleSafe(rw.getReportDescr())]", Utils.oracleSafe(rw.getReportDescr()));
+ sql = sql.replace("[rw.isPublic()]", (rw.isPublic() ? "Y" : "N"));
+ sql = sql.replace("[rw.getMenuID()]", rw.getMenuID());
+ sql = sql.replace("[rw.isMenuApproved()]", (rw.isMenuApproved() ? "Y" : "N"));
+ sql = sql.replace("[rw.getOwnerID()]", rw.getOwnerID());
+ sql = sql.replace("[rw.getCreateID()]", rw.getCreateID());
+ sql = sql.replace("[rw.getCreateDate()]", rw.getCreateDate());
+ sql = sql.replace("[Globals.getTimeFormat()]", Globals.getTimeFormat());
+ sql = sql.replace("[rw.getUpdateID()]", rw.getUpdateID());
+ sql = sql.replace("[rw.getUpdateDate()]", rw.getUpdateDate());
+ sql = sql.replace("[rw.isDashboardType()]", (rw.isDashboardType() ? "Y" : "N"));
+ sql = sql.replace("[rw.getReportType().equals(AppConstants.RT_DASHBOARD)]",
+ (rw.getReportType().equals(AppConstants.RT_DASHBOARD) ? "Y" : "N"));
+ sql = sql.replace("[rw.getFolderId()]", rw.getFolderId());
+
+ DbUtils.executeUpdate(connection, sql);
+
+ dbUpdateReportXML(connection, rw.getReportID(), reportXML);
+ } // createCustomReportRec
+
+ public static Vector getUserReportNames(HttpServletRequest request) {
+ return getUserReportNames(AppUtils.getUserID(request));
+ } // getUserReportNames
+
+ public static Vector getUserReportNames(String userID) {
+ Vector reportIdNames = new Vector();
+
+ try {
+
+ String sql = Globals.getTheUserReportNames();
+ sql = sql.replace("[userID]", userID);
+ DataSet ds = DbUtils.executeQuery(sql);
+
+ // DataSet ds = DbUtils
+ // .executeQuery("SELECT cr.rep_id, cr.title FROM cr_report cr WHERE nvl(cr.owner_id, cr.create_id)
+ // = "
+ // + userID);
+
+ for (int i = 0; i < ds.getRowCount(); i++)
+ reportIdNames.add(new IdNameValue(ds.getString(i, 0), ds.getString(i, 1)));
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Exception occured in getUserReportNames", e);
+ }
+
+ return reportIdNames;
+ } // getUserReportNames
public static String getReportOwnerID(String reportID) throws RaptorException {
@@ -429,6 +392,7 @@ public class ReportLoader extends org.onap.portalsdk.analytics.RaptorObject {
}
}
} catch (SQLException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "SQLException occured in getReportOwnerID", ex);
throw new ReportSQLException(ex.getMessage(), ex.getCause());
} finally {
DbUtils.clearConnection(connection);
@@ -437,615 +401,621 @@ public class ReportLoader extends org.onap.portalsdk.analytics.RaptorObject {
return reportOwnerID;
} // getReportOwnerID
- public static void deleteReportRecord(String reportID) throws RaptorException {
- Connection con = DbUtils.startTransaction();
-
- /*try {
- DbUtils.executeUpdate(con, "DELETE cr_report_log WHERE rep_id = " + reportID);
- DbUtils.executeUpdate(con, "DELETE cr_report_schedule_users WHERE rep_id = "
- + reportID);
- DbUtils.executeUpdate(con, "DELETE cr_report_schedule WHERE rep_id = " + reportID);
- DbUtils.executeUpdate(con, "DELETE cr_report_access WHERE rep_id = " + reportID);
- DbUtils.executeUpdate(con, "DELETE cr_report_email_sent_log WHERE rep_id = " + reportID);
- DbUtils.executeUpdate(con, "DELETE cr_favorite_reports WHERE rep_id = " + reportID);
- DbUtils.executeUpdate(con, "DELETE cr_report WHERE rep_id = " + reportID);
- DbUtils.commitTransaction(con);
- } */
-
- try{
- String sql1= Globals.getDeleteReportRecordLog();
- sql1 = sql1.replace("[reportID]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),reportID));
- String sql2= Globals.getDeleteReportRecordUsers();
- sql2 = sql2.replace("[reportID]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),reportID));
- String sql3= Globals.getDeleteReportRecordSchedule();
- sql3 = sql3.replace("[reportID]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),reportID));
- String sql4= Globals.getDeleteReportRecordAccess();
- sql4 = sql4.replace("[reportID]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),reportID));
- String sql5= Globals.getDeleteReportRecordEmail();
- sql5 = sql5.replace("[reportID]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),reportID));
- String sql6= Globals.getDeleteReportRecordFavorite();
- sql6 = sql6.replace("[reportID]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),reportID));
- String sql7= Globals.getDeleteReportRecordReport();
- sql7 = sql7.replace("[reportID]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),reportID));
-
- DbUtils.executeUpdate(con, sql1);
- DbUtils.executeUpdate(con, sql2);
- DbUtils.executeUpdate(con, sql3);
- DbUtils.executeUpdate(con, sql4);
- DbUtils.executeUpdate(con, sql5);
- DbUtils.executeUpdate(con, sql6);
- DbUtils.executeUpdate(con, sql7);
- DbUtils.commitTransaction(con);
-
- }
-
-
- catch (Exception e) {
- DbUtils.rollbackTransaction(con);
- } finally {
- DbUtils.clearConnection(con);
+ public static void deleteReportRecord(String reportID) throws RaptorException {
+ Connection con = DbUtils.startTransaction();
+
+ /*
+ * try { DbUtils.executeUpdate(con, "DELETE cr_report_log WHERE rep_id = " + reportID);
+ * DbUtils.executeUpdate(con, "DELETE cr_report_schedule_users WHERE rep_id = " + reportID);
+ * DbUtils.executeUpdate(con, "DELETE cr_report_schedule WHERE rep_id = " + reportID);
+ * DbUtils.executeUpdate(con, "DELETE cr_report_access WHERE rep_id = " + reportID);
+ * DbUtils.executeUpdate(con, "DELETE cr_report_email_sent_log WHERE rep_id = " + reportID);
+ * DbUtils.executeUpdate(con, "DELETE cr_favorite_reports WHERE rep_id = " + reportID);
+ * DbUtils.executeUpdate(con, "DELETE cr_report WHERE rep_id = " + reportID);
+ * DbUtils.commitTransaction(con); }
+ */
+
+ try {
+ String sql1 = Globals.getDeleteReportRecordLog();
+ sql1 = sql1.replace("[reportID]", ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), reportID));
+ String sql2 = Globals.getDeleteReportRecordUsers();
+ sql2 = sql2.replace("[reportID]", ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), reportID));
+ String sql3 = Globals.getDeleteReportRecordSchedule();
+ sql3 = sql3.replace("[reportID]", ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), reportID));
+ String sql4 = Globals.getDeleteReportRecordAccess();
+ sql4 = sql4.replace("[reportID]", ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), reportID));
+ String sql5 = Globals.getDeleteReportRecordEmail();
+ sql5 = sql5.replace("[reportID]", ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), reportID));
+ String sql6 = Globals.getDeleteReportRecordFavorite();
+ sql6 = sql6.replace("[reportID]", ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), reportID));
+ String sql7 = Globals.getDeleteReportRecordReport();
+ sql7 = sql7.replace("[reportID]", ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), reportID));
+
+ DbUtils.executeUpdate(con, sql1);
+ DbUtils.executeUpdate(con, sql2);
+ DbUtils.executeUpdate(con, sql3);
+ DbUtils.executeUpdate(con, sql4);
+ DbUtils.executeUpdate(con, sql5);
+ DbUtils.executeUpdate(con, sql6);
+ DbUtils.executeUpdate(con, sql7);
+ DbUtils.commitTransaction(con);
+
}
- } // deleteReportRecord
-
- public static ArrayList loadQuickLinks(HttpServletRequest request, String menuId, boolean b) throws RaptorException {
- String userID = AppUtils.getUserID(request);
- StringBuffer roleList = new StringBuffer();
- roleList.append("-1");
- for (Iterator iter = AppUtils.getUserRoles(request).iterator(); iter.hasNext();)
- roleList.append("," + ((String) iter.next()));
-
- // DataSet ds = DbUtils.executeQuery("SELECT cr.rep_id, cr.title FROM
- // cr_report cr WHERE cr.public_yn = 'Y' AND cr.menu_id =
- // '"+nvls(menuId)+"' AND cr.menu_approved_yn = 'Y' ORDER BY cr.title");
- // Copied from SearchHandler and simplified
- /*String query = "SELECT cr.rep_id, "
- + "cr.title, "
- + "cr.descr "
- + "FROM cr_report cr, "
- + "(SELECT rep_id, "
- + "MIN(read_only_yn) read_only_yn "
- + "FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = "
- + userID
- + ") "
- + "UNION ALL "
- + "(SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN ("
- + roleList.toString() + "))" + ") report_access "
- + "GROUP BY rep_id) ra " + "WHERE INSTR('|'||cr.menu_id||'|', '|'||'"
- + nvls(menuId) + "'||'|') > 0 AND " + "cr.menu_approved_yn = 'Y' AND "
- + "cr.rep_id = ra.rep_id (+) AND "
- + "(nvl(cr.owner_id, cr.create_id) = " + userID
- + " OR cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL) "
- + "ORDER BY cr.title";*/
-
- String query = Globals.getLoadQuickLinks();
- query = query.replace("[userID]", userID);
- query = query.replace("[roleList.toString()]", roleList.toString());
- query = query.replace("[nvls(menuId)]", nvls(menuId));
-
- DataSet ds = DbUtils
- .executeQuery(query);
-
- ArrayList quickLinks = new ArrayList(ds.getRowCount());
- StringBuffer link = new StringBuffer("");
- for (int i = 0; i < ds.getRowCount(); i++) {
- link = new StringBuffer("");
- link.append("<a href=\"" + AppUtils.getReportExecuteActionURL() + ds.getString(i, 0));
- if(b) link.append("&PAGE_ID="+menuId+"&refresh=Y");
- link.append("\">" +ds.getString(i, 1) + "</a>" + (Globals.getShowDescrAtRuntime() ? " - " + ds.getString(i, 2) : "") );
- quickLinks.add(link.toString());
+
+ catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Exception occured in deleteReportRecord", e);
+ DbUtils.rollbackTransaction(con);
+ } finally {
+ DbUtils.clearConnection(con);
}
+ } // deleteReportRecord
+
+ public static ArrayList loadQuickLinks(HttpServletRequest request, String menuId, boolean b)
+ throws RaptorException {
+ String userID = AppUtils.getUserID(request);
+ StringBuffer roleList = new StringBuffer();
+ roleList.append("-1");
+ for (Iterator iter = AppUtils.getUserRoles(request).iterator(); iter.hasNext();)
+ roleList.append("," + ((String) iter.next()));
+
+ // DataSet ds = DbUtils.executeQuery("SELECT cr.rep_id, cr.title FROM
+ // cr_report cr WHERE cr.public_yn = 'Y' AND cr.menu_id =
+ // '"+nvls(menuId)+"' AND cr.menu_approved_yn = 'Y' ORDER BY cr.title");
+ // Copied from SearchHandler and simplified
+ /*
+ * String query = "SELECT cr.rep_id, " + "cr.title, " + "cr.descr " + "FROM cr_report cr, " +
+ * "(SELECT rep_id, " + "MIN(read_only_yn) read_only_yn " +
+ * "FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = " + userID
+ * + ") " + "UNION ALL " +
+ * "(SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN (" +
+ * roleList.toString() + "))" + ") report_access " + "GROUP BY rep_id) ra " +
+ * "WHERE INSTR('|'||cr.menu_id||'|', '|'||'" + nvls(menuId) + "'||'|') > 0 AND " +
+ * "cr.menu_approved_yn = 'Y' AND " + "cr.rep_id = ra.rep_id (+) AND " +
+ * "(nvl(cr.owner_id, cr.create_id) = " + userID +
+ * " OR cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL) " + "ORDER BY cr.title";
+ */
+
+ String query = Globals.getLoadQuickLinks();
+ query = query.replace("[userID]", userID);
+ query = query.replace("[roleList.toString()]", roleList.toString());
+ query = query.replace("[nvls(menuId)]", nvls(menuId));
+
+ DataSet ds = DbUtils
+ .executeQuery(query);
- return quickLinks;
- } // loadQuickLinks
-
- public static ArrayList<QuickLink> getQuickLinksJSON(HttpServletRequest request, String menuId, boolean b) throws RaptorException {
- String userID = AppUtils.getUserID(request);
- StringBuffer roleList = new StringBuffer();
- roleList.append("-1");
- for (Iterator iter = AppUtils.getUserRoles(request).iterator(); iter.hasNext();)
- roleList.append("," + ((String) iter.next()));
-
- String query = Globals.getLoadQuickLinks();
- query = query.replace("[userID]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),userID));
- query = query.replace("[roleList.toString()]", roleList.toString());
- query = query.replace("[nvls(menuId)]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),nvls(menuId)));
-
- DataSet ds = DbUtils
- .executeQuery(query);
-
- ArrayList<QuickLink> quickLinksArray = new ArrayList<QuickLink>(ds.getRowCount());
+ ArrayList quickLinks = new ArrayList(ds.getRowCount());
+ StringBuffer link = new StringBuffer("");
for (int i = 0; i < ds.getRowCount(); i++) {
- QuickLink quickLink = new QuickLink();
- StringBuffer link = new StringBuffer("");
- link.append(AppUtils.getReportExecuteActionURLNG() +"c_master="+ ds.getString(i, 0));
- if(b) link.append("&PAGE_ID="+menuId+"&refresh=Y");
- quickLink.setReportURL(link.toString());
- quickLink.setReportName(ds.getString(i, 1));
- quickLink.setShowDescr(Globals.getShowDescrAtRuntime());
- quickLink.setReportDescr(ds.getString(i, 2));
- quickLinksArray.add(quickLink);
+ link = new StringBuffer("");
+ link.append("<a href=\"" + AppUtils.getReportExecuteActionURL() + ds.getString(i, 0));
+ if (b)
+ link.append("&PAGE_ID=" + menuId + "&refresh=Y");
+ link.append("\">" + ds.getString(i, 1) + "</a>"
+ + (Globals.getShowDescrAtRuntime() ? " - " + ds.getString(i, 2) : ""));
+ quickLinks.add(link.toString());
}
- return quickLinksArray;
- } // loadQuickLinks
-
- //this will retrieve all the reports within the specified folder.
- public static ReportSearchResult loadFolderReports(HttpServletRequest request, String menuId, boolean b, String folderId, boolean isUserReport, boolean isPublicReport) throws RaptorException {
- String HTML_FORM = "forma";
- String userID = AppUtils.getUserID(request);
- StringBuffer roleList = new StringBuffer();
- roleList.append("-1");
- String rep_title_sql = "'<a class=\"hyperref1\" href=''#'' onClick=''document."+HTML_FORM+"."+AppConstants.RI_ACTION+".value=\"report.run\";"+
- "document."+HTML_FORM+".c_master.value=\"'|| cr.rep_id||'\";document."+HTML_FORM+".submit()''>'";
- String PRIVATE_ICON = "<img border=0 src="
- + AppUtils.getImgFolderURL()
- + "accessicon.gif alt=Private width=16 height=12>&nbsp;";
-
- for (Iterator iter = AppUtils.getUserRoles(request).iterator(); iter.hasNext();)
- roleList.append("," + ((String) iter.next()));
-
- /*String sql= "SELECT cr.rep_id, " +
- "cr.rep_id report_id, " +
- rep_title_sql+
- "||DECODE(cr.public_yn, 'Y', '', '" +
- PRIVATE_ICON +
- "')||cr.title||'</a>' title, " +
- "cr.descr, " +
- "au.first_name||' '||au.last_name owner_name, " +
- "TO_CHAR(cr.create_date, 'MM/DD/YYYY') create_date, " +
- "DECODE(NVL(cr.owner_id, cr.create_id), " +
- userID +
- ", 'N', NVL(ra.read_only_yn, 'Y')) read_only_yn, " +
- "DECODE(NVL(cr.owner_id, cr.create_id), " +
- userID +
- ", 'Y', 'N') user_is_owner_yn " +
- " FROM cr_report cr, " +
- "app_user au, " +
- "(SELECT rep_id, MIN(read_only_yn) read_only_yn " +
- "FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = " +
- userID +
- ") " +
- "UNION ALL " +
- "(SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN " +
- "(-1,1000,1))" + ") report_access GROUP BY rep_id) ra " +
- "WHERE TO_CHAR(cr.rep_id) = nvl('', TO_CHAR(cr.rep_id)) AND UPPER(cr.title) LIKE UPPER('%%') " +
- "AND nvl(cr.owner_id, cr.create_id) = au.user_id AND cr.rep_id = ra.rep_id (+) " +
- " AND cr.folder_id= '" + folderId + "'" ;*/
-
- /*String sql = "" +
- "SELECT cr.rep_id, "
- + "cr.rep_id report_id, "
- + rep_title_sql + "||DECODE(cr.public_yn, 'Y', '', '" + PRIVATE_ICON + "')||cr.title||'</a>' title, "
- + "cr.descr, "
- + "au.first_name||' '||au.last_name owner_name, "
- + "TO_CHAR(cr.create_date, 'MM/DD/YYYY') create_date, "
- + "DECODE(NVL(cr.owner_id, cr.create_id), " + userID
- + ", 'N', NVL(ra.read_only_yn, 'Y')) read_only_yn, "
- + "DECODE(NVL(cr.owner_id, cr.create_id), " + userID
- + ", 'Y', 'N') user_is_owner_yn "
- + "FROM cr_report cr, "
- + "app_user au, "
- + "(SELECT rep_id, "
- + "MIN(read_only_yn) read_only_yn "
- + "FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = "
- + userID
- + ") "
- + "UNION ALL "
- + "(SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN ("
- + roleList.toString() + "))" + ") report_access " + "GROUP BY rep_id) ra "
- + "WHERE " + "nvl(cr.owner_id, cr.create_id) = au.user_id "
- + "AND cr.rep_id = ra.rep_id (+) AND cr.folder_id= '" + folderId + "'";*/
-
- String sql = Globals.getLoadFolderReports();
- sql = sql.replace("[userID]", userID);
- sql = sql.replace("[PRIVATE_ICON]", PRIVATE_ICON);
- sql = sql.replace("[rep_title_sql]", rep_title_sql);
- sql = sql.replace("[roleList.toString()]", roleList.toString());
- sql = sql.replace("[folderId]", folderId);
-
-
- // String user_sql = " AND nvl(cr.owner_id, cr.create_id) = " + userID;
- // String public_sql = " AND (nvl(cr.owner_id, cr.create_id) = " + userID
- // + " OR cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL)";
-
- String user_sql = Globals.getLoadFolderReportsUser();
- user_sql = user_sql.replace("[userID]", userID);
- String public_sql = Globals.getLoadFolderReportsPublicSql();
- public_sql = public_sql.replace("[userID]", userID);
-
- if (isUserReport)
- // My reports - user is owner
- sql += user_sql;
- else if (isPublicReport)
- // Public reports - user has read or write access to the report
- // (user is owner or report is public or user has explicit user or
- // role access)
- if (!AppUtils.isSuperUser(request))
- sql += public_sql;
- else if (!AppUtils.isSuperUser(request))
- // All reports
- // If user is super user - gets unrestricted access to all reports
- // (read_only gets overriden later)
- // else - not super user - doesn't get access to private reports of
- // other users (= Public reports); Admin users get edit right
- // override later
- sql += public_sql;
- logger.debug(EELFLoggerDelegate.debugLogger, ("query is for folder list is : " + sql));
-
- DataSet ds = DbUtils.executeQuery(sql);
-
- /*Vector quickLinks = new Vector(ds.getRowCount());
- StringBuffer link = new StringBuffer("");
+ return quickLinks;
+ } // loadQuickLinks
+
+ public static ArrayList<QuickLink> getQuickLinksJSON(HttpServletRequest request, String menuId, boolean b)
+ throws RaptorException {
+ String userID = AppUtils.getUserID(request);
+ StringBuffer roleList = new StringBuffer();
+ roleList.append("-1");
+ for (Iterator iter = AppUtils.getUserRoles(request).iterator(); iter.hasNext();)
+ roleList.append("," + ((String) iter.next()));
+
+ String query = Globals.getLoadQuickLinks();
+ query = query.replace("[userID]", ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), userID));
+ query = query.replace("[roleList.toString()]", roleList.toString());
+ query = query.replace("[nvls(menuId)]",
+ ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), nvls(menuId)));
+
+ DataSet ds = DbUtils
+ .executeQuery(query);
+
+ ArrayList<QuickLink> quickLinksArray = new ArrayList<QuickLink>(ds.getRowCount());
for (int i = 0; i < ds.getRowCount(); i++) {
- link = new StringBuffer("");
- link.append("<a href=\"" + AppUtils.getReportExecuteActionURL() + ds.getString(i, 0));
- if(b) link.append("&PAGE_ID="+menuId+"&refresh=Y");
- link.append("\">" +ds.getString(i, 2) + "</a>" + (Globals.getShowDescrAtRuntime() ? " - " + ds.getString(i, 2) : "") );
- quickLinks.add(link.toString());
+ QuickLink quickLink = new QuickLink();
+ StringBuffer link = new StringBuffer("");
+ link.append(AppUtils.getReportExecuteActionURLNG() + "c_master=" + ds.getString(i, 0));
+ if (b)
+ link.append("&PAGE_ID=" + menuId + "&refresh=Y");
+ quickLink.setReportURL(link.toString());
+ quickLink.setReportName(ds.getString(i, 1));
+ quickLink.setShowDescr(Globals.getShowDescrAtRuntime());
+ quickLink.setReportDescr(ds.getString(i, 2));
+ quickLinksArray.add(quickLink);
}
- return quickLinks;*/
- ReportSearchResult rsr = new ReportSearchResult(-1, ds.getRowCount(), 6, 7);
- rsr.parseData(ds, request);
- //rsr.truncateToPage(pageNo);
-
- return rsr;
- } // loadFolderReports
+ return quickLinksArray;
+ } // loadQuickLinks
+
+ // this will retrieve all the reports within the specified folder.
+ public static ReportSearchResult loadFolderReports(HttpServletRequest request, String menuId, boolean b,
+ String folderId, boolean isUserReport, boolean isPublicReport) throws RaptorException {
+ String HTML_FORM = "forma";
+ String userID = AppUtils.getUserID(request);
+ StringBuffer roleList = new StringBuffer();
+ roleList.append("-1");
+ String rep_title_sql = "'<a class=\"hyperref1\" href=''#'' onClick=''document." + HTML_FORM + "."
+ + AppConstants.RI_ACTION + ".value=\"report.run\";" +
+ "document." + HTML_FORM + ".c_master.value=\"'|| cr.rep_id||'\";document." + HTML_FORM
+ + ".submit()''>'";
+ String PRIVATE_ICON = "<img border=0 src="
+ + AppUtils.getImgFolderURL()
+ + "accessicon.gif alt=Private width=16 height=12>&nbsp;";
+
+ for (Iterator iter = AppUtils.getUserRoles(request).iterator(); iter.hasNext();)
+ roleList.append("," + ((String) iter.next()));
+
+ /*
+ * String sql= "SELECT cr.rep_id, " + "cr.rep_id report_id, " + rep_title_sql+
+ * "||DECODE(cr.public_yn, 'Y', '', '" + PRIVATE_ICON + "')||cr.title||'</a>' title, " +
+ * "cr.descr, " + "au.first_name||' '||au.last_name owner_name, " +
+ * "TO_CHAR(cr.create_date, 'MM/DD/YYYY') create_date, " + "DECODE(NVL(cr.owner_id, cr.create_id), "
+ * + userID + ", 'N', NVL(ra.read_only_yn, 'Y')) read_only_yn, " +
+ * "DECODE(NVL(cr.owner_id, cr.create_id), " + userID + ", 'Y', 'N') user_is_owner_yn " +
+ * " FROM cr_report cr, " + "app_user au, " + "(SELECT rep_id, MIN(read_only_yn) read_only_yn " +
+ * "FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = " + userID
+ * + ") " + "UNION ALL " +
+ * "(SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN " +
+ * "(-1,1000,1))" + ") report_access GROUP BY rep_id) ra " +
+ * "WHERE TO_CHAR(cr.rep_id) = nvl('', TO_CHAR(cr.rep_id)) AND UPPER(cr.title) LIKE UPPER('%%') " +
+ * "AND nvl(cr.owner_id, cr.create_id) = au.user_id AND cr.rep_id = ra.rep_id (+) " +
+ * " AND cr.folder_id= '" + folderId + "'" ;
+ */
+
+ /*
+ * String sql = "" + "SELECT cr.rep_id, " + "cr.rep_id report_id, " + rep_title_sql +
+ * "||DECODE(cr.public_yn, 'Y', '', '" + PRIVATE_ICON + "')||cr.title||'</a>' title, " +
+ * "cr.descr, " + "au.first_name||' '||au.last_name owner_name, " +
+ * "TO_CHAR(cr.create_date, 'MM/DD/YYYY') create_date, " + "DECODE(NVL(cr.owner_id, cr.create_id), "
+ * + userID + ", 'N', NVL(ra.read_only_yn, 'Y')) read_only_yn, " +
+ * "DECODE(NVL(cr.owner_id, cr.create_id), " + userID + ", 'Y', 'N') user_is_owner_yn " +
+ * "FROM cr_report cr, " + "app_user au, " + "(SELECT rep_id, " + "MIN(read_only_yn) read_only_yn "
+ * + "FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = " +
+ * userID + ") " + "UNION ALL " +
+ * "(SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN (" +
+ * roleList.toString() + "))" + ") report_access " + "GROUP BY rep_id) ra " + "WHERE " +
+ * "nvl(cr.owner_id, cr.create_id) = au.user_id " +
+ * "AND cr.rep_id = ra.rep_id (+) AND cr.folder_id= '" + folderId + "'";
+ */
+
+ String sql = Globals.getLoadFolderReports();
+ sql = sql.replace("[userID]", userID);
+ sql = sql.replace("[PRIVATE_ICON]", PRIVATE_ICON);
+ sql = sql.replace("[rep_title_sql]", rep_title_sql);
+ sql = sql.replace("[roleList.toString()]", roleList.toString());
+ sql = sql.replace("[folderId]", folderId);
+
+ // String user_sql = " AND nvl(cr.owner_id, cr.create_id) = " + userID;
+ // String public_sql = " AND (nvl(cr.owner_id, cr.create_id) = " + userID
+ // + " OR cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL)";
+
+ String user_sql = Globals.getLoadFolderReportsUser();
+ user_sql = user_sql.replace("[userID]", userID);
+ String public_sql = Globals.getLoadFolderReportsPublicSql();
+ public_sql = public_sql.replace("[userID]", userID);
+
+ if (isUserReport)
+ // My reports - user is owner
+ sql += user_sql;
+ else if (isPublicReport)
+ // Public reports - user has read or write access to the report
+ // (user is owner or report is public or user has explicit user or
+ // role access)
+ if (!AppUtils.isSuperUser(request))
+ sql += public_sql;
+ else if (!AppUtils.isSuperUser(request))
+ // All reports
+ // If user is super user - gets unrestricted access to all reports
+ // (read_only gets overriden later)
+ // else - not super user - doesn't get access to private reports of
+ // other users (= Public reports); Admin users get edit right
+ // override later
+ sql += public_sql;
+ logger.debug(EELFLoggerDelegate.debugLogger, ("query is for folder list is : " + sql));
+
+ DataSet ds = DbUtils.executeQuery(sql);
+
+ /*
+ * Vector quickLinks = new Vector(ds.getRowCount()); StringBuffer link = new StringBuffer(""); for
+ * (int i = 0; i < ds.getRowCount(); i++) { link = new StringBuffer(""); link.append("<a href=\"" +
+ * AppUtils.getReportExecuteActionURL() + ds.getString(i, 0)); if(b)
+ * link.append("&PAGE_ID="+menuId+"&refresh=Y"); link.append("\">" +ds.getString(i, 2) + "</a>" +
+ * (Globals.getShowDescrAtRuntime() ? " - " + ds.getString(i, 2) : "") );
+ * quickLinks.add(link.toString()); }
+ *
+ * return quickLinks;
+ */
+ ReportSearchResult rsr = new ReportSearchResult(-1, ds.getRowCount(), 6, 7);
+ rsr.parseData(ds, request);
+ // rsr.truncateToPage(pageNo);
+
+ return rsr;
+ } // loadFolderReports
public static ArrayList loadQuickDownloadLinks(String userID, HttpServletRequest request) throws RaptorException {
- /*String query = " SELECT a.file_name, b.title,to_char(a.dwnld_start_time, 'Dy DD-Mon-YYYY HH24:MI:SS') as time, "+
- " a.dwnld_start_time " +
- " FROM cr_report_dwnld_log a, cr_report b where a.user_id = "+userID +" and "+
- " a.rep_id = b.rep_id " +
- " and (a.dwnld_start_time) >= to_date(to_char(sysdate-24/24, 'mm/dd/yyyy'), 'mm/dd/yyyy') " +
- " and a.record_ready_time is not null " +
- " order by a.dwnld_start_time desc"; */
-
- String query = Globals.getLoadQuickDownloadLinks();
- query = query.replace("[userID]", userID);
-
-
+ /*
+ * String query =
+ * " SELECT a.file_name, b.title,to_char(a.dwnld_start_time, 'Dy DD-Mon-YYYY HH24:MI:SS') as time, "
+ * + " a.dwnld_start_time " + " FROM cr_report_dwnld_log a, cr_report b where a.user_id = "+userID
+ * +" and "+ " a.rep_id = b.rep_id " +
+ * " and (a.dwnld_start_time) >= to_date(to_char(sysdate-24/24, 'mm/dd/yyyy'), 'mm/dd/yyyy') " +
+ * " and a.record_ready_time is not null " + " order by a.dwnld_start_time desc";
+ */
+
+ String query = Globals.getLoadQuickDownloadLinks();
+ query = query.replace("[userID]", userID);
+
DataSet ds = DbUtils
.executeQuery(query);
ArrayList quickDownloadLinks = new ArrayList(ds.getRowCount());
logger.debug(EELFLoggerDelegate.debugLogger, ("ROW SIZE " + ds.getRowCount()));
for (int i = 0; i < ds.getRowCount(); i++) {
- quickDownloadLinks.add("<a href=\"" + AppUtils.getRaptorActionURL()+"download.data.file&filename="
- + ds.getString(i, 0)+"\">" + ds.getString(i, 1)+ "</a>" + "&nbsp;"+ ds.getString(i, 2));
+ quickDownloadLinks.add("<a href=\"" + AppUtils.getRaptorActionURL() + "download.data.file&filename="
+ + ds.getString(i, 0) + "\">" + ds.getString(i, 1) + "</a>" + "&nbsp;" + ds.getString(i, 2));
}
logger.debug(EELFLoggerDelegate.debugLogger, ("VECTOR SIZE " + quickDownloadLinks.size()));
return quickDownloadLinks;
} // loadQuickLinks
-
- public static HashMap loadReportsToSchedule (HttpServletRequest request) throws RaptorException {
- String userID = AppUtils.getUserID(request);
- StringBuffer roleList = new StringBuffer();
- roleList.append("-1");
- for (Iterator iter = AppUtils.getUserRoles(request).iterator(); iter.hasNext();)
- roleList.append("," + ((String) iter.next()));
- /*StringBuffer query = new StringBuffer("");
- query.append("SELECT cr.rep_id, ");
- query.append("Initcap(cr.title), ");
- query.append("cr.descr ");
- query.append("FROM cr_report cr, ");
- query.append("(SELECT rep_id, ");
- query.append("MIN(read_only_yn) read_only_yn ");
- query.append("FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = ");
- query.append(userID);
- query.append(") ");
- query.append("UNION ALL ");
- query.append("(SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN (");
- query.append(roleList.toString() + "))" + ") report_access ");
- query.append("GROUP BY rep_id) ra " + "WHERE ");
- query.append("cr.rep_id = ra.rep_id (+) AND ");
- query.append(" (cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL or cr.owner_id = " + userID +") ");
- query.append("ORDER BY Initcap(cr.title)") ;*/
-
- String sql = Globals.getLoadReportsToSchedule();
- sql = sql.replace("[userID]", userID);
- sql = sql.replace("[roleList.toString()]", roleList.toString());
-
- // DataSet ds = DbUtils
- // .executeQuery(query.toString());
-
- DataSet ds = DbUtils
- .executeQuery(sql);
- HashMap map = new HashMap();
- for (int i = 0; i < ds.getRowCount(); i++) {
- map.put(ds.getItem(i,0), ds.getItem(i,1));
- }
-
- return map;
+
+ public static HashMap loadReportsToSchedule(HttpServletRequest request) throws RaptorException {
+ String userID = AppUtils.getUserID(request);
+ StringBuffer roleList = new StringBuffer();
+ roleList.append("-1");
+ for (Iterator iter = AppUtils.getUserRoles(request).iterator(); iter.hasNext();)
+ roleList.append("," + ((String) iter.next()));
+ /*
+ * StringBuffer query = new StringBuffer(""); query.append("SELECT cr.rep_id, ");
+ * query.append("Initcap(cr.title), "); query.append("cr.descr ");
+ * query.append("FROM cr_report cr, "); query.append("(SELECT rep_id, ");
+ * query.append("MIN(read_only_yn) read_only_yn "); query.
+ * append("FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = ");
+ * query.append(userID); query.append(") "); query.append("UNION ALL ");
+ * query.append("(SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN ("
+ * ); query.append(roleList.toString() + "))" + ") report_access ");
+ * query.append("GROUP BY rep_id) ra " + "WHERE "); query.append("cr.rep_id = ra.rep_id (+) AND ");
+ * query.append(" (cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL or cr.owner_id = " + userID
+ * +") "); query.append("ORDER BY Initcap(cr.title)") ;
+ */
+
+ String sql = Globals.getLoadReportsToSchedule();
+ sql = sql.replace("[userID]", userID);
+ sql = sql.replace("[roleList.toString()]", roleList.toString());
+
+ // DataSet ds = DbUtils
+ // .executeQuery(query.toString());
+
+ DataSet ds = DbUtils
+ .executeQuery(sql);
+ HashMap map = new HashMap();
+ for (int i = 0; i < ds.getRowCount(); i++) {
+ map.put(ds.getItem(i, 0), ds.getItem(i, 1));
+ }
+
+ return map;
}
-
- public static HashMap loadReportsToAddInDashboard (HttpServletRequest request) throws RaptorException {
- String userID = AppUtils.getUserID(request);
- StringBuffer roleList = new StringBuffer();
- roleList.append("-1");
- for (Iterator iter = AppUtils.getUserRoles(request).iterator(); iter.hasNext();)
- roleList.append("," + ((String) iter.next()));
- /*StringBuffer query = new StringBuffer("");
- query.append("SELECT cr.rep_id, ");
- query.append("cr.title, ");
- query.append("cr.descr ");
- query.append("FROM cr_report cr, ");
- query.append("(SELECT rep_id, ");
- query.append("MIN(read_only_yn) read_only_yn ");
- query.append("FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = ");
- query.append(userID);
- query.append(") ");
- query.append("UNION ALL ");
- query.append("(SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN (");
- query.append(roleList.toString() + "))" + ") report_access ");
- query.append("GROUP BY rep_id) ra " + "WHERE ");
- query.append("cr.rep_id = ra.rep_id (+) AND ");
- query.append("(nvl(cr.owner_id, cr.create_id) = " + userID);
- query.append(" OR cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL) ");
- query.append(" AND (cr.dashboard_yn = 'N' or cr.dashboard_yn is null) ");
- query.append("ORDER BY cr.title") ;*/
-
- String sql = Globals.getLoadReportsToAddInDashboard();
- sql = sql.replace("[userID]", userID);
- sql = sql.replace("[roleList.toString()]", roleList.toString());
-
- // DataSet ds = DbUtils
- // .executeQuery(query.toString());
-
- DataSet ds = DbUtils
- .executeQuery(sql);
-
- HashMap map = new HashMap();
- for (int i = 0; i < ds.getRowCount(); i++) {
- map.put(ds.getItem(i,0), ds.getItem(i,1));
- }
-
- return map;
+
+ public static HashMap loadReportsToAddInDashboard(HttpServletRequest request) throws RaptorException {
+ String userID = AppUtils.getUserID(request);
+ StringBuffer roleList = new StringBuffer();
+ roleList.append("-1");
+ for (Iterator iter = AppUtils.getUserRoles(request).iterator(); iter.hasNext();)
+ roleList.append("," + ((String) iter.next()));
+ /*
+ * StringBuffer query = new StringBuffer(""); query.append("SELECT cr.rep_id, ");
+ * query.append("cr.title, "); query.append("cr.descr "); query.append("FROM cr_report cr, ");
+ * query.append("(SELECT rep_id, "); query.append("MIN(read_only_yn) read_only_yn "); query.
+ * append("FROM ((SELECT ua.rep_id, ua.read_only_yn FROM cr_report_access ua WHERE ua.user_id = ");
+ * query.append(userID); query.append(") "); query.append("UNION ALL ");
+ * query.append("(SELECT ra.rep_id, ra.read_only_yn FROM cr_report_access ra WHERE ra.role_id IN ("
+ * ); query.append(roleList.toString() + "))" + ") report_access ");
+ * query.append("GROUP BY rep_id) ra " + "WHERE "); query.append("cr.rep_id = ra.rep_id (+) AND ");
+ * query.append("(nvl(cr.owner_id, cr.create_id) = " + userID);
+ * query.append(" OR cr.public_yn = 'Y' OR ra.read_only_yn IS NOT NULL) ");
+ * query.append(" AND (cr.dashboard_yn = 'N' or cr.dashboard_yn is null) ");
+ * query.append("ORDER BY cr.title") ;
+ */
+
+ String sql = Globals.getLoadReportsToAddInDashboard();
+ sql = sql.replace("[userID]", userID);
+ sql = sql.replace("[roleList.toString()]", roleList.toString());
+
+ // DataSet ds = DbUtils
+ // .executeQuery(query.toString());
+
+ DataSet ds = DbUtils
+ .executeQuery(sql);
+
+ HashMap map = new HashMap();
+ for (int i = 0; i < ds.getRowCount(); i++) {
+ map.put(ds.getItem(i, 0), ds.getItem(i, 1));
+ }
+
+ return map;
}
-
+
public static Vector loadMyRecentLinks(String userID, HttpServletRequest request) throws RaptorException {
- /* StringBuffer query = new StringBuffer("");
- query.append("select rep_id, title, descr, form_fields from ( select rownum, rep_id, title, descr, form_fields from ");
- query.append(" (select cr.rep_id, cr.title, a.form_fields, cr.descr, a.log_time, a.user_id, a.action, a.action_value " );
- query.append(" from cr_report_log a, cr_report cr where user_id = " + userID);
- query.append(" and action = 'Report Execution Time' and a.rep_id = cr.rep_id order by log_time desc) x where rownum <= 6 ) y where rownum >= 1");*/
-// DataSet ds = DbUtils
-// .executeQuery(
-// " SELECT a.file_name, b.title,to_char(a.dwnld_start_time, 'Dy DD-Mon-YYYY HH24:MI:SS') as time, "+
-// " a.dwnld_start_time " +
-// " FROM cr_report_dwnld_log a, cr_report b where a.user_id = "+userID +" and "+
-// " a.rep_id = b.rep_id and (a.dwnld_start_time) >= to_date(to_char(sysdate-24/24, 'mm/dd/yyyy'), 'mm/dd/yyyy') " +
-// " and a.record_ready_time is not null " +
-// " order by a.dwnld_start_time desc");
-// DataSet ds = DbUtils
- // .executeQuery(query.toString());
-
-
- String sql = Globals.getLoadMyRecentLinks();
- sql = sql.replace("[userID]", userID);
-
- DataSet ds = DbUtils
- .executeQuery(sql);
-
+ /*
+ * StringBuffer query = new StringBuffer(""); query.
+ * append("select rep_id, title, descr, form_fields from ( select rownum, rep_id, title, descr, form_fields from "
+ * ); query.
+ * append(" (select cr.rep_id, cr.title, a.form_fields, cr.descr, a.log_time, a.user_id, a.action, a.action_value "
+ * ); query.append(" from cr_report_log a, cr_report cr where user_id = " + userID); query.
+ * append(" and action = 'Report Execution Time' and a.rep_id = cr.rep_id order by log_time desc) x where rownum <= 6 ) y where rownum >= 1"
+ * );
+ */
+ // DataSet ds = DbUtils
+ // .executeQuery(
+ // " SELECT a.file_name, b.title,to_char(a.dwnld_start_time, 'Dy DD-Mon-YYYY HH24:MI:SS') as time,
+ // "+
+ // " a.dwnld_start_time " +
+ // " FROM cr_report_dwnld_log a, cr_report b where a.user_id = "+userID +" and "+
+ // " a.rep_id = b.rep_id and (a.dwnld_start_time) >= to_date(to_char(sysdate-24/24, 'mm/dd/yyyy'),
+ // 'mm/dd/yyyy') " +
+ // " and a.record_ready_time is not null " +
+ // " order by a.dwnld_start_time desc");
+ // DataSet ds = DbUtils
+ // .executeQuery(query.toString());
+
+ String sql = Globals.getLoadMyRecentLinks();
+ sql = sql.replace("[userID]", userID);
+
+ DataSet ds = DbUtils
+ .executeQuery(sql);
+
Vector myRecentLinks = new Vector(ds.getRowCount());
logger.debug(EELFLoggerDelegate.debugLogger, ("ROW SIZE " + ds.getRowCount()));
for (int i = 0; i < ds.getRowCount(); i++) {
- myRecentLinks.add("<a href=\"" + AppUtils.getRaptorActionURL()+"report.run.container&display_content=Y&fromReportLog=Y&refresh=Y&c_master="+ds.getString(i, 0)+ds.getString(i, 3)+"\">" + ds.getString(i, 1)+ "</a>");
+ myRecentLinks.add("<a href=\"" + AppUtils.getRaptorActionURL()
+ + "report.run.container&display_content=Y&fromReportLog=Y&refresh=Y&c_master=" + ds.getString(i, 0)
+ + ds.getString(i, 3) + "\">" + ds.getString(i, 1) + "</a>");
}
logger.debug(EELFLoggerDelegate.debugLogger, ("VECTOR SIZE " + myRecentLinks.size()));
return myRecentLinks;
- } // loadQuickLinks
-
+ } // loadQuickLinks
+
public static void createReportLogEntry(Connection connection, String reportID,
- String userID, String action, String executionTime,String form_fields) throws RaptorException {
- if(form_fields.length()>=4000) form_fields = "";
- //String stmt = "INSERT INTO cr_report_log (rep_id, log_time, user_id, action, action_value, form_fields) VALUES("
- // + reportID + ", SYSDATE, " + userID + ", '" + action + "' , '" + executionTime + "', '"+ form_fields +"')";
-
- String stmt = Globals.getCreateReportLogEntry();
- stmt = stmt.replace("[reportID]", reportID);
- stmt = stmt.replace("[userID]", userID);
- stmt = stmt.replace("[action]", action);
- stmt = stmt.replace("[executionTime]", executionTime);
- stmt = stmt.replace("[form_fields]", form_fields);
-
- if (Globals.getEnableReportLog())
- if (connection == null)
- DbUtils.executeUpdate(stmt);
- else
- DbUtils.executeUpdate(connection, stmt);
- } // createReportLogEntry
-
+ String userID, String action, String executionTime, String form_fields) throws RaptorException {
+ if (form_fields.length() >= 4000)
+ form_fields = "";
+ // String stmt = "INSERT INTO cr_report_log (rep_id, log_time, user_id, action, action_value,
+ // form_fields) VALUES("
+ // + reportID + ", SYSDATE, " + userID + ", '" + action + "' , '" + executionTime + "', '"+
+ // form_fields +"')";
+
+ String stmt = Globals.getCreateReportLogEntry();
+ stmt = stmt.replace("[reportID]", reportID);
+ stmt = stmt.replace("[userID]", userID);
+ stmt = stmt.replace("[action]", action);
+ stmt = stmt.replace("[executionTime]", executionTime);
+ stmt = stmt.replace("[form_fields]", form_fields);
+
+ if (Globals.getEnableReportLog())
+ if (connection == null)
+ DbUtils.executeUpdate(stmt);
+ else
+ DbUtils.executeUpdate(connection, stmt);
+ } // createReportLogEntry
+
public static void createReportLogEntryForExecutionTime(Connection connection, String reportID,
- String userID, String executionTime, String action, String formFields) throws RaptorException {
- if(formFields.length()>=4000) formFields = "";
- //String stmt = "INSERT INTO cr_report_log (rep_id, log_time, user_id, action, action_value, form_fields) VALUES("
- // + reportID + ", sysdate+1/(24*60*60) , " + userID + ", '" + action + "' , '" + executionTime + "', '"+ formFields +"')";
-
- String stmt = Globals.getCreateReportLogEntryExecTime();
- stmt = stmt.replace("[reportID]", reportID);
- stmt = stmt.replace("[userID]", userID);
- stmt = stmt.replace("[action]", action);
- stmt = stmt.replace("[executionTime]", executionTime);
- stmt = stmt.replace("[formFields]", formFields);
-
- if (Globals.getEnableReportLog())
- if (connection == null)
- DbUtils.executeUpdate(stmt);
- else
- DbUtils.executeUpdate(connection, stmt);
- } // createReportLogEntry
-
- public static void clearReportLogEntries(String reportId, String userId) throws RaptorException {
- String sql = Globals.getClearReportLogEntries();
- Connection connection = DbUtils.getConnection();
- int rowsAffected = 0;
- try(PreparedStatement stmt = connection.prepareStatement(sql)) {
- stmt.setInt(1, Integer.parseInt(reportId));
- stmt.setInt(2, Integer.parseInt(userId));
- rowsAffected = stmt.executeUpdate();
- if(rowsAffected > 0) connection.commit();
- } catch (SQLException ex) {
- throw new ReportSQLException (ex.getMessage(), ex.getCause());
- } finally {
- DbUtils.clearConnection(connection);
- }
- } // clearReportLogEntries
-
- public static Vector loadReportLogEntries(String reportId) throws RaptorException {
- /* StringBuffer query = new StringBuffer("SELECT x.log_time, x.user_id,") ;
- query.append(" (CASE WHEN x.action = 'Report Execution Time' THEN ");
- query.append(" '<a href=\"" + AppUtils.getRaptorActionURL() +"report.run.container&c_master='||x.rep_id||'&'||x.form_fields||'&fromReportLog=Y&display_content=Y&noFormFields=Y&refresh=Y\">'||x.action||'</a>'");
- query.append(" ELSE x.action END) action, " );
- query.append(" (CASE WHEN x.action = 'Report Execution Time' THEN ");
- query.append(" action_value " );
- query.append(" ELSE 'N/A' END) time_taken, " );
- query.append( " (CASE WHEN x.action = 'Report Execution Time' THEN '<a href=\"" + AppUtils.getRaptorActionURL() +"report.run.container&c_master='||x.rep_id||'&'||x.form_fields||'&fromReportLog=Y&display_content=Y&noFormFields=Y&refresh=Y\"><img src=\""+AppUtils.getImgFolderURL()+ "test_run.gif\" width=\"12\" height=\"12\" border=0 alt=\"Run report\"/></a>' ELSE 'N/A' END) run_image, " );
- query.append(" x.name FROM ");
- query.append(" (SELECT rl.rep_id, TO_CHAR(rl.log_time, 'Month DD, YYYY HH:MI:SS AM') log_time, rl.action_value, fuser.last_name ||', '||fuser.first_name name, ");
- query.append(" rl.user_id, rl.action, rl.form_fields FROM cr_report_log rl, fn_user fuser WHERE rl.rep_id = "+ nvls(reportId)+ " and rl.action != 'Report Run' and fuser.user_id = rl.user_id" );
- query.append(" ORDER BY rl.log_time DESC) x WHERE ROWNUM <= 100");*/
-// DataSet ds = DbUtils
-// .executeQuery("SELECT x.log_time, x.user_id, x.action FROM (SELECT TO_CHAR(rl.log_time, 'Month DD, YYYY HH:MI:SS AM') log_time, rl.user_id, rl.action FROM cr_report_log rl WHERE rl.rep_id = "
-// + nvls(reportId) + " ORDER BY rl.log_time DESC) x WHERE ROWNUM <= 100");
- // DataSet ds = DbUtils.executeQuery(query.toString());
-
+ String userID, String executionTime, String action, String formFields) throws RaptorException {
+ if (formFields.length() >= 4000)
+ formFields = "";
+ // String stmt = "INSERT INTO cr_report_log (rep_id, log_time, user_id, action, action_value,
+ // form_fields) VALUES("
+ // + reportID + ", sysdate+1/(24*60*60) , " + userID + ", '" + action + "' , '" + executionTime +
+ // "', '"+ formFields +"')";
+
+ String stmt = Globals.getCreateReportLogEntryExecTime();
+ stmt = stmt.replace("[reportID]", reportID);
+ stmt = stmt.replace("[userID]", userID);
+ stmt = stmt.replace("[action]", action);
+ stmt = stmt.replace("[executionTime]", executionTime);
+ stmt = stmt.replace("[formFields]", formFields);
+
+ if (Globals.getEnableReportLog())
+ if (connection == null)
+ DbUtils.executeUpdate(stmt);
+ else
+ DbUtils.executeUpdate(connection, stmt);
+ } // createReportLogEntry
+
+ public static void clearReportLogEntries(String reportId, String userId) throws RaptorException {
+ String sql = Globals.getClearReportLogEntries();
+ Connection connection = DbUtils.getConnection();
+ int rowsAffected = 0;
+ try (PreparedStatement stmt = connection.prepareStatement(sql)) {
+ stmt.setInt(1, Integer.parseInt(reportId));
+ stmt.setInt(2, Integer.parseInt(userId));
+ rowsAffected = stmt.executeUpdate();
+ if (rowsAffected > 0)
+ connection.commit();
+ } catch (SQLException ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "SQLException occured in clearReportLogEntries", ex);
+ throw new ReportSQLException(ex.getMessage(), ex.getCause());
+ } finally {
+ DbUtils.clearConnection(connection);
+ }
+ } // clearReportLogEntries
+
+ public static Vector loadReportLogEntries(String reportId) throws RaptorException {
+ /*
+ * StringBuffer query = new StringBuffer("SELECT x.log_time, x.user_id,") ;
+ * query.append(" (CASE WHEN x.action = 'Report Execution Time' THEN "); query.append(" '<a href=\""
+ * + AppUtils.getRaptorActionURL()
+ * +"report.run.container&c_master='||x.rep_id||'&'||x.form_fields||'&fromReportLog=Y&display_content=Y&noFormFields=Y&refresh=Y\">'||x.action||'</a>'"
+ * ); query.append(" ELSE x.action END) action, " );
+ * query.append(" (CASE WHEN x.action = 'Report Execution Time' THEN ");
+ * query.append(" action_value " ); query.append(" ELSE 'N/A' END) time_taken, " ); query.append(
+ * " (CASE WHEN x.action = 'Report Execution Time' THEN '<a href=\"" + AppUtils.getRaptorActionURL()
+ * +"report.run.container&c_master='||x.rep_id||'&'||x.form_fields||'&fromReportLog=Y&display_content=Y&noFormFields=Y&refresh=Y\"><img src=\""
+ * +AppUtils.getImgFolderURL()+
+ * "test_run.gif\" width=\"12\" height=\"12\" border=0 alt=\"Run report\"/></a>' ELSE 'N/A' END) run_image, "
+ * ); query.append(" x.name FROM "); query.
+ * append(" (SELECT rl.rep_id, TO_CHAR(rl.log_time, 'Month DD, YYYY HH:MI:SS AM') log_time, rl.action_value, fuser.last_name ||', '||fuser.first_name name, "
+ * ); query.
+ * append(" rl.user_id, rl.action, rl.form_fields FROM cr_report_log rl, fn_user fuser WHERE rl.rep_id = "
+ * + nvls(reportId)+ " and rl.action != 'Report Run' and fuser.user_id = rl.user_id" );
+ * query.append(" ORDER BY rl.log_time DESC) x WHERE ROWNUM <= 100");
+ */
+ // DataSet ds = DbUtils
+ // .executeQuery("SELECT x.log_time, x.user_id, x.action FROM (SELECT TO_CHAR(rl.log_time, 'Month
+ // DD, YYYY HH:MI:SS AM') log_time, rl.user_id, rl.action FROM cr_report_log rl WHERE rl.rep_id = "
+ // + nvls(reportId) + " ORDER BY rl.log_time DESC) x WHERE ROWNUM <= 100");
+ // DataSet ds = DbUtils.executeQuery(query.toString());
+
String sql = Globals.getLoadReportLogEntries();
- sql = sql.replace("[AppUtils.getRaptorActionURL()]", AppUtils.getRaptorActionURL());
+ sql = sql.replace("[AppUtils.getRaptorActionURL()]", AppUtils.getRaptorActionURL());
sql = sql.replace("[AppUtils.getImgFolderURL()]", AppUtils.getImgFolderURL());
sql = sql.replace("[nvls(reportId)]", nvls(reportId));
-
-
+
DataSet ds = DbUtils.executeQuery(sql);
-
- Vector logEntries = new Vector(ds.getRowCount());
-
- for (int i = 0; i < ds.getRowCount(); i++)
- logEntries.add(new ReportLogEntry(ds.getString(i, 0), ds
- .getString(i, 5), ds.getString(i, 2), ds.getString(i, 3), ds.getString(i, 4)));
-
- return logEntries;
- } // loadReportLogEntries
-
- public static boolean doesUserCanScheduleReport(HttpServletRequest request, String scheduleId) throws RaptorException {
- boolean flagLimit = false;
- boolean flagScheduleIdPresent = false;
- String userId = AppUtils.getUserID(request);
- if(AppUtils.isAdminUser(request))return true;
- //String query = "select crs.sched_user_id, count(*) from cr_report_schedule crs where sched_user_id = " + userId + " group by crs.sched_user_id having count(*) >= " + Globals.getScheduleLimit();
- String query = Globals.getDoesUserCanScheduleReport();
- query = query.replace("[userId]", userId);
- query = query.replace("[Globals.getScheduleLimit()]", String.valueOf(Globals.getScheduleLimit()));
-
- DataSet ds = DbUtils.executeQuery(query);
- logger.debug(EELFLoggerDelegate.debugLogger, (" User Schedule ds.getRowCount() " + ds.getRowCount() + " " +(ds.getRowCount()>0)));
- if(ds.getRowCount() > 0) flagLimit = true;
- else flagLimit = false;
- logger.debug(EELFLoggerDelegate.debugLogger, ("scheduleId " + scheduleId));
- if(scheduleId==null || scheduleId.trim().length()<=0) return !flagLimit;
- //query = "select crs.schedule_id from cr_report_schedule crs where schedule_id = " + scheduleId;
- query = Globals.getDoesUserCanSchedule();
- query = query.replace("[scheduleId]", scheduleId);
-
- if(ds.getRowCount() > 0) flagScheduleIdPresent = true;
- else flagScheduleIdPresent = false;
- if(!flagLimit) return true;
- if(flagLimit && flagScheduleIdPresent) return true;
- else return false;
- }
-
- public static String getSystemDateTime() throws RaptorException {
- //String query = "select to_char(sysdate,'MM/dd/yyyy HH24:mi:ss') from dual";
- String query = Globals.getTheSystemDateTime();
-
- DataSet ds = DbUtils.executeQuery(query);
- String timeStr = "";
- if(ds.getRowCount() > 0) {
- timeStr = ds.getString(0,0);
- }
- return timeStr;
-
- }
-
- public static String getNextDaySystemDateTime() throws RaptorException {
- //String query = "select to_char(sysdate+1,'MM/dd/yyyy HH24:mi:ss') from dual";
- String query = Globals.getTheNextDayDateTime();
- DataSet ds = DbUtils.executeQuery(query);
- String timeStr = "";
- if(ds.getRowCount() > 0) {
- timeStr = ds.getString(0,0);
- }
- return timeStr;
-
- }
-
- public static String getNext15MinutesOfSystemDateTime() throws RaptorException {
- //String query = "select to_char(sysdate+15/(24*60),'MM/dd/yyyy HH24:mi:ss') from dual";
- String query = Globals.getTheNextFifteenMinDateTime();
-
- DataSet ds = DbUtils.executeQuery(query);
- String timeStr = "";
- if(ds.getRowCount() > 0) {
- timeStr = ds.getString(0,0);
- }
- return timeStr;
-
- }
-
- public static String getNext30MinutesOfSystemDateTime() throws RaptorException {
- //String query = "select to_char(sysdate+30/(24*60),'MM/dd/yyyy HH24:mi:ss') from dual";
- String query = Globals.getTheNextThirtyMinDateTime();
- DataSet ds = DbUtils.executeQuery(query);
- String timeStr = "";
- if(ds.getRowCount() > 0) {
- timeStr = ds.getString(0,0);
- }
- return timeStr;
-
- }
-
- public static String getTemplateFile(String reportId) throws RaptorException {
- //String query = "select template_file from cr_report_template_map where report_id = " + reportId;
- String query = Globals.getTheTemplateFile();
- query = query.replace("[reportId]", reportId);
- String templateFile = "";
- try {
- DataSet ds = DbUtils.executeQuery(query);
- if(ds.getRowCount() > 0) {
- templateFile = ds.getString(0,0);
- }
- }catch(RaptorException ex) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("SQL Exception while trying to access cr_report_template_map "));
- }
- return templateFile;
-
- }
-
-
- public static HashMap loadPDFImgLookUp() throws RaptorException {
- StringBuffer query = new StringBuffer("");
- HashMap pdfImgMap = new HashMap();
- //query.append("select image_id, image_loc from cr_raptor_pdf_img");
- query.append(Globals.getLoadPdfImgLookup());
- DataSet ds = DbUtils.executeQuery(query.toString());
- for (int i = 0; i < ds.getRowCount(); i++) {
- pdfImgMap.put(ds.getString(i, 0), ds.getString(i,1));
- }
- return pdfImgMap;
- } // loadQuickLinks
-
- public static HashMap loadActionImgLookUp() throws RaptorException {
- StringBuffer query = new StringBuffer("");
- HashMap pdfImgMap = new HashMap();
- //query.append("select image_id, image_loc from cr_raptor_action_img");
- query.append(Globals.getLoadActionImgLookup());
- DataSet ds = DbUtils.executeQuery(query.toString());
- for (int i = 0; i < ds.getRowCount(); i++) {
- pdfImgMap.put(ds.getString(i, 0), ds.getString(i,1));
- }
- return pdfImgMap;
- } // loadQuickLinks
-} // ReportLoader
+ Vector logEntries = new Vector(ds.getRowCount());
+
+ for (int i = 0; i < ds.getRowCount(); i++)
+ logEntries.add(new ReportLogEntry(ds.getString(i, 0), ds
+ .getString(i, 5), ds.getString(i, 2), ds.getString(i, 3), ds.getString(i, 4)));
+
+ return logEntries;
+ } // loadReportLogEntries
+
+ public static boolean doesUserCanScheduleReport(HttpServletRequest request, String scheduleId)
+ throws RaptorException {
+ boolean flagLimit = false;
+ boolean flagScheduleIdPresent = false;
+ String userId = AppUtils.getUserID(request);
+ if (AppUtils.isAdminUser(request))
+ return true;
+ // String query = "select crs.sched_user_id, count(*) from cr_report_schedule crs where
+ // sched_user_id = " + userId + " group by crs.sched_user_id having count(*) >= " +
+ // Globals.getScheduleLimit();
+ String query = Globals.getDoesUserCanScheduleReport();
+ query = query.replace("[userId]", userId);
+ query = query.replace("[Globals.getScheduleLimit()]", String.valueOf(Globals.getScheduleLimit()));
+
+ DataSet ds = DbUtils.executeQuery(query);
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ (" User Schedule ds.getRowCount() " + ds.getRowCount() + " " + (ds.getRowCount() > 0)));
+ if (ds.getRowCount() > 0)
+ flagLimit = true;
+ else
+ flagLimit = false;
+ logger.debug(EELFLoggerDelegate.debugLogger, ("scheduleId " + scheduleId));
+ if (scheduleId == null || scheduleId.trim().length() <= 0)
+ return !flagLimit;
+ // query = "select crs.schedule_id from cr_report_schedule crs where schedule_id = " + scheduleId;
+ query = Globals.getDoesUserCanSchedule();
+ query = query.replace("[scheduleId]", scheduleId);
+
+ if (ds.getRowCount() > 0)
+ flagScheduleIdPresent = true;
+ else
+ flagScheduleIdPresent = false;
+ if (!flagLimit)
+ return true;
+ if (flagLimit && flagScheduleIdPresent)
+ return true;
+ else
+ return false;
+ }
+
+ public static String getSystemDateTime() throws RaptorException {
+ // String query = "select to_char(sysdate,'MM/dd/yyyy HH24:mi:ss') from dual";
+ String query = Globals.getTheSystemDateTime();
+
+ DataSet ds = DbUtils.executeQuery(query);
+ String timeStr = "";
+ if (ds.getRowCount() > 0) {
+ timeStr = ds.getString(0, 0);
+ }
+ return timeStr;
+
+ }
+
+ public static String getNextDaySystemDateTime() throws RaptorException {
+ // String query = "select to_char(sysdate+1,'MM/dd/yyyy HH24:mi:ss') from dual";
+ String query = Globals.getTheNextDayDateTime();
+ DataSet ds = DbUtils.executeQuery(query);
+ String timeStr = "";
+ if (ds.getRowCount() > 0) {
+ timeStr = ds.getString(0, 0);
+ }
+ return timeStr;
+
+ }
+
+ public static String getNext15MinutesOfSystemDateTime() throws RaptorException {
+ // String query = "select to_char(sysdate+15/(24*60),'MM/dd/yyyy HH24:mi:ss') from dual";
+ String query = Globals.getTheNextFifteenMinDateTime();
+
+ DataSet ds = DbUtils.executeQuery(query);
+ String timeStr = "";
+ if (ds.getRowCount() > 0) {
+ timeStr = ds.getString(0, 0);
+ }
+ return timeStr;
+
+ }
+
+ public static String getNext30MinutesOfSystemDateTime() throws RaptorException {
+ // String query = "select to_char(sysdate+30/(24*60),'MM/dd/yyyy HH24:mi:ss') from dual";
+ String query = Globals.getTheNextThirtyMinDateTime();
+ DataSet ds = DbUtils.executeQuery(query);
+ String timeStr = "";
+ if (ds.getRowCount() > 0) {
+ timeStr = ds.getString(0, 0);
+ }
+ return timeStr;
+
+ }
+
+ public static String getTemplateFile(String reportId) throws RaptorException {
+ // String query = "select template_file from cr_report_template_map where report_id = " + reportId;
+ String query = Globals.getTheTemplateFile();
+ query = query.replace("[reportId]", reportId);
+ String templateFile = "";
+ try {
+ DataSet ds = DbUtils.executeQuery(query);
+ if (ds.getRowCount() > 0) {
+ templateFile = ds.getString(0, 0);
+ }
+ } catch (RaptorException ex) {
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ ("SQL Exception while trying to access cr_report_template_map "), ex);
+ }
+ return templateFile;
+ }
+
+ public static HashMap loadPDFImgLookUp() throws RaptorException {
+ StringBuffer query = new StringBuffer("");
+ HashMap pdfImgMap = new HashMap();
+ // query.append("select image_id, image_loc from cr_raptor_pdf_img");
+ query.append(Globals.getLoadPdfImgLookup());
+ DataSet ds = DbUtils.executeQuery(query.toString());
+ for (int i = 0; i < ds.getRowCount(); i++) {
+ pdfImgMap.put(ds.getString(i, 0), ds.getString(i, 1));
+ }
+ return pdfImgMap;
+ } // loadQuickLinks
+
+ public static HashMap loadActionImgLookUp() throws RaptorException {
+ StringBuffer query = new StringBuffer("");
+ HashMap pdfImgMap = new HashMap();
+ // query.append("select image_id, image_loc from cr_raptor_action_img");
+ query.append(Globals.getLoadActionImgLookup());
+ DataSet ds = DbUtils.executeQuery(query.toString());
+ for (int i = 0; i < ds.getRowCount(); i++) {
+ pdfImgMap.put(ds.getString(i, 0), ds.getString(i, 1));
+ }
+ return pdfImgMap;
+ } // loadQuickLinks
+
+} // ReportLoader