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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.lang.String
createNewProcessFile(java.lang.String fileUploadId)
Create new process file record with file upload id.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.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.static PhysicalDataContainer
getActivePxCdPromoByPoolID(java.lang.String aPx_poolID)
Get activePx_cdpromo
physical data objects byPX_CDPOOL_ID
.static PhysicalDataContainer
getCDUsageByOrderId(java.lang.Long orderId)
Get physical data objects ofPx_cdusage
by order id.static PhysicalDataContainer
getCDUsageByOrderIdAndPoolId(java.lang.Long orderId, java.lang.Long cdPoolId)
Get physical data object ofPx_cdusage
by order id and promotion code id.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 filestatic PhysicalDataContainer
getEmptyPhysicalDataContainer()
Get an empty Physical Data Containerstatic 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 passedpromotionCodes
belonging to store with IDstoreID
.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 passedpromotionCodes
belonging to store with IDstoreID
.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 IDstoreID
.static KeyManager
getKeyManager()
Get the key manager for the promotion componentstatic PhysicalDataContainer
getPromotionById(java.lang.String promoId)
Get physical data object of promotionstatic PhysicalDataContainer
getPromotionByOrderId(java.lang.String orderId)
Get physical data object ofPx_promotion
by order id.static PhysicalDataContainer
getPromotionByUniqueCodeAndStatus(java.lang.String uniqueCode, java.util.List listPromotionStatus, java.util.List listPxCdPromoStatus, java.util.List listPxCdPoolStatus)
Get physical data object ofPx_promotion
by unique promotion code, the status of promotion, the status ofPx_cdpromo
and the status ofPx_cdusage
.static PhysicalDataContainer
getPromotionCodePool(java.lang.String code)
This method is used to return aPhysicalDataContainer
which contains thePx_cdpool
physical objects.static PhysicalDataContainer
getPromotionCodes(java.lang.String promoId)
Get the promotion related promotion code.static PhysicalDataContainer
getPromotionCodesByOrderId(java.lang.Long orderId)
Get physical data object of unique promotion by unique codestatic PhysicalDataContainer
getPromotionCodesByReferenceID(java.util.List referenceIDs)
Get the promotion codes with the passed list ofreferenceIDs
.static PhysicalDataContainer
getPromotionCodeSpec(java.lang.String promoId)
Get Physical Data Container of code specificationstatic com.ibm.commerce.promotion.facade.server.entity.datatypes.Px_cdspec
getPromotionCodeSpecPhysicalObject(int promoId)
Get the promotion code specification physical object by promotion Idstatic com.ibm.commerce.promotion.facade.server.entity.datatypes.Px_cdspec
getPromotionCodeSpecPhysicalObject(PhysicalDataContainer promoPDC)
Get the promotion physical object by the Physical data containerstatic Px_promotion
getPromotionPhysicalObject(PhysicalDataContainer promoPDC)
The promotion physical data object of the promotionstatic PhysicalDataContainer
getPxCdPromoByPoolIDAndPromotionID(java.lang.String aPx_promotionID, java.lang.String aPx_poolID)
Get allPx_cdpromo
physical data objects byPX_PROMOTION_ID
andPX_CDPOOL_ID
.static PhysicalDataContainer
getPxCdPromoByPromotionID(java.lang.String aPx_promotionID)
Get allPx_cdpromo
physical data objects byPX_PROMOTION_ID
.static org.w3c.dom.Document
getXMLDocument(java.lang.String xmlString)
Generator the XML Document object based on the XML String input.static boolean
isAppliedToOrderCodeUsageStatus(int status)
This method validates if a unique promotion code status is applied to an order status.static boolean
isCodeAvailableToUse(java.lang.Long cdPoolId)
Validates the code to see if the code is still available to use.static boolean
isPromoCodePerformanceEnhancementEnabled()
This method checks if the schema change from APAR#JR45153 has been applied to the database.static boolean
isRedeemedToOrderCodeUsageStatus(int status)
This method validates if a unique promotion code status is redeemed to an order status.static int
updateProcessFileEndTime(java.lang.String processFileId)
This method is used to update process file end timestatic int
updateProcessFileProcessInfo(java.lang.String processFileId, java.lang.String processInfo)
This method is used to update process file process info.static int
updateProcessFileStatus(java.lang.String processFileId, int newStatus)
This method is used to update process file status.static boolean
validateUniqueCodeUsageStatus(int status)
This method validates if a unique promotion code can adds to an order by its usage status.
-
-
-
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 aPhysicalDataContainer
which contains thePx_cdpool
physical objects. The objects are obtained using an expression that searches by the promotioncode
.- Parameters:
code
- The promotion code to use to search forPx_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 ofreferenceIDs
.- 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 idnewStatus
- 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 idprocessInfo
- 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 ofPx_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 ofPx_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 ofPx_promotion
by unique promotion code, the status of promotion, the status ofPx_cdpromo
and the status ofPx_cdusage
.- Parameters:
uniqueCode
- A String representing the unique promotion code of promotionlistPromotionStatus
- 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 ofPx_cdpromo
. If current parameter not set, it will default as 'Active' status.listPxCdPoolStatus
- A List representing the allowed status ofPx_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 ofPx_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 allPx_cdpromo
physical data objects byPX_PROMOTION_ID
andPX_CDPOOL_ID
.- Parameters:
aPx_promotionID
- A String representing thePX_PROMOTION_ID
.aPx_poolID
- A String representing thePX_CDPOOL_ID
.- Returns:
- The
PhysicalDataContainer
containing thePx_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 allPx_cdpromo
physical data objects byPX_PROMOTION_ID
.- Parameters:
aPx_promotionID
- A String representing thePX_PROMOTION_ID
.- Returns:
- The
PhysicalDataContainer
containing thePx_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 activePx_cdpromo
physical data objects byPX_CDPOOL_ID
.- Parameters:
aPx_poolID
- A String representing thePX_CDPOOL_ID
.- Returns:
- The
PhysicalDataContainer
containing thePx_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 passedpromotionCodes
belonging to store with IDstoreID
. ThecodeMin
andcodeMax
parameters are used to control the search expression using a between predicate. TheinternalID
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 passedpromotionCodes
belonging to store with IDstoreID
. ThecodeMin
andcodeMax
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 codeusageType
- 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 IDstoreID
. TheinternalID
parameter is used in the query for the INTERNAL_ID column in the PX_CDPOOL_ERROR table. ThereferenceID
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.
-
-