Class AbstractExcelMediaImportTranslator<T>
java.lang.Object
com.hybris.backoffice.excel.translators.AbstractValidationAwareTranslator<T>
com.hybris.backoffice.excel.translators.AbstractExcelValueTranslator<T>
com.hybris.backoffice.excel.translators.AbstractCatalogVersionAwareTranslator<T>
com.hybris.backoffice.excel.translators.AbstractExcelMediaImportTranslator<T>
- Type Parameters:
T- type of imported reference. It should be related to Media e.g. single reference or collection of medias.
- All Implemented Interfaces:
ExcelValueTranslator<T>,org.springframework.core.Ordered
- Direct Known Subclasses:
ExcelMediaCollectionImportTranslator,ExcelMediaImportTranslator
public abstract class AbstractExcelMediaImportTranslator<T>
extends AbstractCatalogVersionAwareTranslator<T>
Abstract media translator which allows to import media references with content. Format:
filePath:code:catalog:version
Where:
- "filePath" - defines file in the uploaded zip (sub dirs can be specified)
- "code" - media's code
MediaModel.CODE.- if empty and "filePath" is defined then code will be generated.
- if code:catalog:version corresponds to an existing media it will be assigned as a reference
- if "filePath" is defined and code:catalog:version corresponds to an existing media it's content will be updated and it will be assigned as a reference
- catalog:version - defines media's catalog version
MediaModel.CATALOGVERSION
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class com.hybris.backoffice.excel.translators.AbstractExcelValueTranslator
orderFields inherited from class com.hybris.backoffice.excel.translators.AbstractValidationAwareTranslator
validatorsFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddReferencedMedia(ImpexForType impexForType, AttributeDescriptorModel attributeDescriptor, String mediaRef) protected voidaddReferencedMedia(ImpexForType impexForType, AttributeDescriptorModel attributeDescriptor, String mediaRef, String isoCode) protected voidaddReferencedMedia(ImpexForType impexForType, AttributeDescriptorModel attributeDescriptor, Collection<String> mediaRefs) protected ImpexHeaderValuecreateMediaCatalogVersionHeader(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) protected ImpexHeaderValuecreateMediaCodeHeader(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) protected ImpexHeaderValuecreateMediaContentHeader(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) protected ImpexHeaderValuecreateMediaFolderHeader(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) protected ImpexHeaderValuecreateMediaReferenceIdHeader(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) protected Map<ImpexHeaderValue,Object> createMediaRow(AttributeDescriptorModel attributeDescriptor, String mediaRefId, Map<String, String> params) protected ImpexHeaderValuecreateReferenceHeader(AttributeDescriptorModel attributeDescriptor) protected ImpexHeaderValuecreateReferenceHeader(AttributeDescriptorModel attributeDescriptor, String isoCode) exportMedia(MediaModel media) Exports single mediaprotected StringgenerateMediaRefId(AttributeDescriptorModel attributedescriptor, Map<String, String> params) protected StringgetCode(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) protected StringgetFilePath(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) protected StringgetFolder(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) protected booleanhasImportData(Map<String, String> singleParams) importData(AttributeDescriptorModel attributeDescriptor, ImportParameters importParameters) Imports data based on provided importParameters for given attributeDescriptor.importValue(AttributeDescriptorModel attributeDescriptor, ImportParameters importParameters) Imports single value instead of whole Impex object.referenceFormat(AttributeDescriptorModel attributeDescriptor) Format how a reference should be presented.voidsetMandatoryFilter(ExcelFilter<AttributeDescriptorModel> mandatoryFilter) voidsetMediaCodeGenerator(KeyGenerator mediaCodeGenerator) voidsetMediaFolderProvider(MediaFolderProvider mediaFolderProvider) Methods inherited from class com.hybris.backoffice.excel.translators.AbstractCatalogVersionAwareTranslator
catalogVersionData, catalogVersionHeader, exportCatalogVersionData, getCatalogTypeService, referenceCatalogVersionFormat, setCatalogTypeServiceMethods inherited from class com.hybris.backoffice.excel.translators.AbstractExcelValueTranslator
getOrder, getTypeService, isLocalizedOfType, setOrder, setTypeServiceMethods inherited from class com.hybris.backoffice.excel.translators.AbstractValidationAwareTranslator
getValidators, setValidators, validateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.hybris.backoffice.excel.translators.ExcelValueTranslator
canHandle, canHandle, exportData, exportData
-
Field Details
-
PARAM_FILE_PATH
- See Also:
-
PARAM_FOLDER
- See Also:
-
PARAM_CODE
- See Also:
-
MEDIA_CONTENT_HEADER_NAME
- See Also:
-
-
Constructor Details
-
AbstractExcelMediaImportTranslator
public AbstractExcelMediaImportTranslator()
-
-
Method Details
-
referenceFormat
Description copied from interface:ExcelValueTranslatorFormat 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
-
exportMedia
Exports single media- Parameters:
media- media to export- Returns:
- media exported according to
referenceFormat(AttributeDescriptorModel)
-
createMediaRow
protected Map<ImpexHeaderValue,Object> createMediaRow(AttributeDescriptorModel attributeDescriptor, String mediaRefId, Map<String, String> params) -
hasImportData
-
generateMediaRefId
protected String generateMediaRefId(AttributeDescriptorModel attributedescriptor, Map<String, String> params) -
addReferencedMedia
protected void addReferencedMedia(ImpexForType impexForType, AttributeDescriptorModel attributeDescriptor, Collection<String> mediaRefs) -
addReferencedMedia
protected void addReferencedMedia(ImpexForType impexForType, AttributeDescriptorModel attributeDescriptor, String mediaRef) -
addReferencedMedia
protected void addReferencedMedia(ImpexForType impexForType, AttributeDescriptorModel attributeDescriptor, String mediaRef, String isoCode) -
createReferenceHeader
-
createReferenceHeader
protected ImpexHeaderValue createReferenceHeader(AttributeDescriptorModel attributeDescriptor, String isoCode) -
createMediaContentHeader
protected ImpexHeaderValue createMediaContentHeader(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) -
createMediaCatalogVersionHeader
protected ImpexHeaderValue createMediaCatalogVersionHeader(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) -
createMediaCodeHeader
protected ImpexHeaderValue createMediaCodeHeader(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) -
createMediaReferenceIdHeader
protected ImpexHeaderValue createMediaReferenceIdHeader(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) -
createMediaFolderHeader
protected ImpexHeaderValue createMediaFolderHeader(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) -
getCode
-
getFilePath
protected String getFilePath(AttributeDescriptorModel attributeDescriptor, Map<String, String> params) -
getFolder
-
importValue
public ImpexValue importValue(AttributeDescriptorModel attributeDescriptor, ImportParameters importParameters) Description copied from class:AbstractExcelValueTranslatorImports single value instead of whole Impex object. Impex value consists of header and value.- Specified by:
importValuein classAbstractExcelValueTranslator<T>- Parameters:
attributeDescriptor-AttributeDescriptorModeldescribes attribute which should be importedimportParameters- - contains information about language for localized field, type code, parsed parameters inserted into excel's cell.- Returns:
ImpexValuevalue which should be imported
-
importData
public Impex importData(AttributeDescriptorModel attributeDescriptor, ImportParameters importParameters) Description copied from class:AbstractExcelValueTranslatorImports data based on provided importParameters for given attributeDescriptor. The method returnsImpexthanks to that it is possible to creating additional entries ( or example creating part-of entries: product - price row, ect.)- Specified by:
importDatain interfaceExcelValueTranslator<T>- Overrides:
importDatain classAbstractExcelValueTranslator<T>- Parameters:
attributeDescriptor- describes attribute which should be importedimportParameters- contains information about language for localized field, type code, parsed parameters inserted into excel's cell.- Returns:
Impexobject which is representation of impex script.
-
getMediaCodeGenerator
-
setMediaCodeGenerator
-
getMandatoryFilter
-
setMandatoryFilter
-
setMediaFolderProvider
-