Class DefaultImpexConverter

java.lang.Object
com.hybris.backoffice.excel.importing.DefaultImpexConverter
All Implemented Interfaces:
ImpexConverter

public class DefaultImpexConverter extends Object implements ImpexConverter
Default service responsible for generating impex script based on Impex object.
  • Field Details

    • IMPEX_OPERATION_TYPE

      public static final String IMPEX_OPERATION_TYPE
      See Also:
    • DEFAULT_FIELD_SEPARATOR

      public static final String DEFAULT_FIELD_SEPARATOR
    • DEFAULT_LINE_SEPARATOR

      public static final String DEFAULT_LINE_SEPARATOR
  • Constructor Details

    • DefaultImpexConverter

      public DefaultImpexConverter()
  • Method Details

    • convert

      public String convert(Impex impex)
      Description copied from interface: ImpexConverter
      Generates impex script which contains impex header (for example INSERT_UPDATE Product;code[unique=true];name[lang=en];) and multi-lines which represent impex's data. Lines which does not contain all unique attributes are omitted.
      Specified by:
      convert in interface ImpexConverter
      Parameters:
      impex -
      Returns:
      converted impex script. Lines which does not contain all unique attributes are omitted.
    • prepareImpexRows

      protected String prepareImpexRows(ImpexForType impexForType)
      Generates String which contains many lines represent rows for impex scripts. Lines which does not contain all unique attributes are omitted.
      Parameters:
      impexForType - ImpexForType
      Returns:
      multi-lines String represents rows of impex scripts
    • getValue

      protected String getValue(Object value)
      Returns escaped string value. If value contains semicolon, coma, new lines then value is wrapped in double quotes. If the value is null then empty string will be returned.
      Parameters:
      value - which should be converted to string and escaped if needed
      Returns:
      escaped value
    • areUniqueAttributesPopulated

      protected boolean areUniqueAttributesPopulated(Map<ImpexHeaderValue,Object> row)
      Returns true when all values indicated as unique have not empty value.
      Parameters:
      row - maps contains ImpexHeaderValue as keys and Object as values.
      Returns:
      true when all values indicated as unique have not empty value.
    • prepareImpexHeader

      protected String prepareImpexHeader(ImpexForType impexForType)
      Prepares first row of impex script for given type. Example result: INSERT_UPDATE Product;code[unique=true];name[lang=en];
      Parameters:
      impexForType - ImpexForType
      Returns:
      first row of impex script for given type.
    • prepareHeaderAttribute

      protected String prepareHeaderAttribute(ImpexHeaderValue headerAttribute)
      Prepares single header value of impex. Example outputs: code[unique=true], name[unique=true, lang=en]
      Parameters:
      headerAttribute - ImpexHeaderValue consists of header name, language and indicator whether attribute is unique
      Returns:
      represents single header value