Class DefaultExcelImportService

java.lang.Object
com.hybris.backoffice.excel.importing.DefaultExcelImportService
All Implemented Interfaces:
ExcelImportService

public class DefaultExcelImportService extends Object implements ExcelImportService
Service responsible for generating Impex based on excel file represented by Workbook object. In order to generating impex script, we can pass the cellValidation of {#importData} to ImpexConverter.convert(Impex).
  • Field Details

  • Constructor Details

    • DefaultExcelImportService

      public DefaultExcelImportService()
  • Method Details

    • convertToImpex

      public Impex convertToImpex(org.apache.poi.ss.usermodel.Workbook workbook)
      Transforms excel workbook into Impex object. It takes into account all sheets included in excel file.
      Specified by:
      convertToImpex in interface ExcelImportService
      Parameters:
      workbook - Workbook object which represents excel file
      Returns:
      generated Impex object which represents data from the workbook
    • validate

      public List<ExcelValidationResult> validate(org.apache.poi.ss.usermodel.Workbook workbook, Set<String> mediaContentEntries)
      Description copied from interface: ExcelImportService
      Validates a workbook.
      Specified by:
      validate in interface ExcelImportService
      Parameters:
      workbook - workbook to validate.
      mediaContentEntries - set of entries names inside media content attached to the excel file. Null if media is not attached.
      Returns:
      list of validation results.
    • validate

      public List<ExcelValidationResult> validate(org.apache.poi.ss.usermodel.Workbook workbook, Set<String> mediaContentEntries, Map<String,Object> context)
      Description copied from interface: ExcelImportService
      Validates a workbook.
      Specified by:
      validate in interface ExcelImportService
      Parameters:
      workbook - workbook to validate.
      mediaContentEntries - set of entries names inside media content attached to the excel file. Null if media is not attached.
      context - context with additional parameters
      Returns:
      list of validation results.
    • validate

      public List<ExcelValidationResult> validate(org.apache.poi.ss.usermodel.Workbook workbook)
      Description copied from interface: ExcelImportService
      Validates a workbook.
      Specified by:
      validate in interface ExcelImportService
      Parameters:
      workbook - workbook to validate.
      Returns:
      list of validation results.
    • validateExcelFileOrigin

      protected Optional<ExcelValidationResult> validateExcelFileOrigin(org.apache.poi.ss.usermodel.Workbook workbook)
    • validateWorkbook

      protected List<ExcelValidationResult> validateWorkbook(org.apache.poi.ss.usermodel.Workbook workbook)
    • populate

      protected ExcelWorkbook populate(org.apache.poi.ss.usermodel.Workbook workbook)
    • populate

      protected ExcelWorksheet populate(org.apache.poi.ss.usermodel.Sheet typeSystemSheet, org.apache.poi.ss.usermodel.Sheet typeSheet)
    • populateRows

      protected void populateRows(org.apache.poi.ss.usermodel.Sheet typeSheet, ExcelWorksheet excelWorksheet, List<String> entriesRef, SelectedAttribute selectedAttribute, int columnIndex)
    • hasRowCorrectData

      protected boolean hasRowCorrectData(org.apache.poi.ss.usermodel.Row row)
    • findFirstNotBlankCell

      protected boolean findFirstNotBlankCell(org.apache.poi.ss.usermodel.Row row)
    • validate

      protected List<ExcelValidationResult> validate(ExcelWorksheet excelWorksheet, Map<String,Object> context)
    • mergeWithRowValidation

      protected void mergeWithRowValidation(Map<Integer,ExcelValidationResult> rowsValidation, Integer rowIndex, ExcelValidationResult cellValidation)
    • getAttributeDisplayName

      protected String getAttributeDisplayName(SelectedAttribute attribute)
    • validateCell

    • prepareValidationHeader

      protected ValidationMessage prepareValidationHeader(DefaultExcelImportService.CellValidationMetaData metaData)
    • populateHeaderMetadata

      protected void populateHeaderMetadata(ValidationMessage header, DefaultExcelImportService.CellValidationMetaData metaData)
    • generateImpexForSheet

      protected Impex generateImpexForSheet(org.apache.poi.ss.usermodel.Sheet typeSystemSheet, org.apache.poi.ss.usermodel.Sheet typeSheet)
      Generates impex for given sheet
      Parameters:
      typeSystemSheet - - sheet contains metainformation about type codes
      typeSheet - - sheet contains data for given type code
      Returns:
      Impex generated impex object
    • insertDocumentReferences

      protected void insertDocumentReferences(Impex mainImpex, String typeCode, List<String> entriesRef)
      In order to simplify cross-reference imports, impex allows to use document reference. This method inserts references for each row.
      Parameters:
      mainImpex - Impex - represents impex for currently processing workbook
      typeCode - - type code of currently processing sheet
      entriesRef - - list of generated document references
    • generateDocumentRefs

      protected List<String> generateDocumentRefs(Integer rowsCount)
      In order to simplify cross-reference imports, impex allows to use document reference. The method generates list of random UUIDs for each row of imported excel.
      Parameters:
      rowsCount - - indicates how many document references should be generated.
      Returns:
      list of UUIDs
    • findImportParameters

      protected ImportParameters findImportParameters(SelectedAttribute selectedAttribute, String cellValue, String typeCode, String entryRef)
      Parses cell's value taking into account reference pattern and default values (which are located in the second and third row). Merges default values if needed.
      Parameters:
      selectedAttribute - SelectedAttribute - Information about selected attribute: its isoCode (for localized values), referencePattern for references and attributeDescriptor
      cellValue - - Original cell's value represented as String
      typeCode - - Type code of current sheet
      Returns:
      ImportParameters Converted import parameters, merged with default values
    • getExcelTemplateService

      @Deprecated(since="1808", forRemoval=true) public ExcelTemplateService getExcelTemplateService()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 1808
    • setExcelTemplateService

      @Deprecated(since="1808", forRemoval=true) public void setExcelTemplateService(ExcelTemplateService excelTemplateService)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 1808
    • getExcelTranslatorRegistry

      public ExcelTranslatorRegistry getExcelTranslatorRegistry()
    • setExcelTranslatorRegistry

      public void setExcelTranslatorRegistry(ExcelTranslatorRegistry excelTranslatorRegistry)
    • getWorkbookValidators

      public List<WorkbookValidator> getWorkbookValidators()
    • setWorkbookValidators

      public void setWorkbookValidators(List<WorkbookValidator> workbookValidators)
    • getExcelValidationEngineAwareValidator

      public ExcelValidationEngineAwareValidator getExcelValidationEngineAwareValidator()
    • setExcelValidationEngineAwareValidator

      public void setExcelValidationEngineAwareValidator(ExcelValidationEngineAwareValidator excelValidationEngineAwareValidator)
    • getParserRegistry

      public ParserRegistry getParserRegistry()
    • setParserRegistry

      public void setParserRegistry(ParserRegistry parserRegistry)
    • getExcelWorkbookService

      public ExcelWorkbookService getExcelWorkbookService()
    • setExcelWorkbookService

      public void setExcelWorkbookService(ExcelWorkbookService excelWorkbookService)
    • getExcelSheetService

      public ExcelSheetService getExcelSheetService()
    • setExcelSheetService

      public void setExcelSheetService(ExcelSheetService excelSheetService)
    • getExcelCellService

      public ExcelCellService getExcelCellService()
    • setExcelCellService

      public void setExcelCellService(ExcelCellService excelCellService)
    • getExcelHeaderService

      public ExcelHeaderService getExcelHeaderService()
    • setExcelHeaderService

      public void setExcelHeaderService(ExcelHeaderService excelHeaderService)
    • getDisplayNameAttributeNameFormatter

      public DisplayNameAttributeNameFormatter getDisplayNameAttributeNameFormatter()
    • setDisplayNameAttributeNameFormatter

      public void setDisplayNameAttributeNameFormatter(DisplayNameAttributeNameFormatter displayNameAttributeNameFormatter)