Class DefaultImpexConverter

  • All Implemented Interfaces:
    ImpexConverter

    public class DefaultImpexConverter
    extends java.lang.Object
    implements ImpexConverter
    Default service responsible for generating impex script based on Impex object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean areUniqueAttributesPopulated​(java.util.Map<ImpexHeaderValue,​java.lang.Object> row)
      Returns true when all values indicated as unique have not empty value.
      java.lang.String convert​(Impex impex)
      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.
      protected java.lang.String getValue​(java.lang.Object value)
      Returns escaped string value.
      protected java.lang.String prepareHeaderAttribute​(ImpexHeaderValue headerAttribute)
      Prepares single header value of impex.
      protected java.lang.String prepareImpexHeader​(ImpexForType impexForType)
      Prepares first row of impex script for given type.
      protected java.lang.String prepareImpexRows​(ImpexForType impexForType)
      Generates String which contains many lines represent rows for impex scripts.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • IMPEX_OPERATION_TYPE

        public static final java.lang.String IMPEX_OPERATION_TYPE
        See Also:
        Constant Field Values
      • DEFAULT_FIELD_SEPARATOR

        public static final java.lang.String DEFAULT_FIELD_SEPARATOR
      • DEFAULT_LINE_SEPARATOR

        public static final java.lang.String DEFAULT_LINE_SEPARATOR
    • Constructor Detail

      • DefaultImpexConverter

        public DefaultImpexConverter()
    • Method Detail

      • convert

        public java.lang.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 java.lang.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 java.lang.String getValue​(java.lang.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​(java.util.Map<ImpexHeaderValue,​java.lang.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 java.lang.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 java.lang.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