com.ibm.commerce.orderitems.commands

Class OrderItemsCmdHelper

  • java.lang.Object
    • com.ibm.commerce.orderitems.commands.OrderItemsCmdHelper


  • public final class OrderItemsCmdHelper
    extends java.lang.Object
    This is a helper class containing some useful methods used in the order item related commands.
    • Constructor Summary

      Constructors 
      Constructor and Description
      OrderItemsCmdHelper()
      OrderProcessingHelper constructor.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.sql.Timestamp getEarliestShipTime(StoreAccessBean abStore)
      This method gets the earliest ship time of a future order for a given store.
      static java.lang.String[] getEligibleTradingAgreements(CommandContext commandContext, java.lang.Long memberId)
      Obtains a list of eligible trading agreements to be used.
      static double getInventoryOffsetInDays(java.lang.String storeId)
      get the numeric value of the Inventory Allocation Offset in days for a given store
      static java.lang.String getPriceFromConfigurator(java.util.Hashtable ihshQuantity, java.util.Hashtable ihshDk_price, java.util.Hashtable ihshComp_quantity, java.util.Hashtable ihshComp_prices)
      Get price from the BOM XML if price is locked from sterling configurator.
      static OrderItemsCmdHelper getUniqueInstance()
      Get the unique instance of the OrderItemsCmdHelper object.
      static void handleKitPriceNotFoundException(OrderItemAccessBean abOrderItem, java.lang.String aClassName)
      Handles the Kit price not found exception.
      static void insertOrderItemOffer(OrderItemAccessBean orderitemAB, java.lang.Long[] offerIds)
      Saves the offers that were used for searching the price for an order item.
      static void insertOrderItemTrading(OrderItemAccessBean orderitemAB, java.lang.Long[] tradingIds)
      Saves the trading agreements that were used for searching the price for an order item.
      static boolean isNonPriceLock(java.util.Hashtable ihash_dk_priceLock, java.util.Hashtable ihash_Comp_priceLocks)
      Check whether the price is not locked by sterling configurator
      static boolean isPriceLock(java.util.Hashtable ihash_dk_priceLock, java.util.Hashtable ihash_Comp_priceLocks)
      Check whether the price is locked by sterling configurator
      static boolean isPriceLock(java.lang.String[] comp_priceLocks)
      Check whether the configuration is price locked.
      static boolean isTradingAgreementValid(java.lang.Long tradingId, java.lang.String[] eligibleTradingIds)
      Verifies the input trading agreement against a list of eligible trading agreements.
      static void notifyBlocker(boolean toBlock, java.lang.Integer aStoreId, CommandContext aContext, java.lang.String aOrderId, java.lang.String aBlockReasonCode, java.lang.String aComment)
      notify the order block manager of an override on an order Invokes NotifyBlockCmd.
      static java.lang.Long[] resolveTradingAgreements(CommandContext commandContext, OrderItemAccessBean orderitemAB, java.lang.Long[] tradingIds, int refreshFlag)
      Verifies and resolves a list of eligible trading agreements for the user.
      static java.lang.Long[] retrieveOffers(OrderItemAccessBean anabOrderItem, int anRefreshFlag)
      Retrieves previously searched offers for an order item based on the Price Refresh Flag (PRICEREFFLAGS) in STORE: 0: Default, same as 1 except that it will not save the offer id.
      static java.lang.Long[] retrieveOffers(OrderItemAccessBean orderitemAB, int refreshFlag, boolean retryFlag)
      Retrieves previously searched offers for an order item based on the Price Refresh Flag (PRICEREFFLAGS) in STORE: 0: Default, same as 1 except that it will not save the offer id.
      static java.lang.Long[] retrieveSearchedAndSavedOffers(OrderItemAccessBean anabOrderItem)
      Retrieves previously searched offers for an order item.
      static java.lang.Long[] retrieveSearchedAndSavedTradings(OrderItemAccessBean anabOrderItem, CommandContext aCommandContext)
      Retrieves previously searched valid trading agreements for an order item.
      static java.lang.Long[] retrieveTradings(CommandContext aCommandContext, OrderItemAccessBean anabOrderItem, int anRefreshFlag)
      This method calls the task command RetrieveTradingsTaskCmd to retrieve previously searched trading agreements for an orderitem based on the Price Refresh Flag (PRICEREFFLAGS) in STORE: 0: Default, same as 1 except that it will not save the trading agreement id.
      static java.lang.Long[] retrieveTradings(CommandContext commandContext, OrderItemAccessBean orderitemAB, int refreshFlag, boolean retryFlag)
      Retrieves previously searched trading agreements for an order item based on the Price Refresh Flag (PRICEREFFLAGS) in STORE: 0: Default, same as 1 except that it will not save the trading agreement id.
      static void setInventoryOffsetInDays(java.lang.String storeId, double days)
      set the Allocation Offset for a store by days
      static java.lang.String toString(java.lang.Long[] anArr) 
      static void updateContractId(OrderItemAccessBean orderitemAB, StoreAccessBean storeAB)
      Saves the default contract id that provided the price for the order item (old support).
      static void updateOrderItemConfigurations(java.util.Vector ivOrderItems, CommandContext commandContext)
      Updates order item configurations.
      static void updateTotalProductPrice(OrderItemAccessBean orderitemAB)
      Update the total price for the order item.
      static void updateTradingId(OrderItemAccessBean orderitemAB, StoreAccessBean storeAB, java.lang.Long anTradingId)
      Saves the trading agreement ids that provided the best price for the order item.
      static int validatePrice(java.lang.Integer aStoreId, CommandContext aContext, java.lang.String aCurrency, java.lang.Long aUserId, java.lang.Long aCatEntry, java.lang.String aPrice)
      to validate if a price is valid by calling the ValidateDelegatedPriceCmd by CSR/TSR.
      static void verifyTradingIsStillValid(CommandContext theCommandContext, OrderItemAccessBean theOrderItemAB)
      Verifies that the trading id of the order item is still valid.
      static void verifyTradingPaymentMethods(CommandContext commandContext, java.util.Enumeration enOrderItemABs)
      Validate the trading agreements used by the order items in an order.
      static java.lang.Long[] verifyTradingPaymentMethods(CommandContext commandContext, OrderItemAccessBean orderitemAB, java.lang.Long[] tradingIds)
      Verifies if the trading agreements used in the orderitem have defined compatible payment methods with those trading agreements used in the order.
      • Methods inherited from class java.lang.Object

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

      • PRICEREF_DEFAULT

        public static final int PRICEREF_DEFAULT
        The price refresh flag in the store table. PRICEREF_DEFAULT = 0
        See Also:
        Constant Field Values
      • PRICEREF_QUICK_REFRESH

        public static final int PRICEREF_QUICK_REFRESH
        The price refresh flag in the store table. PRICEREF_QUICK_REFRESH = 1
        See Also:
        Constant Field Values
      • PRICEREF_QUICK_COMPLETE_REFRESH

        public static final int PRICEREF_QUICK_COMPLETE_REFRESH
        The price refresh flag in the store table. PRICEREF_QUICK_COMPLETE_REFRESH = 2
        See Also:
        Constant Field Values
      • PRICEREF_COMPLETE_REFRESH

        public static final int PRICEREF_COMPLETE_REFRESH
        The price refresh flag in the store table. PRICEREF_COMPLETE_REFRESH = 4
        See Also:
        Constant Field Values
      • PRICEREF_MERGE_BEFORE_CAL

        public static final int PRICEREF_MERGE_BEFORE_CAL
        The price refresh flag in the store table. PRICEREF_MERGE_BEFORE_CAL = 8
        See Also:
        Constant Field Values
    • Constructor Detail

      • OrderItemsCmdHelper

        public OrderItemsCmdHelper()
        OrderProcessingHelper constructor.
    • Method Detail

      • getEligibleTradingAgreements

        public static java.lang.String[] getEligibleTradingAgreements(CommandContext commandContext,
                                                                      java.lang.Long memberId)
                                                               throws ECException,
                                                                      java.sql.SQLException
        Obtains a list of eligible trading agreements to be used.

        The eligible list of trading agreements can be obtained directly from the Command Context. This case occurs if no member id is provided or the input member id is the one in Command Context. Else, they are retrieved by the member id if the id is provided and different from that in the Command Context.

        Parameters:
        commandContext - the current command context.
        memberId - the id of the member.

        Returns:
        The list of trading agreement ids.
        Throws:
        ECException
        java.sql.SQLException
      • getUniqueInstance

        public static OrderItemsCmdHelper getUniqueInstance()
        Get the unique instance of the OrderItemsCmdHelper object.
        Returns:
        OrderItemsCmdHelper
      • insertOrderItemOffer

        public static void insertOrderItemOffer(OrderItemAccessBean orderitemAB,
                                                java.lang.Long[] offerIds)
                                         throws ECException,
                                                java.sql.SQLException
        Saves the offers that were used for searching the price for an order item.

        Parameters:
        orderitemAB - the access bean of the order item.
        offerIds - the ids of the offers to be saved.
        Throws:
        ECException
        java.sql.SQLException
      • insertOrderItemTrading

        public static void insertOrderItemTrading(OrderItemAccessBean orderitemAB,
                                                  java.lang.Long[] tradingIds)
                                           throws ECException,
                                                  java.sql.SQLException
        Saves the trading agreements that were used for searching the price for an order item.

        Parameters:
        orderitemAB - the access bean of the order item.
        tradingIds - the ids of the tradings to be saved.
        Throws:
        ECException
        java.sql.SQLException
      • isTradingAgreementValid

        public static boolean isTradingAgreementValid(java.lang.Long tradingId,
                                                      java.lang.String[] eligibleTradingIds)
                                               throws ECException
        Verifies the input trading agreement against a list of eligible trading agreements.

        Parameters:
        tradingId - the id of the trading agreement to be verified.
        eligibleTradingIds - the ids of the list of eligible trading agreements.

        Returns:
        true if the trading agreements is valid; false otherwise.
        Throws:
        ECException
      • resolveTradingAgreements

        public static java.lang.Long[] resolveTradingAgreements(CommandContext commandContext,
                                                                OrderItemAccessBean orderitemAB,
                                                                java.lang.Long[] tradingIds,
                                                                int refreshFlag)
                                                         throws ECException,
                                                                java.sql.SQLException
        Verifies and resolves a list of eligible trading agreements for the user.

        If trading agreements are specified, the input list will be verified against the eligible list before they will be used.

        If the orderitem is newly created but no trading agreements are specified. The trading agreements can be obtained from the Command Context if the input member id is the one in Command Context. Or they can be retrieved by the member id (if it is provided and different from that in the Command Context). Existing order item will have the price refreshed according to the price refresh flag.

        Parameters:
        commandContext - the command context.
        orderitemAB - the access bean of the order item.
        tradingIds - the input trading agreement ids.
        refreshFlag - the price refresh flag.

        Returns:
        a list of trading agreements to be used for price.
        Throws:
        ECException
        java.sql.SQLException
      • verifyTradingIsStillValid

        public static void verifyTradingIsStillValid(CommandContext theCommandContext,
                                                     OrderItemAccessBean theOrderItemAB)
                                              throws ECException
        Verifies that the trading id of the order item is still valid. If it is not still valid then an exception is raised.
        Parameters:
        theCommandContext - The command context.
        theOrderItemAB - The order item to check.
        Throws:
        ECException - If the trading is no longer valid then this exception is raised with the message _ERR_INVALID_TRADING.
      • retrieveOffers

        public static java.lang.Long[] retrieveOffers(OrderItemAccessBean orderitemAB,
                                                      int refreshFlag,
                                                      boolean retryFlag)
                                               throws ECException,
                                                      java.sql.SQLException
        Retrieves previously searched offers for an order item based on the Price Refresh Flag (PRICEREFFLAGS) in STORE: 0: Default, same as 1 except that it will not save the offer id. 1: This means useCurrentOnly. This uses the prices directly referenced by the OrderItems. Fail if they can no longer be used. 2: This means useCurrentOrSearchAgain. This is the same as useCurrentOnly. But instead of failing when they can no longer be used, it searches the ones that were originally searched. That is, when the OrderItems were created or updated with new offer ids specified. 4: This means alwaysSearchAgain. This option always searches the prices that were originally searched when the OrderItems were created or updated with new offer ids specified. 8: Before calling price command, sum the quantity for the order items with same catentry. It will get the best price and update the orderitem offerId. It will not save the offerId in the ORDIOFFER.

        Parameters:
        orderitemAB - the access bean of the order item.
        refreshFlag - the price refresh flag.
        retryFlag - the price calculation retry flag.

        Returns:
        a list of offer ids to be used for price.
        Throws:
        ECException
        java.sql.SQLException
      • retrieveOffers

        public static java.lang.Long[] retrieveOffers(OrderItemAccessBean anabOrderItem,
                                                      int anRefreshFlag)
        Retrieves previously searched offers for an order item based on the Price Refresh Flag (PRICEREFFLAGS) in STORE: 0: Default, same as 1 except that it will not save the offer id. 1: This means useCurrentOnly. This uses the prices directly referenced by the OrderItems. Fail if they can no longer be used. 2: This means useCurrentOrSearchAgain. This is the same as useCurrentOnly. But instead of failing when they can no longer be used, it searches the ones that were originally searched. That is, when the OrderItems were created or updated with new offer ids specified. 4: This means alwaysSearchAgain. This option always searches the prices that were originally searched when the OrderItems were created or updated with new offer ids specified. 8: Before calling price command, sum the quantity for the order items with same catentry. It will get the best price and update the orderitem offerId. It will not save the offerId in the ORDIOFFER.

        Parameters:
        anabOrderItem - the access bean of the order item.
        anRefreshFlag - the price refresh flag.

        Returns:
        a list of offer ids to be used for price.
      • retrieveSearchedAndSavedOffers

        public static java.lang.Long[] retrieveSearchedAndSavedOffers(OrderItemAccessBean anabOrderItem)
        Retrieves previously searched offers for an order item.

        Parameters:
        anabOrderItem - the access bean of the order item.

        Returns:
        a list of trading agreement ids to be used for price.
      • retrieveTradings

        public static java.lang.Long[] retrieveTradings(CommandContext aCommandContext,
                                                        OrderItemAccessBean anabOrderItem,
                                                        int anRefreshFlag)
                                                 throws java.sql.SQLException,
                                                        ECException
        This method calls the task command RetrieveTradingsTaskCmd to retrieve previously searched trading agreements for an orderitem based on the Price Refresh Flag (PRICEREFFLAGS) in STORE: 0: Default, same as 1 except that it will not save the trading agreement id. 1: This means useCurrentOnly. This uses the prices directly referenced by the OrderItems. Fail if they can no longer be used. 2: This means useCurrentOrSearchAgain. This is the same as useCurrentOnly. But instead of failing when they can no longer be used, it searches the ones that were originally searched. That is, when the OrderItems were created or updated with new trading agreement ids specified. 4: This means alwaysSearchAgain. This option always searches the prices that were originally searched when the OrderItems were created or updated with new trading agreement ids specified. 8: Before calling price command, sum the quantity for the order items with same catentry. It will get the best price and update the orderitem tradingId. It will not save the tradingId in the ORDITRD.

        Parameters:
        aCommandContext - the current command context.
        anabOrderItem - the access bean of the order item.
        anRefreshFlag - the price refresh flag.

        Returns:
        a list of trading agreement ids to be used for price.
        Throws:
        java.sql.SQLException
        ECException
      • retrieveSearchedAndSavedTradings

        public static java.lang.Long[] retrieveSearchedAndSavedTradings(OrderItemAccessBean anabOrderItem,
                                                                        CommandContext aCommandContext)
                                                                 throws java.sql.SQLException,
                                                                        ECException
        Retrieves previously searched valid trading agreements for an order item.

        Parameters:
        anabOrderItem - the access bean of the order item.
        aCommandContext - the current command context.

        Returns:
        a list of trading agreement ids to be used for price.
        Throws:
        java.sql.SQLException
        ECException
      • toString

        public static java.lang.String toString(java.lang.Long[] anArr)
      • retrieveTradings

        public static java.lang.Long[] retrieveTradings(CommandContext commandContext,
                                                        OrderItemAccessBean orderitemAB,
                                                        int refreshFlag,
                                                        boolean retryFlag)
                                                 throws ECException,
                                                        java.sql.SQLException
        Retrieves previously searched trading agreements for an order item based on the Price Refresh Flag (PRICEREFFLAGS) in STORE: 0: Default, same as 1 except that it will not save the trading agreement id. 1: This means useCurrentOnly. This uses the prices directly referenced by the OrderItems. Fail if they can no longer be used. 2: This means useCurrentOrSearchAgain. This is the same as useCurrentOnly. But instead of failing when they can no longer be used, it searches the ones that were originally searched. That is, when the OrderItems were created or updated with new trading agreement ids specified. 4: This means alwaysSearchAgain. This option always searches the prices that were originally searched when the OrderItems were created or updated with new trading agreement ids specified. 8: Before calling price command, sum the quantity for the order items with same catentry. It will get the best price and update the orderitem tradingId. It will not save the tradingId in the ORDITRD.

        Parameters:
        commandContext - command context.
        orderitemAB - the access bean of the order item.
        refreshFlag - the price refresh flag.
        retryFlag - the price calculation retry flag.

        Returns:
        a list of trading agreement ids to be used for price.
        Throws:
        ECException
        java.sql.SQLException
      • updateContractId

        public static void updateContractId(OrderItemAccessBean orderitemAB,
                                            StoreAccessBean storeAB)
                                     throws ECException,
                                            java.sql.SQLException
        Saves the default contract id that provided the price for the order item (old support).

        Parameters:
        orderitemAB - the access bean of the order item.
        storeAB - the access bean of the store.
        Throws:
        ECException
        java.sql.SQLException
      • updateTotalProductPrice

        public static void updateTotalProductPrice(OrderItemAccessBean orderitemAB)
                                            throws ECException,
                                                   java.sql.SQLException
        Update the total price for the order item.
        Parameters:
        orderitemAB - OrderItemAccessBean
        Throws:
        ECException
        java.sql.SQLException
      • updateTradingId

        public static void updateTradingId(OrderItemAccessBean orderitemAB,
                                           StoreAccessBean storeAB,
                                           java.lang.Long anTradingId)
        Saves the trading agreement ids that provided the best price for the order item.

        Parameters:
        orderitemAB - the access bean of the order item.
        storeAB - the access bean of the store.
        anTradingId - the id of the trading agreement.
      • verifyTradingPaymentMethods

        public static java.lang.Long[] verifyTradingPaymentMethods(CommandContext commandContext,
                                                                   OrderItemAccessBean orderitemAB,
                                                                   java.lang.Long[] tradingIds)
                                                            throws ECException
        Verifies if the trading agreements used in the orderitem have defined compatible payment methods with those trading agreements used in the order.

        Parameters:
        commandContext - the command context.
        orderitemAB - the access bean of the order item.
        tradingIds - the trading agreement ids to be used in the order item.

        Returns:
        a result list of trading agreements that all have compatible payment methods, those that do not, should have been discarded.
        Throws:
        ECException
      • verifyTradingPaymentMethods

        public static void verifyTradingPaymentMethods(CommandContext commandContext,
                                                       java.util.Enumeration enOrderItemABs)
                                                throws ECException
        Validate the trading agreements used by the order items in an order. Check if they define compatible payment methods and are associated with the same account as the other order items in the order.
        Parameters:
        commandContext - CommandContext
        enOrderItemABs - Enumeration
        Throws:
        ECException
      • getEarliestShipTime

        public static java.sql.Timestamp getEarliestShipTime(StoreAccessBean abStore)
                                                      throws ECException
        This method gets the earliest ship time of a future order for a given store. It assumes the inventoryoffset is in seconds
        Parameters:
        abStore - as StoreAccessBean
        Returns:
        Timestamp
        Throws:
        ECException
      • getInventoryOffsetInDays

        public static double getInventoryOffsetInDays(java.lang.String storeId)
                                               throws ECException
        get the numeric value of the Inventory Allocation Offset in days for a given store
        Parameters:
        storeId - String of store entity Id such as "201"
        Returns:
        double value of days
        Throws:
        ECException
      • setInventoryOffsetInDays

        public static void setInventoryOffsetInDays(java.lang.String storeId,
                                                    double days)
                                             throws ECException
        set the Allocation Offset for a store by days
        Parameters:
        storeId - such as "201"
        days - such as 1.5
        Throws:
        ECException
      • notifyBlocker

        public static void notifyBlocker(boolean toBlock,
                                         java.lang.Integer aStoreId,
                                         CommandContext aContext,
                                         java.lang.String aOrderId,
                                         java.lang.String aBlockReasonCode,
                                         java.lang.String aComment)
                                  throws ECException
        notify the order block manager of an override on an order Invokes NotifyBlockCmd. When do blocking / unblocking, proper block reason code has to be provided, along with the orderId, and so on.
        Parameters:
        toBlock - boolean, true for blocking, false for unblocking
        aStoreId - Integer
        aContext - CommandContext
        aOrderId - String orderId
        aBlockReasonCode - String predefined
        aComment - String comment
        Throws:
        ECException - propagated from the NotifyBlockCmd
      • validatePrice

        public static int validatePrice(java.lang.Integer aStoreId,
                                        CommandContext aContext,
                                        java.lang.String aCurrency,
                                        java.lang.Long aUserId,
                                        java.lang.Long aCatEntry,
                                        java.lang.String aPrice)
                                 throws ECException
        to validate if a price is valid by calling the ValidateDelegatedPriceCmd by CSR/TSR. There are three possibilities if successful: is Valid. This may give a green light for a TSR to use the price for negotiation; is Not valid (below floor price). This gives the warning to the TSR for not authorized but pending for approval by TSR supervisor. is Not valid due to floor price not found: This needs floor price setup
        Parameters:
        aStoreId - Integer
        aContext - CommandContext
        aCurrency - String
        aUserId - Long
        aCatEntry - Long
        aPrice - String
        Returns:
        int 1 for being valid; 0 for invalid; -1 for missing floor price
        Throws:
        ECException - propagated from ValidateDelegatedPriceCmd
      • handleKitPriceNotFoundException

        public static void handleKitPriceNotFoundException(OrderItemAccessBean abOrderItem,
                                                           java.lang.String aClassName)
                                                    throws ECException
        Handles the Kit price not found exception.

        Parameters:
        abOrderItem - OrderItemAccessBean.
        aClassName - the name of the Class that detects the exception.
        Throws:
        ECException, - FinderException, CreateException, NamingException, RemoteException
        ECException
      • isPriceLock

        public static boolean isPriceLock(java.util.Hashtable ihash_dk_priceLock,
                                          java.util.Hashtable ihash_Comp_priceLocks)
        Check whether the price is locked by sterling configurator
        Parameters:
        ihash_dk_priceLock - pricelock of the dk
        ihash_Comp_priceLocks - pricelocks of the components
        Returns:
        true if the price of all the components and dk parent is locked, false otherwise Keep the old behavior for now. To be modified in future: true if the price of one component or parent is locked.
      • isPriceLock

        public static boolean isPriceLock(java.lang.String[] comp_priceLocks)
        Check whether the configuration is price locked.
        Parameters:
        comp_priceLocks - The price lock property of components
        Returns:
        true if there is price lock set to be true for the components, false if price lock is false for all the components. Parent is treated as a component.
      • isNonPriceLock

        public static boolean isNonPriceLock(java.util.Hashtable ihash_dk_priceLock,
                                             java.util.Hashtable ihash_Comp_priceLocks)
        Check whether the price is not locked by sterling configurator
        Parameters:
        ihash_dk_priceLock - pricelock of the dk
        ihash_Comp_priceLocks - pricelocks of the components
        Returns:
        true if the price of all the components and dk parent is not locked, false otherwise
      • getPriceFromConfigurator

        public static java.lang.String getPriceFromConfigurator(java.util.Hashtable ihshQuantity,
                                                                java.util.Hashtable ihshDk_price,
                                                                java.util.Hashtable ihshComp_quantity,
                                                                java.util.Hashtable ihshComp_prices)
        Get price from the BOM XML if price is locked from sterling configurator.
        Parameters:
        ihshQuantity - The quantity of the dk.
        ihshDk_price - The price of the dk.
        ihshComp_quantity - A list of component quantities.
        ihshComp_prices - A list of component prices.
        Returns:
        The total price of the dk
      • updateOrderItemConfigurations

        public static void updateOrderItemConfigurations(java.util.Vector ivOrderItems,
                                                         CommandContext commandContext)
                                                  throws ECException
        Updates order item configurations.
        Parameters:
        ivOrderItems - the order items to be updated.
        commandContext - command context
        Throws:
        ECException.
        ECException