Class DefaultCatalogSynchronizationService
- java.lang.Object
-
- de.hybris.platform.catalog.synchronization.DefaultCatalogSynchronizationService
-
- All Implemented Interfaces:
CatalogSynchronizationService
public class DefaultCatalogSynchronizationService extends java.lang.Object implements CatalogSynchronizationService
-
-
Constructor Summary
Constructors Constructor Description DefaultCatalogSynchronizationService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddScheduleFromConfig(SyncItemCronJobModel cronJob, SyncConfig config)booleancanSynchronize(SyncItemJobModel syncJob, PrincipalModel principal)Returns true if the principal has sync permissions to synchronize between catalog versions from given sync job.protected SyncConfigcloneSyncConfig(SyncConfig givenSyncConfig)protected SyncItemCronJobModelcreateSyncCronJob(SyncItemJobModel job)protected CatalogVersionSyncJobModelcreateSyncJob(CatalogVersionModel source, CatalogVersionModel target)protected CatalogVersionSyncJobModelcreateSyncJob(CatalogVersionModel source, CatalogVersionModel target, int numberOfThreads)java.util.List<ItemModel>getApplicableItems(java.util.List<ItemModel> inputItems, SyncItemJobModel syncItemJob)Filters given items returning only the ones being applicable to the given sync job.protected java.lang.IntegergetMaxThreads()ItemModelgetSynchronizationSourceFor(SyncItemJobModel theSyncJob, ItemModel targetItem)Returns the counterpart for thetargetitem against given sync jobtheSyncJob.ItemSyncTimestampModelgetSynchronizationSourceTimestampFor(SyncItemJobModel theSyncJob, ItemModel source)Returns the existingItemSyncTimestampModelfor thesourceitem in the scope of the given sync job.ItemModelgetSynchronizationTargetFor(SyncItemJobModel theSyncJob, ItemModel sourceItem)Returns the counterpart for thesourceitem against given sync jobtheSyncJob.ItemSyncTimestampModelgetSynchronizationTargetTimestampFor(SyncItemJobModel theSyncJob, ItemModel target)Returns the existingItemSyncTimestampModelfor the target item in the scope of the given sync job.SyncItemJobModelgetSyncJob(CatalogVersionModel source, CatalogVersionModel target, java.lang.String qualifier)Returns the publication rule (asSyncItemJobModelitem) between a specified source catalog version and target catalog version.booleanisInProgress(SyncItemJobModel theSyncJob)Checks whether the givengivenSyncJobis currently in progress.java.util.Collection<SyncResult>lookupCurrentSynchronizations(SyncItemJobModel theSyncJob)Returns the current executions for the giventheSyncJob.SyncResultperformSynchronization(java.util.List<ItemModel> givenItems, SyncItemJobModel syncItemJob, SyncConfig syncConfig)Performs the synchronization for given items.java.util.List<SyncResult>performSynchronization(java.util.List<ItemModel> givenItems, java.util.List<SyncItemJobModel> syncItemJobs, SyncConfig syncConfig)Performs the synchronization for given items against given sync jobs.protected SyncConfigscheduleItemsWithConfig(SyncConfig syncConfig, SyncItemJobModel syncJob, java.util.List<ItemModel> applicableItems)voidsetCatalogTypeService(CatalogTypeService catalogTypeService)voidsetCatalogVersionService(CatalogVersionService catalogVersionService)voidsetCronJobService(CronJobService cronJobService)voidsetFlexibleSearchService(FlexibleSearchService flexibleSearchService)voidsetItemSyncTimestampDao(ItemSyncTimestampDao itemSyncTimestampDao)voidsetModelService(ModelService modelService)voidsetSyncJobApplicableTypesStrategy(SyncJobApplicableTypesStrategy syncJobApplicableTypesStrategy)voidsetUserService(UserService userService)SyncResultsynchronize(SyncItemJobModel syncJob, SyncConfig syncConfig)Starts synchronization for an existingSyncItemJobModel.voidsynchronizeFully(CatalogVersionModel source, CatalogVersionModel target)For the given catalog version pair a newCatalogVersionSyncJobModelis being created configured to sync all default catalog item types.voidsynchronizeFully(CatalogVersionModel source, CatalogVersionModel target, int numberOfThreads)For the given catalog version pair a newCatalogVersionSyncJobModelis being created configured to sync all default catalog item types.voidsynchronizeFullyInBackground(CatalogVersionModel source, CatalogVersionModel target)For the given catalog version pair a newCatalogVersionSyncJobModelis being created configured to sync all default catalog item types.
-
-
-
Method Detail
-
synchronizeFully
public void synchronizeFully(CatalogVersionModel source, CatalogVersionModel target)
Description copied from interface:CatalogSynchronizationServiceFor the given catalog version pair a newCatalogVersionSyncJobModelis being created configured to sync all default catalog item types. The actual sync process is backed by a also newCatalogVersionSyncCronJobModelwhich is performed synchronously.- Specified by:
synchronizeFullyin interfaceCatalogSynchronizationService
-
synchronizeFully
public void synchronizeFully(CatalogVersionModel source, CatalogVersionModel target, int numberOfThreads)
Description copied from interface:CatalogSynchronizationServiceFor the given catalog version pair a newCatalogVersionSyncJobModelis being created configured to sync all default catalog item types. The actual sync process is backed by a also newCatalogVersionSyncCronJobModelwhich is started synchronously.- Specified by:
synchronizeFullyin interfaceCatalogSynchronizationServicenumberOfThreads- specifies the number of sync workers to be used - overrides the number configured incatalog.sync.workers
-
synchronizeFullyInBackground
public void synchronizeFullyInBackground(CatalogVersionModel source, CatalogVersionModel target)
Description copied from interface:CatalogSynchronizationServiceFor the given catalog version pair a newCatalogVersionSyncJobModelis being created configured to sync all default catalog item types. The actual sync process is backed by a also newCatalogVersionSyncCronJobModelwhich is started asynchronously.- Specified by:
synchronizeFullyInBackgroundin interfaceCatalogSynchronizationService
-
synchronize
public SyncResult synchronize(SyncItemJobModel syncJob, SyncConfig syncConfig)
Description copied from interface:CatalogSynchronizationServiceStarts synchronization for an existingSyncItemJobModel. The configuration parameter allows to configure/override a number of synchronization job settings.The returned
SyncResultgives both access to the execution result or, in case the process was started asynchronously, to observe the running process- Specified by:
synchronizein interfaceCatalogSynchronizationService
-
performSynchronization
public java.util.List<SyncResult> performSynchronization(java.util.List<ItemModel> givenItems, java.util.List<SyncItemJobModel> syncItemJobs, SyncConfig syncConfig)
Description copied from interface:CatalogSynchronizationServicePerforms the synchronization for given items against given sync jobs.Note that for each job the list of items is being filtered to schedule only the ones which are actually applicable (being compatible with the job's root type collection).
For influencing the sync behavior a sync config object can be passed, e.g. for controlling the level of multi-threading.
- Specified by:
performSynchronizationin interfaceCatalogSynchronizationService
-
scheduleItemsWithConfig
protected SyncConfig scheduleItemsWithConfig(SyncConfig syncConfig, SyncItemJobModel syncJob, java.util.List<ItemModel> applicableItems)
-
getSyncJob
public SyncItemJobModel getSyncJob(CatalogVersionModel source, CatalogVersionModel target, java.lang.String qualifier)
Description copied from interface:CatalogSynchronizationServiceReturns the publication rule (asSyncItemJobModelitem) between a specified source catalog version and target catalog version.- Specified by:
getSyncJobin interfaceCatalogSynchronizationService
-
performSynchronization
public SyncResult performSynchronization(java.util.List<ItemModel> givenItems, SyncItemJobModel syncItemJob, SyncConfig syncConfig)
Description copied from interface:CatalogSynchronizationServicePerforms the synchronization for given items.Note that the list of items is being filtered to schedule only the ones which are actually applicable (being compatible with the job's root type collection).
For influencing the sync behavior a sync config object can be passed, e.g. for controlling the level of multi-threading.
- Specified by:
performSynchronizationin interfaceCatalogSynchronizationService
-
getApplicableItems
public java.util.List<ItemModel> getApplicableItems(java.util.List<ItemModel> inputItems, SyncItemJobModel syncItemJob)
Description copied from interface:CatalogSynchronizationServiceFilters given items returning only the ones being applicable to the given sync job. Being applicable means whether or not an item is compatible to the job's root type collection and whether it belongs to the specified catalog version.- Specified by:
getApplicableItemsin interfaceCatalogSynchronizationService
-
isInProgress
public boolean isInProgress(SyncItemJobModel theSyncJob)
Description copied from interface:CatalogSynchronizationServiceChecks whether the givengivenSyncJobis currently in progress.- Specified by:
isInProgressin interfaceCatalogSynchronizationService
-
lookupCurrentSynchronizations
public java.util.Collection<SyncResult> lookupCurrentSynchronizations(SyncItemJobModel theSyncJob)
Description copied from interface:CatalogSynchronizationServiceReturns the current executions for the giventheSyncJob.- Specified by:
lookupCurrentSynchronizationsin interfaceCatalogSynchronizationService
-
getSynchronizationSourceTimestampFor
public ItemSyncTimestampModel getSynchronizationSourceTimestampFor(SyncItemJobModel theSyncJob, ItemModel source)
Description copied from interface:CatalogSynchronizationServiceReturns the existingItemSyncTimestampModelfor thesourceitem in the scope of the given sync job. In case of the item never been synchronized before NULL is returned.- Specified by:
getSynchronizationSourceTimestampForin interfaceCatalogSynchronizationService
-
getSynchronizationTargetTimestampFor
public ItemSyncTimestampModel getSynchronizationTargetTimestampFor(SyncItemJobModel theSyncJob, ItemModel target)
Description copied from interface:CatalogSynchronizationServiceReturns the existingItemSyncTimestampModelfor the target item in the scope of the given sync job. In case of the original source item being deleted this methods will return NULL.- Specified by:
getSynchronizationTargetTimestampForin interfaceCatalogSynchronizationService
-
getSynchronizationSourceFor
public ItemModel getSynchronizationSourceFor(SyncItemJobModel theSyncJob, ItemModel targetItem)
Description copied from interface:CatalogSynchronizationServiceReturns the counterpart for thetargetitem against given sync jobtheSyncJob.- Specified by:
getSynchronizationSourceForin interfaceCatalogSynchronizationService
-
getSynchronizationTargetFor
public ItemModel getSynchronizationTargetFor(SyncItemJobModel theSyncJob, ItemModel sourceItem)
Description copied from interface:CatalogSynchronizationServiceReturns the counterpart for thesourceitem against given sync jobtheSyncJob.- Specified by:
getSynchronizationTargetForin interfaceCatalogSynchronizationService
-
canSynchronize
public boolean canSynchronize(SyncItemJobModel syncJob, PrincipalModel principal)
Returns true if the principal has sync permissions to synchronize between catalog versions from given sync job. Returns true if the principal has sync permissions by checking sync job has syncPrincipalsOnly set to true and given principal is part of sync job's syncPrincipals list or by checking write permissions on target catalog.- Specified by:
canSynchronizein interfaceCatalogSynchronizationService- Parameters:
syncJob- the sync jobprincipal- the principal- Returns:
- a boolean
-
addScheduleFromConfig
protected void addScheduleFromConfig(SyncItemCronJobModel cronJob, SyncConfig config)
-
createSyncJob
protected CatalogVersionSyncJobModel createSyncJob(CatalogVersionModel source, CatalogVersionModel target)
-
createSyncJob
protected CatalogVersionSyncJobModel createSyncJob(CatalogVersionModel source, CatalogVersionModel target, int numberOfThreads)
-
createSyncCronJob
protected SyncItemCronJobModel createSyncCronJob(SyncItemJobModel job)
-
cloneSyncConfig
protected SyncConfig cloneSyncConfig(SyncConfig givenSyncConfig)
-
getMaxThreads
protected java.lang.Integer getMaxThreads()
-
setCronJobService
public void setCronJobService(CronJobService cronJobService)
-
setModelService
public void setModelService(ModelService modelService)
-
setItemSyncTimestampDao
public void setItemSyncTimestampDao(ItemSyncTimestampDao itemSyncTimestampDao)
-
setSyncJobApplicableTypesStrategy
public void setSyncJobApplicableTypesStrategy(SyncJobApplicableTypesStrategy syncJobApplicableTypesStrategy)
-
setCatalogTypeService
public void setCatalogTypeService(CatalogTypeService catalogTypeService)
-
setFlexibleSearchService
public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
-
setCatalogVersionService
public void setCatalogVersionService(CatalogVersionService catalogVersionService)
-
setUserService
public void setUserService(UserService userService)
-
-