Sonar Fix- PageEvet.Java - Rename the field to match regular expression and define... 22/92722/1
authordinesha <dineshgs@in.ibm.com>
Fri, 2 Aug 2019 10:22:58 +0000 (15:52 +0530)
committerManoop Talasila <talasila@research.att.com>
Mon, 5 Aug 2019 18:40:53 +0000 (18:40 +0000)
Fixed Sonar Issues accross the file

Issue-ID: PORTAL-686
Change-Id: I73e775aab6f8d6b80a65bc0c5cb0614d5de21271
Signed-off-by: dinesha <dineshgs@in.ibm.com>
(cherry picked from commit e699cb06640796f62cd2b8ab70a74d1677ec5d20)

ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PageEvent.java

index 5b8ae4d..59bbed3 100644 (file)
@@ -69,8 +69,9 @@ class PageEvent extends PdfPageEventHelper {
        
        private PdfBean pb;
        private int pageNo = 0;
-       private int omit_page_count = 0;
-       private int DEFAULT_LOGO_SIZE = 100;
+       private int omitPageCount = 0;
+       private int defaultLogoSize = 100;
+       private static String nLogo = "<no logo>";
 
        public PageEvent(PdfBean pb) {
                this.pb = pb;
@@ -79,10 +80,10 @@ class PageEvent extends PdfPageEventHelper {
        private int getHowManyLogos(){
                int howManyLogos = 0;
                
-               if(AppUtils.isNotEmpty(pb.getLogo1Url()) && !pb.getLogo1Url().equalsIgnoreCase("<no logo>"))
+               if(AppUtils.isNotEmpty(pb.getLogo1Url()) && !pb.getLogo1Url().equalsIgnoreCase(nLogo))
                        howManyLogos ++;
                
-               if(AppUtils.isNotEmpty(pb.getLogo2Url()) && !pb.getLogo2Url().equalsIgnoreCase("<no logo>"))
+               if(AppUtils.isNotEmpty(pb.getLogo2Url()) && !pb.getLogo2Url().equalsIgnoreCase(nLogo))
                        howManyLogos ++;
                
                return howManyLogos;
@@ -121,16 +122,16 @@ class PageEvent extends PdfPageEventHelper {
                                
                PdfPTable foot = new PdfPTable(widths);
                
-               if(AppUtils.isNotEmpty(pb.getLogo1Url()) && !pb.getLogo1Url().equalsIgnoreCase("<no logo>"))
-                       addLogo(foot, font, pb.getLogo1Url().substring(pb.getLogo1Url().indexOf("|") + 1).trim(), Cell.ALIGN_LEFT, pb.getLogo1Size() == null ? DEFAULT_LOGO_SIZE : pb.getLogo1Size());
+               if(AppUtils.isNotEmpty(pb.getLogo1Url()) && !pb.getLogo1Url().equalsIgnoreCase(nLogo))
+                       addLogo(foot, font, pb.getLogo1Url().substring(pb.getLogo1Url().indexOf("|") + 1).trim(), Cell.ALIGN_LEFT, pb.getLogo1Size() == null ? defaultLogoSize : pb.getLogo1Size());
                
                PdfPCell spacingCell = new PdfPCell();
                spacingCell.setBorderColor(Color.WHITE);
                foot.addCell(spacingCell);
                
                //Using logo1 size for now - use logo2 size if it is required to deal it separately.
-               if(AppUtils.isNotEmpty(pb.getLogo2Url()) && !pb.getLogo2Url().equalsIgnoreCase("<no logo>"))
-                       addLogo(foot, font, pb.getLogo2Url().substring(pb.getLogo2Url().indexOf("|") + 1).trim(),  Cell.ALIGN_RIGHT, pb.getLogo2Size() == null ? DEFAULT_LOGO_SIZE : pb.getLogo2Size());
+               if(AppUtils.isNotEmpty(pb.getLogo2Url()) && !pb.getLogo2Url().equalsIgnoreCase(nLogo))
+                       addLogo(foot, font, pb.getLogo2Url().substring(pb.getLogo2Url().indexOf("|") + 1).trim(),  Cell.ALIGN_RIGHT, pb.getLogo2Size() == null ? defaultLogoSize : pb.getLogo2Size());
 
                foot.setTotalWidth(getPageWidth(document));
                foot.writeSelectedRows(0, -1, 36, 600, writer.getDirectContent());
@@ -167,19 +168,19 @@ class PageEvent extends PdfPageEventHelper {
                        pageNo++;
                        PdfContentByte cb = writer.getDirectContent();
                        PdfDestination destination = new PdfDestination(PdfDestination.FITH);
-                       String bookmark = "Data Page " + (pageNo - omit_page_count);
+                       String bookmark = "Data Page " + (pageNo - omitPageCount);
                        if (pageNo == 1) {
                                if (pb.isCoverPageIncluded()) {
                                        bookmark = "Cover Page";
-                                       omit_page_count++;
+                                       omitPageCount++;
                                } else if (pb.isDisplayChart()) {
                                        bookmark = "Chart";
-                                       omit_page_count++;
+                                       omitPageCount++;
                                }
                        }
                        if (pageNo == 2 && pb.isCoverPageIncluded() && pb.isDisplayChart()) {
                                bookmark = "Chart";
-                               omit_page_count++;
+                               omitPageCount++;
                        }
 
                        PdfOutline outline = new PdfOutline(cb.getRootOutline(), destination, bookmark);