From 34dad1cdfd40a80fd37e5f68139e68743d1963d4 Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Tue, 9 Jun 2020 08:44:46 +0530 Subject: lowered code smells in PdfReportHandler.java lowered code smells in PdfReportHandler.java Issue-ID: PORTAL-813 Change-Id: I93bcc30c44d8cd5c4b5583584ff5b131a3dad6e1 Signed-off-by: Indrijeet Kumar --- .../analytics/model/pdf/PdfReportHandler.java | 52 ++-------------------- 1 file changed, 3 insertions(+), 49 deletions(-) (limited to 'ecomp-sdk') diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PdfReportHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PdfReportHandler.java index f3aad70f..496b1598 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PdfReportHandler.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PdfReportHandler.java @@ -1108,7 +1108,6 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{ for(dr.resetNext();dr.hasNext();) { DataValue dv = dr.getNext(); - //System.out.println(columnCount +" --> "+dv); if(dv.isVisible()) { HtmlFormatter cfmt = dv.getCellFormatter(); HtmlFormatter rfmt = dv.getRowFormatter(); @@ -1161,7 +1160,6 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{ for(;dr.hasNext();) { DataValue dv = dr.getNext(); - //System.out.println(columnCount +" --> "+dv); if(dv.isVisible()) { HtmlFormatter cfmt = dv.getCellFormatter(); HtmlFormatter rfmt = dv.getRowFormatter(); @@ -1226,8 +1224,6 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{ font.setColor(Color.decode(fmt.getFontColor())); if(fmt.getFontSize().trim().length()>0) font.setSize(Float.parseFloat(fmt.getFontSize())-Globals.getDataFontSizeOffset()); -// if(fmt.getFontFace().trim().length()>0) -// cellFont.setFamily() } @@ -1363,7 +1359,6 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{ String title = (String) session.getAttribute("TITLE_"+index); String subtitle = (String) session.getAttribute("SUBTITLE_"+index); if(nvl(title).length()>0) { - //PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100f); table.getDefaultCell().setHorizontalAlignment(Rectangle.ALIGN_CENTER); table.getDefaultCell().setVerticalAlignment(Rectangle.ALIGN_BOTTOM); @@ -1374,17 +1369,11 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{ Font.BOLD, Color.BLACK); - //addEmptyRows(table,1); table.getDefaultCell().setHorizontalAlignment(Rectangle.ALIGN_CENTER); - //table.getDefaultCell().setBackgroundColor(Color.decode(Globals.getDataTableHeaderBackgroundFontColor())); title = Utils.replaceInString(title, "
", " "); title = Utils.replaceInString(title, "
", " "); title = Utils.replaceInString(title, "
", " "); title = strip.stripHtml(nvl(title).trim()); - //subtitle = Utils.replaceInString(subtitle, "
", " "); - //subtitle = Utils.replaceInString(subtitle, "
", " "); - //subtitle = Utils.replaceInString(subtitle, "
", " "); - //subtitle = strip.stripHtml(nvl(subtitle).trim()); StyleSheet styles = new StyleSheet(); HTMLWorker htmlWorker = new HTMLWorker(document); @@ -1401,17 +1390,11 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{ } p1.add(elem); } - //cell = new PdfPCell(p1); StyleSheet style = new StyleSheet(); style.loadTagStyle("font", "font-size", "3"); style.loadTagStyle("font", "size", "3"); styles.loadStyle("pdfFont1", "size", "11px"); styles.loadStyle("pdfFont1", "font-size", "11px"); - /*ArrayList p = HTMLWorker.parseToList(new StringReader(nvl(title)), style); - for (int k = 0; k < p.size(); ++k){ - document.add((com.lowagie.text.Element)p.get(k)); - }*/ - //p1.font().setSize(3.0f); PdfPCell titleCell = new PdfPCell(new Phrase(title, font)); titleCell.setColspan(rr.getVisibleColumnCount()); PdfPCell subtitleCell = new PdfPCell(p1); @@ -1420,7 +1403,6 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{ subtitleCell.setHorizontalAlignment(1); table.addCell(titleCell); table.addCell(subtitleCell); - //document.add(table); } return table; } @@ -1450,14 +1432,7 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{ Font.BOLD, Color.BLACK); - - //addEmptyRows(table,1); table.getDefaultCell().setHorizontalAlignment(Rectangle.ALIGN_CENTER); - //table.getDefaultCell().setBackgroundColor(Color.decode(Globals.getDataTableHeaderBackgroundFontColor())); - /*title = Utils.replaceInString(title, "
", " "); - title = Utils.replaceInString(title, "
", " "); - title = Utils.replaceInString(title, "
", " "); - title = strip.stripHtml(nvl(title).trim());*/ StyleSheet style = new StyleSheet(); HTMLWorker htmlWorker = new HTMLWorker(document); @@ -1475,15 +1450,12 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{ p1.add(elem); } -/* - HTMLWorker.parseToList(new StringReader(nvl(title)), style);*/ PdfPCell titleCell = new PdfPCell(p1); titleCell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(titleCell); //table. document.add(table); } - //return table; } @@ -1494,39 +1466,26 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{ FONT_SIZE+1f, Font.BOLD, Color.decode(Globals.getDataTableHeaderFontColor())); - //table.setHeaderRows(1); table.getDefaultCell().setHorizontalAlignment(Rectangle.ALIGN_CENTER); table.getDefaultCell().setBackgroundColor(Color.decode(Globals.getDataTableHeaderBackgroundFontColor())); String title = ""; boolean firstPass = true; - /*if(rd.reportTotalRowHeaderCols!=null) { - if(firstPass) { - table.addCell(new Paragraph("No.", font)); - firstPass = false; - } - }*/ for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) { if(firstPass) { for(rd.reportRowHeaderCols.resetNext();rd.reportRowHeaderCols.hasNext();) { - /*if(firstPass) { - table.addCell(new Paragraph("No.", font)); - firstPass = false; - } else {*/ RowHeaderCol rhc = rd.reportRowHeaderCols.getNext(); title = rhc.getColumnTitle(); title = Utils.replaceInString(title,"_nl_", " \n"); table.addCell(new Paragraph(title,font)); - //} } } ColumnHeaderRow chr = rd.reportColumnHeaderRows.getNext(); for (chr.resetNext(); chr.hasNext();) { ColumnHeader ch = chr.getNext(); - //System.out.println(ch); if(ch.isVisible()) { title = ch.getColumnTitle(); title = Utils.replaceInString(title,"_nl_", " \n"); @@ -1542,13 +1501,10 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{ Date sysdate = oracleDateFormat.parse(ReportLoader.getSystemDateTime()); SimpleDateFormat dtimestamp = new SimpleDateFormat(Globals.getScheduleDatePattern()); return dtimestamp.format(sysdate)+" "+Globals.getTimeZone(); - //paramList.add(new IdNameValue("DATE", dtimestamp.format(sysdate)+" "+Globals.getTimeZone())); } catch(Exception ex) {} SimpleDateFormat s = new SimpleDateFormat(pattern); s.setTimeZone(TimeZone.getTimeZone(Globals.getTimeZone())); - //System.out.println("^^^^^^^^^^^^^^^^^^^^ " + Calendar.getInstance().getTime()); - //System.out.println("^^^^^^^^^^^^^^^^^^^^ " + s.format(Calendar.getInstance().getTime())); return s.format(Calendar.getInstance().getTime()); } @@ -1567,12 +1523,10 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{ } catch (NumberFormatException e) {} pb.setCurrentPage(temp); - //pb.setPortrait( trueORfalse(request.getParameter("isPortrait"),true)); pb.setPortrait(trueORfalse(rr.getPDFOrientation() == "portait"?"true":"false", true)); - //pb.setCoverPageIncluded( trueORfalse(request.getParameter("isCoverPageIncluded"), true)); - //if(Globals.isCoverPageNeeded()) { - pb.setCoverPageIncluded(Globals.isCoverPageNeeded()?rr.isPDFCoverPage():false); - //} + + pb.setCoverPageIncluded(Globals.isCoverPageNeeded()?rr.isPDFCoverPage():false); + pb.setTitle(nvl(request.getParameter("title"))); pb.setPagesize(nvls(request.getParameter("pagesize"),"LETTER")); -- cgit 1.2.3-korg