Class DefaultExcelImportService
java.lang.Object
com.hybris.backoffice.excel.importing.DefaultExcelImportService
- All Implemented Interfaces:
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).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classPOJO which contains cell validation meta data -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final StringDeprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertToImpex(org.apache.poi.ss.usermodel.Workbook workbook) Transforms excel workbook intoImpexobject.protected booleanfindFirstNotBlankCell(org.apache.poi.ss.usermodel.Row row) protected ImportParametersfindImportParameters(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).generateDocumentRefs(Integer rowsCount) In order to simplify cross-reference imports, impex allows to use document reference.protected ImpexgenerateImpexForSheet(org.apache.poi.ss.usermodel.Sheet typeSystemSheet, org.apache.poi.ss.usermodel.Sheet typeSheet) Generates impex for given sheetprotected StringgetAttributeDisplayName(SelectedAttribute attribute) Deprecated, for removal: This API element is subject to removal in a future version.since 1808protected booleanhasRowCorrectData(org.apache.poi.ss.usermodel.Row row) protected voidinsertDocumentReferences(Impex mainImpex, String typeCode, List<String> entriesRef) In order to simplify cross-reference imports, impex allows to use document reference.protected voidmergeWithRowValidation(Map<Integer, ExcelValidationResult> rowsValidation, Integer rowIndex, ExcelValidationResult cellValidation) protected ExcelWorksheetpopulate(org.apache.poi.ss.usermodel.Sheet typeSystemSheet, org.apache.poi.ss.usermodel.Sheet typeSheet) protected ExcelWorkbookpopulate(org.apache.poi.ss.usermodel.Workbook workbook) protected voidpopulateHeaderMetadata(ValidationMessage header, DefaultExcelImportService.CellValidationMetaData metaData) protected voidpopulateRows(org.apache.poi.ss.usermodel.Sheet typeSheet, ExcelWorksheet excelWorksheet, List<String> entriesRef, SelectedAttribute selectedAttribute, int columnIndex) protected ValidationMessagevoidsetDisplayNameAttributeNameFormatter(DisplayNameAttributeNameFormatter displayNameAttributeNameFormatter) voidsetExcelCellService(ExcelCellService excelCellService) voidsetExcelHeaderService(ExcelHeaderService excelHeaderService) voidsetExcelSheetService(ExcelSheetService excelSheetService) voidsetExcelTemplateService(ExcelTemplateService excelTemplateService) Deprecated, for removal: This API element is subject to removal in a future version.since 1808voidsetExcelTranslatorRegistry(ExcelTranslatorRegistry excelTranslatorRegistry) voidsetExcelValidationEngineAwareValidator(ExcelValidationEngineAwareValidator excelValidationEngineAwareValidator) voidsetExcelWorkbookService(ExcelWorkbookService excelWorkbookService) voidsetParserRegistry(ParserRegistry parserRegistry) voidsetWorkbookValidators(List<WorkbookValidator> workbookValidators) protected List<ExcelValidationResult>validate(ExcelWorksheet excelWorksheet, Map<String, Object> context) validate(org.apache.poi.ss.usermodel.Workbook workbook) Validates a workbook.Validates a workbook.validate(org.apache.poi.ss.usermodel.Workbook workbook, Set<String> mediaContentEntries, Map<String, Object> context) Validates a workbook.protected Optional<ExcelValidationResult>validateCell(ExcelValueTranslator translator, DefaultExcelImportService.CellValidationMetaData metaData) protected Optional<ExcelValidationResult>validateExcelFileOrigin(org.apache.poi.ss.usermodel.Workbook workbook) protected List<ExcelValidationResult>validateWorkbook(org.apache.poi.ss.usermodel.Workbook workbook)
-
Field Details
-
MULTIVALUE_SEPARATOR
Deprecated, for removal: This API element is subject to removal in a future version.since 1808 - UseImportParameters.MULTIVALUE_SEPARATOR- See Also:
-
FIRST_DATA_ROW_INDEX
public static final int FIRST_DATA_ROW_INDEX- See Also:
-
-
Constructor Details
-
DefaultExcelImportService
public DefaultExcelImportService()
-
-
Method Details
-
convertToImpex
Transforms excel workbook intoImpexobject. It takes into account all sheets included in excel file.- Specified by:
convertToImpexin interfaceExcelImportService- Parameters:
workbook-Workbookobject which represents excel file- Returns:
- generated
Impexobject 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:ExcelImportServiceValidates a workbook.- Specified by:
validatein interfaceExcelImportService- 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:ExcelImportServiceValidates a workbook.- Specified by:
validatein interfaceExcelImportService- 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
Description copied from interface:ExcelImportServiceValidates a workbook.- Specified by:
validatein interfaceExcelImportService- 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
-
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
-
validateCell
protected Optional<ExcelValidationResult> validateCell(ExcelValueTranslator translator, DefaultExcelImportService.CellValidationMetaData metaData) -
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 codestypeSheet- - sheet contains data for given type code- Returns:
Impexgenerated impex object
-
insertDocumentReferences
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 workbooktypeCode- - type code of currently processing sheetentriesRef- - list of generated document references
-
generateDocumentRefs
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 attributeDescriptorcellValue- - Original cell's value represented as StringtypeCode- - Type code of current sheet- Returns:
ImportParametersConverted import parameters, merged with default values
-
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
-
setExcelTranslatorRegistry
-
getWorkbookValidators
-
setWorkbookValidators
-
getExcelValidationEngineAwareValidator
-
setExcelValidationEngineAwareValidator
public void setExcelValidationEngineAwareValidator(ExcelValidationEngineAwareValidator excelValidationEngineAwareValidator) -
getParserRegistry
-
setParserRegistry
-
getExcelWorkbookService
-
setExcelWorkbookService
-
getExcelSheetService
-
setExcelSheetService
-
getExcelCellService
-
setExcelCellService
-
getExcelHeaderService
-
setExcelHeaderService
-
getDisplayNameAttributeNameFormatter
-
setDisplayNameAttributeNameFormatter
public void setDisplayNameAttributeNameFormatter(DisplayNameAttributeNameFormatter displayNameAttributeNameFormatter)
-
ImportParameters.MULTIVALUE_SEPARATOR