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 void
addScheduleFromConfig(SyncItemCronJobModel cronJob, SyncConfig config)
boolean
canSynchronize(SyncItemJobModel syncJob, PrincipalModel principal)
Returns true if the principal has sync permissions to synchronize between catalog versions from given sync job.protected SyncConfig
cloneSyncConfig(SyncConfig givenSyncConfig)
protected SyncItemCronJobModel
createSyncCronJob(SyncItemJobModel job)
protected CatalogVersionSyncJobModel
createSyncJob(CatalogVersionModel source, CatalogVersionModel target)
protected CatalogVersionSyncJobModel
createSyncJob(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.Integer
getMaxThreads()
ItemModel
getSynchronizationSourceFor(SyncItemJobModel theSyncJob, ItemModel targetItem)
Returns the counterpart for thetarget
item against given sync jobtheSyncJob
.ItemSyncTimestampModel
getSynchronizationSourceTimestampFor(SyncItemJobModel theSyncJob, ItemModel source)
Returns the existingItemSyncTimestampModel
for thesource
item in the scope of the given sync job.ItemModel
getSynchronizationTargetFor(SyncItemJobModel theSyncJob, ItemModel sourceItem)
Returns the counterpart for thesource
item against given sync jobtheSyncJob
.ItemSyncTimestampModel
getSynchronizationTargetTimestampFor(SyncItemJobModel theSyncJob, ItemModel target)
Returns the existingItemSyncTimestampModel
for the target item in the scope of the given sync job.SyncItemJobModel
getSyncJob(CatalogVersionModel source, CatalogVersionModel target, java.lang.String qualifier)
Returns the publication rule (asSyncItemJobModel
item) between a specified source catalog version and target catalog version.boolean
isInProgress(SyncItemJobModel theSyncJob)
Checks whether the givengivenSyncJob
is currently in progress.java.util.Collection<SyncResult>
lookupCurrentSynchronizations(SyncItemJobModel theSyncJob)
Returns the current executions for the giventheSyncJob
.SyncResult
performSynchronization(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 SyncConfig
scheduleItemsWithConfig(SyncConfig syncConfig, SyncItemJobModel syncJob, java.util.List<ItemModel> applicableItems)
void
setCatalogTypeService(CatalogTypeService catalogTypeService)
void
setCatalogVersionService(CatalogVersionService catalogVersionService)
void
setCronJobService(CronJobService cronJobService)
void
setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
void
setItemSyncTimestampDao(ItemSyncTimestampDao itemSyncTimestampDao)
void
setModelService(ModelService modelService)
void
setSyncJobApplicableTypesStrategy(SyncJobApplicableTypesStrategy syncJobApplicableTypesStrategy)
void
setUserService(UserService userService)
SyncResult
synchronize(SyncItemJobModel syncJob, SyncConfig syncConfig)
Starts synchronization for an existingSyncItemJobModel
.void
synchronizeFully(CatalogVersionModel source, CatalogVersionModel target)
For the given catalog version pair a newCatalogVersionSyncJobModel
is being created configured to sync all default catalog item types.void
synchronizeFully(CatalogVersionModel source, CatalogVersionModel target, int numberOfThreads)
For the given catalog version pair a newCatalogVersionSyncJobModel
is being created configured to sync all default catalog item types.void
synchronizeFullyInBackground(CatalogVersionModel source, CatalogVersionModel target)
For the given catalog version pair a newCatalogVersionSyncJobModel
is being created configured to sync all default catalog item types.
-
-
-
Method Detail
-
synchronizeFully
public void synchronizeFully(CatalogVersionModel source, CatalogVersionModel target)
Description copied from interface:CatalogSynchronizationService
For the given catalog version pair a newCatalogVersionSyncJobModel
is being created configured to sync all default catalog item types. The actual sync process is backed by a also newCatalogVersionSyncCronJobModel
which is performed synchronously.- Specified by:
synchronizeFully
in interfaceCatalogSynchronizationService
-
synchronizeFully
public void synchronizeFully(CatalogVersionModel source, CatalogVersionModel target, int numberOfThreads)
Description copied from interface:CatalogSynchronizationService
For the given catalog version pair a newCatalogVersionSyncJobModel
is being created configured to sync all default catalog item types. The actual sync process is backed by a also newCatalogVersionSyncCronJobModel
which is started synchronously.- Specified by:
synchronizeFully
in interfaceCatalogSynchronizationService
numberOfThreads
- 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:CatalogSynchronizationService
For the given catalog version pair a newCatalogVersionSyncJobModel
is being created configured to sync all default catalog item types. The actual sync process is backed by a also newCatalogVersionSyncCronJobModel
which is started asynchronously.- Specified by:
synchronizeFullyInBackground
in interfaceCatalogSynchronizationService
-
synchronize
public SyncResult synchronize(SyncItemJobModel syncJob, SyncConfig syncConfig)
Description copied from interface:CatalogSynchronizationService
Starts synchronization for an existingSyncItemJobModel
. The configuration parameter allows to configure/override a number of synchronization job settings.The returned
SyncResult
gives both access to the execution result or, in case the process was started asynchronously, to observe the running process- Specified by:
synchronize
in interfaceCatalogSynchronizationService
-
performSynchronization
public java.util.List<SyncResult> performSynchronization(java.util.List<ItemModel> givenItems, java.util.List<SyncItemJobModel> syncItemJobs, SyncConfig syncConfig)
Description copied from interface:CatalogSynchronizationService
Performs 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:
performSynchronization
in 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:CatalogSynchronizationService
Returns the publication rule (asSyncItemJobModel
item) between a specified source catalog version and target catalog version.- Specified by:
getSyncJob
in interfaceCatalogSynchronizationService
-
performSynchronization
public SyncResult performSynchronization(java.util.List<ItemModel> givenItems, SyncItemJobModel syncItemJob, SyncConfig syncConfig)
Description copied from interface:CatalogSynchronizationService
Performs 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:
performSynchronization
in interfaceCatalogSynchronizationService
-
getApplicableItems
public java.util.List<ItemModel> getApplicableItems(java.util.List<ItemModel> inputItems, SyncItemJobModel syncItemJob)
Description copied from interface:CatalogSynchronizationService
Filters 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:
getApplicableItems
in interfaceCatalogSynchronizationService
-
isInProgress
public boolean isInProgress(SyncItemJobModel theSyncJob)
Description copied from interface:CatalogSynchronizationService
Checks whether the givengivenSyncJob
is currently in progress.- Specified by:
isInProgress
in interfaceCatalogSynchronizationService
-
lookupCurrentSynchronizations
public java.util.Collection<SyncResult> lookupCurrentSynchronizations(SyncItemJobModel theSyncJob)
Description copied from interface:CatalogSynchronizationService
Returns the current executions for the giventheSyncJob
.- Specified by:
lookupCurrentSynchronizations
in interfaceCatalogSynchronizationService
-
getSynchronizationSourceTimestampFor
public ItemSyncTimestampModel getSynchronizationSourceTimestampFor(SyncItemJobModel theSyncJob, ItemModel source)
Description copied from interface:CatalogSynchronizationService
Returns the existingItemSyncTimestampModel
for thesource
item in the scope of the given sync job. In case of the item never been synchronized before NULL is returned.- Specified by:
getSynchronizationSourceTimestampFor
in interfaceCatalogSynchronizationService
-
getSynchronizationTargetTimestampFor
public ItemSyncTimestampModel getSynchronizationTargetTimestampFor(SyncItemJobModel theSyncJob, ItemModel target)
Description copied from interface:CatalogSynchronizationService
Returns the existingItemSyncTimestampModel
for 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:
getSynchronizationTargetTimestampFor
in interfaceCatalogSynchronizationService
-
getSynchronizationSourceFor
public ItemModel getSynchronizationSourceFor(SyncItemJobModel theSyncJob, ItemModel targetItem)
Description copied from interface:CatalogSynchronizationService
Returns the counterpart for thetarget
item against given sync jobtheSyncJob
.- Specified by:
getSynchronizationSourceFor
in interfaceCatalogSynchronizationService
-
getSynchronizationTargetFor
public ItemModel getSynchronizationTargetFor(SyncItemJobModel theSyncJob, ItemModel sourceItem)
Description copied from interface:CatalogSynchronizationService
Returns the counterpart for thesource
item against given sync jobtheSyncJob
.- Specified by:
getSynchronizationTargetFor
in 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:
canSynchronize
in 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)
-
-