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 ofCustomerModelmodels and fetches relatedAddressModeland 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.StringCUSTOMER_QUERYSelect customer by PK.protected static java.lang.StringCUSTOMERS_ADDRESSES_QUERYSelect addresses what belong to given customer.protected static java.lang.StringOWNING_CUSTOMER_QUERYSelect customer model that owns given address.protected static java.lang.StringPRIMARY_KEY_PARAM_NAMEName of primary key param in all queries.protected static java.lang.StringVERSION_MARKER_QUERYSelect version marker.
-
Constructor Summary
Constructors Constructor Description DefaultC4CAggregatingCollector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancollect(ItemChangeDTO itemChangeDTO)Collects the given change in a specified way.protected voidcollectAddressesOf(ItemChangeDTO customer)Fetches addresses owned by the customer.protected voidfetchAllDependenciesOf(ItemChangeDTO itemChangeDTO)For customer pulls in all dependent addresses.voidfinish()This implementation does not finalizes the subsequent collectors.C4CBatchingCollectorgetAddressCollector()protected java.lang.StringgetAddressConfigurationId()protected ChangeTypegetChangeTypeOf(java.lang.Long pk, java.lang.String streamId)protected CustomerModelgetCustomer(long customerPk)Looks for a customer based on its PK.C4CBatchingCollectorgetCustomerCollector()protected java.lang.StringgetCustomerConfigurationId()protected ItemVersionMarkerModelgetVersionMarkerForItem(java.lang.Long pk, java.lang.String streamId)voidsetAddressCollector(C4CBatchingCollector addressCollector)voidsetAddressConfigurationId(java.lang.String id)voidsetChangeDetectionService(ChangeDetectionService changeDetectionService)voidsetCustomerCollector(C4CBatchingCollector customerCollector)voidsetCustomerConfigurationId(java.lang.String id)voidsetFlexibleSearchService(FlexibleSearchService flexibleSearchService)voidsetTypeService(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:ChangesCollectorCollects the given change in a specified way.- Specified by:
collectin interfaceChangesCollector- Parameters:
itemChangeDTO- change to be collected- Returns:
true, if the collecting process should continue,falseotherwise
-
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:
finishin interfaceChangesCollector
-
setCustomerConfigurationId
public void setCustomerConfigurationId(@Nonnull java.lang.String id)- Specified by:
setCustomerConfigurationIdin interfaceC4CAggregatingCollector- Parameters:
id- stream configuration id for customers.
-
setAddressConfigurationId
public void setAddressConfigurationId(@Nonnull java.lang.String id)- Specified by:
setAddressConfigurationIdin 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:
setCustomerCollectorin interfaceC4CAggregatingCollector- Parameters:
customerCollector- Collector that will take care of customers.
-
getAddressCollector
public C4CBatchingCollector getAddressCollector()
-
setAddressCollector
public void setAddressCollector(C4CBatchingCollector addressCollector)
- Specified by:
setAddressCollectorin interfaceC4CAggregatingCollector- Parameters:
addressCollector- Collector that will take care of addresses.
-
-