Class CMSVersionToItemModelPopulator
java.lang.Object
de.hybris.platform.cms2.version.populator.CMSVersionToItemModelPopulator
- All Implemented Interfaces:
Populator<AuditPayload,ItemModel>
public class CMSVersionToItemModelPopulator
extends Object
implements Populator<AuditPayload,ItemModel>
Populates a DTO from the payload (
AuditPayload) contained in a CMSVersionModel.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyAttributeValuesToItemModel(ItemModel itemModel, Map<String, Object> values) Applies converted attributes toItemModel.protected voidapplyCustomAttributeValue(ItemModel itemModel, CustomAttributeContentConverter converter, TypedValue typedValue) Applies custom attribute values to theItemModel.protected Collection<Object>collectStreamResult(ValueType valueType, Stream<Object> stream) convertCollectionValue(ValueType valueType) protected voidconvertCustomAttributesValues(ItemModel itemModel, Map<String, TypedValue> values) Converts custom attribute values that are represented byCMSVersionCustomAttribute.Converts the localized attribute values fromAuditPayloadto attribute values ofItemModelprotected ObjectconvertLocalizedValue(LocalizedTypedValue localizedTypedValue, Function<List<String>, Object> localizedValueConverter) convertSimpleAttributes(Map<String, TypedValue> values) Converts the attribute values fromAuditPayloadto attribute values ofItemModelconvertSimpleValue(ValueType valueType) getAttributeRelatedData(Supplier<Object> collectionGetter, Supplier<Object> simpleGetter) protected Function<LocalizedTypedValue,Optional<Object>> Returns aFunctionaimed at converting any localized value described by aLocalizedTypedValue.protected Function<TypedValue,Optional<Object>> Returns aFunctionaimed at converting any non localized value described by aTypedValue.protected List<CMSVersionApplyAttributeValuesToModel>protected CMSVersionHelperprotected CollectionHelperprotected CommonI18NServiceprotected AttributeStrategyConverterProvider<String>protected Optional<CustomAttributeContentConverter>getCustomAttributeConverterByQualifier(List<CustomAttributeContentConverter> converters, String qualifier) Returns thee first found converter for a custom attribute based on the qualifier.protected CustomAttributeStrategyConverterProviderprotected ObjectgetEmptyCollectionValue(AttributeDescriptorModel attribute) Returns an empty collection based onAttributeDescriptorModeltype.getEmptyCollectionValuesPerQualifier(ItemModel itemModel, AuditPayload auditPayload) Returns theMapthat contains default (empty) collection values for every collection attribute that is null.protected Predicate<AttributeDescriptorModel>protected LocalegetLocale(LocalizedValue localizedValue) Returns aLocaleforLocalizedValue.protected booleanisCollectionPayloadType(ValueType valueType) Verifies whether theValueTypefrom payload represents a collection or not.protected booleanisCustomAttributeDataType(String payloadType) Verifies whether the payloadType represents theCMSVersionCustomAttributeor not.protected Predicate<AttributeDescriptorModel>isInAuditPayload(AuditPayload payload) Verifies that the value of an attribute is inAuditPayload.voidpopulate(AuditPayload auditPayload, ItemModel itemModel) Populate the target instance with values from the source instance.voidsetCmsVersionApplyAttributesValuesToModelServiceList(List<CMSVersionApplyAttributeValuesToModel> cmsVersionApplyAttributesValuesToModelServiceList) voidsetCmsVersionHelper(CMSVersionHelper cmsVersionHelper) voidsetCollectionHelper(CollectionHelper collectionHelper) voidsetCommonI18NService(CommonI18NService commonI18NService) voidsetConverterProvider(AttributeStrategyConverterProvider<String> converterProvider) voidsetCustomConverterProvider(CustomAttributeStrategyConverterProvider customConverterProvider) voidsetIsCollectionPredicate(Predicate<AttributeDescriptorModel> isCollectionPredicate)
-
Constructor Details
-
CMSVersionToItemModelPopulator
public CMSVersionToItemModelPopulator()
-
-
Method Details
-
populate
Description copied from interface:PopulatorPopulate the target instance with values from the source instance.- Specified by:
populatein interfacePopulator<AuditPayload,ItemModel> - Parameters:
auditPayload- the source objectitemModel- the target to fill
-
convertSimpleAttributes
Converts the attribute values fromAuditPayloadto attribute values ofItemModel- Parameters:
values- the list of attributes fromAuditPayload- Returns:
- the list of attributes applicable for
ItemModel
-
convertLocalizedAttributes
Converts the localized attribute values fromAuditPayloadto attribute values ofItemModel- Parameters:
values- the list of localized attributes fromAuditPayload- Returns:
- the list of localized attributes applicable for
ItemModel
-
getAttributeValueMapperForTypedValue
Returns aFunctionaimed at converting any non localized value described by aTypedValue.- Returns:
- a
Functionto convert a non localized value.
-
getAttributeValueMapperForLocalizedTypedValue
protected Function<LocalizedTypedValue,Optional<Object>> getAttributeValueMapperForLocalizedTypedValue()Returns aFunctionaimed at converting any localized value described by aLocalizedTypedValue.- Returns:
- the
Functionto convert a localized value.
-
convertLocalizedValue
protected Object convertLocalizedValue(LocalizedTypedValue localizedTypedValue, Function<List<String>, Object> localizedValueConverter) - Parameters:
localizedTypedValue- theLocalizedTypedValuevalue.localizedValueConverter- theFunctionthat converts the list ofStringvalues toObject.- Returns:
- the
Mapthat contains localized values.
-
convertCollectionValue
-
convertSimpleValue
-
applyAttributeValuesToItemModel
Applies converted attributes toItemModel. -
isInAuditPayload
Verifies that the value of an attribute is inAuditPayload.- Parameters:
payload- theAuditPayloadto verify the attribute on.- Returns:
- false if the attribute is not in
AuditPayload, true otherwise.
-
getEmptyCollectionValuesPerQualifier
protected Map<String,Object> getEmptyCollectionValuesPerQualifier(ItemModel itemModel, AuditPayload auditPayload) Returns theMapthat contains default (empty) collection values for every collection attribute that is null. -
getEmptyCollectionValue
Returns an empty collection based onAttributeDescriptorModeltype.- Parameters:
attribute- a collectionAttributeDescriptorModel.- Returns:
- empty representation of a collection.
-
getLocale
Returns aLocaleforLocalizedValue.- Parameters:
localizedValue- theLocalizedValue.- Returns:
- the
Locale.
-
collectStreamResult
- Parameters:
valueType- theValueTypethat is used to extract the collection type of a payload's attribute.stream- theStreamto which the collector should be applied.- Returns:
- the
Collection.
-
getAttributeRelatedData
protected Function<ValueType,Optional<Object>> getAttributeRelatedData(Supplier<Object> collectionGetter, Supplier<Object> simpleGetter) -
convertCustomAttributesValues
Converts custom attribute values that are represented byCMSVersionCustomAttribute.- Parameters:
itemModel- theItemModelto which the custom attributes are applied.values- the list of non localized attributes from the payload.
-
getCustomAttributeConverterByQualifier
protected Optional<CustomAttributeContentConverter> getCustomAttributeConverterByQualifier(List<CustomAttributeContentConverter> converters, String qualifier) Returns thee first found converter for a custom attribute based on the qualifier.- Parameters:
converters- the list ofCustomAttributeContentConverter.qualifier- the target qualifier for which the converter should be returned- Returns:
- the
OptionalofCustomAttributeContentConverter.
-
applyCustomAttributeValue
protected void applyCustomAttributeValue(ItemModel itemModel, CustomAttributeContentConverter converter, TypedValue typedValue) Applies custom attribute values to theItemModel.- Parameters:
itemModel- theItemModelto which the custom attributes are applied.converter- theCustomAttributeContentConverter.typedValue- theTypedValuethat contains the value/values that must be applied toItemModel.
-
isCustomAttributeDataType
Verifies whether the payloadType represents theCMSVersionCustomAttributeor not.- Parameters:
payloadType- the type to verify.- Returns:
- true if the payloadType represents
CMSVersionCustomAttribute, false otherwise. Suppress sonar warning (squid:S1166 | Exception handlers should preserve the original exception) : The exception is correctly handled in the catch clause.
-
isCollectionPayloadType
Verifies whether theValueTypefrom payload represents a collection or not. -
getCollectionHelper
-
setCollectionHelper
-
getCmsVersionHelper
-
setCmsVersionHelper
-
getCommonI18NService
-
setCommonI18NService
-
getCustomConverterProvider
-
setCustomConverterProvider
public void setCustomConverterProvider(CustomAttributeStrategyConverterProvider customConverterProvider) -
getConverterProvider
-
setConverterProvider
-
getIsCollectionPredicate
-
setIsCollectionPredicate
-
getCmsVersionApplyAttributesValuesToModelServiceList
protected List<CMSVersionApplyAttributeValuesToModel> getCmsVersionApplyAttributesValuesToModelServiceList() -
setCmsVersionApplyAttributesValuesToModelServiceList
public void setCmsVersionApplyAttributesValuesToModelServiceList(List<CMSVersionApplyAttributeValuesToModel> cmsVersionApplyAttributesValuesToModelServiceList)
-