atg.commerce.csr.approvals.order
Class OrderApprovalsHandler

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.csr.approvals.GenericApprovalsHandler
              extended by atg.commerce.csr.approvals.order.OrderApprovalsHandler
All Implemented Interfaces:
atg.naming.AbsoluteNameable, atg.naming.NameContextBindingListener, atg.naming.NameContextElement, atg.naming.NameContextParentable, atg.naming.NameResolver, atg.nucleus.AdminableService, atg.nucleus.Configured, atg.nucleus.logging.ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, atg.nucleus.naming.ComponentNameResolver, atg.nucleus.Service, atg.nucleus.ServiceListener, java.util.EventListener

public class OrderApprovalsHandler
extends GenericApprovalsHandler

Order Approvals Handler. This handler is responsible for dealing with approvals relating to orders. It is called from the Approvals Manager to determine if an approval is required for an order, to save and load the approval's order specific information from the ApprovalRepository, and also to perform order specific operations during the approval and rejection process.


Field Summary
static double APPROVAL_NOT_REQUIRED
          Approval not required constant
static java.lang.String ATTRIBUTE_APPROVER_LOCALE
          The attribute name used to store the locale of the user doing the approval
static java.lang.String ATTRIBUTE_CUSTOMER_EMAIL
          the attribute name used to store the customers email address in the Approval object's attributes.
static java.lang.String ATTRIBUTE_ORDER
          the attribute name used to store the Order in the Approval object's attributes.
static java.lang.String ATTRIBUTE_ORDER_TOTAL
          the attribute name used to store the Order's total in the Approval object's attributes.
static java.lang.String ATTRIBUTE_TOTAL_APPEASEMENTS
          the attribute name used to store the total appeasement amount in the Approval object's attributes.
static java.lang.String CLASS_VERSION
           
protected  atg.security.UserAuthority mAuthority
           
protected  CSRAgentTools mCSRAgentTools
           
protected  OrderApprovalTools mOrderApprovalTools
           
protected  java.lang.String mOrderApproverAccessRight
           
protected  atg.commerce.order.OrderManager mOrderManager
           
protected  atg.commerce.payment.PaymentManager mPaymentManager
           
protected  atg.security.GenericSecurityDomain mSecurityDomain
           
protected  javax.transaction.TransactionManager mTransactionManager
           
 
Fields inherited from class atg.commerce.csr.approvals.GenericApprovalsHandler
mApprovalAcceptedJMSType, mApprovalCreatedJMSType, mApprovalItemDescriptorName, mApprovalRejectedJMSType, mCSRAgentMessagingTools
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
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
OrderApprovalsHandler()
           
 
Method Summary
 void approve(Approval pApproval)
          processes the order supplied as an attribute on the pApproval
protected  boolean doesAgentHaveAppeasmentLimit(Approval pApproval)
          checks if the agent has an unlimited appeasement limit, and returns false not
protected  boolean doesAgentRequireApproval(Approval pApproval)
          checks if the Agent has an approvers role, and return false if it is present
protected  boolean doesAppeasementsExceedLimit(Approval pApproval)
          checks if the total appeasements on the orders exceed the agent's appeasement limit
protected  void doPaymentGroupAuthorizations(atg.commerce.order.Order pOrder, Approval pApproval, atg.repository.MutableRepositoryItem pItem)
          This method is called when saving the approval and executes the initial payment group authorization for payment groups that have no authorization status yet.
protected  java.util.Map generateOrderApprovalParameters(Approval pApproval)
          Generates the extra parameter map that is passed to processOrder when approving an Order.
protected  double getAgentAppeasementLimit(Approval pApproval)
          get the agent's appeasement limit
 atg.commerce.csr.events.ApprovalEvent getApprovalAcceptedEvent(Approval pApproval)
          creates and populates an OrderApprovalEvent
 atg.commerce.csr.events.ApprovalEvent getApprovalCreatedEvent(Approval pApproval)
          creates and populates an OrderApprovalEvent
 atg.commerce.csr.events.ApprovalEvent getApprovalRejectedEvent(Approval pApproval)
          creates and populates an OrderApprovalEvent
 CSRAgentTools getCSRAgentTools()
          Returns the CSR Agent Tools Component
 OrderApprovalTools getOrderApprovalTools()
          Returns a reference to the OrderApprovalTools component that provides order approval helper methods and property definitions.
 java.lang.String getOrderApproverAccessRight()
          Returns the name of the access right that permits agents to complete order approvals.
 atg.commerce.order.OrderManager getOrderManager()
          Returns a reference to the Order Manager conmponent
 atg.commerce.payment.PaymentManager getPaymentManager()
          Returns a reference to the Payement Manager conmponent
 atg.security.GenericSecurityDomain getSecurityDomain()
          Return the security domain currently in use for checking order approval access rights.
 double getTotalAppeasementsForOrder(atg.commerce.order.Order pOrder)
          calculates the total appeasements for the specified order
 javax.transaction.TransactionManager getTransactionManager()
          Returns the Transaction manager component
 atg.security.UserAuthority getUserAuthority()
          Returns an reference to the InternalUserProfileAuthority that's used to check access rights for the agent identified in the Approval object.
 boolean isApprovalRequired(Approval pApproval)
          Determines if an order approval is required for the specified approval object.
 void loadApproval(Approval pApproval)
          Loads the order associated with the approval and also the order specific properties for the approval
 void reject(Approval pApproval)
          Executes the process of rejecting an order that is pending approval.
 void saveApproval(Approval pApproval, atg.repository.MutableRepositoryItem pItem)
          This method saves the application specific data for an Order approval.
 void setCSRAgentTools(CSRAgentTools pCSRAgentTools)
          Sets the CSR Agent Tools component
 void setOrderApprovalTools(OrderApprovalTools pOrderApprovalTools)
          Sets a reference to the OrderApprovalTools component that provides order approval helper methods and property definitions.
 void setOrderApproverAccessRight(java.lang.String pOrderApproverAccessRight)
          Sets the Order Approver Access Right that permits agents to complete order approvals.
 void setOrderManager(atg.commerce.order.OrderManager pOrderManager)
          Sets the Order Manager conmponent
protected  void setOrderStateToPendingApproval(atg.commerce.order.Order pOrder, Approval pApproval)
          This method is called when saving the approval and sets the Order to the appropriate pending approval state.
protected  void setOrderStateToRejected(atg.commerce.order.Order pOrder, Approval pApproval)
          This method is called when an approval is rejected to set the order's state.
 void setPaymentManager(atg.commerce.payment.PaymentManager pPaymentManager)
          Sets the Payement Manager conmponent
 void setSecurityDomain(atg.security.GenericSecurityDomain pSecurityDomain)
          Set the security domain currently in use for checking order approval access rights.
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Sets the Transaction manager component
 void setUserAuthority(atg.security.UserAuthority pAuthority)
          Sets the user Authority.
 
Methods inherited from class atg.commerce.csr.approvals.GenericApprovalsHandler
getApprovalAcceptedJMSType, getApprovalCreatedJMSType, getApprovalItemDescriptorName, getApprovalRejectedJMSType, getCSRAgentMessagingTools, setApprovalAcceptedJMSType, setApprovalCreatedJMSType, setApprovalItemDescriptorName, setApprovalRejectedJMSType, setCSRAgentMessagingTools
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
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

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
See Also:
Constant Field Values

APPROVAL_NOT_REQUIRED

public static final double APPROVAL_NOT_REQUIRED
Approval not required constant

See Also:
Constant Field Values

ATTRIBUTE_ORDER

public static final java.lang.String ATTRIBUTE_ORDER
the attribute name used to store the Order in the Approval object's attributes.

See Also:
Constant Field Values

ATTRIBUTE_TOTAL_APPEASEMENTS

public static final java.lang.String ATTRIBUTE_TOTAL_APPEASEMENTS
the attribute name used to store the total appeasement amount in the Approval object's attributes.

See Also:
Constant Field Values

ATTRIBUTE_CUSTOMER_EMAIL

public static final java.lang.String ATTRIBUTE_CUSTOMER_EMAIL
the attribute name used to store the customers email address in the Approval object's attributes.

See Also:
Constant Field Values

ATTRIBUTE_ORDER_TOTAL

public static final java.lang.String ATTRIBUTE_ORDER_TOTAL
the attribute name used to store the Order's total in the Approval object's attributes.

See Also:
Constant Field Values

ATTRIBUTE_APPROVER_LOCALE

public static final java.lang.String ATTRIBUTE_APPROVER_LOCALE
The attribute name used to store the locale of the user doing the approval

See Also:
Constant Field Values

mSecurityDomain

protected atg.security.GenericSecurityDomain mSecurityDomain

mOrderApproverAccessRight

protected java.lang.String mOrderApproverAccessRight

mAuthority

protected atg.security.UserAuthority mAuthority

mOrderApprovalTools

protected OrderApprovalTools mOrderApprovalTools

mPaymentManager

protected atg.commerce.payment.PaymentManager mPaymentManager

mOrderManager

protected atg.commerce.order.OrderManager mOrderManager

mCSRAgentTools

protected CSRAgentTools mCSRAgentTools

mTransactionManager

protected javax.transaction.TransactionManager mTransactionManager
Constructor Detail

OrderApprovalsHandler

public OrderApprovalsHandler()
Method Detail

getSecurityDomain

public atg.security.GenericSecurityDomain getSecurityDomain()
Return the security domain currently in use for checking order approval access rights.

Returns:
the security domain

setSecurityDomain

public void setSecurityDomain(atg.security.GenericSecurityDomain pSecurityDomain)
Set the security domain currently in use for checking order approval access rights.

Parameters:
pSecurityDomain - The security domain to set

getOrderApproverAccessRight

public java.lang.String getOrderApproverAccessRight()
Returns the name of the access right that permits agents to complete order approvals. This access right is checked when determining if an order requires approval. If present on the agent's profile, the appeasement limit check is bypassed and no approval is required.


setOrderApproverAccessRight

public void setOrderApproverAccessRight(java.lang.String pOrderApproverAccessRight)
Sets the Order Approver Access Right that permits agents to complete order approvals. This access right is checked when determining if an order requires approval. If present on the agent's profile, the appeasement limit check is bypassed and no approval is required.


getUserAuthority

public atg.security.UserAuthority getUserAuthority()
Returns an reference to the InternalUserProfileAuthority that's used to check access rights for the agent identified in the Approval object.


setUserAuthority

public void setUserAuthority(atg.security.UserAuthority pAuthority)
Sets the user Authority. Used to check access rights for the agent identified in the Approval object.


getOrderApprovalTools

public OrderApprovalTools getOrderApprovalTools()
Returns a reference to the OrderApprovalTools component that provides order approval helper methods and property definitions.


setOrderApprovalTools

public void setOrderApprovalTools(OrderApprovalTools pOrderApprovalTools)
Sets a reference to the OrderApprovalTools component that provides order approval helper methods and property definitions.


getPaymentManager

public atg.commerce.payment.PaymentManager getPaymentManager()
Returns a reference to the Payement Manager conmponent


setPaymentManager

public void setPaymentManager(atg.commerce.payment.PaymentManager pPaymentManager)
Sets the Payement Manager conmponent


getOrderManager

public atg.commerce.order.OrderManager getOrderManager()
Returns a reference to the Order Manager conmponent


setOrderManager

public void setOrderManager(atg.commerce.order.OrderManager pOrderManager)
Sets the Order Manager conmponent


setCSRAgentTools

public void setCSRAgentTools(CSRAgentTools pCSRAgentTools)
Sets the CSR Agent Tools component

Parameters:
mCSRAgentTools - the mCSRAgentTools to set

getCSRAgentTools

public CSRAgentTools getCSRAgentTools()
Returns the CSR Agent Tools Component

Returns:
the mCSRAgentTools

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Sets the Transaction manager component

Parameters:
pTransactionManager - the TransactionManager to set

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Returns the Transaction manager component

Returns:
the mTransactionManager

isApprovalRequired

public boolean isApprovalRequired(Approval pApproval)
                           throws ApprovalsException
Determines if an order approval is required for the specified approval object. An approval is required IF:

- the agent does not have the 'cmcApproval' role

- the agent has an appeasement limit

- the appeasements applied to the order exceed the agents appeasement limit

Specified by:
isApprovalRequired in class GenericApprovalsHandler
Parameters:
pApproval - the Approval upon which a decision is made
Throws:
ApprovalsException

saveApproval

public void saveApproval(Approval pApproval,
                         atg.repository.MutableRepositoryItem pItem)
                  throws ApprovalsException
This method saves the application specific data for an Order approval.

It sets the orderId property of the approval item and updates the Order to the appropriate pending approval state; adds the Order to the repository, if transient and performs the initial authorizations on the Order's payment groups.

Specified by:
saveApproval in class GenericApprovalsHandler
Parameters:
pApproval - the Approval to save
pApproval - the Approval object being saved
pItem - the associated approval repository item
pApproval - the Approval to save
Throws:
ApprovalsException
See Also:
setOrderStateToPendingApproval(Order, Approval), doPaymentGroupAuthorizations(Order, Approval, MutableRepositoryItem)

setOrderStateToPendingApproval

protected void setOrderStateToPendingApproval(atg.commerce.order.Order pOrder,
                                              Approval pApproval)
                                       throws ApprovalsException
This method is called when saving the approval and sets the Order to the appropriate pending approval state.

Parameters:
pOrder -
pApproval -
Throws:
ApprovalsException

setOrderStateToRejected

protected void setOrderStateToRejected(atg.commerce.order.Order pOrder,
                                       Approval pApproval)
                                throws ApprovalsException
This method is called when an approval is rejected to set the order's state.

Parameters:
pOrder -
pApproval -
Throws:
ApprovalsException

doPaymentGroupAuthorizations

protected void doPaymentGroupAuthorizations(atg.commerce.order.Order pOrder,
                                            Approval pApproval,
                                            atg.repository.MutableRepositoryItem pItem)
                                     throws ApprovalsException
This method is called when saving the approval and executes the initial payment group authorization for payment groups that have no authorization status yet.

This method is intended to handle initial authorizations when the Order is first submitted and requires approval. Authorizations done on subsequent attempts to submit the same Order that still needs approval are handled in the clone edit reconciliation process.

Parameters:
pOrder - the Order
pApproval - the current approval objects
pItem - the approval repository item
Throws:
ApprovalsException

doesAgentRequireApproval

protected boolean doesAgentRequireApproval(Approval pApproval)
                                    throws ApprovalsException
checks if the Agent has an approvers role, and return false if it is present

Parameters:
pApproval -
Returns:
false if Agent has approvers role
Throws:
ApprovalsException

doesAgentHaveAppeasmentLimit

protected boolean doesAgentHaveAppeasmentLimit(Approval pApproval)
                                        throws ApprovalsException
checks if the agent has an unlimited appeasement limit, and returns false not

Parameters:
pApproval -
Returns:
false if agent has unlimited appeasements
Throws:
ApprovalsException

doesAppeasementsExceedLimit

protected boolean doesAppeasementsExceedLimit(Approval pApproval)
                                       throws ApprovalsException
checks if the total appeasements on the orders exceed the agent's appeasement limit

Parameters:
pApproval -
Returns:
false if appeasements haven't exceeded limit
Throws:
ApprovalsException

getAgentAppeasementLimit

protected double getAgentAppeasementLimit(Approval pApproval)
                                   throws ApprovalsException
get the agent's appeasement limit

Parameters:
pApproval -
Returns:
the appeasement limit for the agent
Throws:
ApprovalsException

getTotalAppeasementsForOrder

public double getTotalAppeasementsForOrder(atg.commerce.order.Order pOrder)
                                    throws ApprovalsException
calculates the total appeasements for the specified order

Parameters:
pOrder -
Returns:
the total amount of appeasements for the order
Throws:
ApprovalsException

loadApproval

public void loadApproval(Approval pApproval)
                  throws ApprovalsException
Loads the order associated with the approval and also the order specific properties for the approval

Specified by:
loadApproval in class GenericApprovalsHandler
Parameters:
pApproval -
Throws:
ApprovalsException

approve

public void approve(Approval pApproval)
             throws ApprovalsException
processes the order supplied as an attribute on the pApproval

Specified by:
approve in class GenericApprovalsHandler
Parameters:
pApproval - - the approval to approve
Throws:
ApprovalsException

generateOrderApprovalParameters

protected java.util.Map generateOrderApprovalParameters(Approval pApproval)
                                                 throws ApprovalsException
Generates the extra parameter map that is passed to processOrder when approving an Order.

Parameters:
pApproval -
Returns:
Map of extra parameters
Throws:
ApprovalsException

reject

public void reject(Approval pApproval)
            throws ApprovalsException
Executes the process of rejecting an order that is pending approval.

The payment group authorizations are reverted and the order's state is changed to a failed approval state.

Specified by:
reject in class GenericApprovalsHandler
Parameters:
pApproval - approval to reject
Throws:
ApprovalsException

getApprovalAcceptedEvent

public atg.commerce.csr.events.ApprovalEvent getApprovalAcceptedEvent(Approval pApproval)
creates and populates an OrderApprovalEvent

Specified by:
getApprovalAcceptedEvent in class GenericApprovalsHandler
Parameters:
pApproval - - the approval
Returns:
ApprovalEvent of type OrderApprovalEvent, pre-populated with data from the Approval object

getApprovalCreatedEvent

public atg.commerce.csr.events.ApprovalEvent getApprovalCreatedEvent(Approval pApproval)
creates and populates an OrderApprovalEvent

Specified by:
getApprovalCreatedEvent in class GenericApprovalsHandler
Parameters:
pApproval - - the approval
Returns:
ApprovalEvent of type OrderApprovalEvent, pre-populated with data from the Approval object

getApprovalRejectedEvent

public atg.commerce.csr.events.ApprovalEvent getApprovalRejectedEvent(Approval pApproval)
creates and populates an OrderApprovalEvent

Specified by:
getApprovalRejectedEvent in class GenericApprovalsHandler
Parameters:
pApproval - - the approval
Returns:
ApprovalEvent of type OrderApprovalEvent, pre-populated with data from the Approval object