/**
  * @param clazz
  * @param reportParams
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalAccessException Setting the report header all params
  * @throws ClassNotFoundException
  */
 @SuppressWarnings("rawtypes")
 protected Kismiss setReportParams(Class clazz, Map<String, Object> reportParams)
     throws Exception {
   Kismiss kismiss = null;
   try {
     Annotation[] annotations = clazz.getAnnotations();
     for (Annotation annotation : annotations) {
       if (annotation instanceof Kismiss) {
         kismiss = (Kismiss) annotation;
         setReportParams(kismiss, reportParams);
         setReportParams(reportParams, kismiss, kismiss.paperType());
       }
     }
   } catch (Exception e) {
     logger.error("[Kismiss:setreportParams] Error happended => {}", e.getMessage());
     throw new Exception(e);
   }
   return kismiss;
 }
 /**
  * @param kismiss
  * @param reportParams
  */
 private void overideParamsWhenDefined(Kismiss kismiss, Map<String, Object> reportParams) {
   if (kismiss.pageWidth() > -1) {
     reportParams.put(ReportFactory.PAGE_WIDTH, kismiss.pageWidth());
   }
   if (kismiss.pageHeight() > -1) {
     reportParams.put(ReportFactory.PAGE_HEIGHT, kismiss.pageHeight());
   }
   if (kismiss.columnWidth() > -1) {
     reportParams.put(ReportFactory.COLUMN_WIDTH, kismiss.columnWidth());
   }
   if (kismiss.columnSpacing() > -1) {
     reportParams.put(ReportFactory.COLUMN_SPACING, kismiss.columnSpacing());
   }
 }
  /**
   * @param paperType
   * @param reportParams
   * @throws IllegalArgumentException
   * @throws IllegalAccessException Switching paper type to get the paper information such as height
   *     and width of the paper now, this can only support for A4 size
   * @throws ClassNotFoundException
   * @throws NoSuchFieldException
   * @throws SecurityException
   */
  @SuppressWarnings("rawtypes")
  private void setReportParams(
      PaperType paperType, Kismiss kismiss, Map<String, Object> reportParams)
      throws IllegalArgumentException, IllegalAccessException, ClassNotFoundException,
          SecurityException, NoSuchFieldException {
    Class clazz =
        ReportConstant.class
            .getClassLoader()
            .loadClass(ReportConstant.class.getCanonicalName() + "$Paper_" + paperType.toString());

    // setting paper property to header params
    Field[] fields = clazz.getFields();
    for (Field field : fields) {
      field.setAccessible(true);
      if (ReportFactory.COLUMN_WIDTH.equals(field.getName())
          && kismiss.orientation() == Orientation.Portrait) {
        reportParams.put(
            field.getName(),
            (Integer) field.get(field.getName()) - kismiss.leftMargin() + kismiss.rightMargin());
      } else if (ReportFactory.COLUMN_WIDTH.equals(field.getName())
          && kismiss.orientation() == Orientation.Landscape) {
        reportParams.put(
            field.getName(),
            (Integer) clazz.getField(ReportFactory.PAGE_HEIGHT).get(ReportFactory.PAGE_HEIGHT)
                - (kismiss.leftMargin() + kismiss.rightMargin()));
      } else if (ReportFactory.PAGE_WIDTH.equals(field.getName())
          && kismiss.orientation() == Orientation.Landscape) {
        reportParams.put(ReportFactory.PAGE_HEIGHT, field.get(field.getName()));
      } else if (ReportFactory.PAGE_HEIGHT.equals(field.getName())
          && kismiss.orientation() == Orientation.Landscape) {
        reportParams.put(ReportFactory.PAGE_WIDTH, field.get(field.getName()));
      } else {
        reportParams.put(field.getName(), field.get(field.getName()));
      }
    }
  }
  /**
   * @param kismiss
   * @param reportParams
   * @throws IllegalArgumentException setting information of report header
   */
  private void setReportParams(Kismiss kismiss, Map<String, Object> reportParams)
      throws KismissException {
    try {
      reportParams.put(ReportFactory.REPORT_NAME, kismiss.name());
      reportParams.put(ReportFactory.PRINT_ORDER, kismiss.printOrder());
      reportParams.put(ReportFactory.ORIENTATION, kismiss.orientation());
      reportParams.put(ReportFactory.WHEN_NO_DATA_TYPE, kismiss.whenNoDataType());
      reportParams.put(ReportFactory.IS_FLOAT_COLUMN_FOOTER, kismiss.isFloatColumnFooter());

      reportParams.put(ReportFactory.IS_TITLE_NEW_PAGE, kismiss.isTitleNewPage());
      reportParams.put(ReportFactory.IS_TITLE_EVERY_PAGE, kismiss.isTitleEveryPage());
      reportParams.put(ReportFactory.IS_SUMMARY_NEW_PAGE, kismiss.isSummaryNewPage());
      reportParams.put(ReportFactory.IS_PAGINATION_IGNORE, kismiss.isIgnorePagination());

      reportParams.put(ReportFactory.LEFT_MARGIN, kismiss.leftMargin());
      reportParams.put(ReportFactory.RIGHT_MARGIN, kismiss.rightMargin());
      reportParams.put(ReportFactory.TOP_MARGIN, kismiss.topMargin());
      reportParams.put(ReportFactory.BOTTOM_MARGIN, kismiss.bottomMargin());

      reportParams.put(ReportFactory.TITLE_FONT_SIZE, kismiss.titleFontSize());
      reportParams.put(ReportFactory.TITLE_ALIGNMENT, kismiss.titleAlignment());
      reportParams.put(ReportFactory.TITLE_IS_BOLD, kismiss.titleIsBold());
      reportParams.put(ReportFactory.TITLE_PDF_FONT_NAME, kismiss.titlePdfFontName());

      reportParams.put(ReportFactory.PAGE_NUMBER_ALIGNMENT, kismiss.pageNumberAlignment());
      reportParams.put(ReportFactory.NO_DATA_FOUND, kismiss.noDataFound());
      reportParams.put(ReportFactory.COLUMN_AUTO_SIZE, kismiss.columnAutoSize());
      reportParams.put(ReportFactory.TITLE_HEIGHT, kismiss.titleHeight());

      reportParams.put(
          ReportFactory.IS_REPEAT_COLUMN_HEADER_XLS, kismiss.isRepeatColumnHeaderXls());
      reportParams.put(ReportFactory.IS_IGNORE_PAGINATION_XLS, kismiss.isIgnorePaginationXls());

    } catch (Exception e) {
      logger.error("[Kismiss:setreportParams] Error happended => {}", e.getMessage());
      throw new KismissException(e);
    }
  }