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>
TheConverter
is invoked when cloning a component which contain aMediaContainer
. This converts a Maprepresentation of a MediaContainerModel
into an actualMediaContainerModel
When 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 aMap
of all media format qualifiers defined in the platform and allMediaModel
defined in the cloned component model.MediaContainerModel
convert(java.util.Map<java.lang.String,java.lang.String> source)
Uses the sourceS
object 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 CloneComponentContextProvider
getCloneComponentContextProvider()
protected MediaContainerFacade
getMediaContainerFacade()
protected CMSMediaFormatService
getMediaFormatService()
protected ModelService
getModelService()
protected UniqueItemIdentifierService
getUniqueItemIdentifierService()
void
setCloneComponentContextProvider(CloneComponentContextProvider cloneComponentContextProvider)
void
setMediaContainerFacade(MediaContainerFacade mediaContainerFacade)
void
setMediaFormatService(CMSMediaFormatService mediaFormatService)
void
setModelService(ModelService modelService)
void
setUniqueItemIdentifierService(UniqueItemIdentifierService uniqueItemIdentifierService)
-
-
-
Method Detail
-
convert
public MediaContainerModel convert(java.util.Map<java.lang.String,java.lang.String> source)
Description copied from interface:Converter
Uses the sourceS
object and produces an new instance ofT
.- Specified by:
convert
in 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 aMap
of all media format qualifiers defined in the platform and allMediaModel
defined in the cloned component model. If aMediaModel
is not found for a given media format, the value is set to NULLMap
of 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 aMediaModel
is 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:
Optional
containing anMap.Entry
from thesrcAttributeMap
which matches the givenmediaCode
andmediaFormat
; 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)
-
-