public class PriceRuleHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT
IBM copyright notice field.
|
Constructor and Description |
---|
PriceRuleHelper() |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.Boolean,java.math.BigDecimal> |
applyRounding(java.lang.String roundingPatterns,
java.lang.String definingCurrencies,
java.math.BigDecimal value,
java.lang.String currency)
This method applies rounding on the input value.
|
boolean |
belongsToMemberGroup(java.lang.String memberId,
java.lang.String memberGroupId,
java.lang.Integer storeId)
Check if a person belongs to a member group.
|
boolean |
belongsToOrganization(java.lang.String userID,
java.lang.String orgIdentifier)
Check if a user belongs to an organization.
|
java.util.HashMap |
constructRoudingPatternsHashMap(java.lang.String pattern)
This method constructs a hash map to contain the rounding values.
|
java.math.BigDecimal |
digitsToValue(java.lang.Integer[] inputDigits)
The method converts the array of digits into a value.
|
java.math.BigDecimal |
digitsToValue(java.lang.String[] inputDigits)
The method converts the array of digits into a value.
|
boolean |
doesContractHavePriceRuleTC(java.lang.Long contractID,
java.lang.Long memberID)
Check whether the specified contract contains Price Rule TC, no matter it is in effective date or not
|
boolean |
doesPriceRuleHaveSpecifiedElement(java.lang.String priceRuleId,
java.lang.String elementTplId)
Checks whether the price rule has specified element.
|
java.util.Set<java.lang.Integer> |
findPriceRuleExtendedStores(java.lang.Integer storeId)
This method find all stores which will extend the price rules of a specific store in store relations.
|
java.lang.String |
getAllCategoriesForCatentry(java.lang.String catentryId)
This method returns all parent categories for a catalog entry.
|
java.lang.String |
getAllCatentriesForCatentry(java.lang.String catentryId)
This method returns all parent catalog entries for a catalog entry.
|
java.util.Map<java.lang.String,java.util.List<com.ibm.commerce.price.rule.runtime.objects.PriceRuleElementObject>> |
getAllPathsInRule(java.lang.String priceRuleId,
boolean inspectNestedRule)
This method calculate all possible paths in the price rule object by tracing all its branches and their combination.
|
java.util.List<java.util.List<java.lang.String>> |
getAllPriceListsFromPriceRule(java.lang.String priceRuleId)
Gets all the price list identifiers from a price rule.
|
java.math.BigDecimal |
getBestPriceConstantValueWithCurrencyConversion(java.util.List prconvalueList,
java.lang.String storeId,
java.lang.String toCurrency)
This method retrieves the best currency value of a price constant
with conversion to the desired currency.
|
MonetaryAmount |
getBestPriceForOfferWithSpecificCurrency(java.lang.String offerId,
java.lang.String currency,
java.lang.String storeId)
Get best price for an offer with specific currency, if the currency is
null, will return alternative prices.
|
java.lang.String |
getCategoriesForCategory(java.lang.String catalogId,
java.lang.String categoryId)
This method returns all parent categories for a category.
|
java.util.List<ContractType> |
getContractsByReferrencedPriceRule(java.lang.String priceRuleId)
Gets the contract logical noun which refer the price rule.
|
java.lang.String |
getCurrency(CommandContext aCommandContext)
Get currency with the Helper utility.
|
java.sql.Timestamp |
getCurrentTime(CommandContext commandContext)
Returns the current time from the command context.
|
java.lang.String |
getExpressionByEquationId(java.lang.String priceEquationId)
This method will retrieve expression from equation.
|
java.lang.Integer[][] |
getInputDigits(java.math.BigDecimal value,
int decimalLength)
This method parses the input value and retrieves the array of digits
from smallest to highest of the input value.
|
static PriceRuleHelper |
getInstance()
This method returns an instance of this class.
|
java.math.BigDecimal |
getOfferPriceWithSpecifiedCurrency(java.lang.String priceListIdStr,
java.lang.String catentryIdStr,
java.lang.String storeId,
java.lang.String currency,
java.lang.String uom,
java.lang.Double quantity)
This method is used to get the base offer price for a catalog entry in a
specific price list.
|
java.math.BigDecimal |
getOfferPriceWithSpecifiedCurrency(java.lang.String priceListIdStr,
java.lang.String catentryIdStr,
java.lang.String storeId,
java.lang.String currency,
java.lang.String uom,
java.lang.Double quantity,
java.util.Map runtimeParameters)
This method is used to get the base offer price for a catalog entry in a
specific price list.
|
java.util.List<com.ibm.commerce.price.facade.datatypes.PriceEquationType> |
getPriceEquationsByReferrencedPriceConstant(java.lang.String priceConstantId)
Gets the price equation logical noun which refer the price constant.
|
java.util.List<com.ibm.commerce.price.facade.datatypes.PriceEquationType> |
getPriceEquationsByReferrencedPriceConstantInAllStores(java.lang.String priceConstantId)
Gets the price equation logical noun which refer the price constant from all stores.
|
java.util.List<com.ibm.commerce.price.facade.datatypes.PriceEquationType> |
getPriceEquationsByReferrencedPriceList(java.lang.String priceListId)
Gets the price equation logical noun which refer the price list.
|
java.util.Set<java.lang.Integer> |
getPriceRuleReferencedStoreIds(java.lang.String priceRuleId)
This method find all stores which could reference a price rule
It will return the Id of the stores as a
java.util.Set |
java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> |
getPriceRulesByReferrencedPriceConstant(java.lang.String priceConstantId)
Gets the price rule logical noun which refer the price constant.
|
java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> |
getPriceRulesByReferrencedPriceConstantInAllStores(java.lang.String priceConstantId)
Gets the price rule logical noun which refer the price constant from all stores.
|
java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> |
getPriceRulesByReferrencedPriceEquation(java.lang.String priceEquationId)
Gets the price rule logical noun which refer the price equation.
|
java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> |
getPriceRulesByReferrencedPriceEquationInAllStores(java.lang.String priceEquationId)
Gets the price rule logical noun which refer the price equation from all stores.
|
java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> |
getPriceRulesByReferrencedPriceList(java.lang.String priceListId)
Gets the price rule logical noun which refer the price list.
|
java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> |
getPriceRulesByReferrencedPriceRule(java.lang.String priceRuleId)
Gets the price rule logical noun which refer the price rule.
|
RuleEngineExecutePriceRuleCmd |
getRuleExecutionCommand(com.ibm.commerce.price.facade.datatypes.PriceRuleType priceRule,
java.lang.Integer aStoreId)
This method returns a proper implementation of
RuleEngineExecutePriceRuleCmd command according to price
rule name, price rule type and store. |
java.util.List<java.lang.String> |
getSortedPathsInRule(java.lang.String priceRuleId,
boolean inspectNestedRule)
This method calculate all possible paths in the price rule object by tracing all its branches and their combination.
|
ExtendedTermConditionAccessBean |
getValidPriceRuleExtendeTC(java.lang.Long contractID,
java.lang.Long memberID,
java.sql.Timestamp currentTime)
Get valid price rule extended term condition.
|
boolean |
isCatentryInCatalogFilter(java.lang.String catFilterId,
java.lang.String catEntryId)
Determine if a catalog entry is included by a catalog filter.
|
boolean |
isPatternMatchCurrency(java.lang.String pattern,
java.lang.String currency)
Judge if the specified pattern matches the input currency.
|
boolean |
isValidDate(java.sql.Timestamp beginDate,
java.sql.Timestamp expiryDate,
java.sql.Timestamp currentTime)
Check whether the date is valid compared with the current time.
|
boolean |
isValidOffer(java.lang.Double offerMinQuantity,
java.lang.Double offerMaxQuantity,
java.lang.String offerUOM,
QuantityAmount aQuantity,
java.lang.Long catentryID)
Filter the valid offer.
|
boolean |
isValidPriceRuleId(java.lang.String priceRuleId)
Check whether the price rule id is not empty
|
java.lang.String |
resolvePriceRuleIdFromContract(java.lang.Long aContractId,
CommandContext commandContext)
Resolves price rule identifier from a given contract.
|
java.util.Map |
retrieveParentCatalogEntryIds(java.lang.Long[] aCatEntryIDsArr)
This method retrieves the parent catalog entry IDs for an
array of catalog entries.
|
java.lang.String[] |
rounding(java.lang.Integer[][] digitsToBeRounded,
java.util.HashMap hshRoudingPatterns)
This method applies the rounding rules on the input digits.
|
static java.lang.Boolean |
setCaching(java.lang.Boolean abEnabled)
Temporarily enables or disables local transaction caching in this thread only.
|
public static final java.lang.String COPYRIGHT
public static final java.lang.Boolean setCaching(java.lang.Boolean abEnabled)
abEnabled
- specify Boolean.TRUE to enable or resume local transaction caching,
Boolean.FALSE to disable or pause local transaction caching,
or specify null to both disable and clear the local transaction cache.public static PriceRuleHelper getInstance()
public java.lang.String getAllCategoriesForCatentry(java.lang.String catentryId)
catentryId
- The catalog entry id. If null or empty, will return null.public java.lang.String getCategoriesForCategory(java.lang.String catalogId, java.lang.String categoryId)
catalogId
- The catalog id. If null or empty, will return null.categoryId
- The category id. If null or empty, will return null.public java.lang.String getAllCatentriesForCatentry(java.lang.String catentryId)
catentryId
- The catalog entry id. If null or empty, will return null.public java.lang.String getCurrency(CommandContext aCommandContext)
aCommandContext
- The command context. If null or empty, will return null.public MonetaryAmount getBestPriceForOfferWithSpecificCurrency(java.lang.String offerId, java.lang.String currency, java.lang.String storeId)
offerId
- The offerId. If null or empty, will return null.currency
- The currency. If null or empty, will return null.storeId
- The storeId. If null or empty, will return null.public boolean isValidOffer(java.lang.Double offerMinQuantity, java.lang.Double offerMaxQuantity, java.lang.String offerUOM, QuantityAmount aQuantity, java.lang.Long catentryID)
offerMinQuantity
- The minimum quantity. If null or empty, will return false.offerMaxQuantity
- The maximum quantity. If null or empty, will return false.offerUOM
- The UOM. If null or empty, will return false.aQuantity
- The quantity. If null or empty, will return false.catentryID
- The catalog entry id. This parameter can't be null or empty.public java.math.BigDecimal getOfferPriceWithSpecifiedCurrency(java.lang.String priceListIdStr, java.lang.String catentryIdStr, java.lang.String storeId, java.lang.String currency, java.lang.String uom, java.lang.Double quantity) throws ECException
priceListIdStr
- The price list ID.catentryIdStr
- The catalog entry ID.storeId
- The store ID.currency
- The currency.uom
- The unit of measurement.quantity
- The quantity.ECException
- If problems happens when retrieving offers from database.public java.math.BigDecimal getOfferPriceWithSpecifiedCurrency(java.lang.String priceListIdStr, java.lang.String catentryIdStr, java.lang.String storeId, java.lang.String currency, java.lang.String uom, java.lang.Double quantity, java.util.Map runtimeParameters) throws ECException
priceListIdStr
- The price list ID.catentryIdStr
- The catalog entry ID.storeId
- The store ID.currency
- The currency.uom
- The unit of measurement.quantity
- The quantity.runtimeParameters
- The runtime parameters for rule, from which the pricing time
can be retrieved.ECException
- If problems happens when retrieving offers from database.public java.util.Map retrieveParentCatalogEntryIds(java.lang.Long[] aCatEntryIDsArr) throws ECException
aCatEntryIDsArr
- The array of catalog entry IDs.
Can't be null or empty.ECException
public boolean isCatentryInCatalogFilter(java.lang.String catFilterId, java.lang.String catEntryId)
catFilterId
- The catalog filter id. If null or empty, will return false.catEntryId
- The catalog entry. If null or empty, will return false.public java.math.BigDecimal getBestPriceConstantValueWithCurrencyConversion(java.util.List prconvalueList, java.lang.String storeId, java.lang.String toCurrency) throws ECException
prconvalueList
- storeId
- toCurrency
- ECException
public java.util.Map<java.lang.Boolean,java.math.BigDecimal> applyRounding(java.lang.String roundingPatterns, java.lang.String definingCurrencies, java.math.BigDecimal value, java.lang.String currency)
roundingPatterns
- The rounding patterns represented by a string.
It can't be null or empty.definingCurrencies
- The string representing the list of currencies delimited
by a comma. Can't be null or empty.value
- The value to be rounded. It can't be null.currency
- The desired currency. It can't be null or empty.public boolean isPatternMatchCurrency(java.lang.String pattern, java.lang.String currency)
pattern
- The rounding pattern. Can't be null or empty.currency
- The input currency code.public java.lang.String[] rounding(java.lang.Integer[][] digitsToBeRounded, java.util.HashMap hshRoudingPatterns)
digitsToBeRounded
- The two-dimension array to represent
digits to be rounded.
It can't be null or empty.hshRoudingPatterns
- The hash map which contains the rounding patterns.
It can't be null or empty.public java.math.BigDecimal digitsToValue(java.lang.Integer[] inputDigits)
inputDigits
- The array of digits. Can't be null or empty.public java.lang.Integer[][] getInputDigits(java.math.BigDecimal value, int decimalLength)
value
- The input value to be parsed. It can't be null.decimalLength
- The length of decimal part which is required to reserved.value
is null. It doesn't return empty array.public java.util.HashMap constructRoudingPatternsHashMap(java.lang.String pattern)
pattern
- The string representing a rounding pattern
Can't be null or empty.public java.math.BigDecimal digitsToValue(java.lang.String[] inputDigits)
inputDigits
- The array of digits. Can't be null or empty.public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> getPriceRulesByReferrencedPriceConstant(java.lang.String priceConstantId) throws com.ibm.commerce.price.facade.client.PriceRuleException
priceConstantId
- The referred price constant Id.com.ibm.commerce.price.facade.client.PriceRuleException
- If errors occurred when calling the get price rule service to get the price rules.public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> getPriceRulesByReferrencedPriceRule(java.lang.String priceRuleId) throws com.ibm.commerce.price.facade.client.PriceRuleException
priceRuleId
- The referred price rule Id.com.ibm.commerce.price.facade.client.PriceRuleException
- If errors occurred when calling the get price rule service to get the price rules.public java.util.List<ContractType> getContractsByReferrencedPriceRule(java.lang.String priceRuleId) throws ContractException
priceRuleId
- The referred price rule Id.ContractException
- If errors occurred when calling the get contract service to get the contracts.public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> getPriceRulesByReferrencedPriceEquation(java.lang.String priceEquationId) throws com.ibm.commerce.price.facade.client.PriceRuleException
priceEquationId
- The referred price equation Id.com.ibm.commerce.price.facade.client.PriceRuleException
- If errors occurred when calling the get price rule service to get the price rules.public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> getPriceRulesByReferrencedPriceList(java.lang.String priceListId) throws com.ibm.commerce.price.facade.client.PriceRuleException
priceListId
- The referred price list Id.com.ibm.commerce.price.facade.client.PriceRuleException
- If errors occurred when calling the get price rule service to get the price rules.public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceEquationType> getPriceEquationsByReferrencedPriceConstant(java.lang.String priceConstantId) throws com.ibm.commerce.price.facade.client.PriceEquationException
priceConstantId
- The referred price constant Id.com.ibm.commerce.price.facade.client.PriceEquationException
- If errors occurred when calling the get price equation service to get the price equations.public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceEquationType> getPriceEquationsByReferrencedPriceList(java.lang.String priceListId) throws com.ibm.commerce.price.facade.client.PriceEquationException
priceListId
- The referred price list Id.com.ibm.commerce.price.facade.client.PriceEquationException
- If errors occurred when calling the get price equation service to get the price equations.public java.lang.String getExpressionByEquationId(java.lang.String priceEquationId) throws DataMediatorException
priceEquationId
- The price equation id. It can't be null.DataMediatorException
public boolean belongsToMemberGroup(java.lang.String memberId, java.lang.String memberGroupId, java.lang.Integer storeId) throws java.lang.Exception
memberId
- The unique ID of the person. If the memberId is null, return false.
Cannot be empty.memberGroupId
- The unique ID or member group name of a member group.
If the memberGroupId is null, return false. Cannot be empty.storeId
- The store ID. If the storeId is null, return false.java.lang.Exception
- If problems occur during invocation of the web services.public boolean belongsToOrganization(java.lang.String userID, java.lang.String orgIdentifier) throws java.lang.Exception
userID
- The unique ID of a user member. Can't be null or empty.orgIdentifier
- The unique ID or name or distinguished name an organization. Can't be null or
empty.java.lang.Exception
public RuleEngineExecutePriceRuleCmd getRuleExecutionCommand(com.ibm.commerce.price.facade.datatypes.PriceRuleType priceRule, java.lang.Integer aStoreId)
RuleEngineExecutePriceRuleCmd
command according to price
rule name, price rule type and store.priceRule
- The price rule logical object, cannot be null or empty.aStoreId
- The store Id, cannot be null or empty.public ExtendedTermConditionAccessBean getValidPriceRuleExtendeTC(java.lang.Long contractID, java.lang.Long memberID, java.sql.Timestamp currentTime) throws ECSystemException
contractID
- The contract identifier. Cannot be null.memberID
- The user identifier. Cannot be null.currentTime
- The current time. If null, will not validate the effective date of Price Rule TC.ECSystemException
public boolean doesContractHavePriceRuleTC(java.lang.Long contractID, java.lang.Long memberID) throws ECSystemException
contractID
- The contract id.memberID
- The member id.ECSystemException
- If problem occurs during retriving Price Rule TC.public boolean isValidDate(java.sql.Timestamp beginDate, java.sql.Timestamp expiryDate, java.sql.Timestamp currentTime)
beginDate
- The begin date. Can be null.expiryDate
- The end date. Can be null.currentTime
- The current time.public boolean isValidPriceRuleId(java.lang.String priceRuleId)
priceRuleId
- The price rule id. Can be empty or null.public java.util.Map<java.lang.String,java.util.List<com.ibm.commerce.price.rule.runtime.objects.PriceRuleElementObject>> getAllPathsInRule(java.lang.String priceRuleId, boolean inspectNestedRule)
priceRuleId
- The Id of the price rule.inspectNestedRule
- The flag to control whether to trace into nested rules.public java.util.List<java.lang.String> getSortedPathsInRule(java.lang.String priceRuleId, boolean inspectNestedRule)
priceRuleId
- The Id of the price rule.inspectNestedRule
- The flag to control whether to trace into nested rules.public java.util.List<java.util.List<java.lang.String>> getAllPriceListsFromPriceRule(java.lang.String priceRuleId)
priceRuleId
- The price rule identifier.public java.util.Set<java.lang.Integer> getPriceRuleReferencedStoreIds(java.lang.String priceRuleId)
java.util.Set
priceRuleId
- The Id of the price rule.public java.util.Set<java.lang.Integer> findPriceRuleExtendedStores(java.lang.Integer storeId)
java.util.Set
storeId
- The Id of the specific store.public java.lang.String resolvePriceRuleIdFromContract(java.lang.Long aContractId, CommandContext commandContext) throws ECSystemException
aContractId
- The contract identifier. Cannot be null.commandContext
- The command context. Can't be null.ECSystemException
- If fails to get price rule from contractpublic java.sql.Timestamp getCurrentTime(CommandContext commandContext)
commandContext
- The command context. It may be null. If it is null, return the current
system time.public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> getPriceRulesByReferrencedPriceConstantInAllStores(java.lang.String priceConstantId) throws com.ibm.commerce.price.facade.client.PriceRuleException
priceConstantId
- The referred price constant Id.com.ibm.commerce.price.facade.client.PriceRuleException
- If errors occurred when calling the get price rule service to get the price rules.public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> getPriceRulesByReferrencedPriceEquationInAllStores(java.lang.String priceEquationId) throws com.ibm.commerce.price.facade.client.PriceRuleException
priceEquationId
- The referred price equation Id.com.ibm.commerce.price.facade.client.PriceRuleException
- If errors occurred when calling the get price rule service to get the price rules.public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceEquationType> getPriceEquationsByReferrencedPriceConstantInAllStores(java.lang.String priceConstantId) throws com.ibm.commerce.price.facade.client.PriceEquationException
priceConstantId
- The referred price constant Id.com.ibm.commerce.price.facade.client.PriceEquationException
- If errors occurred when calling the get price equation service to get the price equations.public boolean doesPriceRuleHaveSpecifiedElement(java.lang.String priceRuleId, java.lang.String elementTplId)
priceRuleId
- price rule id. cannot be null.elementTplId
- element template id. cannot be null.