Class DefaultPersistenceContext

java.lang.Object
de.hybris.platform.inboundservices.persistence.impl.DefaultPersistenceContext
All Implemented Interfaces:
PersistenceContext

public class DefaultPersistenceContext extends Object implements PersistenceContext
Context which contains details about the item(s) for persistence.
  • Method Details

    • persistenceContextBuilder

      public static DefaultPersistenceContextBuilder persistenceContextBuilder()
      Instantiates a new builder for creating instances of a PersistenceContext
      Returns:
      the DefaultPersistenceContextBuilder
    • getIntegrationItem

      @Nonnull public IntegrationItem getIntegrationItem()
      Description copied from interface: PersistenceContext
      Retrieves item data to be persisted.
      Specified by:
      getIntegrationItem in interface PersistenceContext
      Returns:
      item data to be persisted into an ItemModel.
    • getContextItem

      public Optional<ItemModel> getContextItem()
      Description copied from interface: PersistenceContext
      Determines whether the payload item that can be retrieved by PersistenceContext.getIntegrationItem() method has been persisted already in the course of the root persistent context processing and retrieves the persisted item from the context. This is the case when a nested item refers back to another item present earlier on the payload graph. For example, an Order contains OrderEntries and OrderEntry refers back to its container Order. The already persisted item match should be done by the item type and its key value. Only when those two characteristics match, the context item was already persisted and can be retrieved by this method.
      Specified by:
      getContextItem in interface PersistenceContext
      Returns:
      an item, if this persistent context represents an already persisted payload item from higher levels of the root item graph or an empty Optional, if the item was not persisted yet.
      See Also:
    • putItem

      public void putItem(ItemModel item)
      Description copied from interface: PersistenceContext
      Adds the item model corresponding to the payload, i.e. PersistenceContext.getIntegrationItem(), into this context for being persisted. Every single payload item that is converted to an ItemModel must be put into this context explicitly.
      Specified by:
      putItem in interface PersistenceContext
    • getReferencedContext

      public PersistenceContext getReferencedContext(TypeAttributeDescriptor attribute)
      Description copied from interface: PersistenceContext
      Retrieves the persistence context for an item referenced by the specified attribute
      Specified by:
      getReferencedContext in interface PersistenceContext
      Parameters:
      attribute - specifies referenced item
      Returns:
      the context containing information about the referenced item
    • getReferencedContexts

      public Collection<PersistenceContext> getReferencedContexts(TypeAttributeDescriptor attribute)
      Description copied from interface: PersistenceContext
      Retrieves the persistence contexts for the items referenced by the specified attribute
      Specified by:
      getReferencedContexts in interface PersistenceContext
      Parameters:
      attribute - specifies referenced items
      Returns:
      the context containing information about the referenced items
    • getSourceContext

      public Optional<PersistenceContext> getSourceContext()
      Description copied from interface: PersistenceContext
      Retrieves the persistence context that the referenced context was gotten from
      Specified by:
      getSourceContext in interface PersistenceContext
      Returns:
      parent context, from which this context was retrieved. If this context is the root item context, Optional.empty is returned
    • getRootContext

      @Nonnull public PersistenceContext getRootContext()
      Description copied from interface: PersistenceContext
      Retrieves the top most persistence context
      Specified by:
      getRootContext in interface PersistenceContext
      Returns:
      the root context
    • toItemSearchRequest

      @Nonnull public ItemSearchRequest toItemSearchRequest()
      Description copied from interface: PersistenceContext
      Specified by:
      toItemSearchRequest in interface PersistenceContext
      Returns:
      a newly constructed ItemSearchRequest
    • isItemCanBeCreated

      public boolean isItemCanBeCreated()
      Description copied from interface: PersistenceContext
      Determines whether a new item model can be created for the context payload.
      Specified by:
      isItemCanBeCreated in interface PersistenceContext
      Returns:
      true, when new item can be create, if an item matching the context was not found in the persistent storage; false, if the context implies update only and therefore the item should not be created, if it does not exist yet.
    • getAcceptLocale

      @Nonnull public Locale getAcceptLocale()
      Description copied from interface: PersistenceContext
      Indicates locale, in which data must be returned in the response to the persistence request.
      Specified by:
      getAcceptLocale in interface PersistenceContext
      Returns:
      locale to be used for localized attribute values in the response. The locale should be always explicitly specified in this context, so that clients would not need to duplicate logic for determining a default value to be used for returned data.
    • getContentLocale

      @Nonnull public Locale getContentLocale()
      Description copied from interface: PersistenceContext
      Indicates the language, in which localized attributes content is provided.
      Specified by:
      getContentLocale in interface PersistenceContext
      Returns:
      content locale that must be always explicitly specified in this context, so that clients would not need to duplicate logic for determining a locale for the localized attributes in the payload.
    • isReplaceAttributes

      public boolean isReplaceAttributes()
      Description copied from interface: PersistenceContext
      Indicates the persistence is to replace the item attributes with what's provided in the IntegrationItem. This is primarily applicable to collections. The default behavior is to append to the collection. With this method being true, the item's collection attribute will be replaced instead of appended.
      Specified by:
      isReplaceAttributes in interface PersistenceContext
      Returns:
      true means to replace attributes, otherwise false.
    • getPrePersistHook

      public String getPrePersistHook()
      Description copied from interface: PersistenceContext
      Returns name of the PrePersistHook to be executed before saving this context data.
      Specified by:
      getPrePersistHook in interface PersistenceContext
      Returns:
      name of the hook to execute or null, if there is no need to execute a hook.
    • getPostPersistHook

      public String getPostPersistHook()
      Description copied from interface: PersistenceContext
      Returns name of the PostPersistHook to be executed after saving this context data.
      Specified by:
      getPostPersistHook in interface PersistenceContext
      Returns:
      name of the hook to execute or null, if there is no need to execute a hook.