public class RenderingAttributeValueToRepresentationStrategy extends java.lang.Object implements AttributeValueToRepresentationStrategy
DefaultCMSItemConverter to convert items into a representation suited for rendering
purposes.
The transformation strategy is be based on the following rules:
- Simple Value:
-> If it's a Cms Component it needs to be converted into an AbstractCMSComponentData
(through the cmsComponentModelToDataRenderingConverter)
-> Otherwise, use the default transformation function.
- Collection:
-> If the collection contains Cms Components, get simple representation (uid).
-> Otherwise, use the default transformation function for each item.
- Localized Value:
-> Get value for current language, and use same approach as Simple Value.
- Localized Collection:
-> For each element, do the same as Localized Value.| Constructor and Description |
|---|
RenderingAttributeValueToRepresentationStrategy() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
attributeContainsCmsComponents(AttributeDescriptorModel attributeDescriptorModel)
Helper method to determine whether an attribute contains cms components.
|
protected AttributeContainsCMSComponentsPredicate |
getAttributeContainsCMSComponentsPredicate() |
protected <T> T |
getAttributeValue(AttributeDescriptorModel attribute,
ItemModel sourceModel)
This method is used to get the value of the desired attribute in the provided source model.
|
protected Converter<AbstractCMSComponentModel,AbstractCMSComponentData> |
getCmsComponentModelToDataRenderingConverter() |
protected java.util.function.Function<java.lang.Object,java.lang.Object> |
getCmsComponentRenderingDataTransformationFunction()
This method returns the transformation function to use to render CMS components.
|
java.util.function.Supplier<java.lang.Object> |
getCollectionGetter(AttributeDescriptorModel attribute,
ItemModel sourceModel,
java.util.function.Function<java.lang.Object,java.lang.Object> goDeeperOrSerialize)
This function is used to retrieve a
Supplier that can be used to get the representation of a collection stored in an attribute. |
protected AttributeValueToRepresentationConverter<java.util.Collection<java.lang.Object>,java.util.Collection<java.lang.Object>> |
getCollectionToRepresentationConverter() |
protected java.util.function.Function<java.lang.Object,java.lang.Object> |
getElementToRenderingDataTransformationFunction(AttributeDescriptorModel attributeDescriptorModel,
java.util.function.Function<java.lang.Object,java.lang.Object> defaultTransformationFunction)
This method receives a transformation function, and wraps it in a new function that contains necessary logic for
rendering purposes.
|
java.util.function.Supplier<java.lang.Object> |
getLocalizedCollectionGetter(AttributeDescriptorModel attribute,
ItemModel sourceModel,
java.util.function.Function<java.lang.Object,java.lang.Object> goDeeperOrSerialize)
This function is used to retrieve a
Supplier that can be used to get the representation of a localized collection value stored
in an attribute. |
java.util.function.Supplier<java.lang.Object> |
getLocalizedGetter(AttributeDescriptorModel attribute,
ItemModel sourceModel,
java.util.function.Function<java.lang.Object,java.lang.Object> goDeeperOrSerialize)
This function is used to retrieve a
Supplier that can be used to get the representation of a localized value stored in an attribute. |
protected ModelService |
getModelService() |
protected RenderingVisibilityService |
getRenderingVisibilityService() |
protected Converter<AbstractCMSComponentModel,java.lang.String> |
getSimpleCmsComponentAttributeConverter() |
java.util.function.Supplier<java.lang.Object> |
getSimpleGetter(AttributeDescriptorModel attribute,
ItemModel sourceModel,
java.util.function.Function<java.lang.Object,java.lang.Object> goDeeperOrSerialize)
This function is used to retrieve a Supplier that can be used to get the representation of the value of an attribute.
|
protected boolean |
isElementEligibleForRendering(AttributeDescriptorModel attributeDescriptorModel,
java.lang.Object element)
This method is used to determine if an element is allowed to be rendered.
|
void |
setAttributeContainsCMSComponentsPredicate(AttributeContainsCMSComponentsPredicate attributeContainsCMSComponentsPredicate) |
void |
setCmsComponentModelToDataRenderingConverter(Converter<AbstractCMSComponentModel,AbstractCMSComponentData> cmsComponentModelToDataRenderingConverter) |
void |
setCollectionToRepresentationConverter(AttributeValueToRepresentationConverter<java.util.Collection<java.lang.Object>,java.util.Collection<java.lang.Object>> collectionToRepresentationConverter) |
void |
setModelService(ModelService modelService) |
void |
setRenderingVisibilityService(RenderingVisibilityService renderingVisibilityService) |
void |
setSimpleCmsComponentAttributeConverter(Converter<AbstractCMSComponentModel,java.lang.String> simpleCmsComponentAttributeConverter) |
public RenderingAttributeValueToRepresentationStrategy()
public java.util.function.Supplier<java.lang.Object> getSimpleGetter(AttributeDescriptorModel attribute, ItemModel sourceModel, java.util.function.Function<java.lang.Object,java.lang.Object> goDeeperOrSerialize)
AttributeValueToRepresentationStrategygetSimpleGetter in interface AttributeValueToRepresentationStrategyattribute - The object describing the attribute whose value will be transformed.sourceModel - The model containing the value that will be transformed.goDeeperOrSerialize - The function that will be used to transform the value into the expected object.Supplier. Use get() to retrieve the transformed object.public java.util.function.Supplier<java.lang.Object> getCollectionGetter(AttributeDescriptorModel attribute, ItemModel sourceModel, java.util.function.Function<java.lang.Object,java.lang.Object> goDeeperOrSerialize)
AttributeValueToRepresentationStrategySupplier that can be used to get the representation of a collection stored in an attribute. This
representation is generated by leveraging the provided transformation function.getCollectionGetter in interface AttributeValueToRepresentationStrategyattribute - The object describing the attribute whose value will be transformed.sourceModel - The model containing the collection that will be transformed.goDeeperOrSerialize - The function that will be used to transform the collection into the expected representation.Supplier. Use get() to retrieve the transformed collection.public java.util.function.Supplier<java.lang.Object> getLocalizedGetter(AttributeDescriptorModel attribute, ItemModel sourceModel, java.util.function.Function<java.lang.Object,java.lang.Object> goDeeperOrSerialize)
AttributeValueToRepresentationStrategySupplier that can be used to get the representation of a localized value stored in an attribute.
This representation is generated by leveraging the provided transformation function.getLocalizedGetter in interface AttributeValueToRepresentationStrategyattribute - The object describing the attribute whose value will be transformed.sourceModel - The model containing the localized value that will be transformed.goDeeperOrSerialize - The function that will be used to transform the localized value into the expected representation.Supplier. Use get() to retrieve the transformed localized value.public java.util.function.Supplier<java.lang.Object> getLocalizedCollectionGetter(AttributeDescriptorModel attribute, ItemModel sourceModel, java.util.function.Function<java.lang.Object,java.lang.Object> goDeeperOrSerialize)
AttributeValueToRepresentationStrategySupplier that can be used to get the representation of a localized collection value stored
in an attribute.
This representation is generated by leveraging the provided transformation function.getLocalizedCollectionGetter in interface AttributeValueToRepresentationStrategyattribute - The object describing the attribute whose value will be transformed.sourceModel - The model containing the localized collection value that will be transformed.goDeeperOrSerialize - The function that will be used to transform the localized collection value into the expected representation.Supplier. Use get() to retrieve the transformed localized collection value.protected boolean attributeContainsCmsComponents(AttributeDescriptorModel attributeDescriptorModel)
attributeDescriptorModel - The attribute to analyze.protected java.util.function.Function<java.lang.Object,java.lang.Object> getCmsComponentRenderingDataTransformationFunction()
protected java.util.function.Function<java.lang.Object,java.lang.Object> getElementToRenderingDataTransformationFunction(AttributeDescriptorModel attributeDescriptorModel, java.util.function.Function<java.lang.Object,java.lang.Object> defaultTransformationFunction)
attributeDescriptorModel - The model that describes the attribute whose element(s) will be transformed with the provided
transformation function.defaultTransformationFunction - The default function used to transform element(s) in the provided attribute.protected boolean isElementEligibleForRendering(AttributeDescriptorModel attributeDescriptorModel, java.lang.Object element)
attributeDescriptorModel - The model describing the attribute to analyze.element - The item to analyze.protected <T> T getAttributeValue(AttributeDescriptorModel attribute, ItemModel sourceModel)
T - The type of the returned value.attribute - The attribute to retrieve from the modelsourceModel - The model where to retrieve the value from.protected ModelService getModelService()
public void setModelService(ModelService modelService)
protected AttributeContainsCMSComponentsPredicate getAttributeContainsCMSComponentsPredicate()
public void setAttributeContainsCMSComponentsPredicate(AttributeContainsCMSComponentsPredicate attributeContainsCMSComponentsPredicate)
protected Converter<AbstractCMSComponentModel,java.lang.String> getSimpleCmsComponentAttributeConverter()
public void setSimpleCmsComponentAttributeConverter(Converter<AbstractCMSComponentModel,java.lang.String> simpleCmsComponentAttributeConverter)
protected AttributeValueToRepresentationConverter<java.util.Collection<java.lang.Object>,java.util.Collection<java.lang.Object>> getCollectionToRepresentationConverter()
public void setCollectionToRepresentationConverter(AttributeValueToRepresentationConverter<java.util.Collection<java.lang.Object>,java.util.Collection<java.lang.Object>> collectionToRepresentationConverter)
protected RenderingVisibilityService getRenderingVisibilityService()
public void setRenderingVisibilityService(RenderingVisibilityService renderingVisibilityService)
protected Converter<AbstractCMSComponentModel,AbstractCMSComponentData> getCmsComponentModelToDataRenderingConverter()
public void setCmsComponentModelToDataRenderingConverter(Converter<AbstractCMSComponentModel,AbstractCMSComponentData> cmsComponentModelToDataRenderingConverter)
Copyright © 2018 SAP SE. All Rights Reserved.