atg.commerce.csr.approvals
Class ApprovalsManager

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.csr.approvals.ApprovalsManager
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 ApprovalsManager
extends atg.nucleus.GenericService

Class to manage approvals. This class will call delegate classes to determine if an approval is necessary, create an approval record, retrieve any approval records from the repository and deal with an approval after a decision has been made


Field Summary
static java.lang.String APPROVED
          the state when an approval has been approved
static java.lang.String CLASS_VERSION
           
protected  atg.nucleus.ServiceMap mApprovalHandlers
           
protected  ApprovalsPropertyManager mApprovalsPropertyManager
           
protected  atg.repository.MutableRepository mApprovalsRepository
           
protected  java.lang.String mBaseApprovalItemDescriptorName
           
protected  CSRAgentMessagingTools mCSRAgentMessagingTools
           
protected  atg.repository.Repository mInternalProfileRepository
           
protected  atg.svc.agent.ticketing.TicketingTools mTicketingTools
           
static java.lang.String PENDING
          the state when an approval is pending approval
static java.lang.String REJECTED
          the state when an approval has been rejected
static java.lang.String SERVER_LOCALIZED_RESOURCE_NAME
          Resource bundle name for server localized resources.
protected static java.util.ResourceBundle sServerLocalizedResourceBundle
          Resource bundle for servlet localized resources.
static java.lang.String USER_LOCALIZED_RESOURCE_NAME
          Resource bundle name for user localized resources.
 
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
ApprovalsManager()
           
 
Method Summary
 void approve(Approval pApproval, atg.repository.RepositoryItem pApprovingAgentProfile)
          Approves the Approval object provided by calling approve() on the appropriate Approval Handler.
 Approval createApproval(java.lang.String pApprovalType, atg.repository.RepositoryItem pAgentProfile, atg.repository.RepositoryItem pTicket, java.lang.String pSiteId, java.lang.String pCustomerProfileId)
          Creates a new Approval Object
 atg.repository.Query createApprovalsQuery(java.lang.String[] pStates, atg.repository.QueryBuilder pQueryBuilder)
          Create a Query object for approval states and approval type.
 atg.repository.RepositoryItem[] findAllApprovals(java.lang.String[] pStates, java.lang.String pApprovalType)
          Returns all the approval RepositoryItems for given state and approval types.
 atg.repository.RepositoryItem[] findAllPendingApprovalsByType(java.lang.String pApprovalType)
          Returns all Pending approvals for a supplied type If pApprovalType is empty or null, all types will be returned
 GenericApprovalsHandler getApprovalHandler(java.lang.String pApprovalType)
          Returns the handler for an approval type
 atg.nucleus.ServiceMap getApprovalHandlers()
          Returns the collection of approvals handlers with corresponding keys as a ServiceMap.
 ApprovalsPropertyManager getApprovalsPropertyManager()
          Returns the ApprovalsPropertyManager.
 atg.repository.MutableRepository getApprovalsRepository()
          Returns the approvals repository.
 java.lang.String getBaseApprovalItemDescriptorName()
           
 CSRAgentMessagingTools getCSRAgentMessagingTools()
          Returns the CSR Agent Messaging Tools.
 atg.repository.Repository getInternalProfileRepository()
          Returns the internal profile repository used to load agent profiles.
protected  atg.repository.RepositoryView getRepositoryViewForItemDescriptor(java.lang.String pApprovalType)
          returns the RepositoryView based on the approval type
 java.lang.String getServerLocalizedResource(java.lang.String pKey, java.lang.Object[] pMessageArgs)
          Returns the message string from the exception resource library.
 atg.svc.agent.ticketing.TicketingTools getTicketingTools()
          Returns the Ticketing Tools.
 java.lang.String getUserLocalizedResource(java.lang.String pKey, java.lang.Object[] pMsgArgs, java.util.Locale pLocale)
          Returns a resource from the user resource bundle
 boolean isApprovalRequired(Approval pApproval)
          Determines if an approval is required for the specified approval object by calling isApprovalRequired() on the appropraite Approval Handler.
 Approval loadApproval(java.lang.String pApprovalId)
          Loads the approval item from the repository, and sets it on a newly created Approval object
protected  void loadBaseApprovalProperties(Approval pApproval, atg.repository.RepositoryItem pApprovalItem)
          loads the common approval properties
 void logApprovalAcceptedEvent(Approval pApproval)
          logs an agent event when an approval is accepted
 void logApprovalCreatedEvent(Approval pApproval)
          logs an agent event when an approval is created
 void logApprovalRejectedEvent(Approval pApproval)
          logs an agent event when an approval is rejected
protected  void processApproveException(Approval pApproval, java.lang.Exception pException)
          This method is called to process any exception that occurs in the approval process.
protected  void processRejectException(Approval pApproval, java.lang.Exception pException)
          This method is called to process any exception that occurs in the rejection process.
 void reject(Approval pApproval, atg.repository.RepositoryItem pApprovingAgentProfile)
          Rejects the Approval object provided by calling reject() on the appropriate Approval Handler.
 void saveApproval(Approval pApproval)
          Saves the approval to the approval repository.
protected  void saveBaseApprovalProperties(Approval pApproval, atg.repository.MutableRepositoryItem pItem)
          saves the common approval properties
 void setApprovalHandlers(atg.nucleus.ServiceMap mApprovalHandlers)
          Sets the collection of approvals handlers with corresponding keys as a ServiceMap.
 void setApprovalsPropertyManager(ApprovalsPropertyManager mApprovalsPropertyManager)
          Sets the ApprovalsPropertyManager.
 void setApprovalsRepository(atg.repository.MutableRepository mApprovalsRepository)
          Sets the approvals repository.
 void setBaseApprovalItemDescriptorName(java.lang.String pBaseApprovalItemDescriptorName)
           
 void setCSRAgentMessagingTools(CSRAgentMessagingTools pCSRAgentMessagingTools)
          Sets the CSR Agent Messaging Tools.
 void setInternalProfileRepository(atg.repository.Repository pInternalProfileRepository)
          Sets the internal profile repository used to load agent profiles
 void setTicketingTools(atg.svc.agent.ticketing.TicketingTools pTicketingTools)
          Sets the Ticketing Tools.
 
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

SERVER_LOCALIZED_RESOURCE_NAME

public static final java.lang.String SERVER_LOCALIZED_RESOURCE_NAME
Resource bundle name for server localized resources. these resourced are used to exceptions and log messaging. Use the getServerLocalizedResource method to get resources from this bundle.

See Also:
Constant Field Values

sServerLocalizedResourceBundle

protected static java.util.ResourceBundle sServerLocalizedResourceBundle
Resource bundle for servlet localized resources. these resources are used for user display messaging. Use the getServerLocalizedResource method to get resources from this bundle.


USER_LOCALIZED_RESOURCE_NAME

public static final java.lang.String USER_LOCALIZED_RESOURCE_NAME
Resource bundle name for user localized resources. these resources are used for user display messaging Use the getUserLocalizedResource method to get resources from this bundle.

See Also:
Constant Field Values

PENDING

public static final java.lang.String PENDING
the state when an approval is pending approval

See Also:
Constant Field Values

APPROVED

public static final java.lang.String APPROVED
the state when an approval has been approved

See Also:
Constant Field Values

REJECTED

public static final java.lang.String REJECTED
the state when an approval has been rejected

See Also:
Constant Field Values

mInternalProfileRepository

protected atg.repository.Repository mInternalProfileRepository

mBaseApprovalItemDescriptorName

protected java.lang.String mBaseApprovalItemDescriptorName

mApprovalHandlers

protected atg.nucleus.ServiceMap mApprovalHandlers

mApprovalsPropertyManager

protected ApprovalsPropertyManager mApprovalsPropertyManager

mApprovalsRepository

protected atg.repository.MutableRepository mApprovalsRepository

mTicketingTools

protected atg.svc.agent.ticketing.TicketingTools mTicketingTools

mCSRAgentMessagingTools

protected CSRAgentMessagingTools mCSRAgentMessagingTools
Constructor Detail

ApprovalsManager

public ApprovalsManager()
Method Detail

getInternalProfileRepository

public atg.repository.Repository getInternalProfileRepository()
Returns the internal profile repository used to load agent profiles.


setInternalProfileRepository

public void setInternalProfileRepository(atg.repository.Repository pInternalProfileRepository)
Sets the internal profile repository used to load agent profiles


getBaseApprovalItemDescriptorName

public java.lang.String getBaseApprovalItemDescriptorName()

setBaseApprovalItemDescriptorName

public void setBaseApprovalItemDescriptorName(java.lang.String pBaseApprovalItemDescriptorName)

setApprovalHandlers

public void setApprovalHandlers(atg.nucleus.ServiceMap mApprovalHandlers)
Sets the collection of approvals handlers with corresponding keys as a ServiceMap.

Parameters:
mApprovalHandlers - the mApprovalHandlers to set

getApprovalHandlers

public atg.nucleus.ServiceMap getApprovalHandlers()
Returns the collection of approvals handlers with corresponding keys as a ServiceMap.

Returns:
the mApprovalHandlers

setApprovalsPropertyManager

public void setApprovalsPropertyManager(ApprovalsPropertyManager mApprovalsPropertyManager)
Sets the ApprovalsPropertyManager. This controls the names of the approval's propertys.

Parameters:
mApprovalsPropertyManager - the mApprovalsPropertyManager to set

getApprovalsPropertyManager

public ApprovalsPropertyManager getApprovalsPropertyManager()
Returns the ApprovalsPropertyManager. This controls the names of the approval's propertys.

Returns:
the mApprovalsPropertyManager

getApprovalHandler

public GenericApprovalsHandler getApprovalHandler(java.lang.String pApprovalType)
                                           throws ApprovalsException
Returns the handler for an approval type

Parameters:
pApprovalType -
Returns:
GenericApprovalsHandler
Throws:
ApprovalsException

setApprovalsRepository

public void setApprovalsRepository(atg.repository.MutableRepository mApprovalsRepository)
Sets the approvals repository. This stores all approvals data.

Parameters:
mApprovalsRepository - the mApprovalsRepository to set

getApprovalsRepository

public atg.repository.MutableRepository getApprovalsRepository()
Returns the approvals repository. This stores all approvals data.

Returns:
the mApprovalsRepository

setTicketingTools

public void setTicketingTools(atg.svc.agent.ticketing.TicketingTools pTicketingTools)
Sets the Ticketing Tools.

Parameters:
pTicketingTools - the TicketingTools to set

getTicketingTools

public atg.svc.agent.ticketing.TicketingTools getTicketingTools()
Returns the Ticketing Tools.

Returns:
the TicketingTools

setCSRAgentMessagingTools

public void setCSRAgentMessagingTools(CSRAgentMessagingTools pCSRAgentMessagingTools)
Sets the CSR Agent Messaging Tools.

Parameters:
pCSRAgentMessagingTools - the CSRAgentMessagingTools to set

getCSRAgentMessagingTools

public CSRAgentMessagingTools getCSRAgentMessagingTools()
Returns the CSR Agent Messaging Tools.

Returns:
the mCSRAgentMessagingTools

createApproval

public Approval createApproval(java.lang.String pApprovalType,
                               atg.repository.RepositoryItem pAgentProfile,
                               atg.repository.RepositoryItem pTicket,
                               java.lang.String pSiteId,
                               java.lang.String pCustomerProfileId)
Creates a new Approval Object

Parameters:
pApprovalType - - Corresponds to the type of ApprovalHandler which will deal with the approval
pAgentProfile - - The profile of the agent who submitted the order
pTicket - - The current ticket
pSite - - The current Site Id
pCustomerProfileId - - The customer profile associated with the order
Returns:
Approval

loadApproval

public Approval loadApproval(java.lang.String pApprovalId)
                      throws ApprovalsException
Loads the approval item from the repository, and sets it on a newly created Approval object

Parameters:
pApprovalId - - the ID of the approval item to load
Returns:
a new Approval object with the repository item set
Throws:
ApprovalsException

approve

public void approve(Approval pApproval,
                    atg.repository.RepositoryItem pApprovingAgentProfile)
             throws ApprovalsException
Approves the Approval object provided by calling approve() on the appropriate Approval Handler. The approval state is then set to APPROVED, the approving agent's ID is set and the completion time stamp is set.

The approvals repository item is then updated and an Event is sent.

Parameters:
pApproval - - the approval to approve
pApprovingAgentProfile - - the agent who is approving the approval
Throws:
ApprovalsException

processApproveException

protected void processApproveException(Approval pApproval,
                                       java.lang.Exception pException)
                                throws ApprovalsException
This method is called to process any exception that occurs in the approval process.

This implementation will log a generic error along with the exception.

If the given exception was an ApprovalsException it is thrown. All other exceptions are wrapped in an ApprovalsException and thrown.

Parameters:
pApproval - the approval object
pException - the exception that occurred during the approval process.
Throws:
ApprovalsException

processRejectException

protected void processRejectException(Approval pApproval,
                                      java.lang.Exception pException)
                               throws ApprovalsException
This method is called to process any exception that occurs in the rejection process.

This implementation will log an generic error along with the exception.

If the given exception was an ApprovalsException it is thrown. All other exceptions are wrapped in an ApprovalsException and thrown.

Parameters:
pApproval - the approval object
pException - the exception that occurred during the rejection process.
Throws:
ApprovalsException

reject

public void reject(Approval pApproval,
                   atg.repository.RepositoryItem pApprovingAgentProfile)
            throws ApprovalsException
Rejects the Approval object provided by calling reject() on the appropriate Approval Handler. The approval state is then set to REJECTED, the rejecting agent's ID is set and the completion time stamp is set.

The approvals repository item is then updated and an Event is sent.

Parameters:
pApproval - - the approval to be rejected
pApprovingAgentProfile - - the rejecting agent's profile
Throws:
ApprovalsException

isApprovalRequired

public boolean isApprovalRequired(Approval pApproval)
                           throws ApprovalsException
Determines if an approval is required for the specified approval object by calling isApprovalRequired() on the appropraite Approval Handler.

Parameters:
pApproval - the Approval object
Throws:
ApprovalsException

saveApproval

public void saveApproval(Approval pApproval)
                  throws ApprovalsException
Saves the approval to the approval repository. This method creates a repository item in the approvals repository, saves the base properties for an approval, then calls saveApproval() on the appropriate Approval Handler.

Parameters:
pApproval - the Approval to save
Throws:
ApprovalsException

loadBaseApprovalProperties

protected void loadBaseApprovalProperties(Approval pApproval,
                                          atg.repository.RepositoryItem pApprovalItem)
                                   throws ApprovalsException
loads the common approval properties

Parameters:
pApproval - the Approval to load
pApprovalItem - the associated approval item from which to load the base properties
Throws:
ApprovalsException

saveBaseApprovalProperties

protected void saveBaseApprovalProperties(Approval pApproval,
                                          atg.repository.MutableRepositoryItem pItem)
saves the common approval properties

Parameters:
pApproval - the Approval to save
pItem - the associated approval item upon which to save the base properties

getServerLocalizedResource

public java.lang.String getServerLocalizedResource(java.lang.String pKey,
                                                   java.lang.Object[] pMessageArgs)
Returns the message string from the exception resource library.

Parameters:
pKey -
pMessageArgs -
Returns:
message string from the execption resource bundle

getUserLocalizedResource

public java.lang.String getUserLocalizedResource(java.lang.String pKey,
                                                 java.lang.Object[] pMsgArgs,
                                                 java.util.Locale pLocale)
Returns a resource from the user resource bundle

Parameters:
pKey -
pMsgArgs - msg arguments
pLocale - the locale
Returns:
String

findAllApprovals

public atg.repository.RepositoryItem[] findAllApprovals(java.lang.String[] pStates,
                                                        java.lang.String pApprovalType)
                                                 throws ApprovalsException
Returns all the approval RepositoryItems for given state and approval types. If pStates is empty, all states will be returned If pApprovalType is null or empty, all types will be returned

Parameters:
pStates -
pApprovalType -
Returns:
an array of all approval RepositoryItems which match the supplied parameters
Throws:
ApprovalsException

getRepositoryViewForItemDescriptor

protected atg.repository.RepositoryView getRepositoryViewForItemDescriptor(java.lang.String pApprovalType)
                                                                    throws atg.repository.RepositoryException
returns the RepositoryView based on the approval type

Parameters:
pApprovalType -
Returns:
the repository view
Throws:
atg.repository.RepositoryException

createApprovalsQuery

public atg.repository.Query createApprovalsQuery(java.lang.String[] pStates,
                                                 atg.repository.QueryBuilder pQueryBuilder)
                                          throws atg.repository.RepositoryException
Create a Query object for approval states and approval type. This method creates it's own QueryBuilder from the approvals repository

Parameters:
pStates - - the states required
pApprovalType - - the approval type required
Returns:
a Query object to be executed
Throws:
atg.repository.RepositoryException

findAllPendingApprovalsByType

public atg.repository.RepositoryItem[] findAllPendingApprovalsByType(java.lang.String pApprovalType)
                                                              throws ApprovalsException
Returns all Pending approvals for a supplied type If pApprovalType is empty or null, all types will be returned

Returns:
an array of approval RepositoryItems which have a pending State, and supplied type
Throws:
ApprovalsException

logApprovalCreatedEvent

public void logApprovalCreatedEvent(Approval pApproval)
                             throws ApprovalsException
logs an agent event when an approval is created

Parameters:
pApproval - - the approval to create the event for
Throws:
ApprovalsException

logApprovalAcceptedEvent

public void logApprovalAcceptedEvent(Approval pApproval)
                              throws ApprovalsException
logs an agent event when an approval is accepted

Parameters:
pApproval - - the approval to create the event for
Throws:
ApprovalsException

logApprovalRejectedEvent

public void logApprovalRejectedEvent(Approval pApproval)
                              throws ApprovalsException
logs an agent event when an approval is rejected

Parameters:
pApproval - - the approval to create the event for
Throws:
ApprovalsException