Class DefaultSynchronizationFacade
java.lang.Object
com.hybris.backoffice.sync.facades.DefaultSynchronizationFacade
- All Implemented Interfaces:
SynchronizationFacade
Default implementation using the
CatalogSynchronizationService. The synchronizations are done asynchronously
using a background process (cron job).-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanSync(SyncItemJobModel sync) Tells whether current user can perform given sync.protected voidcopyCronJobData(CatalogVersionSyncCronJobModel newCronJob, CatalogVersionSyncCronJobModel cronJobForRerun) protected CatalogVersionSyncCronJobModelcopyCronJobSafely(Supplier<CatalogVersionSyncCronJobModel> copySupplier) protected voidcopyScheduledMedia(CatalogVersionSyncCronJobModel newCronJob, CatalogVersionSyncCronJobModel cronJobForRerun) protected CatalogVersionSyncCronJobModelcreateCronJobForRerun(CatalogVersionSyncCronJobModel cronJobForRerun) protected SyncConfigCreates sync config based on project properties and syncJob settings.protected <T> TexecuteInTransaction(Supplier<T> toExecute) executeSync(SyncTask syncTask, BiFunction<SyncItemJobModel, SyncConfig, SyncResult> syncRunner) protected <T> TexecuteWithoutTypeInterceptors(Supplier<T> toExecute) findSyncCounterpart(ItemModel item, SyncItemJobModel syncItemJob) Finds a counterpart of given item in respective catalog version defined by the syncItemJob.protected BooleangetBooleanFromSystemConfig(String property, Boolean defaultValue) getCatalogVersionAwareItems(List<? extends ItemModel> items) Extract catalog version aware itemsCatalogTypeService.isCatalogVersionAwareModel(ItemModel)protected StringgetConfigValue(String property, String defaultValue) protected <T extends Enum>
TgetEnumValueFromSystemConfig(Class<T> enumType, String property, T defaultValue) getInboundSynchronizations(CatalogVersionModel catalogVersion) Gets inbound sync jobs for given catalog version.getItemsCatalogVersions(List<? extends ItemModel> items) Extracts from given list items which are CatalogVersiongetOutboundSynchronizations(CatalogVersionModel catalogVersion) Gets outbound sync jobs for given catalog version.getPartialSyncStatusInfo(ItemModel itemModel, SyncItemStatus status, Map<String, Object> ctxMap) ChecksItemModel's status in all available synchronizations.getSyncCatalogVersion(Collection<ItemModel> items) Returns catalog version for given items if they are from the same catalog version or are CatalogVersion itself.protected List<SyncItemJobModel>getSynchronizations(CatalogVersionModel syncCatalogVersion) protected SyncJobApplicableTypesStrategybooleanisApplicableForItems(SyncItemJobModel jobModel, Collection<ItemModel> items) Checks ifSyncItemJobModelis applicable forItemModelsisInSync(ItemModel syncItem, Collection<SyncItemJobModel> syncJobs) ChecksItemModel's status in all available synchronizations.Checks if allItemModels are sync according to source and target fromSyncItemJobModel.booleanisSyncInProgress(ItemModel item) Tells if given item is being synchronized.matchesSyncStatus(List<ItemModel> syncItems, List<SyncItemJobModel> allJobs, SyncItemStatus inSync) performCatalogSync(SyncTask syncTask) performSynchronization(SyncTask syncTask) Performs synchronization based on given sync task.preformItemsSync(SyncTask syncTask) protected SyncConfigprepareSyncConfig(SyncConfig syncConfig, SyncItemJobModel syncJob) Prepares sync config.voidRuns given sync cron job again omitting items already processed in the previous run.voidsetCatalogSynchronizationService(CatalogSynchronizationService catalogSynchronizationService) voidsetCatalogTypeService(CatalogTypeService catalogTypeService) voidsetCatalogVersionService(CatalogVersionService catalogVersionService) voidsetCronJobService(CronJobService cronJobService) voidsetMediaService(MediaService mediaService) voidsetModelService(ModelService modelService) voidsetRelatedItemsCollector(RelatedItemsCollector relatedItemsCollector) voidsetSessionService(SessionService sessionService) voidsetSynchronizationStatusService(SynchronizationStatusService synchronizationStatusService) voidsetSyncJobApplicableTypesStrategy(SyncJobApplicableTypesStrategy syncJobApplicableTypesStrategy) voidsetUserService(UserService userService)
-
Field Details
-
SYNC_CONFIG_CREATE_SAVED_VALUES
- See Also:
-
SYNC_CONFIG_FORCE_UPDATE
- See Also:
-
SYNC_CONFIG_SYNCHRONOUS
- See Also:
-
SYNC_CONFIG_LOG_TO_FILE
- See Also:
-
SYNC_CONFIG_LOG_TO_DATABASE
- See Also:
-
SYNC_CONFIG_KEEP_CRON_JOB
- See Also:
-
SYNC_CONFIG_LOG_LEVEL_DATABASE
- See Also:
-
SYNC_CONFIG_LOG_LEVEL_FILE
- See Also:
-
SYNC_CONFIG_ERROR_MODE
- See Also:
-
BACKOFFICE_SYNC_CONFIG_ABORT_ON_COLLIDING
- See Also:
-
-
Constructor Details
-
DefaultSynchronizationFacade
public DefaultSynchronizationFacade()
-
-
Method Details
-
performSynchronization
Description copied from interface:SynchronizationFacadePerforms synchronization based on given sync task.- Specified by:
performSynchronizationin interfaceSynchronizationFacade- Parameters:
syncTask- - defines sync jobs and items to sync.- Returns:
- executed sync cron job code
CronJobModel.getCode()if sync has been started.
-
performCatalogSync
-
preformItemsSync
-
executeSync
protected Optional<String> executeSync(SyncTask syncTask, BiFunction<SyncItemJobModel, SyncConfig, SyncResult> syncRunner) -
getItemsCatalogVersions
Description copied from interface:SynchronizationFacadeExtracts from given list items which are CatalogVersion- Specified by:
getItemsCatalogVersionsin interfaceSynchronizationFacade- Parameters:
items- list of items- Returns:
- list of catalog version items
-
getCatalogVersionAwareItems
Description copied from interface:SynchronizationFacadeExtract catalog version aware itemsCatalogTypeService.isCatalogVersionAwareModel(ItemModel)- Specified by:
getCatalogVersionAwareItemsin interfaceSynchronizationFacade- Parameters:
items- list of items- Returns:
- list of catalog version aware items
-
getSynchronizations
-
getInboundSynchronizations
Description copied from interface:SynchronizationFacadeGets inbound sync jobs for given catalog version.- Specified by:
getInboundSynchronizationsin interfaceSynchronizationFacade- Parameters:
catalogVersion- - catalog version for which outbound synchronizations will be returned. To obtain catalog version please useSynchronizationFacade.getSyncCatalogVersion(Collection)- Returns:
- list of sync jobs
-
getOutboundSynchronizations
Description copied from interface:SynchronizationFacadeGets outbound sync jobs for given catalog version.- Specified by:
getOutboundSynchronizationsin interfaceSynchronizationFacade- Parameters:
catalogVersion- - catalog version for which outbound synchronizations will be returned. To obtain catalog version please useSynchronizationFacade.getSyncCatalogVersion(Collection)- Returns:
- list of sync jobs
-
getSyncCatalogVersion
Description copied from interface:SynchronizationFacadeReturns catalog version for given items if they are from the same catalog version or are CatalogVersion itself.- Specified by:
getSyncCatalogVersionin interfaceSynchronizationFacade- Parameters:
items- items for which catalog version will be extracted.- Returns:
- catalog version for given items.
-
isInSync
public Optional<Boolean> isInSync(List<ItemModel> itemModels, SyncItemJobModel jobModel, Map<String, Object> ctxMap) Description copied from interface:SynchronizationFacadeChecks if allItemModels are sync according to source and target fromSyncItemJobModel.- Specified by:
isInSyncin interfaceSynchronizationFacade- Parameters:
itemModels- defines items for which sync status is checkedjobModel- defines sync item job model from which source and target is taken to perform status checkctxMap- defines additional context- Returns:
- true if all itemModels are in sync
-
isInSync
Description copied from interface:SynchronizationFacadeChecksItemModel's status in all available synchronizations.- Specified by:
isInSyncin interfaceSynchronizationFacade- Parameters:
itemModel- defines item for which sync status is checkedctxMap- defines additional context- Returns:
- true if all itemModel are in sync, Optional.empty if sync status is not available e.g. item is not catalog version aware
-
isInSync
-
isInSync
-
matchesSyncStatus
protected Optional<Boolean> matchesSyncStatus(List<ItemModel> syncItems, List<SyncItemJobModel> allJobs, SyncItemStatus inSync) -
isApplicableForItems
Description copied from interface:SynchronizationFacadeChecks ifSyncItemJobModelis applicable forItemModels- Specified by:
isApplicableForItemsin interfaceSynchronizationFacade- Parameters:
jobModel- define sync job which will be checked if is applicable for itemsitems- defines items for which sync job is checked- Returns:
- true if sync job is applicable for items, false if it is not applicable
-
isSyncInProgress
Description copied from interface:SynchronizationFacadeTells if given item is being synchronized.- Specified by:
isSyncInProgressin interfaceSynchronizationFacade- Parameters:
item- item to check- Returns:
- true if item is being synchronized.
-
reRunCronJob
Description copied from interface:SynchronizationFacadeRuns given sync cron job again omitting items already processed in the previous run.- Specified by:
reRunCronJobin interfaceSynchronizationFacade- Parameters:
cronJob- sync cron job to rerun.
-
copyCronJobSafely
protected CatalogVersionSyncCronJobModel copyCronJobSafely(Supplier<CatalogVersionSyncCronJobModel> copySupplier) -
executeInTransaction
-
executeWithoutTypeInterceptors
-
createCronJobForRerun
protected CatalogVersionSyncCronJobModel createCronJobForRerun(CatalogVersionSyncCronJobModel cronJobForRerun) -
copyCronJobData
protected void copyCronJobData(CatalogVersionSyncCronJobModel newCronJob, CatalogVersionSyncCronJobModel cronJobForRerun) -
copyScheduledMedia
protected void copyScheduledMedia(CatalogVersionSyncCronJobModel newCronJob, CatalogVersionSyncCronJobModel cronJobForRerun) -
getPartialSyncStatusInfo
public Optional<PartialSyncInfo> getPartialSyncStatusInfo(ItemModel itemModel, SyncItemStatus status, Map<String, Object> ctxMap) Description copied from interface:SynchronizationFacadeChecksItemModel's status in all available synchronizations.- Specified by:
getPartialSyncStatusInfoin interfaceSynchronizationFacade- Parameters:
itemModel- defines item for which sync status is checkedstatus- defines target status for partial sync infoPartialSyncInfoctxMap- defines additional context- Returns:
- partial sync information if item is catalog version aware.
-
findSyncCounterpart
Description copied from interface:SynchronizationFacadeFinds a counterpart of given item in respective catalog version defined by the syncItemJob.- Specified by:
findSyncCounterpartin interfaceSynchronizationFacade- Parameters:
item- item of which counterpart will be found.syncItemJob- synchronization job which defines source and target catalog version.- Returns:
- counterpart item if found.
-
collectRelatedItems
-
canSync
Description copied from interface:SynchronizationFacadeTells whether current user can perform given sync.- Specified by:
canSyncin interfaceSynchronizationFacade- Parameters:
sync- synchronization job.- Returns:
- true if user can synchronize.
-
getCtxWithMaxRecursionDepth
-
prepareSyncConfig
Prepares sync config. If given sync config is null then then it will be created usingcreateSyncConfigWithDefaults(SyncItemJobModel)- Parameters:
syncConfig- sync config from sync taskSyncTask.getSyncConfig();syncJob- sync job to be executed.- Returns:
- sync config
-
createSyncConfigWithDefaults
Creates sync config based on project properties and syncJob settings. If one of the settings is not defined in project properties then default from given syncJob is taken- Parameters:
syncJob- sync job to be executed.- Returns:
- sync config with default values
-
getBooleanFromSystemConfig
-
getEnumValueFromSystemConfig
-
getConfigValue
-
getCatalogSynchronizationService
-
setCatalogSynchronizationService
public void setCatalogSynchronizationService(CatalogSynchronizationService catalogSynchronizationService) -
getSynchronizationStatusService
-
setSynchronizationStatusService
public void setSynchronizationStatusService(SynchronizationStatusService synchronizationStatusService) -
getSyncJobApplicableTypesStrategy
-
setSyncJobApplicableTypesStrategy
public void setSyncJobApplicableTypesStrategy(SyncJobApplicableTypesStrategy syncJobApplicableTypesStrategy) -
getCatalogTypeService
-
setCatalogTypeService
-
getRelatedItemsCollector
-
setRelatedItemsCollector
-
getCronJobService
-
setCronJobService
-
getModelService
-
setModelService
-
getMediaService
-
setMediaService
-
getSessionService
-
setSessionService
-
getCatalogVersionService
-
setCatalogVersionService
-
getUserService
-
setUserService
-