com.ibm.commerce.price.rule.runtime.util

Class PriceRuleHelper

  • java.lang.Object
    • com.ibm.commerce.price.rule.runtime.util.PriceRuleHelper


  • public class PriceRuleHelper
    extends java.lang.Object
    This is a utility class for price rule runtime evaluation.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM copyright notice field.
    • Constructor Summary

      Constructors 
      Constructor and Description
      PriceRuleHelper() 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      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.
      • Methods inherited from class java.lang.Object

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

      • COPYRIGHT

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

      • PriceRuleHelper

        public PriceRuleHelper()
    • Method Detail

      • setCaching

        public static final java.lang.Boolean setCaching(java.lang.Boolean abEnabled)
        Temporarily enables or disables local transaction caching in this thread only. The caller should call this method again in a finally block specifying the returned value, to restore the previous setting.
        Parameters:
        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.
        Returns:
        the current setting.
      • getInstance

        public static PriceRuleHelper getInstance()
        This method returns an instance of this class.
        Returns:
        An instance of this class.
      • getAllCategoriesForCatentry

        public java.lang.String getAllCategoriesForCatentry(java.lang.String catentryId)
        This method returns all parent categories for a catalog entry.
        Parameters:
        catentryId - The catalog entry id. If null or empty, will return null.
        Returns:
        A comma separated string containing all parent categories for a catalog entry. It will return null if error occurs, will not return empty string.
      • getCategoriesForCategory

        public java.lang.String getCategoriesForCategory(java.lang.String catalogId,
                                                         java.lang.String categoryId)
        This method returns all parent categories for a category.
        Parameters:
        catalogId - The catalog id. If null or empty, will return null.
        categoryId - The category id. If null or empty, will return null.
        Returns:
        A comma separated string containing all parent categories for a category. It will return null if error occurs, will not return empty string.
      • getAllCatentriesForCatentry

        public java.lang.String getAllCatentriesForCatentry(java.lang.String catentryId)
        This method returns all parent catalog entries for a catalog entry.
        Parameters:
        catentryId - The catalog entry id. If null or empty, will return null.
        Returns:
        A comma separated string containing all parent catalog entries for a catalog entry. It will return null if error occurs, will not return empty string.
      • getCurrency

        public java.lang.String getCurrency(CommandContext aCommandContext)
        Get currency with the Helper utility.
        Parameters:
        aCommandContext - The command context. If null or empty, will return null.
        Returns:
        The proper currency. It will return null if error occurs, will not return empty string.
      • getBestPriceForOfferWithSpecificCurrency

        public 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. It returns null if error occurs.
        Parameters:
        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.
        Returns:
        The best price for the offer. It will return null if error occurs, will not return empty string.
      • isValidOffer

        public boolean isValidOffer(java.lang.Double offerMinQuantity,
                                    java.lang.Double offerMaxQuantity,
                                    java.lang.String offerUOM,
                                    QuantityAmount aQuantity,
                                    java.lang.Long catentryID)
        Filter the valid offer.
        Parameters:
        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.
        Returns:
        True if the offer is valid.
      • getOfferPriceWithSpecifiedCurrency

        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
        This method is used to get the base offer price for a catalog entry in a specific price list. If there is no offer price defined in the desired currency, get the best price after currency conversion.
        Parameters:
        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.
        Returns:
        The base offer price in the specific price list. Return null if there is no valid offer.
        Throws:
        ECException - If problems happens when retrieving offers from database.
      • getOfferPriceWithSpecifiedCurrency

        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
        This method is used to get the base offer price for a catalog entry in a specific price list. If there is no offer price defined in the desired currency, get the best price after currency conversion.
        Parameters:
        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.
        Returns:
        The base offer price in the specific price list. Return null if there is no valid offer.
        Throws:
        ECException - If problems happens when retrieving offers from database.
      • retrieveParentCatalogEntryIds

        public java.util.Map retrieveParentCatalogEntryIds(java.lang.Long[] aCatEntryIDsArr)
                                                    throws ECException
        This method retrieves the parent catalog entry IDs for an array of catalog entries.
        Parameters:
        aCatEntryIDsArr - The array of catalog entry IDs. Can't be null or empty.
        Returns:
        A hash map of parent catalog entry IDs. It doesn't return null.
        Throws:
        ECException
      • isCatentryInCatalogFilter

        public boolean isCatentryInCatalogFilter(java.lang.String catFilterId,
                                                 java.lang.String catEntryId)
        Determine if a catalog entry is included by a catalog filter.
        Parameters:
        catFilterId - The catalog filter id. If null or empty, will return false.
        catEntryId - The catalog entry. If null or empty, will return false.
        Returns:
        True if the catalog entry is included by a catalog filter.
      • getBestPriceConstantValueWithCurrencyConversion

        public java.math.BigDecimal getBestPriceConstantValueWithCurrencyConversion(java.util.List prconvalueList,
                                                                                    java.lang.String storeId,
                                                                                    java.lang.String toCurrency)
                                                                             throws ECException
        This method retrieves the best currency value of a price constant with conversion to the desired currency.
        Parameters:
        prconvalueList -
        storeId -
        toCurrency -
        Returns:
        The best currency value of a price constant in desired currency. It can't be null.
        Throws:
        ECException
      • applyRounding

        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)
        This method applies rounding on the input value.
        Parameters:
        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.
        Returns:
        Return the result value after rounding. It returns null if anything exceptional happens.
      • isPatternMatchCurrency

        public boolean isPatternMatchCurrency(java.lang.String pattern,
                                              java.lang.String currency)
        Judge if the specified pattern matches the input currency. The result is true if the decimal place number in the pattern is not bigger than that in the currency definition.
        Parameters:
        pattern - The rounding pattern. Can't be null or empty.
        currency - The input currency code.
        Returns:
        The judging result
      • rounding

        public java.lang.String[] rounding(java.lang.Integer[][] digitsToBeRounded,
                                           java.util.HashMap hshRoudingPatterns)
        This method applies the rounding rules on the input digits.
        Parameters:
        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.
        Returns:
        The array of digits after applying the rounding rules. It can't be null or empty.
      • digitsToValue

        public java.math.BigDecimal digitsToValue(java.lang.Integer[] inputDigits)
        The method converts the array of digits into a value.
        Parameters:
        inputDigits - The array of digits. Can't be null or empty.
        Returns:
        The value represented by the array of digits. Can't be null.
      • getInputDigits

        public 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.
        Parameters:
        value - The input value to be parsed. It can't be null.
        decimalLength - The length of decimal part which is required to reserved.
        Returns:
        The array of digits to be rounded. It returns null if parameter value is null. It doesn't return empty array.
      • constructRoudingPatternsHashMap

        public java.util.HashMap constructRoudingPatternsHashMap(java.lang.String pattern)
        This method constructs a hash map to contain the rounding values. The hash map makes use of the number place as key. The number place is represented by an integer, e.g. -2 represents hundredths digit, -1 represents tenths, and so on.
        Parameters:
        pattern - The string representing a rounding pattern Can't be null or empty.
        Returns:
        The hash map to contain the rounding values with the number places as key. It doesn't return null.
      • digitsToValue

        public java.math.BigDecimal digitsToValue(java.lang.String[] inputDigits)
        The method converts the array of digits into a value.
        Parameters:
        inputDigits - The array of digits. Can't be null or empty.
        Returns:
        The value represented by the array of digits. Can't be null.
      • getPriceRulesByReferrencedPriceConstant

        public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> getPriceRulesByReferrencedPriceConstant(java.lang.String priceConstantId)
                                                                                                                      throws com.ibm.commerce.price.facade.client.PriceRuleException
        Gets the price rule logical noun which refer the price constant.
        Parameters:
        priceConstantId - The referred price constant Id.
        Returns:
        A list of price rule logical noun.
        Throws:
        com.ibm.commerce.price.facade.client.PriceRuleException - If errors occurred when calling the get price rule service to get the price rules.
      • getPriceRulesByReferrencedPriceRule

        public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> getPriceRulesByReferrencedPriceRule(java.lang.String priceRuleId)
                                                                                                                  throws com.ibm.commerce.price.facade.client.PriceRuleException
        Gets the price rule logical noun which refer the price rule.
        Parameters:
        priceRuleId - The referred price rule Id.
        Returns:
        A list of price rule logical noun.
        Throws:
        com.ibm.commerce.price.facade.client.PriceRuleException - If errors occurred when calling the get price rule service to get the price rules.
      • getContractsByReferrencedPriceRule

        public java.util.List<ContractType> getContractsByReferrencedPriceRule(java.lang.String priceRuleId)
                                                                        throws ContractException
        Gets the contract logical noun which refer the price rule.
        Parameters:
        priceRuleId - The referred price rule Id.
        Returns:
        A list of contract logical noun.
        Throws:
        ContractException - If errors occurred when calling the get contract service to get the contracts.
      • getPriceRulesByReferrencedPriceEquation

        public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> getPriceRulesByReferrencedPriceEquation(java.lang.String priceEquationId)
                                                                                                                      throws com.ibm.commerce.price.facade.client.PriceRuleException
        Gets the price rule logical noun which refer the price equation.
        Parameters:
        priceEquationId - The referred price equation Id.
        Returns:
        A list of price rule logical noun.
        Throws:
        com.ibm.commerce.price.facade.client.PriceRuleException - If errors occurred when calling the get price rule service to get the price rules.
      • getPriceRulesByReferrencedPriceList

        public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> getPriceRulesByReferrencedPriceList(java.lang.String priceListId)
                                                                                                                  throws com.ibm.commerce.price.facade.client.PriceRuleException
        Gets the price rule logical noun which refer the price list.
        Parameters:
        priceListId - The referred price list Id.
        Returns:
        A list of price rule logical noun.
        Throws:
        com.ibm.commerce.price.facade.client.PriceRuleException - If errors occurred when calling the get price rule service to get the price rules.
      • getPriceEquationsByReferrencedPriceConstant

        public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceEquationType> getPriceEquationsByReferrencedPriceConstant(java.lang.String priceConstantId)
                                                                                                                              throws com.ibm.commerce.price.facade.client.PriceEquationException
        Gets the price equation logical noun which refer the price constant.
        Parameters:
        priceConstantId - The referred price constant Id.
        Returns:
        A list of price equation logical noun.
        Throws:
        com.ibm.commerce.price.facade.client.PriceEquationException - If errors occurred when calling the get price equation service to get the price equations.
      • getPriceEquationsByReferrencedPriceList

        public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceEquationType> getPriceEquationsByReferrencedPriceList(java.lang.String priceListId)
                                                                                                                          throws com.ibm.commerce.price.facade.client.PriceEquationException
        Gets the price equation logical noun which refer the price list.
        Parameters:
        priceListId - The referred price list Id.
        Returns:
        A list of price equation logical noun.
        Throws:
        com.ibm.commerce.price.facade.client.PriceEquationException - If errors occurred when calling the get price equation service to get the price equations.
      • getExpressionByEquationId

        public java.lang.String getExpressionByEquationId(java.lang.String priceEquationId)
                                                   throws DataMediatorException
        This method will retrieve expression from equation.
        Parameters:
        priceEquationId - The price equation id. It can't be null.
        Returns:
        The equation expression.
        Throws:
        DataMediatorException
      • belongsToMemberGroup

        public boolean belongsToMemberGroup(java.lang.String memberId,
                                            java.lang.String memberGroupId,
                                            java.lang.Integer storeId)
                                     throws java.lang.Exception
        Check if a person belongs to a member group. Currently only supports the member group with GeneralPurpose usage. Currently only supports the member group ID.
        Parameters:
        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.
        Returns:
        True if the member group contains the person. False if the member group doesn't contain the person or some of the input parameters are null.
        Throws:
        java.lang.Exception - If problems occur during invocation of the web services.
      • belongsToOrganization

        public boolean belongsToOrganization(java.lang.String userID,
                                             java.lang.String orgIdentifier)
                                      throws java.lang.Exception
        Check if a user belongs to an organization.
        Parameters:
        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.
        Returns:
        True if the specified organization identifier matches the unique ID or name of one of the ancestor organizations of the user.
        Throws:
        java.lang.Exception
      • getRuleExecutionCommand

        public 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.
        Parameters:
        priceRule - The price rule logical object, cannot be null or empty.
        aStoreId - The store Id, cannot be null or empty.
        Returns:
        A rule engine execution command, will not be null unless there's an exception thrown.
      • getValidPriceRuleExtendeTC

        public ExtendedTermConditionAccessBean getValidPriceRuleExtendeTC(java.lang.Long contractID,
                                                                          java.lang.Long memberID,
                                                                          java.sql.Timestamp currentTime)
                                                                   throws ECSystemException
        Get valid price rule extended term condition.
        Parameters:
        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.
        Returns:
        The valid price rule extended term condition. Return null when do not find a valid one.
        Throws:
        ECSystemException
      • doesContractHavePriceRuleTC

        public boolean doesContractHavePriceRuleTC(java.lang.Long contractID,
                                                   java.lang.Long memberID)
                                            throws ECSystemException
        Check whether the specified contract contains Price Rule TC, no matter it is in effective date or not
        Parameters:
        contractID - The contract id.
        memberID - The member id.
        Returns:
        true if the specified contract contains Price Rule TC; false otherwise.
        Throws:
        ECSystemException - If problem occurs during retriving Price Rule TC.
      • isValidDate

        public 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.
        Parameters:
        beginDate - The begin date. Can be null.
        expiryDate - The end date. Can be null.
        currentTime - The current time.
        Returns:
        True if the date is valid. Otherwise, false.
      • isValidPriceRuleId

        public boolean isValidPriceRuleId(java.lang.String priceRuleId)
        Check whether the price rule id is not empty
        Parameters:
        priceRuleId - The price rule id. Can be empty or null.
        Returns:
        If the price rule id is not empty, return true; otherwise return false.
      • getAllPathsInRule

        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)
        This method calculate all possible paths in the price rule object by tracing all its branches and their combination. It will return the path which is composed by price rule element entries.
        Parameters:
        priceRuleId - The Id of the price rule.
        inspectNestedRule - The flag to control whether to trace into nested rules.
        Returns:
        A map of entries which is a possible path in the rule. The key of the entry is a comma separated string with the combination of price rule element Id. The value of the entry is the list of price rule element object by their sequence in the path.
      • getSortedPathsInRule

        public 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. It will return the path which is composed by price rule element Id.
        Parameters:
        priceRuleId - The Id of the price rule.
        inspectNestedRule - The flag to control whether to trace into nested rules.
        Returns:
        A list of string which is a possible path identifier in the rule. The string is comma separated with the combination of price rule element Id.
      • getAllPriceListsFromPriceRule

        public java.util.List<java.util.List<java.lang.String>> getAllPriceListsFromPriceRule(java.lang.String priceRuleId)
        Gets all the price list identifiers from a price rule. A price rule may have many different paths, each price list identifiers in one path are composed into a list. All the lists of each path are composed into one list, which is the returned result.
        Parameters:
        priceRuleId - The price rule identifier.
        Returns:
        A list of list of price list identifiers.
      • getPriceRuleReferencedStoreIds

        public 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
        Parameters:
        priceRuleId - The Id of the price rule.
        Returns:
        The set of the store Id.
      • findPriceRuleExtendedStores

        public 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. It will return the Id of the stores as a java.util.Set
        Parameters:
        storeId - The Id of the specific store.
        Returns:
        The set of the store Id.
      • resolvePriceRuleIdFromContract

        public java.lang.String resolvePriceRuleIdFromContract(java.lang.Long aContractId,
                                                               CommandContext commandContext)
                                                        throws ECSystemException
        Resolves price rule identifier from a given contract.
        Parameters:
        aContractId - The contract identifier. Cannot be null.
        commandContext - The command context. Can't be null.
        Returns:
        The price rule identifier belongs to input contract, will return null if there's no price rule in the contract. This value will not be empty.
        Throws:
        ECSystemException - If fails to get price rule from contract
      • getCurrentTime

        public java.sql.Timestamp getCurrentTime(CommandContext commandContext)
        Returns the current time from the command context. First, check the time from the preview context. Then, check the time from the command context. Finally, check the time from the request properties. If there is no time in the request properties, get the current system time and save it in the request properties for next use.
        Parameters:
        commandContext - The command context. It may be null. If it is null, return the current system time.
        Returns:
        The current time. It doesn't return null.
      • getPriceRulesByReferrencedPriceConstantInAllStores

        public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> getPriceRulesByReferrencedPriceConstantInAllStores(java.lang.String priceConstantId)
                                                                                                                                 throws com.ibm.commerce.price.facade.client.PriceRuleException
        Gets the price rule logical noun which refer the price constant from all stores.
        Parameters:
        priceConstantId - The referred price constant Id.
        Returns:
        A list of price rule logical noun.
        Throws:
        com.ibm.commerce.price.facade.client.PriceRuleException - If errors occurred when calling the get price rule service to get the price rules.
      • getPriceRulesByReferrencedPriceEquationInAllStores

        public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceRuleType> getPriceRulesByReferrencedPriceEquationInAllStores(java.lang.String priceEquationId)
                                                                                                                                 throws com.ibm.commerce.price.facade.client.PriceRuleException
        Gets the price rule logical noun which refer the price equation from all stores.
        Parameters:
        priceEquationId - The referred price equation Id.
        Returns:
        A list of price rule logical noun.
        Throws:
        com.ibm.commerce.price.facade.client.PriceRuleException - If errors occurred when calling the get price rule service to get the price rules.
      • getPriceEquationsByReferrencedPriceConstantInAllStores

        public java.util.List<com.ibm.commerce.price.facade.datatypes.PriceEquationType> getPriceEquationsByReferrencedPriceConstantInAllStores(java.lang.String priceConstantId)
                                                                                                                                         throws com.ibm.commerce.price.facade.client.PriceEquationException
        Gets the price equation logical noun which refer the price constant from all stores.
        Parameters:
        priceConstantId - The referred price constant Id.
        Returns:
        A list of price equation logical noun.
        Throws:
        com.ibm.commerce.price.facade.client.PriceEquationException - If errors occurred when calling the get price equation service to get the price equations.
      • doesPriceRuleHaveSpecifiedElement

        public boolean doesPriceRuleHaveSpecifiedElement(java.lang.String priceRuleId,
                                                         java.lang.String elementTplId)
        Checks whether the price rule has specified element.
        Parameters:
        priceRuleId - price rule id. cannot be null.
        elementTplId - element template id. cannot be null.
        Returns:
        true or false