Class CloneComponentMediaContainerDataToAttributeContentConverter
java.lang.Object
de.hybris.platform.acceleratorfacades.cmsitems.attributeconverters.CloneComponentMediaContainerDataToAttributeContentConverter
- All Implemented Interfaces:
Converter<Map<String,Object>, MediaContainerModel>
public class CloneComponentMediaContainerDataToAttributeContentConverter
extends Object
implements Converter<Map<String,Object>,MediaContainerModel>
The
Converter is invoked when cloning a component which contain a MediaContainer. This converts a
Map<String, String> representation of a MediaContainerModel into an actual MediaContainerModel
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 -
Method Summary
Modifier and TypeMethodDescriptionprotected MediaContainerModelBuild a newMediaContainerModelfor Clone Componentprotected Map<String,MediaModel> buildMediaModelMapForAllMediaFormats(Map<String, MediaFormatModel> mediaFormatModelMap, MediaContainerModel mediaContainerModel) Builds aMapof all media format qualifiers defined in the platform and allMediaModeldefined in the cloned component model.Uses the sourceSobject and produces an new instance ofT.findMediaCodeExistsInSourceAndAttributeMap(Map<String, Object> srcLocalizedAttributeMap, String mediaFormat, 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 CloneComponentContextProviderprotected ComponentCloningStrategyprotected MediaContainerFacadeprotected CMSMediaFormatServiceprotected ModelServiceprotected UniqueItemIdentifierServicevoidsetCloneComponentContextProvider(CloneComponentContextProvider cloneComponentContextProvider) voidsetComponentCloningStrategy(ComponentCloningStrategy componentCloningStrategy) voidsetMediaContainerFacade(MediaContainerFacade mediaContainerFacade) voidsetMediaFormatService(CMSMediaFormatService mediaFormatService) voidsetModelService(ModelService modelService) voidsetUniqueItemIdentifierService(UniqueItemIdentifierService uniqueItemIdentifierService)
-
Constructor Details
-
CloneComponentMediaContainerDataToAttributeContentConverter
public CloneComponentMediaContainerDataToAttributeContentConverter()
-
-
Method Details
-
convert
Description copied from interface:ConverterUses the sourceSobject and produces an new instance ofT. -
buildMediaModelMapForAllMediaFormats
protected Map<String,MediaModel> buildMediaModelMapForAllMediaFormats(Map<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.
-
buildMediaContainer
protected MediaContainerModel buildMediaContainer(Map<String, Object> srcLocalizedAttributeMap, Map<String, Object> source) Build a newMediaContainerModelfor Clone Component- Parameters:
srcLocalizedAttributeMap- the Map representation of the source attribute (saved in the session)source- the Map representation of the clone source attribute- Returns:
- a
MediaContainerModel
-
findMediaCodeExistsInSourceAndAttributeMap
protected Optional<Map.Entry<String,Object>> findMediaCodeExistsInSourceAndAttributeMap(Map<String, Object> srcLocalizedAttributeMap, String mediaFormat, 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:
srcLocalizedAttributeMap- the Map representation of the source attribute (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
-
setUniqueItemIdentifierService
-
getMediaFormatService
-
setMediaFormatService
-
getMediaContainerFacade
-
setMediaContainerFacade
-
getCloneComponentContextProvider
-
setCloneComponentContextProvider
public void setCloneComponentContextProvider(CloneComponentContextProvider cloneComponentContextProvider) -
getModelService
-
setModelService
-
getComponentCloningStrategy
-
setComponentCloningStrategy
-