com.ibm.commerce.promotion.uniquecode.util

Class UniquePromotionCodeUtils

  • java.lang.Object
    • com.ibm.commerce.promotion.uniquecode.util.UniquePromotionCodeUtils


  • public class UniquePromotionCodeUtils
    extends java.lang.Object
    The utility class
    • Method Detail

      • getPromotionCodeSpec

        public static PhysicalDataContainer getPromotionCodeSpec(java.lang.String promoId)
                                                          throws DataMediatorException
        Get Physical Data Container of code specification
        Parameters:
        promoId - the target promotion Id
        Returns:
        the physical data container for the code specification
        Throws:
        DataMediatorException - the database query exception
      • getPromotionCodePool

        public static PhysicalDataContainer getPromotionCodePool(java.lang.String code)
                                                          throws DataMediatorException
        This method is used to return a PhysicalDataContainer which contains the Px_cdpool physical objects. The objects are obtained using an expression that searches by the promotion code.
        Parameters:
        code - The promotion code to use to search for Px_cdpool objects.
        Returns:
        The PhysicalDataContainer containing the physical objects.
        Throws:
        DataMediatorException - if an exception is encountered on database query.
      • getPromotionCodeSpecPhysicalObject

        public static com.ibm.commerce.promotion.facade.server.entity.datatypes.Px_cdspec getPromotionCodeSpecPhysicalObject(int promoId)
        Get the promotion code specification physical object by promotion Id
        Parameters:
        promoId - the target promotion Id
        Returns:
        the promotion code specification physical object
      • getPromotionCodeSpecPhysicalObject

        public static com.ibm.commerce.promotion.facade.server.entity.datatypes.Px_cdspec getPromotionCodeSpecPhysicalObject(PhysicalDataContainer promoPDC)
        Get the promotion physical object by the Physical data container
        Parameters:
        promoPDC - the promotion physical data container
        Returns:
        the promotion code specification physical object
      • getPromotionPhysicalObject

        public static Px_promotion getPromotionPhysicalObject(PhysicalDataContainer promoPDC)
        The promotion physical data object of the promotion
        Parameters:
        promoPDC - the promotion physical data container
        Returns:
        the physical data object
      • getPromotionById

        public static PhysicalDataContainer getPromotionById(java.lang.String promoId)
                                                      throws DataMediatorException
        Get physical data object of promotion
        Parameters:
        promoId - the target promotion Id
        Returns:
        the promotion data container that contains the promotion physical object
        Throws:
        DataMediatorException
      • getPromotionCodes

        public static PhysicalDataContainer getPromotionCodes(java.lang.String promoId)
                                                       throws DataMediatorException
        Get the promotion related promotion code. This method uses the PX_CDPROMO table to build the relationship between PX_CDPOOL and PX_PROMOTION.
        Parameters:
        promoId - the target promotion Id
        Returns:
        the promotion physical object
        Throws:
        DataMediatorException
      • getPromotionCodesByReferenceID

        public static PhysicalDataContainer getPromotionCodesByReferenceID(java.util.List referenceIDs)
                                                                    throws DataMediatorException
        Get the promotion codes with the passed list of referenceIDs.
        Parameters:
        referenceIDs - This refers to the values in the PX_CDPOOL.REFERENCE_ID column.
        Returns:
        The physical data container containing Px_cdpool physical objects.
        Throws:
        DataMediatorException - if an error occurs during the execution of the query.
      • getPromotionCodesByOrderId

        public static PhysicalDataContainer getPromotionCodesByOrderId(java.lang.Long orderId)
                                                                throws DataMediatorException
        Get physical data object of unique promotion by unique code
        Parameters:
        orderId - A Long representing the order id to be used in the method.
        Returns:
        A PhysicalDataContainer representing the unique code data container that contains the unique code physical object
        Throws:
        DataMediatorException - This exception is raised when any DataMediatorException happen.
      • getEmptyPhysicalDataContainer

        public static PhysicalDataContainer getEmptyPhysicalDataContainer()
        Get an empty Physical Data Container
        Returns:
        an empty physical data container
      • getKeyManager

        public static KeyManager getKeyManager()
        Get the key manager for the promotion component
        Returns:
        key manager object
      • getConfigProperties

        public static java.lang.String getConfigProperties(java.lang.String configKey)
        Get the configuration property value from the configuration properties file The configuration group is "UniquePromotionCode" which stores in the wc-admin-component.xml file
        Parameters:
        configKey - the configuration property name
        Returns:
        the configuration value to the key
      • isAppliedToOrderCodeUsageStatus

        public static boolean isAppliedToOrderCodeUsageStatus(int status)
        This method validates if a unique promotion code status is applied to an order status.
        Parameters:
        status - The unique promotion usage status which need to validate
        Returns:
        A boolean representing if the unique code status is applied to an order status
      • isRedeemedToOrderCodeUsageStatus

        public static boolean isRedeemedToOrderCodeUsageStatus(int status)
        This method validates if a unique promotion code status is redeemed to an order status.
        Parameters:
        status - The unique promotion usage status which need to validate
        Returns:
        A boolean representing if the unique code status is applied to an order status
      • createNewProcessFile

        public static java.lang.String createNewProcessFile(java.lang.String fileUploadId)
                                                     throws QueryServiceApplicationException,
                                                            java.sql.SQLException
        Create new process file record with file upload id.
        Parameters:
        fileUploadId - A String representing the file upload record id
        Returns:
        A String representing the process file id
        Throws:
        QueryServiceApplicationException
        java.sql.SQLException
      • updateProcessFileStatus

        public static int updateProcessFileStatus(java.lang.String processFileId,
                                                  int newStatus)
                                           throws QueryServiceApplicationException,
                                                  java.sql.SQLException
        This method is used to update process file status.
        Parameters:
        processFileId - A String representing the process file record id
        newStatus - An Integer value representing the new status
        Returns:
        An Integer value representing the update record size
        Throws:
        QueryServiceApplicationException
        java.sql.SQLException
      • updateProcessFileProcessInfo

        public static int updateProcessFileProcessInfo(java.lang.String processFileId,
                                                       java.lang.String processInfo)
                                                throws QueryServiceApplicationException,
                                                       java.sql.SQLException
        This method is used to update process file process info.
        Parameters:
        processFileId - A String representing the process file record id
        processInfo - A String representing the process info message
        Returns:
        An Integer value representing the update record size
        Throws:
        QueryServiceApplicationException
        java.sql.SQLException
      • updateProcessFileEndTime

        public static int updateProcessFileEndTime(java.lang.String processFileId)
                                            throws QueryServiceApplicationException,
                                                   java.sql.SQLException
        This method is used to update process file end time
        Parameters:
        processFileId - A String representing the process file record id
        Returns:
        An Integer value representing the update record size
        Throws:
        QueryServiceApplicationException
        java.sql.SQLException
      • getCDUsageByOrderId

        public static PhysicalDataContainer getCDUsageByOrderId(java.lang.Long orderId)
                                                         throws DataMediatorException
        Get physical data objects of Px_cdusage by order id.
        Parameters:
        orderId - A Long representing the order id to be used in the method.
        Returns:
        A PhysicalDataContainer representing the promotion code usage data container
        Throws:
        DataMediatorException - This exception is raised when any DataMediatorException happens.
      • getCDUsageByOrderIdAndPoolId

        public static PhysicalDataContainer getCDUsageByOrderIdAndPoolId(java.lang.Long orderId,
                                                                         java.lang.Long cdPoolId)
                                                                  throws DataMediatorException
        Get physical data object of Px_cdusage by order id and promotion code id.
        Parameters:
        orderId - A Long representing the order id to be used in the method.
        cdPoolId - A Long representing the promotion code id to be used in the method.
        Returns:
        A PhysicalDataContainer representing the promotion code usage data container
        Throws:
        DataMediatorException - This exception is raised when any DataMediatorException happen.
      • getPromotionByUniqueCodeAndStatus

        public static PhysicalDataContainer getPromotionByUniqueCodeAndStatus(java.lang.String uniqueCode,
                                                                              java.util.List listPromotionStatus,
                                                                              java.util.List listPxCdPromoStatus,
                                                                              java.util.List listPxCdPoolStatus)
                                                                       throws DataMediatorException
        Get physical data object of Px_promotion by unique promotion code, the status of promotion, the status of Px_cdpromo and the status of Px_cdusage.
        Parameters:
        uniqueCode - A String representing the unique promotion code of promotion
        listPromotionStatus - A List representing the allowed status of promotion. If current parameter not set, it will default as 'Activate' status.
        listPxCdPromoStatus - A List representing the allowed status of Px_cdpromo. If current parameter not set, it will default as 'Active' status.
        listPxCdPoolStatus - A List representing the allowed status of Px_cdusage. If current parameter not set, it will default as 'Active' status.
        Returns:
        A PhysicalDataContainer representing the promotion physical data container that contains the promotion physical object
        Throws:
        DataMediatorException - This exception is raised when any DataMediatorException happen.
      • getPromotionByOrderId

        public static PhysicalDataContainer getPromotionByOrderId(java.lang.String orderId)
                                                           throws DataMediatorException
        Get physical data object of Px_promotion by order id.
        Parameters:
        orderId - A String representing the order id
        Returns:
        A PhysicalDataContainer representing the promotion physical data container that contains the promotion physical object
        Throws:
        DataMediatorException - This exception is raised when any DataMediatorException happen.
      • getPxCdPromoByPoolIDAndPromotionID

        public static PhysicalDataContainer getPxCdPromoByPoolIDAndPromotionID(java.lang.String aPx_promotionID,
                                                                               java.lang.String aPx_poolID)
                                                                        throws DataMediatorException
        Get all Px_cdpromo physical data objects by PX_PROMOTION_ID and PX_CDPOOL_ID.
        Parameters:
        aPx_promotionID - A String representing the PX_PROMOTION_ID.
        aPx_poolID - A String representing the PX_CDPOOL_ID.
        Returns:
        The PhysicalDataContainer containing the Px_cdpromo physical objects.
        Throws:
        DataMediatorException - when an error is encountered on executing the query.
      • getPxCdPromoByPromotionID

        public static PhysicalDataContainer getPxCdPromoByPromotionID(java.lang.String aPx_promotionID)
                                                               throws DataMediatorException
        Get all Px_cdpromo physical data objects by PX_PROMOTION_ID.
        Parameters:
        aPx_promotionID - A String representing the PX_PROMOTION_ID.
        Returns:
        The PhysicalDataContainer containing the Px_cdpromo physical objects.
        Throws:
        DataMediatorException - when an error is encountered on executing the query.
      • getActivePxCdPromoByPoolID

        public static PhysicalDataContainer getActivePxCdPromoByPoolID(java.lang.String aPx_poolID)
                                                                throws DataMediatorException
        Get active Px_cdpromo physical data objects by PX_CDPOOL_ID.
        Parameters:
        aPx_poolID - A String representing the PX_CDPOOL_ID.
        Returns:
        The PhysicalDataContainer containing the Px_cdpromo physical objects.
        Throws:
        DataMediatorException - when an error is encountered on executing the query.
      • getXMLDocument

        public static org.w3c.dom.Document getXMLDocument(java.lang.String xmlString)
        Generator the XML Document object based on the XML String input.
        Parameters:
        xmlString - xml string to be built to document.
        Returns:
        org.w3c.dom.Document.
      • isCodeAvailableToUse

        public static boolean isCodeAvailableToUse(java.lang.Long cdPoolId)
        Validates the code to see if the code is still available to use.
        Parameters:
        cdPoolId - a unique ID for the code.
        Returns:
        true if and only if the code has not been used and it is still available to use.
      • validateUniqueCodeUsageStatus

        public static boolean validateUniqueCodeUsageStatus(int status)
        This method validates if a unique promotion code can adds to an order by its usage status. If the unique promotion code usage status matches unassigned, assigned or claimed, the unique promotion code can add to an order.
        Parameters:
        status - The unique promotion usage status which need to validate
        Returns:
        A boolean representing if the unique code can adds to an order
      • getExistingCodesByCodeStoreIDAndInternalID

        public static java.util.List getExistingCodesByCodeStoreIDAndInternalID(java.util.List allPromotionCodes,
                                                                                java.lang.String storeID,
                                                                                java.lang.String codeMin,
                                                                                java.lang.String codeMax,
                                                                                java.lang.String internalID)
        This method is used to determine the promotion codes that already exist in the PX_CDPOOL table from a list of passed promotionCodes belonging to store with ID storeID. The codeMin and codeMax parameters are used to control the search expression using a between predicate. The internalID parameter is used in the query for the INTERNAL_ID column in the PX_CDPOOL table.
        Parameters:
        allPromotionCodes - The promotion codes to check for in the PX_CDPOOL table.
        storeID - The store ID for the codes in the PX_CDPOOL table.
        codeMin - The minimum code to compare with in the search expression.
        codeMax - The maximum code to compare with in the search expression.
        internalID - The value for the INTERNAL_ID column in PX_CDPOOL table. This has a value of 0 for unique promotion codes and the associated promotion ID for public promotion codes.
        Returns:
        The promotion codes found to already exist in the PX_CDPOOL table.
      • getExistingCodesByCodeAndStoreID

        public static java.util.List getExistingCodesByCodeAndStoreID(java.util.List allPromotionCodes,
                                                                      java.lang.String storeID,
                                                                      java.lang.String codeMin,
                                                                      java.lang.String codeMax)
        This method is used to determine the promotion codes that already exist in the PX_CDPOOL table from a list of passed promotionCodes belonging to store with ID storeID. The codeMin and codeMax parameters are used to control the search expression using a between predicate.
        Parameters:
        allPromotionCodes - The promotion codes to check for in the PX_CDPOOL table.
        storeID - The store ID for the codes in the PX_CDPOOL table.
        codeMin - The minimum code to compare with in the search expression.
        codeMax - The maximum code to compare with in the search expression.
        Returns:
        The promotion codes found to already exist in the PX_CDPOOL table.
      • deleteCodesByPromotionIdAndUsagetype

        public static void deleteCodesByPromotionIdAndUsagetype(java.lang.String promotionId,
                                                                java.lang.String usageType)
        Remove entries from px_cdpool table based on code's px_promotion_id and usagetype (i.e. 0: Private codes, single usage. 1: Public codes, multiple usage)
        Parameters:
        promotionId - the promotion id of the code
        usageType - a string value (i.e. "0" or "1") indicating whether the code(s) is private or public respectively
      • getExistingCodesByCodeStoreIDInternalIDAndReferenceIDUsingOracleDMLErrorLog

        public static java.util.List getExistingCodesByCodeStoreIDInternalIDAndReferenceIDUsingOracleDMLErrorLog(java.lang.String storeID,
                                                                                                                 java.lang.String internalID,
                                                                                                                 java.lang.String referenceID)
        This method is used to determine the promotion codes that already exist in the PX_CDPOOL by using the PX_CDPOOL_ERROR table that is populated with the duplicates by Oracle's DML Error Logging feature and the codes belong to store with ID storeID. The internalID parameter is used in the query for the INTERNAL_ID column in the PX_CDPOOL_ERROR table. The referenceID parameter is used in the query for the REFERENCE_ID column in the PX_CDPOOL_ERROR table.
        Parameters:
        storeID - The store ID for the codes in the PX_CDPOOL_ERROR table.
        internalID - The value for the INTERNAL_ID column in PX_CDPOOL_ERROR table. This has a value of 0 for unique promotion codes and the associated promotion ID for public promotion codes.
        referenceID - The value for the REFERENCE_ID COLUMN in the PX_CDPOOL_ERROR table. This is the promotion id that the code is associated with.
        Returns:
        The promotion codes found to already exist in the PX_CDPOOL table. Will return an empty array list if no duplicates were found.
      • deletePromotionCodesFromOracleDMLErrorLogByStoreIDInternalIDAndReferenceID

        public static void deletePromotionCodesFromOracleDMLErrorLogByStoreIDInternalIDAndReferenceID(java.lang.String storeID,
                                                                                                      java.lang.String internalID,
                                                                                                      java.lang.String referenceID)
        Removes all codes from the PX_CDPOOL_ERROR Table based on the STORE_ID, INTERNAL_ID and REFERENCE_ID columns.
        Parameters:
        storeID - The store id for the codes in the PX_CDPOOL_ERROR table.
        internalID - The internal id (0 for unique promotion codes) for the codes in the PX_CDPOOL_ERROR table.
        referenceID - The reference id (the promotion id that the code is associated with) for the codes in the PX_CDPOOL_ERROR table.
      • isPromoCodePerformanceEnhancementEnabled

        public static boolean isPromoCodePerformanceEnhancementEnabled()
        This method checks if the schema change from APAR#JR45153 has been applied to the database.
        Returns:
        true if the promotion code enhancement has been enabled; false otherwise.