Class DefaultC4CAggregatingCollector

java.lang.Object
de.hybris.platform.c4ccustomer.deltadetection.impl.DefaultC4CAggregatingCollector
All Implemented Interfaces:
de.hybris.deltadetection.ChangesCollector, C4CAggregatingCollector

public class DefaultC4CAggregatingCollector extends Object implements C4CAggregatingCollector
Collector that grabs changes of CustomerModel models and fetches related AddressModel and vice versa. So, as a result there is a set of changed customers with all addresses belonging to each. 'Changed' here stands for 'something has changed in customer fields or any of the addresses related'.

Deleted customers are skipped, because C4C does not implement customer removal yet.

  • Field Details

    • PRIMARY_KEY_PARAM_NAME

      protected static final String PRIMARY_KEY_PARAM_NAME
      Name of primary key param in all queries.
      See Also:
    • OWNING_CUSTOMER_QUERY

      protected static final String OWNING_CUSTOMER_QUERY
      Select customer model that owns given address.
      See Also:
    • CUSTOMERS_ADDRESSES_QUERY

      protected static final String CUSTOMERS_ADDRESSES_QUERY
      Select addresses what belong to given customer.
      See Also:
    • CUSTOMER_QUERY

      protected static final String CUSTOMER_QUERY
      Select customer by PK.
      See Also:
    • VERSION_MARKER_QUERY

      protected static final String VERSION_MARKER_QUERY
      Select version marker.
      See Also:
  • Constructor Details

    • DefaultC4CAggregatingCollector

      public DefaultC4CAggregatingCollector()
  • Method Details

    • collect

      public boolean collect(de.hybris.deltadetection.ItemChangeDTO itemChangeDTO)
      Specified by:
      collect in interface de.hybris.deltadetection.ChangesCollector
    • finish

      public void finish()
      This implementation does not finalizes the subsequent collectors. It has to be done manually outside of the class scope.

      The only reason is the collector is used multiple times (for customers and for addresses), so finalizing batching collectors in between would produce smaller chunks.

      Specified by:
      finish in interface de.hybris.deltadetection.ChangesCollector
    • setCustomerConfigurationId

      public void setCustomerConfigurationId(@Nonnull String id)
      Specified by:
      setCustomerConfigurationId in interface C4CAggregatingCollector
      Parameters:
      id - stream configuration id for customers.
    • setAddressConfigurationId

      public void setAddressConfigurationId(@Nonnull String id)
      Specified by:
      setAddressConfigurationId in interface C4CAggregatingCollector
      Parameters:
      id - stream configuration id for addresses.
    • setFlexibleSearchService

      public void setFlexibleSearchService(de.hybris.platform.servicelayer.search.FlexibleSearchService flexibleSearchService)
    • setChangeDetectionService

      public void setChangeDetectionService(de.hybris.deltadetection.ChangeDetectionService changeDetectionService)
    • setTypeService

      public void setTypeService(de.hybris.platform.servicelayer.type.TypeService typeService)
    • fetchAllDependenciesOf

      protected void fetchAllDependenciesOf(@Nonnull de.hybris.deltadetection.ItemChangeDTO itemChangeDTO)
      For customer pulls in all dependent addresses. For address fetches it's owner customer and all the addresses of the customer.
      Parameters:
      itemChangeDTO - changed item
    • collectAddressesOf

      protected void collectAddressesOf(de.hybris.deltadetection.ItemChangeDTO customer)
      Fetches addresses owned by the customer.
      Parameters:
      customer - change of a CustomerModel
    • getChangeTypeOf

      protected ChangeType getChangeTypeOf(Long pk, String streamId)
    • getVersionMarkerForItem

      protected ItemVersionMarkerModel getVersionMarkerForItem(Long pk, String streamId)
    • getCustomer

      protected CustomerModel getCustomer(long customerPk) throws de.hybris.platform.servicelayer.exceptions.ModelNotFoundException
      Looks for a customer based on its PK.
      Parameters:
      customerPk - primary key of customer model
      Throws:
      de.hybris.platform.servicelayer.exceptions.ModelNotFoundException - if the customer does not exist
    • getCustomerConfigurationId

      protected String getCustomerConfigurationId()
      Returns:
      customer configuration id.
    • getAddressConfigurationId

      protected String getAddressConfigurationId()
      Returns:
      address configuration id.
    • getCustomerCollector

      public C4CBatchingCollector getCustomerCollector()
    • setCustomerCollector

      public void setCustomerCollector(C4CBatchingCollector customerCollector)
      Specified by:
      setCustomerCollector in interface C4CAggregatingCollector
      Parameters:
      customerCollector - Collector that will take care of customers.
    • getAddressCollector

      public C4CBatchingCollector getAddressCollector()
    • setAddressCollector

      public void setAddressCollector(C4CBatchingCollector addressCollector)
      Specified by:
      setAddressCollector in interface C4CAggregatingCollector
      Parameters:
      addressCollector - Collector that will take care of addresses.