Class AbstractExcelExportWorkbookDecorator

java.lang.Object
com.hybris.backoffice.excel.exporting.AbstractExcelExportWorkbookDecorator
All Implemented Interfaces:
ExcelExportWorkbookDecorator, org.springframework.core.Ordered
Direct Known Subclasses:
DefaultExcelExportClassificationWorkbookDecorator

public abstract class AbstractExcelExportWorkbookDecorator extends Object implements ExcelExportWorkbookDecorator
Abstract class for workbook export decorator. This class is responsible for finding appropriate cell, selected attribute and item which should be exported. Then it uses translator registry which finds appropriate translator and invokes ExcelAttributeTranslator.exportData(ExcelAttribute, Object). The result of translator is set directly into appropriate cell.
  • Constructor Details

    • AbstractExcelExportWorkbookDecorator

      public AbstractExcelExportWorkbookDecorator()
  • Method Details

    • decorate

      protected void decorate(org.apache.poi.ss.usermodel.Workbook workbook, Collection<ExcelClassificationAttribute> attributes, Collection<ItemModel> items)
      Decorate method responsible for finding appropriate cell for given attribute and item. Then it finds appropriate translator for the attribute and fills the cell with data. It also fills the header and reference format rows for classification attributes.
      Parameters:
      workbook - workbook to work on
      attributes - collection of attributes to iterate on
      items - collection of items to iterate on
    • exportDataIntoCell

      protected void exportDataIntoCell(ExcelAttributeTranslator<ExcelAttribute> translator, ExcelCellValue excelCellValue)
    • insertReferenceFormatIfNecessary

      protected void insertReferenceFormatIfNecessary(org.apache.poi.ss.usermodel.Cell excelCellValue, String referenceFormat)
    • insertHeaderIfNecessary

      protected org.apache.poi.ss.usermodel.Cell insertHeaderIfNecessary(org.apache.poi.ss.usermodel.Sheet sheet, String headerValue)
      Inserts new header cell if row does not contain any cell with given content
      Parameters:
      sheet - container of header values
      headerValue - value to insert
      Returns:
      cell with given headerValue
    • findColumnIndexByContentOrFirstEmptyCell

      protected int findColumnIndexByContentOrFirstEmptyCell(org.apache.poi.ss.usermodel.Row row, String content)
      Finds column index by comparing content of cells.
      Parameters:
      row - source of the searching
      content - content of sought column
      Returns:
      index of sought column - if column was not found then -1 is returned
    • createNewHeaderCell

      protected org.apache.poi.ss.usermodel.Cell createNewHeaderCell(org.apache.poi.ss.usermodel.Row headerRow, int columnIndex, String headerValue)
      Creates new header cell and inserts appropriate header value.
      Parameters:
      headerRow - row will be increased by a new column
      columnIndex - index of newly created cell
      headerValue - value of newly created cell
      Returns:
      newly created cell
    • createCellIfNecessary

      protected org.apache.poi.ss.usermodel.Cell createCellIfNecessary(org.apache.poi.ss.usermodel.Row row, int columnIndex)
      Finds appropriate cell by column index and if cell does not exist then a new cell is created.
      Parameters:
      row - source of the searching
      columnIndex - index of sought column
      Returns:
      cell which is located in row passed as param and in given columnIndex
    • findRow

      protected Optional<org.apache.poi.ss.usermodel.Row> findRow(org.apache.poi.ss.usermodel.Workbook workbook, ItemModel item)
      Finds appropriate row based on provided item.
      Parameters:
      workbook - exported workbook
      item - provided item
      Returns:
      found row
    • getExcelCellService

      public ExcelCellService getExcelCellService()
    • setExcelCellService

      public void setExcelCellService(ExcelCellService excelCellService)
    • getAttributeNameFormatter

      public AttributeNameFormatter<ExcelClassificationAttribute> getAttributeNameFormatter()
    • setAttributeNameFormatter

      public void setAttributeNameFormatter(AttributeNameFormatter<ExcelClassificationAttribute> attributeNameFormatter)
    • getExcelAttributeTranslatorRegistry

      public ExcelAttributeTranslatorRegistry getExcelAttributeTranslatorRegistry()
    • setExcelAttributeTranslatorRegistry

      public void setExcelAttributeTranslatorRegistry(ExcelAttributeTranslatorRegistry excelAttributeTranslatorRegistry)