public class CMSVersionToItemModelPopulator extends java.lang.Object implements Populator<AuditPayload,ItemModel>
AuditPayload) contained in a CMSVersionModel.| Constructor and Description |
|---|
CMSVersionToItemModelPopulator() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
applyAttributeValuesToItemModel(ItemModel itemModel,
java.util.Map<java.lang.String,java.lang.Object> values)
Applies converted attributes to
ItemModel. |
protected void |
applyCustomAttributeValue(ItemModel itemModel,
CustomAttributeContentConverter converter,
TypedValue typedValue)
Applies custom attribute values to the
ItemModel. |
protected java.util.Collection<java.lang.Object> |
collectStreamResult(ValueType valueType,
java.util.stream.Stream<java.lang.Object> stream)
Applies a proper
Collector to a stream using ValueType. |
protected java.util.function.Function<java.util.List<java.lang.String>,java.lang.Object> |
convertCollectionValue(ValueType valueType)
Returns the
Function that converts a collection of String values to Object. |
protected void |
convertCustomAttributesValues(ItemModel itemModel,
java.util.Map<java.lang.String,TypedValue> values)
Converts custom attribute values that are represented by
CMSVersionCustomAttribute. |
protected java.util.Map<java.lang.String,java.lang.Object> |
convertLocalizedAttributes(java.util.Map<java.lang.String,LocalizedTypedValue> values)
Converts the localized attribute values from
AuditPayload to attribute values of ItemModel |
protected java.lang.Object |
convertLocalizedValue(LocalizedTypedValue localizedTypedValue,
java.util.function.Function<java.util.List<java.lang.String>,java.lang.Object> localizedValueConverter)
Converts localized value to a
Map of Locale and Object. |
protected java.util.Map<java.lang.String,java.lang.Object> |
convertSimpleAttributes(java.util.Map<java.lang.String,TypedValue> values)
Converts the attribute values from
AuditPayload to attribute values of ItemModel |
protected java.util.function.Function<java.util.List<java.lang.String>,java.lang.Object> |
convertSimpleValue(ValueType valueType)
Returns the
Function that converts a collection containing one String element to Object. |
protected java.util.function.Function<ValueType,java.util.Optional<java.lang.Object>> |
getAttributeRelatedData(java.util.function.Supplier<java.lang.Object> collectionGetter,
java.util.function.Supplier<java.lang.Object> simpleGetter)
Returns a
Function aimed at converting any value described by a ValueType. |
protected java.util.function.Function<LocalizedTypedValue,java.util.Optional<java.lang.Object>> |
getAttributeValueMapperForLocalizedTypedValue()
Returns a
Function aimed at converting any localized value described by a LocalizedTypedValue. |
protected java.util.function.Function<TypedValue,java.util.Optional<java.lang.Object>> |
getAttributeValueMapperForTypedValue()
Returns a
Function aimed at converting any non localized value described by a TypedValue. |
protected CMSVersionHelper |
getCmsVersionHelper() |
protected CollectionHelper |
getCollectionHelper() |
protected CommonI18NService |
getCommonI18NService() |
protected AttributeStrategyConverterProvider<java.lang.String> |
getConverterProvider() |
protected java.util.Optional<CustomAttributeContentConverter> |
getCustomAttributeConverterByQualifier(java.util.List<CustomAttributeContentConverter> converters,
java.lang.String qualifier)
Returns thee first found converter for a custom attribute based on the qualifier.
|
protected CustomAttributeStrategyConverterProvider |
getCustomConverterProvider() |
protected java.lang.Object |
getEmptyCollectionValue(AttributeDescriptorModel attribute)
Returns an empty collection based on
AttributeDescriptorModel type. |
protected java.util.Map<java.lang.String,java.lang.Object> |
getEmptyCollectionValuesPerQualifier(ItemModel itemModel,
AuditPayload auditPayload)
Returns the
Map that contains default (empty) collection values for every collection attribute that is
null. |
protected java.util.function.Predicate<AttributeDescriptorModel> |
getIsCollectionPredicate() |
protected java.util.Locale |
getLocale(LocalizedValue localizedValue)
Returns a
Locale for LocalizedValue. |
protected ModelService |
getModelService() |
protected boolean |
isCollectionPayloadType(ValueType valueType)
Verifies whether the
ValueType from payload represents a collection or not. |
protected boolean |
isCustomAttributeDataType(java.lang.String payloadType)
Verifies whether the payloadType represents the
CMSVersionCustomAttribute or not. |
protected java.util.function.Predicate<AttributeDescriptorModel> |
isInAuditPayload(AuditPayload payload)
Verifies that the value of an attribute is in
AuditPayload. |
void |
populate(AuditPayload auditPayload,
ItemModel itemModel)
Populate the target instance with values from the source instance.
|
void |
setCmsVersionHelper(CMSVersionHelper cmsVersionHelper) |
void |
setCollectionHelper(CollectionHelper collectionHelper) |
void |
setCommonI18NService(CommonI18NService commonI18NService) |
void |
setConverterProvider(AttributeStrategyConverterProvider<java.lang.String> converterProvider) |
void |
setCustomConverterProvider(CustomAttributeStrategyConverterProvider customConverterProvider) |
void |
setIsCollectionPredicate(java.util.function.Predicate<AttributeDescriptorModel> isCollectionPredicate) |
void |
setModelService(ModelService modelService) |
public void populate(AuditPayload auditPayload, ItemModel itemModel)
Populatorpopulate in interface Populator<AuditPayload,ItemModel>auditPayload - the source objectitemModel - the target to fillprotected java.util.Map<java.lang.String,java.lang.Object> convertSimpleAttributes(java.util.Map<java.lang.String,TypedValue> values)
AuditPayload to attribute values of ItemModelvalues - the list of attributes from AuditPayloadItemModelprotected java.util.Map<java.lang.String,java.lang.Object> convertLocalizedAttributes(java.util.Map<java.lang.String,LocalizedTypedValue> values)
AuditPayload to attribute values of ItemModelvalues - the list of localized attributes from AuditPayloadItemModelprotected java.util.function.Function<TypedValue,java.util.Optional<java.lang.Object>> getAttributeValueMapperForTypedValue()
Function aimed at converting any non localized value described by a TypedValue.Function to convert a non localized value.protected java.util.function.Function<LocalizedTypedValue,java.util.Optional<java.lang.Object>> getAttributeValueMapperForLocalizedTypedValue()
Function aimed at converting any localized value described by a LocalizedTypedValue.Function to convert a localized value.protected java.lang.Object convertLocalizedValue(LocalizedTypedValue localizedTypedValue, java.util.function.Function<java.util.List<java.lang.String>,java.lang.Object> localizedValueConverter)
Map of Locale and Object.localizedTypedValue - the LocalizedTypedValue value.localizedValueConverter - the Function that converts the list of String values to Object.Map that contains localized values.protected java.util.function.Function<java.util.List<java.lang.String>,java.lang.Object> convertCollectionValue(ValueType valueType)
Function that converts a collection of String values to Object.valueType - the ValueType describing the metadata of the payload's attributeFunction.protected java.util.function.Function<java.util.List<java.lang.String>,java.lang.Object> convertSimpleValue(ValueType valueType)
Function that converts a collection containing one String element to Object.valueType - the ValueType describing the metadata of the payload's attribute.Function.protected void applyAttributeValuesToItemModel(ItemModel itemModel, java.util.Map<java.lang.String,java.lang.Object> values)
ItemModel.itemModel - the ItemModel to apply the attribute values.values - the Map of attribute values.protected java.util.function.Predicate<AttributeDescriptorModel> isInAuditPayload(AuditPayload payload)
AuditPayload.payload - the AuditPayload to verify the attribute on.AuditPayload, true otherwise.protected java.util.Map<java.lang.String,java.lang.Object> getEmptyCollectionValuesPerQualifier(ItemModel itemModel, AuditPayload auditPayload)
Map that contains default (empty) collection values for every collection attribute that is
null.itemModel - the ItemModel to verify attributes on.Map.protected java.lang.Object getEmptyCollectionValue(AttributeDescriptorModel attribute)
AttributeDescriptorModel type.attribute - a collection AttributeDescriptorModel.{@link - IllegalArgumentException} if the attribute is not a collection AttributeDescriptorModel.protected java.util.Locale getLocale(LocalizedValue localizedValue)
Locale for LocalizedValue.localizedValue - the LocalizedValue.Locale.protected java.util.Collection<java.lang.Object> collectStreamResult(ValueType valueType, java.util.stream.Stream<java.lang.Object> stream)
Collector to a stream using ValueType.valueType - the ValueType that is used to extract the collection type of a payload's attribute.stream - the Stream to which the collector should be applied.Collection.protected java.util.function.Function<ValueType,java.util.Optional<java.lang.Object>> getAttributeRelatedData(java.util.function.Supplier<java.lang.Object> collectionGetter, java.util.function.Supplier<java.lang.Object> simpleGetter)
Function aimed at converting any value described by a ValueType. This function will
execute one of the provided suppliers depending on whether the value is a collection or not.protected void convertCustomAttributesValues(ItemModel itemModel, java.util.Map<java.lang.String,TypedValue> values)
CMSVersionCustomAttribute.itemModel - the ItemModel to which the custom attributes are applied.values - the list of non localized attributes from the payload.protected java.util.Optional<CustomAttributeContentConverter> getCustomAttributeConverterByQualifier(java.util.List<CustomAttributeContentConverter> converters, java.lang.String qualifier)
converters - the list of CustomAttributeContentConverter.qualifier - the target qualifier for which the converter should be returnedOptional of CustomAttributeContentConverter.protected void applyCustomAttributeValue(ItemModel itemModel, CustomAttributeContentConverter converter, TypedValue typedValue)
ItemModel.itemModel - the ItemModel to which the custom attributes are applied.converter - the CustomAttributeContentConverter.typedValue - the TypedValue that contains the value/values that must be applied to ItemModel.protected boolean isCustomAttributeDataType(java.lang.String payloadType)
CMSVersionCustomAttribute or not.payloadType - the type to verify.CMSVersionCustomAttribute, false otherwise. Suppress sonar
warning (squid:S1166 | Exception handlers should preserve the original exception) : The exception is
correctly handled in the catch clause.protected boolean isCollectionPayloadType(ValueType valueType)
ValueType from payload represents a collection or not.protected CollectionHelper getCollectionHelper()
public void setCollectionHelper(CollectionHelper collectionHelper)
protected CMSVersionHelper getCmsVersionHelper()
public void setCmsVersionHelper(CMSVersionHelper cmsVersionHelper)
protected CommonI18NService getCommonI18NService()
public void setCommonI18NService(CommonI18NService commonI18NService)
protected CustomAttributeStrategyConverterProvider getCustomConverterProvider()
public void setCustomConverterProvider(CustomAttributeStrategyConverterProvider customConverterProvider)
protected ModelService getModelService()
public void setModelService(ModelService modelService)
protected AttributeStrategyConverterProvider<java.lang.String> getConverterProvider()
public void setConverterProvider(AttributeStrategyConverterProvider<java.lang.String> converterProvider)
protected java.util.function.Predicate<AttributeDescriptorModel> getIsCollectionPredicate()
public void setIsCollectionPredicate(java.util.function.Predicate<AttributeDescriptorModel> isCollectionPredicate)
Copyright © 2018 SAP SE. All Rights Reserved.