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.


Field Summary
static int PRICEREF_COMPLETE_REFRESH
           
static int PRICEREF_DEFAULT
           
static int PRICEREF_QUICK_COMPLETE_REFRESH
           
static int PRICEREF_QUICK_REFRESH
           
 
Constructor Summary
OrderItemsCmdHelper()
          OrderProcessingHelper constructor comment.
 
Method Summary
static java.lang.String[] getEligibleTradingAgreements(CommandContext commandContext, java.lang.Long memberId)
          Obtaints a list of eligible trading agreements to be used.
static OrderItemsCmdHelper getUniqueInstance()
          Get the unique instance of the OrderItemsCmdHelper object.
static void insertOrderItemOffer(OrderItemAccessBean orderitemAB, java.lang.Long[] offerIds)
          Saves the offers that were used for searching the price for an orderitem.
static void insertOrderItemTrading(OrderItemAccessBean orderitemAB, java.lang.Long[] tradingIds)
          Saves the trading agreements that were used for searching the price for an orderitem.
static boolean isTradingAgreementValid(java.lang.Long tradingId, java.lang.String[] eligibleTradingIds)
          Verifies the input trading agreement against a list of eligible trading agreements.
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 orderitemAB, int refreshFlag, boolean retryFlag)
          Retrieves previously searched offers for an orderitem 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[] retrieveTradings(CommandContext commandContext, OrderItemAccessBean orderitemAB, int refreshFlag, boolean retryFlag)
          Retrieves previously searched offers 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 void updateContractId(OrderItemAccessBean orderitemAB, StoreAccessBean storeAB)
          Saves the default contract id that provided the price for the orderitem (old support).
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 orderitem.
static void verifyTradingPaymentMethods(CommandContext commandContext, java.util.Enumeration enOrderItemABs)
          Validate the trading agreements used by the orderitems in an order by checking if they define compatible payment methods and are associated with the same account as the other orderitems in the order.
static java.lang.Long[] verifyTradingPaymentMethods(CommandContext commandContext, OrderItemAccessBean orderitemAB, java.lang.Long[] tradingIds)
          Verifies if the trading agreements being used in an orderitem have defined compatible payment methods with those trading agreements that are being used in the order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRICEREF_COMPLETE_REFRESH

public static final int PRICEREF_COMPLETE_REFRESH

PRICEREF_DEFAULT

public static final int PRICEREF_DEFAULT

PRICEREF_QUICK_COMPLETE_REFRESH

public static final int PRICEREF_QUICK_COMPLETE_REFRESH

PRICEREF_QUICK_REFRESH

public static final int PRICEREF_QUICK_REFRESH
Constructor Detail

OrderItemsCmdHelper

public OrderItemsCmdHelper()
OrderProcessingHelper constructor comment.
Method Detail

getEligibleTradingAgreements

public static java.lang.String[] getEligibleTradingAgreements(CommandContext commandContext,
                                                              java.lang.Long memberId)
                                                       throws ECException,
                                                              javax.ejb.FinderException,
                                                              javax.ejb.CreateException,
                                                              javax.naming.NamingException,
                                                              java.rmi.RemoteException,
                                                              java.sql.SQLException
Obtaints a list of eligible trading agreements to be used.

The eligible list of trading agreements can be obtained directly from the Command Context (if no member id is provided or the input member id is the one in Command Context) or retrieved by means of the member id (if the id is provided and is 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.

getUniqueInstance

public static OrderItemsCmdHelper getUniqueInstance()
Get the unique instance of the OrderItemsCmdHelper object.

insertOrderItemOffer

public static void insertOrderItemOffer(OrderItemAccessBean orderitemAB,
                                        java.lang.Long[] offerIds)
                                 throws ECException,
                                        javax.ejb.FinderException,
                                        javax.ejb.CreateException,
                                        javax.naming.NamingException,
                                        java.rmi.RemoteException,
                                        java.sql.SQLException
Saves the offers that were used for searching the price for an orderitem.

Parameters:
orderitemAB - the access bean of the orderitem.
offerIds - the ids of the offers to be saved.

insertOrderItemTrading

public static void insertOrderItemTrading(OrderItemAccessBean orderitemAB,
                                          java.lang.Long[] tradingIds)
                                   throws ECException,
                                          javax.ejb.FinderException,
                                          javax.ejb.CreateException,
                                          javax.naming.NamingException,
                                          java.rmi.RemoteException,
                                          java.sql.SQLException
Saves the trading agreements that were used for searching the price for an orderitem.

Parameters:
orderitemAB - the access bean of the orderitem.
tradingIds - the ids of the tradings to be saved.

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.

resolveTradingAgreements

public static java.lang.Long[] resolveTradingAgreements(CommandContext commandContext,
                                                        OrderItemAccessBean orderitemAB,
                                                        java.lang.Long[] tradingIds,
                                                        int refreshFlag)
                                                 throws ECException,
                                                        javax.ejb.FinderException,
                                                        javax.ejb.CreateException,
                                                        javax.naming.NamingException,
                                                        java.rmi.RemoteException,
                                                        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 retrieved by means of the member id (if the id is provided and is different from that in the Command Context). Existing orderitem will have the price refreshed according to the price refresh flag.

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

Returns:
a list of trading agreements to be used for price.

retrieveOffers

public static java.lang.Long[] retrieveOffers(OrderItemAccessBean orderitemAB,
                                              int refreshFlag,
                                              boolean retryFlag)
                                       throws ECException,
                                              javax.ejb.FinderException,
                                              javax.ejb.CreateException,
                                              javax.naming.NamingException,
                                              java.rmi.RemoteException,
                                              java.sql.SQLException
Retrieves previously searched offers for an orderitem 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 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.

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

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

retrieveTradings

public static java.lang.Long[] retrieveTradings(CommandContext commandContext,
                                                OrderItemAccessBean orderitemAB,
                                                int refreshFlag,
                                                boolean retryFlag)
                                         throws ECException,
                                                javax.ejb.FinderException,
                                                javax.ejb.CreateException,
                                                javax.naming.NamingException,
                                                java.rmi.RemoteException,
                                                java.sql.SQLException
Retrieves previously searched offers 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 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.

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

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

updateContractId

public static void updateContractId(OrderItemAccessBean orderitemAB,
                                    StoreAccessBean storeAB)
                             throws ECException,
                                    javax.ejb.FinderException,
                                    javax.ejb.CreateException,
                                    javax.naming.NamingException,
                                    java.rmi.RemoteException,
                                    java.sql.SQLException
Saves the default contract id that provided the price for the orderitem (old support).

Parameters:
orderitemAB - the access bean of the orderitem.
storeAB - the access bean of the store.

updateTotalProductPrice

public static void updateTotalProductPrice(OrderItemAccessBean orderitemAB)
                                    throws ECException,
                                           javax.ejb.FinderException,
                                           javax.ejb.CreateException,
                                           javax.naming.NamingException,
                                           java.rmi.RemoteException,
                                           java.sql.SQLException
Update the total price for the order item.

updateTradingId

public static void updateTradingId(OrderItemAccessBean orderitemAB,
                                   StoreAccessBean storeAB,
                                   java.lang.Long anTradingId)
                            throws ECException,
                                   javax.ejb.FinderException,
                                   javax.ejb.CreateException,
                                   javax.naming.NamingException,
                                   java.rmi.RemoteException,
                                   java.sql.SQLException
Saves the trading agreement ids that provided the best price for the orderitem.

Parameters:
orderitemAB - the access bean of the orderitem.
storeAB - the access bean of the store.
anTradingId - the id of the trading agreement.

verifyTradingPaymentMethods

public static void verifyTradingPaymentMethods(CommandContext commandContext,
                                               java.util.Enumeration enOrderItemABs)
                                        throws ECException
Validate the trading agreements used by the orderitems in an order by checking if they define compatible payment methods and are associated with the same account as the other orderitems in the order.

verifyTradingPaymentMethods

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

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

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