atg.commerce.csr.environment
Class CSREnvironmentMonitor

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.svc.agent.environment.EnvironmentMonitor
              extended by atg.commerce.csr.environment.CSREnvironmentMonitor
All Implemented Interfaces:
atg.naming.NameContextBindingListener, atg.naming.NameContextElement, atg.naming.NameResolver, atg.nucleus.AdminableService, 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 CSREnvironmentMonitor
extends atg.svc.agent.environment.EnvironmentMonitor

This monitor handles changes to CSR environment objects.

It handles changes to the order, catalog and price list.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String CURRENT_CATALOG_HOLDER_PATH
          The path to the environment's current catalog component
static java.lang.String CURRENT_PRICELIST_HOLDER_PATH
          The path to the environment's current price list component
protected  atg.commerce.profile.CommercePropertyManager mCommercePropertyManager
           
protected  CSREnvironmentTools mCSREnvironmentTools
           
protected static java.lang.String MY_RESOURCES
           
protected  java.util.ResourceBundle sBundle
           
 
Fields inherited from class atg.svc.agent.environment.EnvironmentMonitor
mEnvironmentTools
 
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
CSREnvironmentMonitor()
           
 
Method Summary
 void applyActiveCustomerChangeDetail(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail, atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
          Applies changes related to a current customer change.
 void applyCatalogChangeDetail(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail, atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
          Changes the environment's current catalog based on the change detail.
 void applyChanges(atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
          This method applies changes that this monitor is responsible for.
 void applyOrderChangeDetail(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail, atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
          Changes the current order based on the change detail.
 void applyPriceListChangeDetail(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail, atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
          Changes the environment's current price list based on the change detail.
 void changeOrderOwner(atg.commerce.order.Order pOrder, atg.repository.RepositoryItem pNewOwner)
          Changes the order owner of the order.
protected  boolean compareCurrentCatalog(java.lang.String pCatalogId)
          Compares the environment's current catalog to the catalog id provided.
protected  boolean compareCurrentPriceList(java.lang.String pPriceListId)
          Compares the environment current price list to the price list id provided.
 void createWarningsForEnvironmentChange(atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
          Creates the warnings related to CSR environment changes
protected  void generateChangeDetailsForChangeKey(java.lang.String pChangeKey, atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
          This method is called to generate change details for the given change key.
protected  void generateDependentChangeDetails(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail, atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
          This method is called to generate change details that are dependent on the given EnvironmentChangeDetail
protected  void generateDependentDetailsForActiveCustomerChange(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail, atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
          Generates change details that result from a change of ative profile.
protected  void generateDependentDetailsForOrderChange(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail, atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
          Generates change details that result from a change of order.
 atg.commerce.profile.CommercePropertyManager getCommercePropertyManager()
           
 CSREnvironmentTools getCSREnvironmentTools()
           
 atg.repository.RepositoryItem getCurrentCatalog()
          Returns the environment's current catalog.
 atg.commerce.order.Order getCurrentOrder()
          Returns the current order
 atg.repository.RepositoryItem getCurrentPriceList()
          Returns the environment's current price list.
 java.lang.Object getEnvironmentObject(java.lang.String pEnvironmentObjectName)
          returns the environment objects managed by the CSR application.
protected  atg.repository.RepositoryItem getUsersCatalog(atg.repository.RepositoryItem pProfile)
          Returns a profile's assigned catalog.
protected  atg.repository.RepositoryItem getUsersPriceList(atg.repository.RepositoryItem pProfile)
          Returns a profile's price list by calling the PriceListManager.
 void initializeDefaultsForProfile(atg.repository.MutableRepositoryItem pProfile)
           
 void initializeNewOrderInCart()
          Creates a new order and makes it current in the agent's window state order holder
protected  boolean isOwnerChangeable(atg.commerce.order.Order pOrder, atg.repository.RepositoryItem pNewOwnerProfile)
          Determines if an order may have the new owner assigned.
 void setCommercePropertyManager(atg.commerce.profile.CommercePropertyManager pCommercePropertyManager)
          Sets the component that defines properties of the profile for Commerce
 void setCSREnvironmentTools(CSREnvironmentTools pCSREnvironmentTools)
          Sets the property CSREnvironmentTools.
 void setCurrentCatalog(atg.repository.RepositoryItem pCatalog)
          sets the current catalog in the environment
 void setCurrentOrder(atg.commerce.order.Order pOrder)
          Sets the order as the the current working order in the Environment
 void setCurrentPriceList(atg.repository.RepositoryItem pPriceList)
          sets the current price list in the environment
 
Methods inherited from class atg.svc.agent.environment.EnvironmentMonitor
generateChangeDetails, getEnvironmentTools, postApplyChanges, preApplyChanges, setEnvironmentTools
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, 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 java.lang.String CLASS_VERSION
Class version string


MY_RESOURCES

protected static final java.lang.String MY_RESOURCES
See Also:
Constant Field Values

sBundle

protected final java.util.ResourceBundle sBundle

CURRENT_PRICELIST_HOLDER_PATH

public static final java.lang.String CURRENT_PRICELIST_HOLDER_PATH
The path to the environment's current price list component

See Also:
Constant Field Values

CURRENT_CATALOG_HOLDER_PATH

public static final java.lang.String CURRENT_CATALOG_HOLDER_PATH
The path to the environment's current catalog component

See Also:
Constant Field Values

mCommercePropertyManager

protected atg.commerce.profile.CommercePropertyManager mCommercePropertyManager

mCSREnvironmentTools

protected CSREnvironmentTools mCSREnvironmentTools
Constructor Detail

CSREnvironmentMonitor

public CSREnvironmentMonitor()
Method Detail

setCommercePropertyManager

public void setCommercePropertyManager(atg.commerce.profile.CommercePropertyManager pCommercePropertyManager)
Sets the component that defines properties of the profile for Commerce

Parameters:
pCommercePropertyManager - the component that defines properties of the profile for Commerce

getCommercePropertyManager

public atg.commerce.profile.CommercePropertyManager getCommercePropertyManager()
Returns:
the component that defines properties of the profile for Commerce

setCSREnvironmentTools

public void setCSREnvironmentTools(CSREnvironmentTools pCSREnvironmentTools)
Sets the property CSREnvironmentTools.


getCSREnvironmentTools

public CSREnvironmentTools getCSREnvironmentTools()
Returns:
The CSREnvironmentTools component used to manipulate the profile

initializeDefaultsForProfile

public void initializeDefaultsForProfile(atg.repository.MutableRepositoryItem pProfile)
                                  throws atg.svc.agent.environment.EnvironmentException
Overrides:
initializeDefaultsForProfile in class atg.svc.agent.environment.EnvironmentMonitor
Throws:
atg.svc.agent.environment.EnvironmentException

generateChangeDetailsForChangeKey

protected void generateChangeDetailsForChangeKey(java.lang.String pChangeKey,
                                                 atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
                                          throws atg.svc.agent.environment.EnvironmentChangeDetailConflict,
                                                 atg.svc.agent.environment.EnvironmentException
This method is called to generate change details for the given change key.

This implementation adds details for the following change keys:

Specified by:
generateChangeDetailsForChangeKey in class atg.svc.agent.environment.EnvironmentMonitor
Parameters:
pChangeKey -
pEnvironmentChangeState -
Throws:
atg.svc.agent.environment.EnvironmentChangeDetailConflict
atg.svc.agent.environment.EnvironmentException
See Also:
ServiceEnvironmentConstants.ENV_CHG_START_NEW_CALL, ServiceEnvironmentConstants.ENV_INITIALIZE, CSREnvironmentConstants.ENV_CHG_ORDER, CSREnvironmentConstants.ENV_CHG_CREATE_NEW_ORDER, CSREnvironmentConstants.ENV_CHG_CATALOG_AND_PRICELIST

generateDependentDetailsForOrderChange

protected void generateDependentDetailsForOrderChange(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail,
                                                      atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
                                               throws atg.svc.agent.environment.EnvironmentChangeDetailConflict,
                                                      atg.svc.agent.environment.EnvironmentException
Generates change details that result from a change of order.

Parameters:
pEnvironmentChangeDetail -
pEnvironmentChangeState -
Throws:
atg.svc.agent.environment.EnvironmentChangeDetailConflict
atg.svc.agent.environment.EnvironmentException

generateDependentDetailsForActiveCustomerChange

protected void generateDependentDetailsForActiveCustomerChange(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail,
                                                               atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
                                                        throws atg.svc.agent.environment.EnvironmentChangeDetailConflict,
                                                               atg.svc.agent.environment.EnvironmentException
Generates change details that result from a change of ative profile.

Parameters:
pEnvironmentChangeDetail -
pEnvironmentChangeState -
Throws:
atg.svc.agent.environment.EnvironmentChangeDetailConflict
atg.svc.agent.environment.EnvironmentException

generateDependentChangeDetails

protected void generateDependentChangeDetails(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail,
                                              atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
                                       throws atg.svc.agent.environment.EnvironmentChangeDetailConflict,
                                              atg.svc.agent.environment.EnvironmentException
This method is called to generate change details that are dependent on the given EnvironmentChangeDetail

Specified by:
generateDependentChangeDetails in class atg.svc.agent.environment.EnvironmentMonitor
Parameters:
pEnvironmentChangeDetail -
pEnvironmentChangeState -
Throws:
atg.svc.agent.environment.EnvironmentChangeDetailConflict
atg.svc.agent.environment.EnvironmentException
See Also:
generateDependentDetailsForOrderChange(EnvironmentChangeDetail, EnvironmentChangeState), generateDependentDetailsForActiveCustomerChange(EnvironmentChangeDetail, EnvironmentChangeState)

createWarningsForEnvironmentChange

public void createWarningsForEnvironmentChange(atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
                                        throws atg.svc.agent.environment.EnvironmentException
Creates the warnings related to CSR environment changes

Overrides:
createWarningsForEnvironmentChange in class atg.svc.agent.environment.EnvironmentMonitor
Throws:
atg.svc.agent.environment.EnvironmentException
See Also:
CSREnvironmentTools.createWarningsForPriceListSwitch(EnvironmentChangeState), CSREnvironmentTools.createWarningsForCatalogSwitch(EnvironmentChangeState), CSREnvironmentTools.createWarningsForChangeOrder(EnvironmentChangeState)

applyChanges

public void applyChanges(atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
                  throws atg.svc.agent.environment.EnvironmentException
This method applies changes that this monitor is responsible for. Specifically, all order, price list and catalog changes are applied here.

Specified by:
applyChanges in class atg.svc.agent.environment.EnvironmentMonitor
Throws:
atg.svc.agent.environment.EnvironmentException
See Also:
applyOrderChangeDetail(EnvironmentChangeDetail, EnvironmentChangeState), applyCatalogChangeDetail(EnvironmentChangeDetail, EnvironmentChangeState), applyPriceListChangeDetail(EnvironmentChangeDetail, EnvironmentChangeState)

applyActiveCustomerChangeDetail

public void applyActiveCustomerChangeDetail(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail,
                                            atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
                                     throws atg.svc.agent.environment.EnvironmentException
Applies changes related to a current customer change.

Reinitializes the environment's pricing models.

Changes the current order's owner if there isn't a change order detail in the environment change state.

Parameters:
pEnvironmentChangeDetail -
pEnvironmentChangeState -
Throws:
atg.svc.agent.environment.EnvironmentException

applyOrderChangeDetail

public void applyOrderChangeDetail(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail,
                                   atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
                            throws atg.svc.agent.environment.EnvironmentException
Changes the current order based on the change detail.

Parameters:
pEnvironmentChangeDetail -
pEnvironmentChangeState -
Throws:
atg.svc.agent.environment.EnvironmentException

applyPriceListChangeDetail

public void applyPriceListChangeDetail(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail,
                                       atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
                                throws atg.svc.agent.environment.EnvironmentException
Changes the environment's current price list based on the change detail.

Items in the current order that cannot be priced using the new price list are removed.

Parameters:
pEnvironmentChangeDetail -
pEnvironmentChangeState -
Throws:
atg.svc.agent.environment.EnvironmentException

applyCatalogChangeDetail

public void applyCatalogChangeDetail(atg.svc.agent.environment.EnvironmentChangeDetail pEnvironmentChangeDetail,
                                     atg.svc.agent.environment.EnvironmentChangeState pEnvironmentChangeState)
                              throws atg.svc.agent.environment.EnvironmentException
Changes the environment's current catalog based on the change detail.

Parameters:
pEnvironmentChangeDetail -
pEnvironmentChangeState -
Throws:
atg.svc.agent.environment.EnvironmentException

isOwnerChangeable

protected boolean isOwnerChangeable(atg.commerce.order.Order pOrder,
                                    atg.repository.RepositoryItem pNewOwnerProfile)
Determines if an order may have the new owner assigned.

True is returned if the order is incomplete.

Parameters:
pOrder - the order
pNewOwnerProfile - repository item representing the potential new owner of the order. This can be null.
Returns:
boolean indicating if the order may have the new owner assigned to it

setCurrentOrder

public void setCurrentOrder(atg.commerce.order.Order pOrder)
                     throws atg.svc.agent.environment.EnvironmentException
Sets the order as the the current working order in the Environment

Parameters:
pOrder -
Throws:
atg.svc.agent.environment.EnvironmentException

getCurrentPriceList

public atg.repository.RepositoryItem getCurrentPriceList()
                                                  throws atg.svc.agent.environment.EnvironmentException
Returns the environment's current price list.

If it hasn't been set already, it is set to the price list manager's default price list.

Returns:
the current active price list
Throws:
atg.svc.agent.environment.EnvironmentException
See Also:
PriceListManager.getDefaultPriceList()

setCurrentPriceList

public void setCurrentPriceList(atg.repository.RepositoryItem pPriceList)
                         throws atg.svc.agent.environment.EnvironmentException
sets the current price list in the environment

Parameters:
pPriceList -
Throws:
atg.svc.agent.environment.EnvironmentException

getCurrentCatalog

public atg.repository.RepositoryItem getCurrentCatalog()
                                                throws atg.svc.agent.environment.EnvironmentException
Returns the environment's current catalog.

If it isn't set yet, it is set to the default catalog specified by the CSRConfigurator.

Returns:
Throws:
atg.svc.agent.environment.EnvironmentException
See Also:
CSRConfigurator.getDefaultCatalogId()

setCurrentCatalog

public void setCurrentCatalog(atg.repository.RepositoryItem pCatalog)
                       throws atg.svc.agent.environment.EnvironmentException
sets the current catalog in the environment

Parameters:
pPriceList -
Throws:
atg.svc.agent.environment.EnvironmentException

getCurrentOrder

public atg.commerce.order.Order getCurrentOrder()
Returns the current order

Returns:
Order

initializeNewOrderInCart

public void initializeNewOrderInCart()
                              throws atg.svc.agent.environment.EnvironmentException
Creates a new order and makes it current in the agent's window state order holder

Throws:
atg.svc.agent.environment.EnvironmentException

compareCurrentCatalog

protected boolean compareCurrentCatalog(java.lang.String pCatalogId)
Compares the environment's current catalog to the catalog id provided. True is returned if they reference the same catalog.

Parameters:
pCatalogId -
Returns:
true if the catalog is the same as the environment's current catalog.

compareCurrentPriceList

protected boolean compareCurrentPriceList(java.lang.String pPriceListId)
Compares the environment current price list to the price list id provided. True is returned if they reference the same price list

Parameters:
pPriceListId -
Returns:
true if the price list id references the same price list as the environment's current price list.

getUsersCatalog

protected atg.repository.RepositoryItem getUsersCatalog(atg.repository.RepositoryItem pProfile)
Returns a profile's assigned catalog.

Parameters:
pProfile -
Returns:
price list item
Throws:
atg.commerce.pricing.priceLists.PriceListException

changeOrderOwner

public void changeOrderOwner(atg.commerce.order.Order pOrder,
                             atg.repository.RepositoryItem pNewOwner)
Changes the order owner of the order.

Parameters:
pOrder - the order to change
pNewOwner - the new owner

getUsersPriceList

protected atg.repository.RepositoryItem getUsersPriceList(atg.repository.RepositoryItem pProfile)
                                                   throws atg.commerce.pricing.priceLists.PriceListException
Returns a profile's price list by calling the PriceListManager.

Parameters:
pProfile -
Returns:
price list item
Throws:
atg.commerce.pricing.priceLists.PriceListException
See Also:
PriceListManager.getPriceList(RepositoryItem, String)

getEnvironmentObject

public java.lang.Object getEnvironmentObject(java.lang.String pEnvironmentObjectName)
                                      throws atg.svc.agent.environment.EnvironmentException
returns the environment objects managed by the CSR application. The current order, the current catalog and the current price list.

Specified by:
getEnvironmentObject in class atg.svc.agent.environment.EnvironmentMonitor
Throws:
atg.svc.agent.environment.EnvironmentException