Content Converters
The CMS Item API requires predicates and converters to map an attribute value to its correct representation.
DefaultAttributeContentConverter
The DefaultAttributeContentConverter acts as a dispatcher that returns model-to-data and data-to-model converters based on the result of the constrainedBy predicate.
<alias name="defaultCmsAbstractContentConverter" alias="cmsAbstractContentConverter"/> <bean name="defaultCmsAbstractContentConverter" class="de.hybris.platform.cmsfacades.cmsitems.impl.DefaultAttributeContentConverter"/>
You can use the DefaultAttributeContentConverter to create custom converters as follows:
<alias name="defaultCmsProductContentConverter" alias="cmsProductContentConverter"/> <bean name="defaultCmsProductContentConverter" parent="cmsAbstractContentConverter" p:modelToDataConverter-ref="cmsUniqueIdentifierAttributeToDataContentConverter" p:dataToModelConverter-ref="cmsProductDataToAttributeContentConverter" p:constrainedBy-ref="cmsProductTypeAttributePredicate"> </bean>
Default Predicates
The following table describes the default predicates.
|
Predicate Class |
Abstract |
Description |
|---|---|---|
|
de.hybris.platform.cmsfacades.cmsitems.predicates.CMSItemAttributePredicate |
False |
Identifies if an attribute type can be assigned from a CMSItemModel type. |
|
de.hybris.platform.cmsfacades.cmsitems.predicates.DefaultClassTypeAttributePredicate |
True |
Identifies if an attribute type is of a specified class. <bean name="abstractDefaultClassTypeAttributePredicate" class="de.hybris.platform.cmsfacades.common.predicate.DefaultClassTypeAttributePredicate" abstract="true"> <property name="attributeDescriptorModelHelperService" ref="attributeDescriptorModelHelperService"/> </bean>Can be used to create predicates for custom types: <bean id="cmsProductTypeAttributePredicate" parent="abstractDefaultClassTypeAttributePredicate" p:typeClass="de.hybris.platform.core.model.product.ProductModel"/> |
|
de.hybris.platform.cmsfacades.common.predicate.attributes.NestedOrPartOfAttributePredicate |
False |
Identifies if an attribute type is a part-of or nested attribute. |
Spring Configuration
The CMS Item API declares its predicate Spring beans in the cmsfacades-attribute-predicate-spring.xml and cmsfacades-predicate-spring.xml files.
Default Model to Data Converters
The following table describes the default Mode to Data converters.
|
Model to Data Converters |
Description |
|---|---|
|
de.hybris.platform.cmsfacades.cmsitems.attributeconverters.DateAttributeToDataContentConverter |
Converts the Date value to its proper String format using UTC time zone. Date Time Format: yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ <alias name="defaultCmsDateAttributeToDataContentConverter" alias="cmsDateAttributeToDataContentConverter"/> <bean id="defaultCmsDateAttributeToDataContentConverter" class="de.hybris.platform.cmsfacades.cmsitems.attributeconverters.DateAttributeToDataContentConverter"/> |
|
de.hybris.platform.cmsfacades.cmsitems.attributeconverters.DefaultAttributeToDataContentConverter |
Converts an attribute's value to its string value using the java.lang.Object#toString() method. <alias name="defaultCmsDefaultAttributeToDataContentConverter" alias="cmsDefaultAttributeToDataContentConverter"/> <bean name="defaultCmsDefaultAttributeToDataContentConverter" class="de.hybris.platform.cmsfacades.cmsitems.attributeconverters.DefaultAttributeToDataContentConverter"/> Can be used as attribute-to-data converter primarily for primitive data types. For example: <alias name="defaultCmsBooleanContentConverter" alias="cmsBooleanContentConverter"/> <bean name="defaultCmsBooleanContentConverter" parent="cmsAbstractContentConverter" p:modelToDataConverter-ref="cmsDefaultAttributeToDataContentConverter" p:dataToModelConverter-ref="cmsBooleanDataToAttributeContentConverter" p:constrainedBy-ref="cmsBooleanTypeAttributePredicate"> </bean> |
|
de.hybris.platform.cmsfacades.cmsitems.attributeconverters.MediaContainerAttributeToDataContentConverter |
Converts a MediaContainerModel to its Map<String, String> representation. The key on the map is the media format and the value is the Unique Identifier for the media. |
|
de.hybris.platform.cmsfacades.cmsitems.attributeconverters.UniqueIdentifierAttributeToDataContentConverter |
Converts an attribute's value to its unique identifier's string value. For more information, see de.hybris.platform.cmsfacades.uniqueidentifier.UniqueItemIdentifierService. <alias name="defaultCmsUniqueIdentifierAttributeToDataContentConverter" alias="cmsUniqueIdentifierAttributeToDataContentConverter"/> <bean id="defaultCmsUniqueIdentifierAttributeToDataContentConverter" class="de.hybris.platform.cmsfacades.cmsitems.attributeconverters.UniqueIdentifierAttributeToDataContentConverter"> <property name="uniqueItemIdentifierService" ref="cmsUniqueItemIdentifierService" /> </bean> Can be used to create model-to-data converters. For example: <alias name="defaultCmsMediaContentConverter" alias="cmsMediaContentConverter"/> <bean name="defaultCmsMediaContentConverter" parent="cmsAbstractContentConverter" p:modelToDataConverter-ref="cmsUniqueIdentifierAttributeToDataContentConverter" p:dataToModelConverter-ref="cmsMediaDataToAttributeContentConverter" p:constrainedBy-ref="cmsMediaTypeAttributePredicate"> </bean> |
Spring Configuration
The CMS Item API declares its converter Spring beans in the cmsfacades-cmsitems-converters-spring.xml file.
Default Data-to-Model Converters
The following table describes the default Data-to-Model converters.
|
Data-to-Model Converters |
Description |
|---|---|
|
de.hybris.platform.cmsfacades.cmsitems.attributeconverters.DateDataToAttributeContentConverter |
Converts a String value into a Date. The date must use the following format on the UTC time zone. Date Time Format: yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ <alias name="defaultCmsDateDataToAttributeContentConverter" alias="cmsDateDataToAttributeContentConverter"/> <bean id="defaultCmsDateDataToAttributeContentConverter" class="de.hybris.platform.cmsfacades.cmsitems.attributeconverters.DateDataToAttributeContentConverter"/> |
|
de.hybris.platform.cmsfacades.cmsitems.attributeconverters.DefaultDataToAttributeContentConverter |
Converts any String to its primitive type representation. This converter can be used, for example, to convert Long and Float values. <bean id="abstractDefaultCmsDataToAttributeContentConverter" class="de.hybris.platform.cmsfacades.cmsitems.attributeconverters.DefaultDataToAttributeContentConverter" abstract="true"/>
This converter is used as a parent converter for the following converters:
|
|
de.hybris.platform.cmsfacades.cmsitems.attributeconverters.MediaContainerDataToAttributeContentConverter |
Converts a Map<String, String> representation into a MediaContainerModel. |
|
de.hybris.platform.cmsfacades.cmsitems.attributeconverters.UniqueIdentifierDataToAttributeContentConverter |
Converts a unique identifier's string value into an Item Model. For more information, see de.hybris.platform.cmsfacades.uniqueidentifier.UniqueItemIdentifierService. <alias name="defaultCmsUniqueIdentifierDataToAttributeContentConverter" alias="cmsUniqueIdentifierDataToAttributeContentConverter"/> <bean id="defaultCmsUniqueIdentifierDataToAttributeContentConverter" class="de.hybris.platform.cmsfacades.cmsitems.attributeconverters.UniqueIdentifierDataToAttributeContentConverter" abstract="true"> <property name="uniqueItemIdentifierService" ref="cmsUniqueItemIdentifierService" /> </bean> Can be used to create data-to-model converters for custom type models. For example: <alias name="defaultCmsMediaDataToAttributeContentConverter" alias="cmsMediaDataToAttributeContentConverter"/> <bean id="defaultCmsMediaDataToAttributeContentConverter" parent="cmsUniqueIdentifierDataToAttributeContentConverter"> <property name="modelClass" value="de.hybris.platform.core.model.media.MediaModel" /> </bean> |
|
de.hybris.platform.acceleratorfacades.cmsitems.attributeconverters.CloneComponentMediaContainerDataToAttributeContentConverter |
Converts and executes cloning logic on MediaContainers, such as the MediaContainer in the SimpleResponsiveBannerComponent. <alias name="defaultCmsCloneComponentMediaContainerDataToAttributeContentConverter"
alias="cmsCloneComponentMediaContainerDataToAttributeContentConverter"/>
<bean id="defaultCmsCloneComponentMediaContainerDataToAttributeContentConverter"
class="de.hybris.platform.acceleratorfacades.cmsitems.attributeconverters.CloneComponentMediaContainerDataToAttributeContentConverter"
parent="cmsMediaContainerDataToAttributeContentConverter">
<property name="cloneComponentContextProvider" ref="cmsCloneComponentContextProvider" />
<property name="modelService" ref="modelService" />
</bean>
|
Spring Configuration
The CMS Item API declares its converter Spring beans in the cmsfacades-cmsitems-converters-spring.xml file.