Class DefaultImpexConverter
- java.lang.Object
-
- com.hybris.backoffice.excel.importing.DefaultImpexConverter
-
- All Implemented Interfaces:
ImpexConverter
public class DefaultImpexConverter extends java.lang.Object implements ImpexConverter
Default service responsible for generating impex script based onImpexobject.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_FIELD_SEPARATORstatic java.lang.StringDEFAULT_LINE_SEPARATORstatic java.lang.StringIMPEX_OPERATION_TYPE
-
Constructor Summary
Constructors Constructor Description DefaultImpexConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanareUniqueAttributesPopulated(java.util.Map<ImpexHeaderValue,java.lang.Object> row)Returns true when all values indicated as unique have not empty value.java.lang.Stringconvert(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.StringgetValue(java.lang.Object value)Returns escaped string value.protected java.lang.StringprepareHeaderAttribute(ImpexHeaderValue headerAttribute)Prepares single header value of impex.protected java.lang.StringprepareImpexHeader(ImpexForType impexForType)Prepares first row of impex script for given type.protected java.lang.StringprepareImpexRows(ImpexForType impexForType)Generates String which contains many lines represent rows for impex scripts.
-
-
-
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
-
-
Method Detail
-
convert
public java.lang.String convert(Impex impex)
Description copied from interface:ImpexConverterGenerates 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:
convertin interfaceImpexConverter- 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 containsImpexHeaderValueas keys andObjectas 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-ImpexHeaderValueconsists of header name, language and indicator whether attribute is unique- Returns:
- represents single header value
-
-