Class DefaultC4CAggregatingCollector
- java.lang.Object
-
- de.hybris.platform.c4ccustomer.deltadetection.impl.DefaultC4CAggregatingCollector
-
- All Implemented Interfaces:
ChangesCollector
,C4CAggregatingCollector
public class DefaultC4CAggregatingCollector extends java.lang.Object implements C4CAggregatingCollector
Collector that grabs changes ofCustomerModel
models and fetches relatedAddressModel
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 Summary
Fields Modifier and Type Field Description protected static java.lang.String
CUSTOMER_QUERY
Select customer by PK.protected static java.lang.String
CUSTOMERS_ADDRESSES_QUERY
Select addresses what belong to given customer.protected static java.lang.String
OWNING_CUSTOMER_QUERY
Select customer model that owns given address.protected static java.lang.String
PRIMARY_KEY_PARAM_NAME
Name of primary key param in all queries.protected static java.lang.String
VERSION_MARKER_QUERY
Select version marker.
-
Constructor Summary
Constructors Constructor Description DefaultC4CAggregatingCollector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
collect(ItemChangeDTO itemChangeDTO)
Collects the given change in a specified way.protected void
collectAddressesOf(ItemChangeDTO customer)
Fetches addresses owned by the customer.protected void
fetchAllDependenciesOf(ItemChangeDTO itemChangeDTO)
For customer pulls in all dependent addresses.void
finish()
This implementation does not finalizes the subsequent collectors.C4CBatchingCollector
getAddressCollector()
protected java.lang.String
getAddressConfigurationId()
protected ChangeType
getChangeTypeOf(java.lang.Long pk, java.lang.String streamId)
protected CustomerModel
getCustomer(long customerPk)
Looks for a customer based on its PK.C4CBatchingCollector
getCustomerCollector()
protected java.lang.String
getCustomerConfigurationId()
protected ItemVersionMarkerModel
getVersionMarkerForItem(java.lang.Long pk, java.lang.String streamId)
void
setAddressCollector(C4CBatchingCollector addressCollector)
void
setAddressConfigurationId(java.lang.String id)
void
setChangeDetectionService(ChangeDetectionService changeDetectionService)
void
setCustomerCollector(C4CBatchingCollector customerCollector)
void
setCustomerConfigurationId(java.lang.String id)
void
setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
void
setTypeService(TypeService typeService)
-
-
-
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
-
-
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 interfaceChangesCollector
- 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 interfaceChangesCollector
-
setCustomerConfigurationId
public void setCustomerConfigurationId(@Nonnull java.lang.String id)
- Specified by:
setCustomerConfigurationId
in interfaceC4CAggregatingCollector
- Parameters:
id
- stream configuration id for customers.
-
setAddressConfigurationId
public void setAddressConfigurationId(@Nonnull java.lang.String id)
- Specified by:
setAddressConfigurationId
in interfaceC4CAggregatingCollector
- Parameters:
id
- stream configuration id for addresses.
-
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 aCustomerModel
-
getChangeTypeOf
protected ChangeType getChangeTypeOf(java.lang.Long pk, java.lang.String streamId)
-
getVersionMarkerForItem
protected ItemVersionMarkerModel getVersionMarkerForItem(java.lang.Long pk, java.lang.String streamId)
-
getCustomer
protected CustomerModel getCustomer(long customerPk) throws ModelNotFoundException
Looks for a customer based on its PK.- Parameters:
customerPk
- primary key of customer model- Throws:
ModelNotFoundException
- if the customer does not exist
-
getCustomerConfigurationId
protected java.lang.String getCustomerConfigurationId()
- Returns:
- customer configuration id.
-
getAddressConfigurationId
protected java.lang.String getAddressConfigurationId()
- Returns:
- address configuration id.
-
getCustomerCollector
public C4CBatchingCollector getCustomerCollector()
-
setCustomerCollector
public void setCustomerCollector(C4CBatchingCollector customerCollector)
- Specified by:
setCustomerCollector
in interfaceC4CAggregatingCollector
- Parameters:
customerCollector
- Collector that will take care of customers.
-
getAddressCollector
public C4CBatchingCollector getAddressCollector()
-
setAddressCollector
public void setAddressCollector(C4CBatchingCollector addressCollector)
- Specified by:
setAddressCollector
in interfaceC4CAggregatingCollector
- Parameters:
addressCollector
- Collector that will take care of addresses.
-
-