Data Filtering in personalizationservices Extension

Handling data filtering in the personalizationservices Extension.

DAO Strategy Approach

The personalizationservices extension provides the DAO and services for accessing the following data model items used in personalization:
  • CxCustomization
  • CxVariation
  • CxAbstractAction
  • CxActionResult
  • CxCustomizationGroup
  • CxPersonalizationBusinessProcess
  • CxSegment
  • CxTrigger
  • CxUserToSegment
The services and DAO provide a way of getting all objects or just a single object with a given ID. It also ensures the possibility to call different flexible search queries based on the parameters sent to the DAO. This allows to perform filtering of the data directly in the database instead of on the returned models. The following classes/interfaces play a part in this feature:
  • The de.hybris.platform.personalizationservices.dao.impl.AbstractCxDao class exposes an overloaded queryList method which may override a default query with the one provided by one of available strategies (CxDaoStrategy).
  • The de.hybris.platform.personalizationservices.dao.CxDaoStrategy is an interface which provides the information on the extra parameters required to produce different query. It is also able to produce such query if needed.
  • The de.hybris.platform.personalizationservices.dao.CxDaoQueryBuilder interface and its default implementation DefaultCxDaoQueryBuilder are responsible for building a FlexibleSearchQuery from a default query and additional strategies implementing CxDaoStrategy.
  • The de.hybris.platform.personalizationservices.dao.CxDaoStrategySelector interface and its default implementation DefaultCxDaoStrategySelector are responsible for selecting the best CxDaoStrategy instance to use based on a list of strategies and a list parameters.
These parameters will be passed down to the different layers of the application (facade, service, DAO) and will be used by the DefaultCxCustomizationDAO. This DAO provides a default query that lists all the customization in the system (GET /customizations) but also a list of additional strategies that may be called instead of the default query based on the input parameters:
  • CxCustomizationCodeDaoStrategy which will be used of the customization code is passed as a parameter: GET /customizations?code=somecode
  • CxCustomizationNameStatusesDaoStrategy which will filter the data based on name and status: GET /customizations?name=somename&status=ENABLED

For further examples, see Data Filtering for Customizations Displayed per Page.

An example of such data filtering would be /customizations endpoint from the CustomizationsController. This endpoint can be called with or without parameters.
GET /customizations
GET /customizations?code=somecode
GET /customizations?name=somename&status=ENABLED

DAO Type Approach

Unlike the DAO strategy approach, which allows to define multiple dedicated queries, the DAO type approach allows defining a class that supports a given type. This approach is supported only by de.hybris.platform.personalizationservices.action.impl.DefaultCxActionService, with the use of de.hybris.platform.personalizationservices.action.dao.CxActionTypeDao.

The ]DefaultCxActionService collects all beans that implement the CxActionTypeDao from the spring context and selects one of them using the CxActionType as a key to perform search. Currently, the CxCmsActionTypeDao supporting CxActionType.CXCMSACTION is the only implementation of this mechanism.