Interface ExcelValueTranslator<T>

Type Parameters:
T - class which is supported by given translator
All Superinterfaces:
org.springframework.core.Ordered
All Known Implementing Classes:
AbstractCatalogVersionAwareTranslator, AbstractExcelMediaImportTranslator, AbstractExcelValueTranslator, AbstractValidationAwareTranslator, ExcelBaseProductTypeTranslator, ExcelCatalogVersionTypeTranslator, ExcelEnumTypeTranslator, ExcelEurope1PricesTypeTranslator, ExcelGenericReferenceTranslator, ExcelJavaTypeTranslator, ExcelMediaCollectionImportTranslator, ExcelMediaCollectionUrlTranslator, ExcelMediaImportTranslator, ExcelMediaUrlTranslator, ExcelProductSupercategoriesTypeTranslator

public interface ExcelValueTranslator<T> extends org.springframework.core.Ordered
Base excel translator interface. In case of importing excel, when a translator will be returned just single value and creation of additional entries (for example creating part-of entries: product - price row, ect.) is not required, then consider AbstractExcelValueTranslator
  • Method Details

    • canHandle

      boolean canHandle(AttributeDescriptorModel attributeDescriptorModel)
      Indicates whether the translator can handle given attribute descriptor. This method is Recommended during importing excel file.
      Parameters:
      attributeDescriptorModel - AttributeDescriptorModel
      Returns:
      whether the translator can handle request
    • canHandle

      default boolean canHandle(AttributeDescriptorModel attributeDescriptor, ItemModel itemModel)
      Indicates whether the translator can handle given attribute descriptor. This method is Recommended during exporting. During importing excel file, the itemModel will be always null, because the item will be created by impex.
      Parameters:
      attributeDescriptor - AttributeDescriptorModel
      itemModel - instance of exporting model
      Returns:
      whether the translator can handle request
    • exportData

      Optional<Object> exportData(T objectToExport)
      Converts given object to value which should be put into cell of exported excel file.
      Parameters:
      objectToExport -
      Returns:
      value which will be put into cell of exported excel file.
    • exportData

      default Optional<Object> exportData(AttributeDescriptorModel attributeDescriptorModel, T objectToExport)
      Converts given object to value which should be put into cell of exported excel file.
      Parameters:
      attributeDescriptorModel - AttributeDescriptorModel
      objectToExport -
      Returns:
      value which will be put into cell of exported excel file.
    • importData

      Impex importData(AttributeDescriptorModel attributeDescriptor, ImportParameters importParameters)
      Imports data based on provided importParameters for given attributeDescriptor. The method returns Impex thanks to that it is possible to creating additional entries ( or example creating part-of entries: product - price row, ect.)
      Parameters:
      attributeDescriptor - describes attribute which should be imported
      importParameters - contains information about language for localized field, type code, parsed parameters inserted into excel's cell.
      Returns:
      Impex object which is representation of impex script.
    • referenceFormat

      default String referenceFormat(AttributeDescriptorModel attributeDescriptor)
      Format how a reference should be presented. Usually references consist of a few fields indicated as unique. Therefore all unique attributes should be included in the format. Example reference format: "catalog:version"
      Parameters:
      attributeDescriptor - AttributeDescriptorModel
      Returns:
      Format how a reference should be presented
    • validate

      ExcelValidationResult validate(ImportParameters importParameters, AttributeDescriptorModel attributeDescriptor, Map<String,Object> context)
      Validates single cell based on parsed importParameters. If cell has reference format then parsed values are available in ImportParameters.parameters. Otherwise the value of cell can be obtained by ImportParameters.cellValue.
      Parameters:
      importParameters - - contains information about parsed cell value (for reference format) ImportParameters.parameters and original cell value ImportParameters.cellValue
      attributeDescriptor - - contains information about selected attribute for current cell
      context - - shared context which can be used as a cache
      Returns:
      - validation result