Class C4CSyncJobPerformable
- java.lang.Object
-
- de.hybris.platform.servicelayer.cronjob.AbstractJobPerformable<Y2YSyncCronJobModel>
-
- de.hybris.platform.c4ccustomer.job.C4CSyncJobPerformable
-
- All Implemented Interfaces:
JobPerformable<Y2YSyncCronJobModel>
public abstract class C4CSyncJobPerformable extends AbstractJobPerformable<Y2YSyncCronJobModel>
C4C synchronization cron job.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringCOLUMNS_DELIMITER-
Fields inherited from class de.hybris.platform.servicelayer.cronjob.AbstractJobPerformable
flexibleSearchService, modelService, sessionService
-
-
Constructor Summary
Constructors Constructor Description C4CSyncJobPerformable()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected TypeChangesDataaddTypeChangesDataForConfig(java.util.Map<java.lang.String,TypeChangesData> containers, Y2YStreamConfigurationModel y2YStreamConfigurationModel, BatchingCollector collector)Create entry ofTypeChangesDatacorresponding to the configuration.protected voidassignStreamIds(C4CAggregatingCollector collector, java.util.Set<StreamConfigurationModel> configurations)Assign stream ids to corresponding collectors.protected voidcreateAllTasksInTx(java.lang.String syncExecutionId, java.util.List<MediasForType> allMedia, Y2YSyncType syncType)Run prepared synchronization tasks.protected voidfillParameters(java.util.Map<java.lang.String,java.lang.Object> globalQueryParameters, CatalogVersionModel catalogVersion)Collect parameters.protected java.util.Set<StreamConfigurationModel>getActiveConfigurations(Y2YStreamConfigurationContainerModel container)All active configurations of given container.protected abstract C4CAggregatingCollectorgetAggregatingCollector()Get collector that joins customers and addresses.protected intgetBatchSize()protected ChangeDetectionServicegetChangeDetectionService()protected java.util.Map<java.lang.String,TypeChangesData>getChangesDataMap(java.lang.String syncExecutionId, java.util.Map<java.lang.String,java.lang.Object> globalQueryParameters, java.util.Set<StreamConfigurationModel> configurations)Collect changes, store them on media.protected MediaServicegetMediaService()protected C4CBatchingCollectorgetSplittingCollector(java.lang.String syncExecutionId, java.lang.String collectorId)Get collector that splits change list into chunks.protected SyncTaskFactorygetSyncTaskFactory()protected TypeServicegetTypeService()protected booleanisChangesDetected(java.util.List<MediasForType> allMedias)protected java.lang.Stringjoin(Y2YStreamConfigurationModel y2yStreamConfiguration, java.util.function.Function<Y2YColumnDefinitionModel,java.lang.String> mapper)Create semicolon-delimited list of columns from configuration.PerformResultperform(Y2YSyncCronJobModel cronJob)The execution body for aServicelayerJob.voidsetBatchSize(int value)voidsetChangeDetectionService(ChangeDetectionService changeDetectionService)voidsetMediaService(MediaService mediaService)voidsetSyncTaskFactory(SyncTaskFactory syncTaskFactory)voidsetTypeService(TypeService typeService)protected StreamConfigurationtoStreamConfiguration(java.util.Map<java.lang.String,java.lang.Object> globalQueryParameters, Y2YStreamConfigurationModel y2YStreamConfigurationModel)Merge parameters with stream configuration.-
Methods inherited from class de.hybris.platform.servicelayer.cronjob.AbstractJobPerformable
clearAbortRequestedIfNeeded, isAbortable, isPerformable, setFlexibleSearchService, setModelService, setSessionService
-
-
-
-
Field Detail
-
COLUMNS_DELIMITER
protected static final java.lang.String COLUMNS_DELIMITER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAggregatingCollector
protected abstract C4CAggregatingCollector getAggregatingCollector()
Get collector that joins customers and addresses.- Returns:
- collector
-
getSplittingCollector
protected C4CBatchingCollector getSplittingCollector(java.lang.String syncExecutionId, java.lang.String collectorId)
Get collector that splits change list into chunks.- Returns:
- constructed collector
-
perform
public PerformResult perform(Y2YSyncCronJobModel cronJob)
Description copied from interface:JobPerformableThe execution body for aServicelayerJob. Implement here your execution logic. It can be called synchronous or asynchronous. So be aware of thread-safety. Method will return a result object saying if the execution has reached end and if it was successful.- Specified by:
performin interfaceJobPerformable<Y2YSyncCronJobModel>- Specified by:
performin classAbstractJobPerformable<Y2YSyncCronJobModel>- Parameters:
cronJob- the related CronJob in whose context the execution will be performed.- Returns:
- a
PerformResultthat indicates whether theexecutionwas successfully executed or not and has finished or not.
-
getChangesDataMap
protected java.util.Map<java.lang.String,TypeChangesData> getChangesDataMap(java.lang.String syncExecutionId, java.util.Map<java.lang.String,java.lang.Object> globalQueryParameters, java.util.Set<StreamConfigurationModel> configurations)
Collect changes, store them on media.- Parameters:
syncExecutionId- unique synchronization session idglobalQueryParameters- synchronization settingsconfigurations- what to synchronize- Returns:
- changes grouped by item type
-
assignStreamIds
protected void assignStreamIds(C4CAggregatingCollector collector, java.util.Set<StreamConfigurationModel> configurations)
Assign stream ids to corresponding collectors.Needed for further call of
consumeChanges.- Parameters:
collector- aggregating collector, having separate sub-collectors for customers and for addresses.configurations- synchronization configurations
-
addTypeChangesDataForConfig
protected TypeChangesData addTypeChangesDataForConfig(java.util.Map<java.lang.String,TypeChangesData> containers, Y2YStreamConfigurationModel y2YStreamConfigurationModel, BatchingCollector collector)
Create entry ofTypeChangesDatacorresponding to the configuration.- Parameters:
containers- receiver of the entriesy2YStreamConfigurationModel- configuration details
-
join
protected java.lang.String join(Y2YStreamConfigurationModel y2yStreamConfiguration, java.util.function.Function<Y2YColumnDefinitionModel,java.lang.String> mapper)
Create semicolon-delimited list of columns from configuration.- Parameters:
y2yStreamConfiguration- configurationmapper- how to process each column definition- Returns:
- resulting list
-
getActiveConfigurations
protected java.util.Set<StreamConfigurationModel> getActiveConfigurations(Y2YStreamConfigurationContainerModel container)
All active configurations of given container.- Parameters:
container- configuration container- Returns:
- subsequent configurations
-
createAllTasksInTx
protected void createAllTasksInTx(java.lang.String syncExecutionId, java.util.List<MediasForType> allMedia, Y2YSyncType syncType)Run prepared synchronization tasks.- Parameters:
syncExecutionId- session idallMedia- data descriptorssyncType- how to synchronize
-
toStreamConfiguration
protected StreamConfiguration toStreamConfiguration(java.util.Map<java.lang.String,java.lang.Object> globalQueryParameters, Y2YStreamConfigurationModel y2YStreamConfigurationModel)
Merge parameters with stream configuration.- Parameters:
globalQueryParameters- global settingsy2YStreamConfigurationModel- stream own settings- Returns:
- merged configuration
-
fillParameters
protected void fillParameters(java.util.Map<java.lang.String,java.lang.Object> globalQueryParameters, CatalogVersionModel catalogVersion)Collect parameters.- Parameters:
globalQueryParameters- global parameterscatalogVersion- optional catalog version
-
isChangesDetected
protected boolean isChangesDetected(java.util.List<MediasForType> allMedias)
-
setChangeDetectionService
public void setChangeDetectionService(ChangeDetectionService changeDetectionService)
-
setMediaService
public void setMediaService(MediaService mediaService)
-
setSyncTaskFactory
public void setSyncTaskFactory(SyncTaskFactory syncTaskFactory)
-
setTypeService
public void setTypeService(TypeService typeService)
-
setBatchSize
public void setBatchSize(int value)
-
getChangeDetectionService
protected ChangeDetectionService getChangeDetectionService()
- Returns:
- change detection service.
-
getMediaService
protected MediaService getMediaService()
- Returns:
- media service.
-
getSyncTaskFactory
protected SyncTaskFactory getSyncTaskFactory()
- Returns:
- synchronization task factory.
-
getTypeService
protected TypeService getTypeService()
- Returns:
- type service.
-
getBatchSize
protected int getBatchSize()
- Returns:
- chunk length.
-
-