com.ibm.commerce.giftcenter.facade.server.helpers

Class GiftCenterComponentHelper

  • java.lang.Object
    • com.ibm.commerce.giftcenter.facade.server.helpers.GiftCenterComponentHelper


  • public class GiftCenterComponentHelper
    extends java.lang.Object
    A utility class that has some of the common methods that are used by the gift center component.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.lang.Long addAddressUsingSQL(ContactInfoType contactInfoType)
      Inserts a record into the GRADDR table using the values from logical ContactInfoType type.
      static java.lang.String buildErrorKeyForRuleValidationError(java.lang.String primaryErrorKey, GiftListType giftList, java.lang.Integer ruleName)
      This method constructs the error key to be returned to the client when the rule validation check fails for a gift list.
      static void clearUsersDefaultWishList(java.lang.String userId)
      Sets a user"s default wish list to active.
      static CommandContext createCommandContext()
      Creates a clone of the command context associated with the current activity token.
      static java.util.List executeSelectStatement(java.lang.String query, java.util.Map parameters)
      Executes a select query
      static java.lang.String generateSearchKeyFirstName(java.lang.String firstName, java.lang.Object... parameters)
      Generates the SOUNDEX value for an ASCII input as the search key value in case of DB2 and Oracle databases.
      static java.lang.String generateSearchKeyLastName(java.lang.String lastName, java.lang.Object... parameters)
      Generates the SOUNDEX value for an ASCII input as the search key value in case of DB2 and Oracle databases.
      static CatalogEntryType getCatalogEntry(CatalogEntryIdentifierType catalogEntryIdentifier)
      Fetches the catalog entry details based on the catalog entry identifier passed.
      static CatalogEntryAccessBean getCatalogEntryFromCache(CatalogEntryIdentifierType catalogEntryIdentifier)
      Fetches the catalog entry details based on the catalog entry identifier passed.
      static java.lang.Object[] getControlParamValues(ActionExpression actionExpression, java.lang.String paramName)
      Returns the control parameter values for parameter name present in the action expression
      static java.sql.Date getDate(java.lang.Object inputDate)
      This method formats the date present in logic gift list noun part into java.sql.Date.
      static int getEventIdforAnEventName(java.lang.String eventName, java.lang.String storeId)
      Returns the event_id corresponding to a event name and store identifiers from the gift list event table.
      static java.lang.String getEventTypeName(java.lang.Integer eventId)
      Returns the gift list event type name for a particular event id
      static java.lang.String getExternalIdentifer(com.ibm.commerce.foundation.common.datatypes.GiftListIdentifierType giftListIdentifier)
      Retrieves the external identifier for the gift list.
      static PhysicalDataContainer getGiftList(java.lang.Long giftListID)
      Fetches the PhysicalDataContainer based on UniqueID.
      static com.ibm.commerce.giftcenter.facade.server.helpers.GiftListAddressValidator getGiftListAddressValidator()
      Gets the instance of the GiftListAddressValidator which is used for perform address field validation of the various address noun parts in the gift list noun.
      static com.ibm.commerce.giftcenter.facade.server.entity.datatypes.Grgftreg getGiftListByExternalId(java.lang.String externalId)
      Retrieves the physical gift list object based on the external identifier.
      static GiftListContextUpdateCmd getGiftListContextUpdateCmd()
      Gets the instance of GiftListContextUpdateCmd which is used for performing context updates.
      static GiftListEncryptionHelper getGiftListEncryptionHelper()
      Gets the instance of the GiftListEncryptionHelper which is used for performing encryption in GRUSERAUTH tables.
      static java.lang.String getGiftListOwner(java.lang.String uniqueID)
      Returns the owner of the gift list.
      static PhysicalDataContainer getGiftListRegistrants(java.lang.Long giftListID)
      Fetches the PhysicalDataContainer based on UniqueID.
      static java.lang.String getGuestAccessPassword(java.lang.String giftListUniqueId)
      Returns the guest access password for a registry which requires password for a gift giver.
      static JDBCQueryService getJDBCQueryService()
      Gets the JDBC query service instance.
      static java.lang.Integer getLanguageId()
      Returns the languageId from the service context
      static java.util.Map<java.lang.String,java.lang.Long> getRegistrantsAddresses(java.lang.Long giftListUniqueID)
      Returns the registrant"s addressId and co-registrant"s addressId for a given gift list.
      static java.lang.Long getRunAsId()
      Gets the runAsId from the service context
      static java.lang.Integer getStoreId()
      Gets the storeId from the service context
      static GiftListType populateAccessKeys(GiftListType giftListType)
      Generates and set access keys to the input GiftListType object.
      static GiftListType populateExternalId(GiftListType giftListType)
      Generates the external identifier for an input GiftListType object.
      static void resolveGiftListRegistrant(GiftListType giftList, GiftListRegistrantType giftListRegistrant)
      Resolves the gift list registrant noun part based on the registrantID or GiftList uniqueID or GifList ExternalId
      static void resolveNoun(GiftListType giftList)
      Resolves the gift list noun based on the unique ID or the external ID.
      static void setNewDefaultWishList(java.lang.String userId)
      Sets a user"s active wish list to be the default wish list.
      static void updateGiftList(java.lang.Long giftListID)
      Updates the lastUpdate property of a gift list.
      static boolean useOneWayHashEncryptionForGuestAccessPassword()
      Returns a boolean flag to indicate whether one way hash encryption should be used for manage access passwords.
      static boolean useOneWayHashEncryptionForManageAccessPassword()
      Returns a boolean flag to indicate whether one way hash encryption should be used for manage access passwords.
      static void validateCatalogEntry(CatalogEntryIdentifierType catalogEntryIdentifier)
      Validates the catalog entry identifier by resolving it.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getEventIdforAnEventName

        public static int getEventIdforAnEventName(java.lang.String eventName,
                                                   java.lang.String storeId)
                                            throws AbstractApplicationException
        Returns the event_id corresponding to a event name and store identifiers from the gift list event table. For an invalid event name the method returns 0.
        Parameters:
        eventName - The event name (e.g. Wedding)
        storeId - The store identifier
        Returns:
        The event identifier. If the event identifier cannot be found, the method returns 0.
        Throws:
        AbstractApplicationException
      • executeSelectStatement

        public static java.util.List executeSelectStatement(java.lang.String query,
                                                            java.util.Map parameters)
                                                     throws java.lang.Exception
        Executes a select query
        Parameters:
        query - The SQL query
        parameters - The substitution parameters
        Returns:
        A list of objects
        Throws:
        java.lang.Exception - An exception thrown by the data service during the execution of the update statement
      • generateSearchKeyFirstName

        public static java.lang.String generateSearchKeyFirstName(java.lang.String firstName,
                                                                  java.lang.Object... parameters)
                                                           throws AbstractApplicationException
        Generates the SOUNDEX value for an ASCII input as the search key value in case of DB2 and Oracle databases. Returns null otherwise.
        Parameters:
        firstName - The input for which the SOUNDEX value needs to be generated.
        parameters - Optional parameters which can assist in generation.
        Returns:
        SOUNDEX value for ASCII input in case of DB2 and Oracle databases. null, otherwise.
        Throws:
        AbstractApplicationException
      • generateSearchKeyLastName

        public static java.lang.String generateSearchKeyLastName(java.lang.String lastName,
                                                                 java.lang.Object... parameters)
                                                          throws AbstractApplicationException
        Generates the SOUNDEX value for an ASCII input as the search key value in case of DB2 and Oracle databases. Otherwise returns null
        Parameters:
        lastName - - The input for which the SOUNDEX value needs to be generated.
        parameters - - Optional parameters which can assist in generation.
        Returns:
        - SOUNDEX value for an ASCII input, for DB2 and Oracle databases. Otherwise, returns null.
        Throws:
        - - ECException
        AbstractApplicationException
        See Also:
        GenerateGiftRegistrySearchKeyValuesCmd#generateSearchKeyLastName(String, Object...)
      • getJDBCQueryService

        public static JDBCQueryService getJDBCQueryService()
        Gets the JDBC query service instance.
        Returns:
        The JDBC query service instance
      • validateCatalogEntry

        public static void validateCatalogEntry(CatalogEntryIdentifierType catalogEntryIdentifier)
                                         throws AbstractApplicationException
        Validates the catalog entry identifier by resolving it.
        Parameters:
        catalogEntryIdentifier - The catalog entry identifier to be validated.
        Throws:
        AbstractApplicationException - - When the catalog entry is invalid. The following error keys are returned to signify the various errors encountered during validation. _APP_GIFTLIST_ITEM_CATENTRYDETAIL_MISSING - When the catalog entry identifier is null. _APP_GIFTLIST_ITEM_CATALOGENTRY_INVALID - When the catalog entry belong to WebSphere Commerce catalog system and resolves to a product. _APP_GIFTLIST_ITEM_CATALOGENTRY_NOT_FOUND - When the catalog entry cannot be found. This means that the catalog entry does not belong to WebSphere Commerce catalog system.
      • getCatalogEntry

        public static CatalogEntryType getCatalogEntry(CatalogEntryIdentifierType catalogEntryIdentifier)
                                                throws AbstractApplicationException
        Fetches the catalog entry details based on the catalog entry identifier passed. If the catalog entry could not be resolved, this method returns null.
        Parameters:
        catalogEntryIdentifier - containing either the unique ID of the catalog entry or the part number. The unique ID is given preference over the part number if both are passed.
        Returns:
        The catalog entry object if found. null is returned when,
      • catalogEntryIdentifier is null
      • neither the unique ID nor part number are provided
      • The catalog entry could not be resolved
      • Throws:
        AbstractApplicationException - - When an error occurs while fetching the catalog entry.
      • getCatalogEntryFromCache

        public static CatalogEntryAccessBean getCatalogEntryFromCache(CatalogEntryIdentifierType catalogEntryIdentifier)
                                                               throws AbstractApplicationException
        Fetches the catalog entry details based on the catalog entry identifier passed. If the catalog entry could not be resolved, this method returns null.
        Parameters:
        catalogEntryIdentifier - containing either the unique ID of the catalog entry or the part number. The unique ID is given preference over the part number if both are passed.
        Returns:
        The catalog entry access bean object if found. null is returned when,
      • catalogEntryIdentifier is null
      • neither the unique ID nor part number are provided
      • The catalog entry could not be resolved
      • Throws:
        AbstractApplicationException - - When an error occurs while fetching the catalog entry.
      • resolveGiftListRegistrant

        public static void resolveGiftListRegistrant(GiftListType giftList,
                                                     GiftListRegistrantType giftListRegistrant)
                                              throws AbstractApplicationException
        Resolves the gift list registrant noun part based on the registrantID or GiftList uniqueID or GifList ExternalId
        Parameters:
        giftList - - Logical GiftListType.
        giftListRegistrant - - GiftListRegistrantType noun part to be resolved.
        Throws:
        AbstractApplicationException - - When the noun cannot be resolved.
      • getGiftList

        public static PhysicalDataContainer getGiftList(java.lang.Long giftListID)
                                                 throws AbstractApplicationException
        Fetches the PhysicalDataContainer based on UniqueID. The physical data container is initialized using the /GiftList[GiftListIdentifier[(UniqueID=)]] with the IBM_IdResolve access profile.
        Parameters:
        giftListID - UniqueID of the gift list.
        Returns:
        PhysicalDataContainer containing the physical gift lists.
        Throws:
        AbstractApplicationException
        See Also:
        GiftCenterMetadata#getDataServiceFacade()}
      • getExternalIdentifer

        public static java.lang.String getExternalIdentifer(com.ibm.commerce.foundation.common.datatypes.GiftListIdentifierType giftListIdentifier)
                                                     throws AbstractApplicationException
        Retrieves the external identifier for the gift list.
        Parameters:
        giftListIdentifier - The GiftListIdentifierType object of the gift list noun.
        Returns:
        The external identifier of the gift list or null when the external identifier was not found.
        Throws:
        AbstractApplicationException - When the external identifier could not be resolved. Possible reasons are: The unique ID of the gift list is not valid.
      • getGiftListRegistrants

        public static PhysicalDataContainer getGiftListRegistrants(java.lang.Long giftListID)
                                                            throws AbstractApplicationException
        Fetches the PhysicalDataContainer based on UniqueID. The physical data container is initialized using the /GiftList[GiftListIdentifier[(UniqueID=)]] with the IBM_GiftRegistrant_IdResolve access profile.
        Parameters:
        giftListID - - UniqueID of the gift list.
        Returns:
        PhysicalDataContainer containing the physical gift lists.
        Throws:
        AbstractApplicationException
        See Also:
        GiftCenterMetadata#getDataServiceFacade()}
      • getRegistrantsAddresses

        public static java.util.Map<java.lang.String,java.lang.Long> getRegistrantsAddresses(java.lang.Long giftListUniqueID)
                                                                                      throws AbstractApplicationException
        Returns the registrant"s addressId and co-registrant"s addressId for a given gift list.
        Parameters:
        giftListUniqueID - - UniqueId of the gift list
        Returns:
        Map - Map containing registrant"s and co-registrant"s address id
        Throws:
        AbstractApplicationException
      • setNewDefaultWishList

        public static void setNewDefaultWishList(java.lang.String userId)
                                          throws DataMediatorException
        Sets a user"s active wish list to be the default wish list. If the user has multiple active wish lists, the first wish list returned is marked as the default.
        Parameters:
        userId - The ID of the user who owns the wish list.
        Throws:
        DataMediatorException
      • clearUsersDefaultWishList

        public static void clearUsersDefaultWishList(java.lang.String userId)
                                              throws DataMediatorException
        Sets a user"s default wish list to active.
        Parameters:
        userId - The ID of the user who owns the wish list.
        Throws:
        DataMediatorException
      • getGiftListEncryptionHelper

        public static GiftListEncryptionHelper getGiftListEncryptionHelper()
        Gets the instance of the GiftListEncryptionHelper which is used for performing encryption in GRUSERAUTH tables.
        Returns:
        an instance of GiftListEncryptionHelper
        See Also:
        GiftListEncryptionHelper}
      • getGiftListContextUpdateCmd

        public static GiftListContextUpdateCmd getGiftListContextUpdateCmd()
        Gets the instance of GiftListContextUpdateCmd which is used for performing context updates.
        Returns:
        an instance of GiftListContextUpdateCmd
        See Also:
        GiftListContextUpdateCmd}
      • useOneWayHashEncryptionForManageAccessPassword

        public static boolean useOneWayHashEncryptionForManageAccessPassword()
        Returns a boolean flag to indicate whether one way hash encryption should be used for manage access passwords. This method reads from the component configuration.
        Returns:
        true if one way encryption is enabled. Otherwise, returns false.
      • useOneWayHashEncryptionForGuestAccessPassword

        public static boolean useOneWayHashEncryptionForGuestAccessPassword()
        Returns a boolean flag to indicate whether one way hash encryption should be used for manage access passwords. This method reads from the component configuration.
        Returns:
        true, if one way hash encryption is enabled. false, otherwise.
      • getGiftListOwner

        public static java.lang.String getGiftListOwner(java.lang.String uniqueID)
                                                 throws AbstractApplicationException
        Returns the owner of the gift list.
        Parameters:
        uniqueID - The gift list uniqueID
        Returns:
        The owner"s user ID.
        Throws:
        AbstractApplicationException - When the owner cannot be retrieved.
      • createCommandContext

        public static CommandContext createCommandContext()
        Creates a clone of the command context associated with the current activity token.
        Returns:
        A command context.
      • addAddressUsingSQL

        public static java.lang.Long addAddressUsingSQL(ContactInfoType contactInfoType)
                                                 throws AbstractApplicationException
        Inserts a record into the GRADDR table using the values from logical ContactInfoType type. The method can also pass the user data parameter to the table by following the example below:
         
         ContactInfoType contactInfo = CommerceFoundationFactory.eINSTANCE.createContactInfoType();
         UserDataType userDataType = CommerceFoundationFactory.eINSTANCE.createUserDataType();
         userDataType.getUserDataField().put("field1", "1001"); // Maps to GRADDR.FIELD1 INTEGER 
         userDataType.getUserDataField().put("field2", "1002"); // Maps to GRADDR.FIELD2 INTEGER 
         userDataType.getUserDataField().put("field3", "user data field 1"); // Maps to GRADDR.FIELD3 VARCHAR(64) 
         userDataType.getUserDataField().put("field4", "user data field 2"); // Maps to GRADDR.FIELD4 VARCHAR(64) 
         userDataType.getUserDataField().put("field5", "user data field 3"); // Maps to GRADDR.FIELD5 VARCHAR(64) 
         contactInfo.setUserData(userDataType);
         
         
        Parameters:
        contactInfoType - the ContactInfoType that contains the address.
        Returns:
        the identifier of the new address.
        Throws:
        AbstractApplicationException
      • getControlParamValues

        public static java.lang.Object[] getControlParamValues(ActionExpression actionExpression,
                                                               java.lang.String paramName)
        Returns the control parameter values for parameter name present in the action expression
        Parameters:
        actionExpression - The action expression which contains the control parameters
        paramName - The control parameter name
        Returns:
        An object array containing the parameter values
      • getEventTypeName

        public static java.lang.String getEventTypeName(java.lang.Integer eventId)
                                                 throws AbstractApplicationException
        Returns the gift list event type name for a particular event id
        Parameters:
        eventId - The gift list event id for which the event name need to be known
        Returns:
        The event name
        Throws:
        AbstractApplicationException
      • getDate

        public static java.sql.Date getDate(java.lang.Object inputDate)
        This method formats the date present in logic gift list noun part into java.sql.Date. It converts java.util.Date into java.sql.Date using SDODataTypeHelper
        Parameters:
        inputDate - the date in java.util.Date format
        Returns:
        formatted java.sql.Date
      • getGuestAccessPassword

        public static java.lang.String getGuestAccessPassword(java.lang.String giftListUniqueId)
                                                       throws AbstractApplicationException
        Returns the guest access password for a registry which requires password for a gift giver.
        Parameters:
        giftListUniqueId - The gift list unique identifier
        Returns:
        The guest access password
        Throws:
        AbstractApplicationException
      • getGiftListByExternalId

        public static com.ibm.commerce.giftcenter.facade.server.entity.datatypes.Grgftreg getGiftListByExternalId(java.lang.String externalId)
                                                                                                           throws AbstractApplicationException
        Retrieves the physical gift list object based on the external identifier.
        Parameters:
        externalId - The external identifier of the gift list.
        Returns:
        The physical gift list if found.
        Throws:
        AbstractApplicationException - When an error occurs while fetching the gift list or when the gift list is not found.
      • buildErrorKeyForRuleValidationError

        public static java.lang.String buildErrorKeyForRuleValidationError(java.lang.String primaryErrorKey,
                                                                           GiftListType giftList,
                                                                           java.lang.Integer ruleName)
        This method constructs the error key to be returned to the client when the rule validation check fails for a gift list. The error key returned by this method follows the below mentioned format:
         <primaryErrorKey>.<Event>.<ruleName>
         
        Parameters:
        primaryErrorKey - The primary error key string to which additional reason information is appended to.
        giftList - The gift list noun for which the rule validation check failed.
        ruleName - The rule for which the validation failed.
        Returns:
        The error key which is constructed based on the rule name, noun and the primary error key.
      • getGiftListAddressValidator

        public static com.ibm.commerce.giftcenter.facade.server.helpers.GiftListAddressValidator getGiftListAddressValidator()
        Gets the instance of the GiftListAddressValidator which is used for perform address field validation of the various address noun parts in the gift list noun.
        Returns:
        an instance of GiftListAddressValidator
        See Also:
        GiftListAddressValidator}