|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object atg.nucleus.logging.VariableArgumentApplicationLoggingImpl atg.nucleus.logging.ApplicationLoggingImpl atg.commerce.order.OrderHolder
public class OrderHolder
This component, typically session-scope, keeps track of the Order objects that are associated with a user. A shopping cart in DCS 5 is merely an Order in an INCOMPLETE state. The default Nucleus component which represents this object is /atg/commerce/ShoppingCart. From this component one can reference the current Order (aka shopping cart) that the user is actively adding and removing items to be purchased. Other components such as the ShoppingCartFormHandler are configured to reference the current order. In addition this class keeps track of a collection of saved carts, to allow the user to have multiple shopping carts. The component provides several form handler methods which allow one to give control to the user to create, switch and delete orders.
Here is an example of a form which allows one to manage multiple shopping carts.
<importbean bean="/atg/commerce/ShoppingCart"> <form action="shoppingcart.jhtml" method="post"> <droplet bean="/atg/dynamo/droplet/Switch"> <param name="value" value="bean:ShoppingCart.savedEmpty"> <oparam name="true"> <!-- since there are no saved carts, we cannot switch to another so we only give them the option to create a new cart --> <input type=submit bean="ShoppingCart.create" value="Create"> another shopping cart </oparam> <oparam name="false"> <!-- We have other shopping carts, so let them do everything --> Shopping Cart <select bean="ShoppingCart.handlerOrderId"> <droplet bean="ForEach"> <param name="array" value="bean:ShoppingCart.saved"> <param name="elementName" value="savedcart"> <oparam name="output"> <option value="param:savedcart.id"><valueof param="savedcart.id"></valueof> </oparam> </droplet> </select>: <input type=submit bean="ShoppingCart.switch" value="Switch"> to, <input type=submit bean="ShoppingCart.delete" value="Delete"> or <input type=submit bean="ShoppingCart.create" value="Create"> another shopping cart.<BR> <input type=submit bean="ShoppingCart.deleteAll" value="Delete All Shopping Carts"> </oparam> </droplet> </form>These are a listing of the important properties of the class and their behavior.
current
Order property.
Order
Field Summary | |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string |
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging |
---|
DEFAULT_LOG_TRACE_STATUS |
Fields inherited from interface atg.nucleus.logging.ApplicationLogging |
---|
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS |
Constructor Summary | |
---|---|
OrderHolder()
Constructs an instanceof OrderHolder |
Method Summary | |
---|---|
protected Order |
createInitialOrder(RepositoryItem pProfile)
Creates the initial order for the given user. |
boolean |
deleteOrder(java.lang.String pOrderId)
Delete the order with the given id from the current or saved orders. |
Order |
getCurrent()
Returns the current Order (aka shopping cart). |
Order |
getCurrent(boolean pEnsureOrder)
Returns the current Order (aka shopping cart), optionally loading or creating an order if the current order is null. |
java.lang.String |
getFailoverRecoveryPricingOperation()
Returns property FailoverRecoveryPricingOperation |
java.lang.String |
getHandlerOrderId()
Returns property HandlerOrderId |
Order |
getLast()
Returns the last completed Order. |
java.lang.String |
getLoggingIdentifier()
Returns property LoggingIdentifier |
MessageSender |
getMessageSender()
Returns Message Sender to send scenario Events |
OrderManager |
getOrderManager()
Returns property OrderManager |
java.lang.String |
getOrderType()
Returns the type of order to create when we need to construct a new shopping cart order. |
RepositoryItem |
getProfile()
Returns property Profile |
CommerceProfileTools |
getProfileTools()
Returns property ProfileTools |
RestorableOrders |
getRestorableOrders()
Returns property RestorableOrders |
java.util.Collection |
getSaved()
Returns a collection of Order objects which are the user's saved list of shopping carts. |
javax.transaction.TransactionManager |
getTransactionManager()
|
boolean |
handleCreate(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
This form handler moves the current order into the saved order collection. |
boolean |
handleDelete(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
The handler method takes the order id as specified in the handlerOrderId
property and deletes that order through invoking the deleteOrder method. |
boolean |
handleDeleteAll(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
This handler will delete all the shopping carts (current and saved) |
boolean |
handleSwitch(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
The handler method takes the order id as specified in the handlerOrderId
property and makes that the current order through invoking the switchCurrentOrder
method. |
boolean |
isCurrentEmpty()
Returns true if the current order is null or has no commerce items |
boolean |
isCurrentExists()
Return true if the current order even exists. |
boolean |
isCurrentTransient()
Return true if the current order is null or transient |
boolean |
isEmpty()
Returns true if both the current and the collection of saved orders is empty |
boolean |
isPersistOrders()
Returns property PersistOrders |
boolean |
isPersistOrdersForAnonymousUsers()
Returns the persistOrdersForAnonymousUsers |
boolean |
isRepriceAfterFailoverRecovery()
Returns property RepriceAfterFailoverRecovery |
boolean |
isSavedEmpty()
Returns true if the collection of saved orders is null or empty |
boolean |
isSaveEmptyOrders()
|
void |
removeSavedOrder(java.lang.String pOrderId)
This method removes the order with the given id from the collection of saved orders. |
protected void |
repriceRestoredShoppingCart(Order pOrder,
DynamoHttpServletRequest pRequest)
Fetch the request and response objects through JNDI (e.g. |
protected void |
repriceRestoredShoppingCarts(java.util.Collection pOrders,
DynamoHttpServletRequest pRequest)
Reprice the collection of orders by calling repriceRestoredShoppingCart
on each one. |
protected void |
resetOrderProfileId(Order pOrder)
When a session recovers from failover, if the user is anonymous, then typically they will get a new profile object, and as such a new profile id. |
void |
sendScenarioEvent(CommerceMessage pMessage)
Send the scenario event with the message passed. |
protected void |
sendSwitchOrderMessage(Order pOldOrder,
Order pNewOrder)
|
void |
sessionRestored()
This method is invoked during the recovery phase of a session backup. |
void |
setCurrent(Order pCurrent)
Sets property Current |
void |
setFailoverRecoveryPricingOperation(java.lang.String pFailoverRecoveryPricingOperation)
Sets property FailoverRecoveryPricingOperation |
void |
setHandlerOrderId(java.lang.String pHandlerOrderId)
Sets property HandlerOrderId |
void |
setLast(Order pLast)
Sets property Last |
void |
setLoggingIdentifier(java.lang.String pLoggingIdentifier)
Sets property LoggingIdentifier |
void |
setMessageSender(MessageSender pMessageSender)
Sets Message Sender to send scenario Events |
void |
setOrderManager(OrderManager pOrderManager)
Sets property OrderManager |
void |
setOrderType(java.lang.String pOrderType)
Sets property OrderType |
void |
setPersistOrders(boolean pPersistOrders)
Sets property PersistOrders |
void |
setPersistOrdersForAnonymousUsers(boolean pPersistOrdersForAnonymousUsers)
Sets the persistOrdersForAnonymousUsers |
void |
setProfile(RepositoryItem pProfile)
Sets property Profile |
void |
setProfileTools(CommerceProfileTools pProfileTools)
Sets property ProfileTools |
void |
setRepriceAfterFailoverRecovery(boolean pRepriceAfterFailoverRecovery)
Sets property RepriceAfterFailoverRecovery |
void |
setRestorableOrders(RestorableOrders pRestorableOrders)
Sets property RestorableOrders |
void |
setSaved(java.util.Collection pSaved)
|
void |
setSaveEmptyOrders(boolean pSaveEmptyOrders)
|
void |
setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
|
protected boolean |
shouldSaveOnSwitch(Order pOrder)
Return true if we should save the specified order when doing a switch order operation, false otherwise. |
boolean |
switchCurrentOrder(java.lang.String pNewCurrentId)
Switch the current order to the order with the given id, move the old current order into the saved orders |
protected boolean |
validActiveShoppingCart(Order pOrder)
Return true if the order can be used for a shopping cart. |
protected boolean |
validRestoredShoppingCart(Order pOrder)
Returns true if the order is still valid after a session has been restored. |
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl |
---|
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String CLASS_VERSION
Constructor Detail |
---|
public OrderHolder()
Method Detail |
---|
public void setLoggingIdentifier(java.lang.String pLoggingIdentifier)
setLoggingIdentifier
in class ApplicationLoggingImpl
public java.lang.String getLoggingIdentifier()
getLoggingIdentifier
in class ApplicationLoggingImpl
public void setPersistOrders(boolean pPersistOrders)
public boolean isPersistOrders()
public boolean isSaveEmptyOrders()
public void setSaveEmptyOrders(boolean pSaveEmptyOrders)
pSaveEmptyOrders
- Specify whether or not to save the current order if it's empty
when switching to a previously saved order. Defaults to false,
but can be set to true to preserve backward compatibility with
ATG Commerce version 7.0 and earlier.protected boolean shouldSaveOnSwitch(Order pOrder)
saveEmptyOrders
is set
to true.
Subclasses may override this method to implement different behavior if necessary.
public boolean isPersistOrdersForAnonymousUsers()
public void setPersistOrdersForAnonymousUsers(boolean pPersistOrdersForAnonymousUsers)
public void setOrderType(java.lang.String pOrderType)
public java.lang.String getOrderType()
public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
public javax.transaction.TransactionManager getTransactionManager()
public void setRepriceAfterFailoverRecovery(boolean pRepriceAfterFailoverRecovery)
public boolean isRepriceAfterFailoverRecovery()
public void setFailoverRecoveryPricingOperation(java.lang.String pFailoverRecoveryPricingOperation)
public java.lang.String getFailoverRecoveryPricingOperation()
public void setProfile(RepositoryItem pProfile)
public RepositoryItem getProfile()
public void setOrderManager(OrderManager pOrderManager)
public OrderManager getOrderManager()
public void setProfileTools(CommerceProfileTools pProfileTools)
public CommerceProfileTools getProfileTools()
public boolean isCurrentEmpty()
public boolean isCurrentTransient()
public boolean isCurrentExists()
public boolean isSavedEmpty()
public boolean isEmpty()
public void setCurrent(Order pCurrent)
public Order getCurrent(boolean pEnsureOrder)
pEnsureOrder
- If true and the current order is null, attempt to load previously saved
order or create and return a new order for the user. If false and the
current order is null, simply return null.public Order getCurrent()
CommerceProfileTools.loadShoppingCarts(atg.repository.RepositoryItem, atg.commerce.order.OrderHolder)
public void setSaved(java.util.Collection pSaved)
public java.util.Collection getSaved()
current
Order
property.
public void setRestorableOrders(RestorableOrders pRestorableOrders)
public RestorableOrders getRestorableOrders()
public void setLast(Order pLast)
public Order getLast()
public void setHandlerOrderId(java.lang.String pHandlerOrderId)
public java.lang.String getHandlerOrderId()
public void setMessageSender(MessageSender pMessageSender)
public MessageSender getMessageSender()
public boolean deleteOrder(java.lang.String pOrderId)
public boolean switchCurrentOrder(java.lang.String pNewCurrentId)
public void removeSavedOrder(java.lang.String pOrderId)
protected Order createInitialOrder(RepositoryItem pProfile) throws CommerceException
persistOrders
property is true then we also automatically
save the order in the database so it can be loaded in the future.
CommerceException
public boolean handleSwitch(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
handlerOrderId
property and makes that the current order through invoking the switchCurrentOrder
method.
pRequest
- the servlet's requestpResponse
- the servlet's response
javax.servlet.ServletException
- if there was an error while executing the code
java.io.IOException
- if there was an error with servlet iopublic boolean handleCreate(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
pRequest
- the servlet's requestpResponse
- the servlet's response
javax.servlet.ServletException
- if there was an error while executing the code
java.io.IOException
- if there was an error with servlet iopublic boolean handleDelete(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
handlerOrderId
property and deletes that order through invoking the deleteOrder
method.
pRequest
- the servlet's requestpResponse
- the servlet's response
javax.servlet.ServletException
- if there was an error while executing the code
java.io.IOException
- if there was an error with servlet iopublic boolean handleDeleteAll(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
pRequest
- the servlet's requestpResponse
- the servlet's response
javax.servlet.ServletException
- if there was an error while executing the code
java.io.IOException
- if there was an error with servlet ioprotected boolean validActiveShoppingCart(Order pOrder)
protected boolean validRestoredShoppingCart(Order pOrder)
protected void resetOrderProfileId(Order pOrder)
public void sessionRestored()
sessionRestored
in interface atg.servlet.sessionsaver.Restoreable
protected void repriceRestoredShoppingCarts(java.util.Collection pOrders, DynamoHttpServletRequest pRequest)
repriceRestoredShoppingCart
on each one.
protected void repriceRestoredShoppingCart(Order pOrder, DynamoHttpServletRequest pRequest)
java:dynamo/Request
)
and then call the CommerceProfileTools.repriceShoppingCarts method. This method will
then lookup the UserPricingModels, the user's locale, and then reprice the order.
protected void sendSwitchOrderMessage(Order pOldOrder, Order pNewOrder)
public void sendScenarioEvent(CommerceMessage pMessage)
MessageSender
property and fires
the event.
pMessage
- the message to fire.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |