Class DefaultC4CAggregatingCollector

  • All Implemented Interfaces:
    ChangesCollector, C4CAggregatingCollector

    public class DefaultC4CAggregatingCollector
    extends java.lang.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 Detail

      • PRIMARY_KEY_PARAM_NAME

        protected static final java.lang.String PRIMARY_KEY_PARAM_NAME
        Name of primary key param in all queries.
        See Also:
        Constant Field Values
      • OWNING_CUSTOMER_QUERY

        protected static final java.lang.String OWNING_CUSTOMER_QUERY
        Select customer model that owns given address.
        See Also:
        Constant Field Values
      • CUSTOMERS_ADDRESSES_QUERY

        protected static final java.lang.String CUSTOMERS_ADDRESSES_QUERY
        Select addresses what belong to given customer.
        See Also:
        Constant Field Values
      • CUSTOMER_QUERY

        protected static final java.lang.String CUSTOMER_QUERY
        Select customer by PK.
        See Also:
        Constant Field Values
      • VERSION_MARKER_QUERY

        protected static final java.lang.String VERSION_MARKER_QUERY
        Select version marker.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultC4CAggregatingCollector

        public DefaultC4CAggregatingCollector()
    • Method Detail

      • collect

        public boolean collect​(ItemChangeDTO itemChangeDTO)
        Description copied from interface: ChangesCollector
        Collects the given change in a specified way.
        Specified by:
        collect in interface ChangesCollector
        Parameters:
        itemChangeDTO - change to be collected
        Returns:
        true, if the collecting process should continue, false otherwise
      • 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 ChangesCollector
      • setFlexibleSearchService

        public void setFlexibleSearchService​(FlexibleSearchService flexibleSearchService)
      • setChangeDetectionService

        public void setChangeDetectionService​(ChangeDetectionService changeDetectionService)
      • setTypeService

        public void setTypeService​(TypeService typeService)
      • fetchAllDependenciesOf

        protected void fetchAllDependenciesOf​(@Nonnull
                                              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​(ItemChangeDTO customer)
        Fetches addresses owned by the customer.
        Parameters:
        customer - change of a CustomerModel
      • getChangeTypeOf

        protected ChangeType getChangeTypeOf​(java.lang.Long pk,
                                             java.lang.String streamId)
      • getVersionMarkerForItem

        protected ItemVersionMarkerModel getVersionMarkerForItem​(java.lang.Long pk,
                                                                 java.lang.String streamId)
      • getCustomerConfigurationId

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

        protected java.lang.String getAddressConfigurationId()
        Returns:
        address configuration id.