com.ibm.commerce.component.giftregistry.commands

Class GiftRegistryCmdHelper

  • java.lang.Object
    • com.ibm.commerce.component.giftregistry.commands.GiftRegistryCmdHelper


  • public final class GiftRegistryCmdHelper
    extends java.lang.Object
    This helper class provides methods that are shared by various gift registry component commands
    • Field Detail

      • COPYRIGHT

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

        public static final java.lang.String CLASS_NAME
        Name of this class
    • Constructor Detail

      • GiftRegistryCmdHelper

        public GiftRegistryCmdHelper()
    • Method Detail

      • updateItemRequestQuantity

        public static final void updateItemRequestQuantity(CommandContext context,
                                                           GiftRegistryItemVO item,
                                                           GiftRegistryItemAccessBean itemAB)
                                                    throws ECException
        Updates the quantity of an item in database. The requested quantity of the given itemVO will be copied to the item access bean if no rules are violated.
        Parameters:
        context - the command context in which this method is called
        item - item value object that has the new requested quantity
        itemAB - the item access bean representing the item to be updated.
        Throws:
        ECException - if a specified rule in the gift registry rule table is violated. The message parameter of the exception message indicates which rule is violated.
      • findItem

        public static final GiftRegistryItemAccessBean findItem(java.lang.Long giftRegistryId,
                                                                GiftRegistryItemVO item)
        Finds the item that exactly matches the given item value object. The criteria for exact matching:
        • -- If there is an itemId, only match itemId. Otherwise,
        • -- The same part number
        • -- The same part auxiliary key
        • -- The same personalization
        Parameters:
        giftRegistryId - the primary key of a gift registry that contains the given item
        item - the item value object to be matched
        Returns:
        A populated GiftRegistryItemAccessBean *once* a match is found. null otherwise.
      • findItem

        public static final GiftRegistryItemAccessBean findItem(java.lang.Long giftRegistryId,
                                                                java.lang.String partNumber,
                                                                java.lang.String partAuxKey,
                                                                java.util.Collection personalizations)
        This method finds an item access bean with the given giftRegistryId, part number, and part auxiliary key. The item also contains the given personalizations.
        Parameters:
        giftRegistryId - the id of the gift registry that has the item to be found
        partNumber - the partNumber of the item to be found
        partAuxKey - the auxiliary key of the item to be found
        personalizations - the collection of personalizations of the item that is to be found.
        Returns:
        A populated GiftRegistryItemAccessBean *once* a match is found. null otherwise.
      • findItem

        public static final GiftRegistryItemAccessBean findItem(GiftRegistryPurchaseRecordVO record)
        Finds the gift item that is associated with a purchase record. If a purchase record has gift item id, the item will be the one that has the same item ID. Otherwise, the purchase record's own partNumber/partAuxKey will be used. If nothing is found, null will be returned.
        Parameters:
        record - the record for which a gift item is to be searched.
        Returns:
        This method will return an item access bean if an item is found. Null otherwise.
      • getGiftRegistryId

        public static java.lang.Long getGiftRegistryId(java.lang.String externalId)
        Finds the gift registry id whose externalId is as given.
        Parameters:
        externalId - the externalId of the gift registry whose giftRegistryId is to be found
        Returns:
        the gift registry that is corresponding to externalId.
      • isToAdd

        public static boolean isToAdd(GiftRegistryAddressVO vo,
                                      BusinessObjectDocument bod)
        Determines if an address value object to be created. An address value object is t be created if it has no ID, or a verb specifies that the object will be created.
        Parameters:
        vo - the value object to be examined
        bod - the business object document that contains the value object
        Returns:
        true if a value object is to be created
      • isToAdd

        public static boolean isToAdd(GiftRegistryVO giftRegistry)
      • isToAdd

        public static boolean isToAdd(java.lang.Long giftRegistryId,
                                      GiftRegistryItemVO item)
        Determines if a gift item is to be created into the database. A gift item is to be added into database if one of the following conditions are satisfied:
        • The item has neither giftItemId, nor partnumber
        • The item has a part number, but the part number plus an optional partAuxKey does not identify any item for the given registry
        Parameters:
        giftRegistryId - the ID of the registry the gift item belongs to
        item - The gift item to be examined
        Returns:
        true if the gift item is to be added. False otherwise.
      • isToAdd

        public static boolean isToAdd(GiftRegistryVO giftRegistry,
                                      GiftRegistryItemVO item)
        This is a helper method that is called when only the gift registry value object and gift item is available. It determines if a gift item is to be created into the database. A gift item is to be added into database if one of the following conditions are satisfied:
        • The item has neither giftItemId, nor part number
        • The item has a part number, but the part number plus an optional partAuxKey does not identify any item for the given registry
        Parameters:
        giftRegistryVO - the value object of the gift registry that the gift item belongs
        item - The gift item to be examined
        Returns:
        true if the gift item is to be added. False otherwise.
      • isToAdd

        public static boolean isToAdd(GiftRegistryPurchaseRecordVO record)
        This is a helper method that is called when only the gift registry purchase record value object is available. It determines if a gift registry purchase record is to be created into the database.
        Parameters:
        record - the value object of the gift registry purchase record
        Returns:
        true if the purchase record is to be added. False otherwise.
      • encrypt

        public static java.lang.String encrypt(java.lang.String value)
        Encrypts a given string. the key of the encryption is commerce's merchant key
        Parameters:
        value - the string to be encrypted
        Returns:
        the encrypted string
      • decrypt

        public static java.lang.String decrypt(java.lang.String value)
        decrypts a given string. The key of the encryption is commerce's merchant key
        Parameters:
        value - the string to be encrypted
        Returns:
        the encrypted string
      • getGiftRegistrySearchKeyValueGenerator

        public static com.ibm.commerce.component.giftregistry.commands.GenerateGiftRegistrySearchKeyValuesCmd getGiftRegistrySearchKeyValueGenerator(CommandContext context)
                                                                                                                                              throws ECException
        Gets an instance of GenerateGiftRegistrySearchKeyValuesCmd's implementation, and assign the given command context to the command. The instance is neither changed or executed. It is upto the user of the returned command to set required parameters, and then execute the command.
        Parameters:
        context - - The command context for the instance.
        Returns:
        Instance of GenerateGiftRegistrySearchKeyValuesCmd for the given context and store identifier.
        Throws:
        ECException