personalizationfacades Extension
The personalizationfacades extension provides a suite of facades for the Personalization Module functionality. The facade integrates personalization services and exposes a Data Object (POJO) response adjusted to meet the front-end requirements.
Data Objects
The Data Objects are created only to contain values and have no business logic except for the getter and setter methods. They are populated using a subset of the data contained in the SAP Commerce Cloud ServiceLayer Models and are not backed by a persistence layer like the Model objects. The Data Object definition can be found in the personalizationfacades-beans.xml file. They are generated during the build process. For more information about data object generation, see Generating Beans and Enums.
Converters and Populators
|
Type |
Description |
|---|---|
|
populator |
Simple classes that have sole purpose of setting values in target object using the data from the source object. |
|
populatorList |
A grouping object that invokes a few populators in a row and is a populator itself. |
|
converter |
A converter able to create instance of target or use given prototype for conversion, uses list of populators to execute conversion. |
|
configurableConverter |
A custom extension of the converter principle, has an additional option parameter that is used to define which populators should be invoked. |
|
configurableSubtypeConverter |
An extension of the configurableConverter, has additional properties defining what type is converted and for what parent type using dedicated marker. |
|
configurableSubtypeAwareConverter |
An extension of configurableConverter, automatically finds configurableSubtypeConverter with a given marker and uses it for conversion of objects with type hierarchy (Actions or Triggers) |
Subtype Conversion Mechanism
The ActionData is a DTO representing only a base abstract model (CxAbstractActionModel), not a specific implementation. TriggerData works in the same way. In case of using a standard conversion, you get only the base attributes and lose most of the necessary information from the subclasses. The mechanism, which selects a proper converter for a data class allows avoiding such a situation and creating an object with all the needed attributes.
<bean id="defaultCxTriggerConfigurableConverter" parent="cxSubtypeAwareConverter">
<property name="defaultOptions" ><value type="de.hybris.platform.personalizationfacades.enums.TriggerConversionOptions">BASE</value></property>
<property name="markerClass" value="de.hybris.platform.personalizationfacades.trigger.converters.TriggerConverter" />
</bean>
<bean id="defaultCxSegmentTriggerConfigurableConverter" parent="cxSubtypeConverter" >
<constructor-arg name="markerClass" value="de.hybris.platform.personalizationfacades.trigger.converters.TriggerConverter" />
<constructor-arg name="sourceClass" value="de.hybris.platform.personalizationservices.model.CxSegmentTriggerModel" />
<property name="targetClass" value="de.hybris.platform.personalizationfacades.data.SegmentTriggerData" />
<property name="populators">
<map key-type="de.hybris.platform.personalizationfacades.enums.TriggerConversionOptions">
<entry key="BASE" value-ref="cxTriggerPopulators" />
<entry key="FOR_SEGMENT" value-ref="cxSegmentTriggerForSegmentPopulators" />
<entry key="FOR_VARIATION" value-ref="cxSegmentTriggerForVariationPopulators" />
<entry key="FULL" value-ref="cxSegmentTriggerFullPopulators" />
</map>
</property>
</bean>
All configurableSubtypeConverter with the same markerClass as in configurableSubtypeAwareConverter will be used by it. The source and target classes define what is converted into what, which helps configurableSubtypeAwareConverter to define which of available configurableSubtypeConverter should be used in a given conversion.
Facades
-
The SegmentFacade provides the functionality for searching and managing segments.
-
The CustomerSegmentation is an object representing a relation between the customer and segments. The CustomerSegmentationFacade provides the functionality for searching and managing this relation.
-
The CustomizationFacade provides the functionality for searching and managing customizations.
-
The VariationFacade provides the functionality for searching and managing variations.
-
The VariationSegmentation is an object representing relation between the segment and variations. The VariationSegmentationFacade provides the functionality for searching and managing this relation.
-
The ActionFacade provides the functionality for searching and managing actions. It uses the ActionData object not only as response data, but also as a parameter for the create and update method. Thanks to that, you are able to create specific action objects, which extend a standard action, for example the CmsActionData. A special conversion mechanism is used to ensure such functionality - for details, see the Action Conversion Mechanism section above.
-
The TriggerFacade provides functionality for managing Trigger objects. Triggers are used for evaluating what variation should be evaluated for users. By default, the system provides a SegmentTrigger, which links users with variations using segments and ExpressionTrigger, which works on a boolean expression based on segments (if it exists or not).