Class GenericCatalogCopyContext
java.lang.Object
de.hybris.platform.catalog.jalo.synchronization.AbstractItemCopyContext
de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext
- Direct Known Subclasses:
CatalogVersionSyncCopyContext,GenericCatalogCopyContextTest.TestGenericCatalogCopyContext
- Since:
- 3.1-u6
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classclass -
Field Summary
FieldsFields inherited from class de.hybris.platform.catalog.jalo.synchronization.AbstractItemCopyContext
ctx -
Constructor Summary
ConstructorsConstructorDescriptionGenericCatalogCopyContext(SessionContext ctx, CatalogVersionSyncJob job, CatalogVersionSyncCronJob cronJob, org.apache.log4j.Level logLevel, boolean forceUpdate) -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidaddCreationAttribute(AttributeDescriptor attributeDescriptor) protected voidafterCopying(Item copy, CatalogItemCopyCreator icc) protected voidafterCreate(ItemCopyCreator icc, Item ret) Called duringItemCopyCreator.copy(GenericCatalogCopyContext)right after a new item has been created but before it's partOf items or references have been processed!protected voidprotected booleancanBeTranslatedPartially(AttributeCopyCreator attributeCopyCreator) voidcleanup()protected YLongToObjectMap<Set<de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ParentResolver>>protected booleancomputeIsCopyOnDemand(AttributeDescriptor attributeDescriptor) protected Collection<de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ParentResolver>computeParentResolvers(ComposedType parentType, Set<ComposedType> ctControlSet, Set<AttributeDescriptor> adControlSet) protected Itemcopy(ItemCopyCreator parent, Item original) protected Itemcopy(ItemCopyCreator parent, Item original, Item copyToUpdate, ItemSyncTimestamp itemSyncTimestamp) copy(Item original, Item existingCopy, ItemSyncTimestamp itemSyncTimestamp) protected voidcopyMediaData(Media src, Media tgt) Tries to copy all items fromAttributeCopyCreator.getPartOfItemsToCopy().protected AttributeCopyCreatorcreateAttributeCopyCreator(ItemCopyCreator icc, AttributeCopyDescriptor acd, boolean ispreset, Object sourceValue) protected CatalogItemCopyCreatorcreateCreator(ItemCopyCreator parent, Item source, Item target, ItemSyncTimestamp itemSyncTimestamp, Collection<String> blacklist, Collection<String> whiteList, Map<String, Object> presetValues) protected ItemSyncTimestampcreateSyncTimestamp(CatalogVersionSyncCronJob owningCronJob, int currentTurn, Item source, ItemCopyCreator icc) Creates a new ItemSyncTimestamp based on the current context and parameters.protected voidSuperclass method overridden to callsetTimestamp(CatalogVersionSyncCronJob, int, CatalogItemCopyCreator)for each copied item.booleanforceCopy(AttributeDescriptor attributeDescriptor) protected YLongToObjectMap<Set<String>>protected CatalogVersiongetCatalogVersion(Item item) Returns theCatalogVersionfor the given Item.protected StringgetCatalogVersionAttribute(ComposedType composedType) protected YLongToObjectMap<String>protected final Set<ComposedType>getContainedCatalogItemTypes(AttributeDescriptor attributeDescriptor) protected final Map<PK,de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntry> getCopiedItemCache(boolean create) protected de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntrylonglongintprotected SetgetCopyCreatorBlacklist(Item original, Item toUpdate) protected MapgetCopyCreatorPresetValues(Item original, Item copyToupdate) protected SetgetCopyCreatorWhitelist(Item original, Item toUpdate) protected YLongToByteMapprotected ItemgetCounterpartItem(Item original) protected Set<AttributeDescriptor>Makes sure the following attribute are set during item creation although they are item references (normally item references are translated and set after creating the copy):GeneratedCatalogConstants.Attributes.Product.CATALOGVERSIONCatalogConstants.Attributes.Category.CATALOGVERSIONGeneratedCatalogConstants.Attributes.Media.CATALOGVERSIONGeneratedKeyword.CATALOGVERSIONGeneratedCatalogConstants.Attributes.Product.VARIANTTYPEGeneratedVariantProduct.BASEPRODUCTGeneratedProduct.UNITprotected CatalogVersionSyncCronJobprotected final CatalogItemCopyCreatorgetCurrentlyCopying(Item original) protected abstract intprotected YLongToObjectMap<Set<de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ParentResolver>>protected YLongToByteMapprotected CatalogVersionSyncJobgetJob()getNonCatalogItemUniqueAttributes(ComposedType composedType) protected YLongToObjectMap<Set<String>>protected StringgetRootCatalogType(ComposedType composedType) protected YLongToObjectMap<String>protected StringgetRootUniqueItemType(ComposedType composedType, Set<String> uniqueAttributes) final CatalogVersionfinal CatalogVersionprotected CatalogVersiongetTargetVersionForQueryCatalogItemCopy(Item sourceItem) getUniqueKeyAttributes(ComposedType composedType) protected ItemSyncTimestamphandleStale(Item src, PK tgtPK, Map<PK, ItemSyncTimestamp> all, ItemSyncTimestamp existingOneToUpdate) protected SynchronizationPersistenceAdapterprotected booleanisCatalogItem(Item item) protected booleanisCatalogItemType(ComposedType composedType) protected final booleanisCopyOnDemand(AttributeDescriptor attributeDescriptor) protected booleanisCopyOnDemandCatalogItemType(ComposedType catalogItemType, Class jaloClass) protected final booleanisCurrentlyCopying(Item original) booleanisDependentFromSourceVersion(Item dependentItem) booleanIf true the syncjob is added to theItemSyncTimestampprotected booleanbooleanisFromSourceVersion(Item item) Determines whether or not an item belongs to this contexts source version.protected booleanprotected booleanisRequiredForCreation(AttributeDescriptor attributeDescriptor) Determines whether or not a attribute is required for the creation of a item copy.booleanfinal booleanprotected booleanisUntranslatablePartOfItem(AttributeCopyCreator acc, Item original) Superclass method overridden to avoid copying catalog items which do not originate from the source version.protected booleanisUntranslatableProductFeature(ProductFeature productFeature) protected voidprotected booleanprotected booleanmayBeCatalogItemDependent(ComposedType composedType) protected booleanmustBeTranslated(AttributeCopyCreator acc, Item original) Makes sure each catalog items must always be translated.protected booleanmustBeTranslated(String attributeQualifier, Item original) protected final voidprotected de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntryprotected final voidprotected de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntryqueryCatalogItemCopy(Item sourceItem) protected de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntryprotected ItemSyncTimestampqueryExistingSyncTimestamp(Item src, PK tgtPK) Returns the ItemSyncTimestamp which has the given Item as source and the given PK as targetPK.protected de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntryqueryNonCatalogItemCopy(Item source) protected final voidregisterCopy(de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntry copyInfo) voidsetCategoryOptions(boolean copyProducts, boolean copySubcategories) Sets special options for copying categories: copyProducts - all products of a explicitly copied category are copied as well copySubcategories - all sub categories of a explicitly copied category are copied as wellvoidsetCopyCacheHits(long copyCacheHits) voidsetCopyCacheMisses(long copyCacheMisses) voidsetCopyCacheSize(int copyCacheSize) protected voidsetSavePrevousValues(boolean setSaveToOn) protected voidsetTargetLanguages(Collection<Language> languages) protected ItemSyncTimestampsetTimestamp(CatalogVersionSyncCronJob owningCronJob, int currentTurn, CatalogItemCopyCreator icc) Registers the source item's modification time stamp inside aItemSyncTimestampinstance to allow checking for modifications later.protected ObjectFilters localized attribute values by available catalog languages.protected final StringtranslateAD(AttributeDescriptor attributeDescriptor) protected ItemtranslateItemValue(AttributeCopyCreator acc, Item original, Map<Item, Item> partOfItemsToBeCopied) protected final ObjecttranslateValue(AttributeCopyCreator acc, Object original, Map<Item, Item> partOfItemsToBeCopied, boolean localized) protected voidupdateSyncTimestamp(ItemSyncTimestamp itemSyncTimestamp, CatalogVersionSyncCronJob owningCronJob, int currentTurn, Item source, ItemCopyCreator icc) Updates the given ItemSyncTimestamp based on the given parameters.Methods inherited from class de.hybris.platform.catalog.jalo.synchronization.AbstractItemCopyContext
allItems, createCopyDescriptor, createSession, debug, debug, error, error, getCatalogManager, getCtx, getFlexibleSearch, getSession, getTypeCopyDescriptor, ignoreAttribute, info, info, isAtomic, isAtomic, isDebugEnabled, isErrorEnabled, isInfoEnabled, isPartOf, isWarnEnabled, log, log, safeToString, splitDescriptors, toItem, toItems, toString, valuesToString, warn, warn
-
Field Details
-
LEGACY_MODE_FLAG
- See Also:
-
PARTIAL_COLLECTION_TRANSLATION_ALLOWED
- See Also:
-
-
Constructor Details
-
GenericCatalogCopyContext
public GenericCatalogCopyContext(SessionContext ctx, CatalogVersionSyncJob job, CatalogVersionSyncCronJob cronJob, org.apache.log4j.Level logLevel, boolean forceUpdate) - Parameters:
ctx-
-
-
Method Details
-
initPersistenceAdapter
-
setTargetLanguages
-
getIsCatalogTypeCache
-
getDependentItemTypes
-
getDependentItemResolverCache
protected YLongToObjectMap<Set<de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ParentResolver>> getDependentItemResolverCache() -
mayBeCatalogItemDependent
-
mayBeCatalogItemDependent
-
isCatalogItem
-
isCatalogItemType
-
setCategoryOptions
public void setCategoryOptions(boolean copyProducts, boolean copySubcategories) Sets special options for copying categories:- copyProducts - all products of a explicitly copied category are copied as well
- copySubcategories - all sub categories of a explicitly copied category are copied as well
-
getSourceVersion
- Returns:
- the source for the copy action
-
getTargetVersion
- Returns:
- the target for the copy action
-
getJob
- Returns:
- the job
-
isExclusiveMode
public boolean isExclusiveMode()If true the syncjob is added to theItemSyncTimestamp- Returns:
- the exclusiveMode
-
getCronjob
- Returns:
- the cronjob
-
getCurrentTurn
protected abstract int getCurrentTurn() -
isFromSourceVersion
Determines whether or not an item belongs to this contexts source version.- Parameters:
item- the item to check- Throws:
JaloInvalidParameterException- if the item is no catalog item
-
getCatalogVersion
Returns theCatalogVersionfor the given Item.- Returns:
- null if item is not a catalog aware item or no catalogversion is set.
- Throws:
JaloInvalidParameterException
-
translate
Filters localized attribute values by available catalog languages. Besides it adds {language->null} entries for each missing language within the map. -
finishedCopying
Superclass method overridden to callsetTimestamp(CatalogVersionSyncCronJob, int, CatalogItemCopyCreator)for each copied item. -
createCreator
protected CatalogItemCopyCreator createCreator(ItemCopyCreator parent, Item source, Item target, ItemSyncTimestamp itemSyncTimestamp, Collection<String> blacklist, Collection<String> whiteList, Map<String, Object> presetValues) -
setTimestamp
protected ItemSyncTimestamp setTimestamp(CatalogVersionSyncCronJob owningCronJob, int currentTurn, CatalogItemCopyCreator icc) Registers the source item's modification time stamp inside aItemSyncTimestampinstance to allow checking for modifications later.- Parameters:
icc- the finished copy created
-
updateSyncTimestamp
protected void updateSyncTimestamp(ItemSyncTimestamp itemSyncTimestamp, CatalogVersionSyncCronJob owningCronJob, int currentTurn, Item source, ItemCopyCreator icc) Updates the given ItemSyncTimestamp based on the given parameters. -
createSyncTimestamp
protected ItemSyncTimestamp createSyncTimestamp(CatalogVersionSyncCronJob owningCronJob, int currentTurn, Item source, ItemCopyCreator icc) Creates a new ItemSyncTimestamp based on the current context and parameters. -
queryExistingSyncTimestamp
Returns the ItemSyncTimestamp which has the given Item as source and the given PK as targetPK. An error is reported if more than one timestamp was found.- Returns:
- null if nothing was found.
-
handleStale
protected ItemSyncTimestamp handleStale(Item src, PK tgtPK, Map<PK, ItemSyncTimestamp> all, ItemSyncTimestamp existingOneToUpdate) -
mustBeTranslated
Makes sure each catalog items must always be translated. This way all references to catalog items which do not exist in the target catalog are delayed until they become copied or the copy process ends. -
mustBeTranslated
-
computeDependentItemResolvers
protected YLongToObjectMap<Set<de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ParentResolver>> computeDependentItemResolvers() -
computeParentResolvers
protected Collection<de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ParentResolver> computeParentResolvers(ComposedType parentType, Set<ComposedType> ctControlSet, Set<AttributeDescriptor> adControlSet) -
isDependentFromSourceVersion
-
getCopyCreatorPresetValues
-
getRootCatalogTypeCache
-
getCatalogVersionAttributeCache
-
getCatalogKeyAttributesCache
-
getNonCatalogKeyAttributesCache
-
getCopyOnDemandCache
-
getCatalogVersionAttribute
-
getRootCatalogType
-
getRootUniqueItemType
-
getUniqueKeyAttributes
-
getNonCatalogItemUniqueAttributes
-
isUntranslatablePartOfItem
Superclass method overridden to avoid copying catalog items which do not originate from the source version. -
isUntranslatableProductFeature
-
isCopyOnDemand
- Overrides:
isCopyOnDemandin classAbstractItemCopyContext
-
computeIsCopyOnDemand
-
isCopyOnDemandCatalogItemType
-
getContainedCatalogItemTypes
protected final Set<ComposedType> getContainedCatalogItemTypes(AttributeDescriptor attributeDescriptor) -
getCopiedItemCache
-
getCopy
protected de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntry getCopy(Item source) -
queryCopy
protected de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntry queryCopy(Item source) -
queryCatalogItemCopy
protected de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntry queryCatalogItemCopy(Item sourceItem) -
queryNonCatalogItemCopy
protected de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntry queryNonCatalogItemCopy(Item source) -
processQueryResult
-
getCounterpartItem
-
setSavePrevousValues
protected void setSavePrevousValues(boolean setSaveToOn) -
isSavePrevousValues
public boolean isSavePrevousValues() -
getCreationAttributes
Makes sure the following attribute are set during item creation although they are item references (normally item references are translated and set after creating the copy):GeneratedCatalogConstants.Attributes.Product.CATALOGVERSIONCatalogConstants.Attributes.Category.CATALOGVERSIONGeneratedCatalogConstants.Attributes.Media.CATALOGVERSIONGeneratedKeyword.CATALOGVERSIONGeneratedCatalogConstants.Attributes.Product.VARIANTTYPEGeneratedVariantProduct.BASEPRODUCTGeneratedProduct.UNIT
-
translateAD
-
addCreationAttribute
-
isStarted
public final boolean isStarted()- Returns:
- true if at least one item was copied or is currently being copied.
-
createAttributeCopyCreator
protected AttributeCopyCreator createAttributeCopyCreator(ItemCopyCreator icc, AttributeCopyDescriptor acd, boolean ispreset, Object sourceValue) -
collectPartOfItemsToCopy
-
copyPartOfValues
Tries to copy all items fromAttributeCopyCreator.getPartOfItemsToCopy(). The returned map contains each partOf item and (if successfully copied) the associated copy. Please note that some attribute value items may been untranslatable - they don't turn up in the result map!- Parameters:
acc- the attribute copy creator
-
translateValue
-
translateItemValue
-
getCurrentlyCopying
-
isCurrentlyCopying
-
pushCurrentlyCopying
-
popCurrentlyCopying
-
registerCopy
protected final void registerCopy(de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntry copyInfo) -
beforeCopying
-
afterCopying
-
logSavedValues
-
copyMediaData
-
copy
-
copy
-
copy
-
copy
protected Item copy(ItemCopyCreator parent, Item original, Item copyToUpdate, ItemSyncTimestamp itemSyncTimestamp) -
getCopyCreatorBlacklist
-
getCopyCreatorWhitelist
-
forceCopy
-
isRequiredForCreation
Description copied from class:AbstractItemCopyContextDetermines whether or not a attribute is required for the creation of a item copy. These attributes cannot be delayed, which requires that all values must be translatable or preset.If no item is actually created but an existing copy is updated these attributes are set alltogether before all partOf references and other attributes. Delaying is neither allowed here.
- Overrides:
isRequiredForCreationin classAbstractItemCopyContext- Parameters:
attributeDescriptor- the attribute descriptor to determine creation status for- Returns:
- true if the attribute is required for item creation
-
cleanup
public void cleanup()- Overrides:
cleanupin classAbstractItemCopyContext
-
isForceUpdate
protected boolean isForceUpdate() -
getCopyCacheSize
public int getCopyCacheSize()- Returns:
- the copyCacheSize
-
setCopyCacheSize
public void setCopyCacheSize(int copyCacheSize) - Parameters:
copyCacheSize- the copyCacheSize to set
-
getTargetLanguages
- Returns:
- the targetLanguages
-
afterCreate
Called duringItemCopyCreator.copy(GenericCatalogCopyContext)right after a new item has been created but before it's partOf items or references have been processed!- Parameters:
icc-ret-
-
getCopyCacheHits
public long getCopyCacheHits()- Returns:
- the copyCacheHits
-
setCopyCacheHits
public void setCopyCacheHits(long copyCacheHits) - Parameters:
copyCacheHits- the copyCacheHits to set
-
getCopyCacheMisses
public long getCopyCacheMisses()- Returns:
- the copyCacheMisses
-
setCopyCacheMisses
public void setCopyCacheMisses(long copyCacheMisses) - Parameters:
copyCacheMisses- the copyCacheMisses to set
-
getTargetVersionForQueryCatalogItemCopy
-
canBeTranslatedPartially
-
isPartialCollectionTranslationEnabledGlobally
protected boolean isPartialCollectionTranslationEnabledGlobally()
-