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

public abstract class GenericCatalogCopyContext extends AbstractItemCopyContext
Since:
3.1-u6
  • Field Details

  • Constructor Details

  • Method Details

    • initPersistenceAdapter

      protected SynchronizationPersistenceAdapter initPersistenceAdapter()
    • setTargetLanguages

      protected void setTargetLanguages(Collection<Language> languages)
    • getIsCatalogTypeCache

      protected YLongToByteMap getIsCatalogTypeCache()
    • getDependentItemTypes

      public Set<ComposedType> getDependentItemTypes()
    • getDependentItemResolverCache

      protected YLongToObjectMap<Set<de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ParentResolver>> getDependentItemResolverCache()
    • mayBeCatalogItemDependent

      protected boolean mayBeCatalogItemDependent(Item item)
    • mayBeCatalogItemDependent

      protected boolean mayBeCatalogItemDependent(ComposedType composedType)
    • isCatalogItem

      protected boolean isCatalogItem(Item item)
    • isCatalogItemType

      protected boolean isCatalogItemType(ComposedType composedType)
    • 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

      public final CatalogVersion getSourceVersion()
      Returns:
      the source for the copy action
    • getTargetVersion

      public final CatalogVersion getTargetVersion()
      Returns:
      the target for the copy action
    • getJob

      protected CatalogVersionSyncJob getJob()
      Returns:
      the job
    • isExclusiveMode

      public boolean isExclusiveMode()
      If true the syncjob is added to the ItemSyncTimestamp
      Returns:
      the exclusiveMode
    • getCronjob

      protected CatalogVersionSyncCronJob getCronjob()
      Returns:
      the cronjob
    • getCurrentTurn

      protected abstract int getCurrentTurn()
    • isFromSourceVersion

      public boolean isFromSourceVersion(Item item) throws JaloInvalidParameterException
      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

      protected CatalogVersion getCatalogVersion(Item item) throws JaloInvalidParameterException
      Returns the CatalogVersion for the given Item.
      Returns:
      null if item is not a catalog aware item or no catalogversion is set.
      Throws:
      JaloInvalidParameterException
    • translate

      protected Object translate(AttributeCopyCreator acc)
      Filters localized attribute values by available catalog languages. Besides it adds {language->null} entries for each missing language within the map.
    • finishedCopying

      protected void finishedCopying(ItemCopyCreator icc)
      Superclass method overridden to call setTimestamp(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 a ItemSyncTimestamp instance 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

      protected ItemSyncTimestamp queryExistingSyncTimestamp(Item src, PK tgtPK)
      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

      protected boolean mustBeTranslated(AttributeCopyCreator acc, Item original)
      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.
      See Also:
    • mustBeTranslated

      protected boolean mustBeTranslated(String attributeQualifier, Item original)
    • 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

      public boolean isDependentFromSourceVersion(Item dependentItem)
    • getCopyCreatorPresetValues

      protected Map getCopyCreatorPresetValues(Item original, Item copyToupdate)
      Sets fixedly the catalog version attribute for all Products,Categories, Mediasand Keywords.
    • getRootCatalogTypeCache

      protected YLongToObjectMap<String> getRootCatalogTypeCache()
    • getCatalogVersionAttributeCache

      protected YLongToObjectMap<String> getCatalogVersionAttributeCache()
    • getCatalogKeyAttributesCache

      protected YLongToObjectMap<Set<String>> getCatalogKeyAttributesCache()
    • getNonCatalogKeyAttributesCache

      protected YLongToObjectMap<Set<String>> getNonCatalogKeyAttributesCache()
    • getCopyOnDemandCache

      protected YLongToByteMap getCopyOnDemandCache()
    • getCatalogVersionAttribute

      protected String getCatalogVersionAttribute(ComposedType composedType)
    • getRootCatalogType

      protected String getRootCatalogType(ComposedType composedType)
    • getRootUniqueItemType

      protected String getRootUniqueItemType(ComposedType composedType, Set<String> uniqueAttributes)
    • getUniqueKeyAttributes

      protected Set<String> getUniqueKeyAttributes(ComposedType composedType)
    • getNonCatalogItemUniqueAttributes

      protected Set<String> getNonCatalogItemUniqueAttributes(ComposedType composedType)
    • isUntranslatablePartOfItem

      protected boolean isUntranslatablePartOfItem(AttributeCopyCreator acc, Item original)
      Superclass method overridden to avoid copying catalog items which do not originate from the source version.
    • isUntranslatableProductFeature

      protected boolean isUntranslatableProductFeature(ProductFeature productFeature)
    • isCopyOnDemand

      protected final boolean isCopyOnDemand(AttributeDescriptor attributeDescriptor)
      Overrides:
      isCopyOnDemand in class AbstractItemCopyContext
    • computeIsCopyOnDemand

      protected boolean computeIsCopyOnDemand(AttributeDescriptor attributeDescriptor)
    • isCopyOnDemandCatalogItemType

      protected boolean isCopyOnDemandCatalogItemType(ComposedType catalogItemType, Class jaloClass)
    • getContainedCatalogItemTypes

      protected final Set<ComposedType> getContainedCatalogItemTypes(AttributeDescriptor attributeDescriptor)
    • getCopiedItemCache

      protected final Map<PK,de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntry> getCopiedItemCache(boolean create)
    • 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

      protected de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntry processQueryResult(Item sourceItem, List<Item> rows, List<Object> keys)
    • getCounterpartItem

      protected Item getCounterpartItem(Item original)
    • setSavePrevousValues

      protected void setSavePrevousValues(boolean setSaveToOn)
    • isSavePrevousValues

      public boolean isSavePrevousValues()
    • getCreationAttributes

      protected Set<AttributeDescriptor> getCreationAttributes()
    • translateAD

      protected final String translateAD(AttributeDescriptor attributeDescriptor)
    • addCreationAttribute

      protected final void addCreationAttribute(AttributeDescriptor attributeDescriptor)
    • 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

      protected Set<Item> collectPartOfItemsToCopy(AttributeCopyCreator acc)
    • copyPartOfValues

      protected Map<Item,Item> copyPartOfValues(AttributeCopyCreator acc)
      Tries to copy all items from AttributeCopyCreator.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

      protected final Object translateValue(AttributeCopyCreator acc, Object original, Map<Item,Item> partOfItemsToBeCopied, boolean localized)
    • translateItemValue

      protected Item translateItemValue(AttributeCopyCreator acc, Item original, Map<Item,Item> partOfItemsToBeCopied)
    • getCurrentlyCopying

      protected final CatalogItemCopyCreator getCurrentlyCopying(Item original)
    • isCurrentlyCopying

      protected final boolean isCurrentlyCopying(Item original)
    • pushCurrentlyCopying

      protected final void pushCurrentlyCopying(CatalogItemCopyCreator icc)
    • popCurrentlyCopying

      protected final void popCurrentlyCopying(CatalogItemCopyCreator icc)
    • registerCopy

      protected final void registerCopy(de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext.ItemCopyCacheEntry copyInfo)
    • beforeCopying

      protected void beforeCopying(CatalogItemCopyCreator icc)
    • afterCopying

      protected void afterCopying(Item copy, CatalogItemCopyCreator icc)
    • logSavedValues

      protected void logSavedValues(ItemCopyCreator icc)
    • copyMediaData

      protected void copyMediaData(Media src, Media tgt)
    • copy

      public Item copy(Item original)
    • copy

      public Item copy(Item original, Item existingCopy, ItemSyncTimestamp itemSyncTimestamp)
    • copy

      protected Item copy(ItemCopyCreator parent, Item original)
    • copy

      protected Item copy(ItemCopyCreator parent, Item original, Item copyToUpdate, ItemSyncTimestamp itemSyncTimestamp)
    • getCopyCreatorBlacklist

      protected Set getCopyCreatorBlacklist(Item original, Item toUpdate)
    • getCopyCreatorWhitelist

      protected Set getCopyCreatorWhitelist(Item original, Item toUpdate)
    • forceCopy

      public boolean forceCopy(AttributeDescriptor attributeDescriptor)
    • isRequiredForCreation

      protected boolean isRequiredForCreation(AttributeDescriptor attributeDescriptor)
      Description copied from class: AbstractItemCopyContext
      Determines 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:
      isRequiredForCreation in class AbstractItemCopyContext
      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:
      cleanup in class AbstractItemCopyContext
    • isForceUpdate

      protected boolean isForceUpdate()
    • getCopyCacheSize

      public int getCopyCacheSize()
      Returns:
      the copyCacheSize
    • setCopyCacheSize

      public void setCopyCacheSize(int copyCacheSize)
      Parameters:
      copyCacheSize - the copyCacheSize to set
    • getTargetLanguages

      protected Set<Language> getTargetLanguages()
      Returns:
      the targetLanguages
    • afterCreate

      protected void afterCreate(ItemCopyCreator icc, Item ret)
      Called during ItemCopyCreator.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

      protected CatalogVersion getTargetVersionForQueryCatalogItemCopy(Item sourceItem)
    • canBeTranslatedPartially

      protected boolean canBeTranslatedPartially(AttributeCopyCreator attributeCopyCreator)
    • isPartialCollectionTranslationEnabledGlobally

      protected boolean isPartialCollectionTranslationEnabledGlobally()