Class DefaultSAPCDPCustomerService

java.lang.Object
com.sap.sapsegmentationservices.cdp.service.impl.DefaultSAPCDPCustomerService
All Implemented Interfaces:
SAPCDPCustomerService

public class DefaultSAPCDPCustomerService extends Object implements SAPCDPCustomerService
Fetches customer segments associated with the user. If cached segments are available, they are returned; otherwise, segments are fetched from the Customer Data Platform (CDP), updated in the cache, and returned.
  • Constructor Details

    • DefaultSAPCDPCustomerService

      public DefaultSAPCDPCustomerService(de.hybris.platform.integrationservices.cache.IntegrationCache<CDPCustomerSegmentsCacheKey,List<String>> cdpCustomerSegmentsCache)
      Constructs an instance of DefaultSAPCDPCustomerService with the provided IntegrationCache for storing customer segments.
      Parameters:
      cdpCustomerSegmentsCache - An IntegrationCache instance used to store and retrieve customer segments.
  • Method Details

    • fetchSegmentsFromCDP

      public List<String> fetchSegmentsFromCDP(UserModel user)
      Fetches customer segments associated with the user. If cached segments are available, they are returned; otherwise, segments are fetched from the Customer Data Platform (CDP), updated in the cache, and returned.
      Specified by:
      fetchSegmentsFromCDP in interface SAPCDPCustomerService
      Parameters:
      user - The UserModel representing the user for whom segments need to be fetched.
      Returns:
      A list of strings representing the customer segments associated with the user in CDP.
    • callCDPTofetchSegments

      protected List<String> callCDPTofetchSegments(UserModel user)
      Calls the Customer Data Platform (CDP) to fetch customer segments associated with the user.
      Parameters:
      user - The UserModel representing the user for whom segments need to be fetched.
      Returns:
      A list of strings representing the customer segments associated with the user in CDP.
    • extractSegmentsFromResponse

      protected List<String> extractSegmentsFromResponse(String response) throws IOException
      Extracts customer segments from the response obtained from the Customer Data Platform (CDP).
      Parameters:
      response - The String representation of the response obtained from the CDP.
      Returns:
      A list of strings representing the customer segments extracted from the response.
      Throws:
      IOException - If there's an error while processing the response.
    • createKey

      protected CDPCustomerSegmentsCacheKey createKey(UserModel user)
      Creates a cache key based on the user and current base site.
      Parameters:
      user - The UserModel for which the cache key needs to be created.
      Returns:
      A CDPCustomerSegmentsCacheKey representing the cache key for the user and base site.
    • isPersonalizationEnabled

      protected boolean isPersonalizationEnabled()
      Determines whether CDP personalization features are enabled or not.
      Returns:
      true if CDP Segmentation is enabled, false otherwise.
    • getIntegrationRestTemplateFactory

      public de.hybris.platform.outboundservices.client.IntegrationRestTemplateFactory getIntegrationRestTemplateFactory()
      Returns:
      the integrationRestTemplateFactory
    • setIntegrationRestTemplateFactory

      public void setIntegrationRestTemplateFactory(de.hybris.platform.outboundservices.client.IntegrationRestTemplateFactory integrationRestTemplateFactory)
      Parameters:
      integrationRestTemplateFactory - the integrationRestTemplateFactory to set
    • getBaseSiteService

      public de.hybris.platform.site.BaseSiteService getBaseSiteService()
      Returns:
      the baseSiteService
    • setBaseSiteService

      public void setBaseSiteService(de.hybris.platform.site.BaseSiteService baseSiteService)
      Parameters:
      baseSiteService - the baseSiteService to set
    • getSapPersonalizationConsumedDestinationService

      public SAPPersonalizationConsumedDestinationService getSapPersonalizationConsumedDestinationService()
      Returns:
      the sapPersonalizationConsumedDestinationService
    • setSapPersonalizationConsumedDestinationService

      public void setSapPersonalizationConsumedDestinationService(SAPPersonalizationConsumedDestinationService sapPersonalizationConsumedDestinationService)
      Parameters:
      sapPersonalizationConsumedDestinationService - the sapPersonalizationConsumedDestinationService to set
    • getCdpCustomerSegmentsCache

      public de.hybris.platform.integrationservices.cache.IntegrationCache<CDPCustomerSegmentsCacheKey,List<String>> getCdpCustomerSegmentsCache()
      Returns:
      the cdpCustomerSegmentsCache
    • getCxConfigurationService

      public de.hybris.platform.personalizationservices.configuration.CxConfigurationService getCxConfigurationService()
      Returns:
      the cxConfigurationService
    • setCxConfigurationService

      public void setCxConfigurationService(de.hybris.platform.personalizationservices.configuration.CxConfigurationService cxConfigurationService)
      Parameters:
      cxConfigurationService - the cxConfigurationService to set