com.ibm.commerce.context.giftregistryimpl

Class GiftRegistryContextImpl

  • All Implemented Interfaces:
    Context, ContextSPI, GiftRegistryContext, java.io.Serializable


    public class GiftRegistryContextImpl
    extends AbstractContextImpl
    implements GiftRegistryContext, ContextSPI
    This class implements the GiftRegistryContext interface to provide the implementation details of the context object that is used in GiftRegistry. The context contains the following gift registry information:
    • 1. list of Gift Registry external Ids that this user has accessed
    • 2. relationship that this user has for each of the gift registry (gift giver, registrant or co-registrant)
    • 3. gift registry external id currently being managed
    See Also:
    Serialized Form
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
      • SER_ELEMENT_SEP

        public static final java.lang.String SER_ELEMENT_SEP
        The delimiter used in Vector and HashMap string representation
        See Also:
        Constant Field Values
      • SER_KEY_SEP

        public static final java.lang.String SER_KEY_SEP
        The delimiter used in the key-value of the HashMap string representation
        See Also:
        Constant Field Values
    • Constructor Detail

      • GiftRegistryContextImpl

        public GiftRegistryContextImpl()
        Creates the preview context.
    • Method Detail

      • copyContext

        public void copyContext(Context ctx)
        Copy the content of the specified context to this context.
        Specified by:
        copyContext in interface Context
        Parameters:
        ctx - - The context to be copied from.
      • getContextAttributes

        public java.lang.Object[] getContextAttributes()
                                                throws BusinessContextException
        This method returns an array of context attributes to be persisted. It construct the following attributes into a string representation and add the string to the array:
        • 1. list of Gift Registry external Ids that this user has accessed
        • 2. relationship that this user has for each of the gift registry (gift giver, registrant or co-registrant)
        • 3. gift registry external id currently being managed
        Specified by:
        getContextAttributes in class AbstractContextImpl
        Returns:
        Returns an array of context attributes to be persisted.
        Throws:
        BusinessContextException
        See Also:
        AbstractContextImpl.getContextSerializedString()
      • setContextAttributes

        public void setContextAttributes(java.lang.String[] ctxAttrs)
        This method initializes the context from the specified list of attributes. Here is the list of attributes:
        • 1. list of Gift Registry external Ids that this user has accessed
        • 2. relationship that this user has for each of the gift registry (gift giver, registrant or co-registrant)
        • 3. gift registry external id currently being managed
          Specified by:
          setContextAttributes in class AbstractContextImpl
          Parameters:
          ctxAttrs - An array of attributes of the context
        • initializeContext

          public void initializeContext(com.ibm.commerce.component.contextservice.ActivityData initData,
                                        Context ctx)
                                 throws BusinessContextException
          Initializes the context based on the context passed in as the argument and updates it using the initData.
          Overrides:
          initializeContext in class AbstractContextImpl
          Parameters:
          initData - The sets of attributes that are passed by the request
          ctx - The particular context of the token being copied from.
          Throws:
          java.lang.Exception
          BusinessContextException - on any error encountered
        • getContextName

          public java.lang.String getContextName()
          Returns the name of this context
          Specified by:
          getContextName in interface Context
          Returns:
          ContextName
        • validate

          public boolean validate()
                           throws BusinessContextException
          Validates whether the attributes of this context are valid.
          Specified by:
          validate in interface Context
          Returns:
          Returns true if all the attributes are valid.
          Throws:
          BusinessContextException - Throws exception if any of the attribute is not valid.
        • getRegistryRelationship

          public java.lang.Integer getRegistryRelationship(java.lang.String externalId)
          Returns the relationship of a registrant with regards to a known registry they accessed. The registry must be in the getExternalIdsAccessed() Vector.
          Specified by:
          getRegistryRelationship in interface GiftRegistryContext
          Parameters:
          ExternalId -
          Returns:
          relationship
        • getLastExternalIdAccessed

          public java.lang.String getLastExternalIdAccessed()
          Returns the last gift registry externalId that this shopper has accessed or managed
          Specified by:
          getLastExternalIdAccessed in interface GiftRegistryContext
          Returns:
          ExternalId
        • getCurrentExternalId

          public java.lang.String getCurrentExternalId()
          Returns the current gift registry externalId that this shopper has accessed or managed
          Specified by:
          getCurrentExternalId in interface GiftRegistryContext
          Returns:
          ExternalId
        • getExternalIdsAccessed

          public java.util.Vector getExternalIdsAccessed()
          Returns a vector of all the gift registry externalId's this user accessed this session
          Specified by:
          getExternalIdsAccessed in interface GiftRegistryContext
          Returns:
          Vector of gift registry externalId's
        • setExternalIdAccessed

          public void setExternalIdAccessed(java.lang.String externalId,
                                            java.lang.Integer relationship)
          Adds to a list of gift registry externalId's this user has accessed. If a new registry is accessed, this method is called to store this information. The relationship parameter is the user authentication relationship they play on the registry. A null relationship means they only have guest access.
          Specified by:
          setExternalIdAccessed in interface GiftRegistryContext
          Parameters:
          ExternalId -
          relationship -
        • setExternalIdAccessed

          public void setExternalIdAccessed(java.lang.String externalId)
          Adds to a list of gift registry externalId's this user has accessed. If a new registry is accessed, this method is called to store this information.
          Specified by:
          setExternalIdAccessed in interface GiftRegistryContext
          Parameters:
          ExternalId -
        • getExternalIdsByRegistrantRelationship

          public java.util.Vector getExternalIdsByRegistrantRelationship()
          Returns a list of gift registry externalId's that this user has the Registrant or Co-Registrant relationship with.
          Specified by:
          getExternalIdsByRegistrantRelationship in interface GiftRegistryContext
          Returns:
          Vector of externalId's
        • getExternalIdsAccessedByRelationship

          public java.util.Vector getExternalIdsAccessedByRelationship(java.lang.Integer relationship)
          Returns a list of gift registry externalId's that this user has accessed or managed recently for which they have a particular relationship with.
          Specified by:
          getExternalIdsAccessedByRelationship in interface GiftRegistryContext
          Parameters:
          relationship -
          Returns:
          Vector of externalId's
        • isUserManagingARegistry

          public boolean isUserManagingARegistry()
          Returns true if the user is currently managing a registry. The registry the user is managing can be found by calling: getGiftRegistryBeingManaged().
          Specified by:
          isUserManagingARegistry in interface GiftRegistryContext
          Returns:
          boolean
        • setUserManagingARegistry

          public void setUserManagingARegistry(boolean managing,
                                               java.lang.String externalId)
          Sets if the user is currently managing a particular registry. If this is set to true, it means that the user is in the process of managing their registry. If this is false, it means the user is not managing a registry; ExternalId should be null if managing is false.
          Specified by:
          setUserManagingARegistry in interface GiftRegistryContext
          Parameters:
          managing -
          ExternalId -
        • getGiftRegistryBeingManaged

          public java.lang.String getGiftRegistryBeingManaged()
          If isUserManagingARegistry() is true, it means that a gift registry is being managed by a shopper. This method can then be called to retrieve the gift registry ExternalId that the user is managing.
          Specified by:
          getGiftRegistryBeingManaged in interface GiftRegistryContext
          Returns:
          ExternalId
        • removeExternalIdAccessed

          public java.lang.String removeExternalIdAccessed(java.lang.String externalId)
          Removes an externalId from the list of accessed registries for this user
          Specified by:
          removeExternalIdAccessed in interface GiftRegistryContext
          Parameters:
          ExternalId -
          Returns:
          String