Class CloneComponentMediaContainerDataToAttributeContentConverter
- java.lang.Object
-
- de.hybris.platform.acceleratorfacades.cmsitems.attributeconverters.CloneComponentMediaContainerDataToAttributeContentConverter
-
- All Implemented Interfaces:
Converter<java.util.Map<java.lang.String,java.lang.String>,MediaContainerModel>
public class CloneComponentMediaContainerDataToAttributeContentConverter extends java.lang.Object implements Converter<java.util.Map<java.lang.String,java.lang.String>,MediaContainerModel>
TheConverteris invoked when cloning a component which contain aMediaContainer. This converts a Maprepresentation of a MediaContainerModelinto an actualMediaContainerModelWhen cloning a component, the "source" Map contains the values as inputed by the request payload. The "cloneComponentModel" is the component model created by cloning from the source component uuid specified in the request payload. When editing a MediaContainer, if at least one media was modified in the "source" Map for any given MediaFormat, the resulting "cloneComponentModel" should update the reference to the updated "source" Map value. Otherwise, a reference to the cloned media model is used instead.
-
-
Constructor Summary
Constructors Constructor Description CloneComponentMediaContainerDataToAttributeContentConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Map<java.lang.String,MediaModel>buildMediaModelMapForAllMediaFormats(java.util.Map<java.lang.String,MediaFormatModel> mediaFormatModelMap, MediaContainerModel mediaContainerModel)Builds aMapof all media format qualifiers defined in the platform and allMediaModeldefined in the cloned component model.MediaContainerModelconvert(java.util.Map<java.lang.String,java.lang.String> source)Uses the sourceSobject and produces an new instance ofT.protected java.util.Optional<java.util.Map.Entry<java.lang.String,java.lang.Object>>findMediaCodeExistsInSourceAndAttributeMap(java.util.Map<java.lang.String,java.lang.Object> srcAttributeMap, java.lang.String languageTag, java.lang.String mediaFormat, java.lang.String mediaCode)Compare the mediaCode in the "source" Map and in the "source attribute" Map to determine if it was modified for a given MediaFormat when the mediaCode is different, add the updated value to the mapprotected CloneComponentContextProvidergetCloneComponentContextProvider()protected MediaContainerFacadegetMediaContainerFacade()protected CMSMediaFormatServicegetMediaFormatService()protected ModelServicegetModelService()protected UniqueItemIdentifierServicegetUniqueItemIdentifierService()voidsetCloneComponentContextProvider(CloneComponentContextProvider cloneComponentContextProvider)voidsetMediaContainerFacade(MediaContainerFacade mediaContainerFacade)voidsetMediaFormatService(CMSMediaFormatService mediaFormatService)voidsetModelService(ModelService modelService)voidsetUniqueItemIdentifierService(UniqueItemIdentifierService uniqueItemIdentifierService)
-
-
-
Method Detail
-
convert
public MediaContainerModel convert(java.util.Map<java.lang.String,java.lang.String> source)
Description copied from interface:ConverterUses the sourceSobject and produces an new instance ofT.- Specified by:
convertin interfaceConverter<java.util.Map<java.lang.String,java.lang.String>,MediaContainerModel>- Parameters:
source- the input to be converted.- Returns:
- an instance of
T, converted from the input source.
-
buildMediaModelMapForAllMediaFormats
protected java.util.Map<java.lang.String,MediaModel> buildMediaModelMapForAllMediaFormats(java.util.Map<java.lang.String,MediaFormatModel> mediaFormatModelMap, MediaContainerModel mediaContainerModel)
Builds aMapof all media format qualifiers defined in the platform and allMediaModeldefined in the cloned component model. If aMediaModelis not found for a given media format, the value is set to NULLMapof key-value pairs of <MediaFormatModel.getQualifier()andMediaModel>- Parameters:
mediaFormatModelMap- map containing key-value pairs of <MediaFormatModel.getQualifier()andMediaFormatModel>mediaContainerModel- the media container model defined on the cloned component model- Returns:
- a map of of key-value pairs of <
MediaFormatModel.getQualifier()andMediaModel>. If aMediaModelis not found for a given media format, the entry value is NULL.
-
findMediaCodeExistsInSourceAndAttributeMap
protected java.util.Optional<java.util.Map.Entry<java.lang.String,java.lang.Object>> findMediaCodeExistsInSourceAndAttributeMap(java.util.Map<java.lang.String,java.lang.Object> srcAttributeMap, java.lang.String languageTag, java.lang.String mediaFormat, java.lang.String mediaCode)Compare the mediaCode in the "source" Map and in the "source attribute" Map to determine if it was modified for a given MediaFormat when the mediaCode is different, add the updated value to the map- Parameters:
srcAttributeMap- the Map representation of the source attribute (saved in the session)languageTag- the current language locale (saved in the session)mediaFormat- the media format defined in the source MapmediaCode- the media code defined in the source Map- Returns:
Optionalcontaining anMap.Entryfrom thesrcAttributeMapwhich matches the givenmediaCodeandmediaFormat; otherwiseOptional.empty()
-
getUniqueItemIdentifierService
protected UniqueItemIdentifierService getUniqueItemIdentifierService()
-
setUniqueItemIdentifierService
public void setUniqueItemIdentifierService(UniqueItemIdentifierService uniqueItemIdentifierService)
-
getMediaFormatService
protected CMSMediaFormatService getMediaFormatService()
-
setMediaFormatService
public void setMediaFormatService(CMSMediaFormatService mediaFormatService)
-
getMediaContainerFacade
protected MediaContainerFacade getMediaContainerFacade()
-
setMediaContainerFacade
public void setMediaContainerFacade(MediaContainerFacade mediaContainerFacade)
-
getCloneComponentContextProvider
protected CloneComponentContextProvider getCloneComponentContextProvider()
-
setCloneComponentContextProvider
public void setCloneComponentContextProvider(CloneComponentContextProvider cloneComponentContextProvider)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
-