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.-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.poi.ss.usermodel.CellcreateCellIfNecessary(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.protected org.apache.poi.ss.usermodel.CellcreateNewHeaderCell(org.apache.poi.ss.usermodel.Row headerRow, int columnIndex, String headerValue) Creates new header cell and inserts appropriate header value.protected voiddecorate(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.protected voidexportDataIntoCell(ExcelAttributeTranslator<ExcelAttribute> translator, ExcelCellValue excelCellValue) protected intfindColumnIndexByContentOrFirstEmptyCell(org.apache.poi.ss.usermodel.Row row, String content) Finds column index by comparing content of cells.protected Optional<org.apache.poi.ss.usermodel.Row>Finds appropriate row based on provided item.protected org.apache.poi.ss.usermodel.CellinsertHeaderIfNecessary(org.apache.poi.ss.usermodel.Sheet sheet, String headerValue) Inserts new header cell if row does not contain any cell with given contentprotected voidinsertReferenceFormatIfNecessary(org.apache.poi.ss.usermodel.Cell excelCellValue, String referenceFormat) voidsetAttributeNameFormatter(AttributeNameFormatter<ExcelClassificationAttribute> attributeNameFormatter) voidsetExcelAttributeTranslatorRegistry(ExcelAttributeTranslatorRegistry excelAttributeTranslatorRegistry) voidsetExcelCellService(ExcelCellService excelCellService) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.hybris.backoffice.excel.exporting.ExcelExportWorkbookDecorator
decorateMethods inherited from interface org.springframework.core.Ordered
getOrder
-
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 onattributes- collection of attributes to iterate onitems- 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 valuesheaderValue- 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 searchingcontent- 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 columncolumnIndex- index of newly created cellheaderValue- 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 searchingcolumnIndex- 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 workbookitem- provided item- Returns:
- found row
-
getExcelCellService
-
setExcelCellService
-
getAttributeNameFormatter
-
setAttributeNameFormatter
public void setAttributeNameFormatter(AttributeNameFormatter<ExcelClassificationAttribute> attributeNameFormatter) -
getExcelAttributeTranslatorRegistry
-
setExcelAttributeTranslatorRegistry
public void setExcelAttributeTranslatorRegistry(ExcelAttributeTranslatorRegistry excelAttributeTranslatorRegistry)
-