atg.b2bcommerce.approval
Class ApprovalRequiredDroplet

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.nucleus.servlet.ServletService
                  extended by atg.nucleus.servlet.HttpServletService
                      extended by atg.servlet.DynamoServlet
                          extended by atg.b2bcommerce.approval.ApprovalRequiredDroplet
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, ParameterServlet, java.util.EventListener, javax.servlet.Servlet

public class ApprovalRequiredDroplet
extends DynamoServlet

This droplet is used to load all the orders which require approval and whose authorized approver ids list contains the profile id contained in the approverid parameter.

Example:

Usage:

approverid
The profile id of the approver
siteScope
Optional input parameter to indicate how to further narrow the result set. The siteScope parameter may be "current", "all", or a shareable type ID such as "atg.ShoppingCart". The siteScope parameter is ignored if the siteIds parameter is specified. If both siteIds and siteScope are omitted, the scope defaults to the value of the configured siteScope property, which defaults to "all".
siteIds
Optional input parameter to indicate how to further narrow the result set. If specified, the siteIds parameter must be a Collection of Strings.
startIndex
the first order to return. This is useful for cycling through large amounts of orders. On first first query start at 0 and return 10. On the second query, start at 10, etc. If startIndex is null, it defaults to 0. (the beginning) (optional. used to break large result sets into manageable pieces.)
numOrders
the number of orders to return on the query. (optional. used to break large result sets into manageable pieces.) *
It renders the following oparams:
output
The oparam output is rendered once and the array of order objects (or the single order object if the orderId object was used) will be set in the "result" param. The index of the next displayable order is in the "nextIndex" param. The index of the previous set of orders (allowing the user to cycle back and forth) is in the "previousIndex" param.
error
error will be rendered if an error occurred
empty
empty will be rendered if there are no orders to be approved It sets the following output params:
result
This will contain an array of order objects.
count
This will contain the number of order objects in the result parameter
totalCount
This will contain the total number of order objects which satisfy the criteria
nextIndex
The index of the first order in the next set of results. If startIndex or numOrders was null, this will also be null.
previousIndex
The index of the first order in the previous set of results. If startIndex or numOrders was null, this will also be null.
startRange
The 1-based index of the first order in the set of results.
endRange
The 1-based index of the last order in the set of results.
errorMessage
if an error occurred this will be the detailed error message for the user.
This droplet has a security feature that allows only the current user to view the his own orders. This feature is enabled by default. To disable it, set the property enableSecurity=false


Field Summary
static java.lang.String ALL
           
static ParameterName APPROVERID
           
static java.lang.String CLASS_VERSION
           
static java.lang.String CURRENT
           
protected static int DEFAULT_NUM_ORDERS
           
protected  ComponentName mProfilePath
           
protected static java.lang.String MSG_GENERAL_ERROR
           
protected static java.lang.String MSG_NO_PERMISSION_FOR_ORDERS
           
static ParameterName NUMORDERS
           
static java.lang.String RESOURCE_BUNDLE
          Resource bundle that holds messages to dispay to the end user
static ParameterName SITEIDS
           
static ParameterName SITESCOPE
           
static ParameterName STARTINDEX
           
 
Fields inherited from class atg.servlet.DynamoServlet
mAllowCleanupRequest, mParameters
 
Fields inherited from class atg.nucleus.servlet.ServletService
SERVLET_INFO_KEY
 
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
ApprovalRequiredDroplet()
           
 
Method Summary
 java.lang.String getAuthorizedApproverIdsPropertyName()
          Returns property authorizedApproverIdsPropertyName
protected  java.lang.String getCurrentProfileId(DynamoHttpServletRequest pRequest)
          get the profile id of the current user
 java.util.Locale getDefaultLocale()
          Returns property DefaultLocale.
 int getDefaultNumOrders()
          The default number of orders returned with each call.
 java.lang.String getOrderByProperty()
          Returns property orderByProperty
protected  int getOrderCountToBeApproved(java.lang.String pApproverId)
          This method creates and executes the query that returns the total count of orders for approval by the approver whose id is in pApproverId.
protected  int getOrderCountToBeApproved(java.lang.String pApproverId, java.util.Collection<java.lang.String> pSiteIds)
          This method creates and executes the query that returns the total count of orders for approval by the approver whose id is in pApproverId.
protected  Query getOrderQuery(java.lang.String pApproverId, java.util.Collection<java.lang.String> pSiteIds, RepositoryView pView)
          This method creates the query that returns the orders for approval by the approver whose id is in pApproverId.
 Repository getOrderRepository()
          Returns property orderRepository
 java.lang.String getOrderRepositoryItemName()
          Returns property OrderRepositoryItemName
 java.lang.String getOrderSiteIdPropertyName()
          Returns property orderSiteIdPropertyName
 java.lang.String getOrderStatePropertyName()
          Returns property orderStatePropertyName
 java.lang.String[] getOrderStatesRequiringApproval()
          Returns property orderStatesRequiringApproval
protected  RepositoryItem[] getOrdersToBeApproved(java.lang.String pApproverId, int pStartIndex, int pNumOrders, java.util.Collection<java.lang.String> pSiteIds, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method creates and executes the query that returns the orders for approval by the approver whose id is in pApproverId.
protected  RepositoryItem[] getOrdersToBeApproved(java.lang.String pApproverId, int pStartIndex, int pNumOrders, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method creates and executes the query that returns the orders for approval by the approver whose id is in pApproverId.
 java.lang.String getProfilePath()
          Returns property ProfilePath
 atg.multisite.SiteGroupManager getSiteGroupManager()
          Returns the SiteGroupManager component
 java.lang.String getSiteScope()
          gets the property siteScope
 boolean getSortAscending()
          Returns property sortAscending
 java.util.Locale getUserLocale(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Returns the locale associated with the request.
 boolean isEnableSecurity()
          Returns property enableSecurity
 boolean isQueryTotal()
          True if the total order count should be retrieved when any order lookup is done.
 boolean isUseRequestLocale()
          Returns property UseRequestLocale
 void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
           Looks up all the orders that are pending approval for the approver with the passed in parameter: approverId.
 void setAuthorizedApproverIdsPropertyName(java.lang.String pAuthorizedApproverIdsPropertyName)
          Sets property authorizedApproverIdsPropertyName
 void setDefaultLocale(java.util.Locale pDefaultLocale)
          Sets property DefaultLocale
 void setDefaultNumOrders(int pDefaultNumOrders)
           
 void setEnableSecurity(boolean pEnableSecurity)
          Sets property enableSecurity
 void setOrderByProperty(java.lang.String pOrderByProperty)
          Sets property orderByProperty
 void setOrderRepository(Repository pOrderRepository)
          Sets property orderRepository
 void setOrderRepositoryItemName(java.lang.String pOrderRepositoryItemName)
          Sets property OrderRepositoryItemName
 void setOrderSiteIdPropertyName(java.lang.String pOrderSiteIdPropertyName)
          Sets property orderSiteIdPropertyName
 void setOrderStatePropertyName(java.lang.String pOrderStatePropertyName)
          Sets property orderStatePropertyName
 void setOrderStatesRequiringApproval(java.lang.String[] pOrderStatesRequiringApproval)
          Sets property orderStatesRequiringApproval
 void setProfilePath(java.lang.String pProfilePath)
          Sets property ProfilePath
 void setQueryTotal(boolean pQueryTotal)
          Sets the queryTotal
 void setSiteGroupManager(atg.multisite.SiteGroupManager pSiteGroupManager)
          Sets the SiteGroupManager component
 void setSiteScope(java.lang.String pSiteScope)
          sets the property siteScope.
 void setSortAscending(boolean pSortAscending)
          Sets property sortAscending
 void setUseRequestLocale(boolean pUseRequestLocale)
          Sets property UseRequestLocale
 
Methods inherited from class atg.servlet.DynamoServlet
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, service, service, setParameter
 
Methods inherited from class atg.nucleus.servlet.ServletService
destroy, getServletConfig, getServletInfo, init, setServletInfo
 
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
 
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, reResolveThis, 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

RESOURCE_BUNDLE

public static java.lang.String RESOURCE_BUNDLE
Resource bundle that holds messages to dispay to the end user


APPROVERID

public static final ParameterName APPROVERID

SITEIDS

public static final ParameterName SITEIDS

SITESCOPE

public static final ParameterName SITESCOPE

STARTINDEX

public static final ParameterName STARTINDEX

NUMORDERS

public static final ParameterName NUMORDERS

ALL

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

CURRENT

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

MSG_GENERAL_ERROR

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

MSG_NO_PERMISSION_FOR_ORDERS

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

DEFAULT_NUM_ORDERS

protected static int DEFAULT_NUM_ORDERS

mProfilePath

protected ComponentName mProfilePath
Constructor Detail

ApprovalRequiredDroplet

public ApprovalRequiredDroplet()
Method Detail

setDefaultNumOrders

public void setDefaultNumOrders(int pDefaultNumOrders)

getDefaultNumOrders

public int getDefaultNumOrders()
The default number of orders returned with each call. The default is 10. Use -1 for all orders to be returned.


getOrderRepository

public Repository getOrderRepository()
Returns property orderRepository

Returns:
returns property orderRepository

setOrderRepository

public void setOrderRepository(Repository pOrderRepository)
Sets property orderRepository

Parameters:
pOrderRepository - the value to set for property orderRepository

getOrderStatesRequiringApproval

public java.lang.String[] getOrderStatesRequiringApproval()
Returns property orderStatesRequiringApproval

Returns:
returns property orderStatesRequiringApproval

setOrderStatesRequiringApproval

public void setOrderStatesRequiringApproval(java.lang.String[] pOrderStatesRequiringApproval)
Sets property orderStatesRequiringApproval

Parameters:
pOrderStatesRequiringApproval - the value to set for property orderStatesRequiringApproval

getOrderRepositoryItemName

public java.lang.String getOrderRepositoryItemName()
Returns property OrderRepositoryItemName

Returns:
returns property OrderRepositoryItemName

setOrderRepositoryItemName

public void setOrderRepositoryItemName(java.lang.String pOrderRepositoryItemName)
Sets property OrderRepositoryItemName

Parameters:
pOrderRepositoryItemName - the value to set for property OrderRepositoryItemName

getOrderStatePropertyName

public java.lang.String getOrderStatePropertyName()
Returns property orderStatePropertyName

Returns:
returns property orderStatePropertyName

setOrderStatePropertyName

public void setOrderStatePropertyName(java.lang.String pOrderStatePropertyName)
Sets property orderStatePropertyName

Parameters:
pOrderStatePropertyName - the value to set for property orderStatePropertyName

getAuthorizedApproverIdsPropertyName

public java.lang.String getAuthorizedApproverIdsPropertyName()
Returns property authorizedApproverIdsPropertyName

Returns:
returns property authorizedApproverIdsPropertyName

setAuthorizedApproverIdsPropertyName

public void setAuthorizedApproverIdsPropertyName(java.lang.String pAuthorizedApproverIdsPropertyName)
Sets property authorizedApproverIdsPropertyName

Parameters:
pAuthorizedApproverIdsPropertyName - the value to set for property authorizedApproverIdsPropertyName

getOrderSiteIdPropertyName

public java.lang.String getOrderSiteIdPropertyName()
Returns property orderSiteIdPropertyName

Returns:
returns property orderSiteIdPropertyName

setOrderSiteIdPropertyName

public void setOrderSiteIdPropertyName(java.lang.String pOrderSiteIdPropertyName)
Sets property orderSiteIdPropertyName

Parameters:
pOrderSiteIdPropertyName - the value to set for property orderSiteIdPropertyName

setSiteGroupManager

public void setSiteGroupManager(atg.multisite.SiteGroupManager pSiteGroupManager)
Sets the SiteGroupManager component

Parameters:
pSiteGroupManager - the SiteGroupManager component. Usually /atg/multisite/SiteGroupManager

getSiteGroupManager

public atg.multisite.SiteGroupManager getSiteGroupManager()
Returns the SiteGroupManager component

Returns:
returns property siteGroupManager

setProfilePath

public void setProfilePath(java.lang.String pProfilePath)
Sets property ProfilePath

Parameters:
pProfilePath - path to the profile nucleus component. Usually atg/userprofiling/Profile

getProfilePath

public java.lang.String getProfilePath()
Returns property ProfilePath


isEnableSecurity

public boolean isEnableSecurity()
Returns property enableSecurity

Returns:
returns property enableSecurity

setEnableSecurity

public void setEnableSecurity(boolean pEnableSecurity)
Sets property enableSecurity

Parameters:
pEnableSecurity - the value to set for property enableSecurity

getOrderByProperty

public java.lang.String getOrderByProperty()
Returns property orderByProperty

Returns:
returns property orderByProperty

setOrderByProperty

public void setOrderByProperty(java.lang.String pOrderByProperty)
Sets property orderByProperty

Parameters:
pOrderByProperty - the value to set for property orderByProperty

getSortAscending

public boolean getSortAscending()
Returns property sortAscending

Returns:
returns property sortAscending

setSortAscending

public void setSortAscending(boolean pSortAscending)
Sets property sortAscending

Parameters:
pSortAscending - the value to set for property sortAscending

isQueryTotal

public boolean isQueryTotal()
True if the total order count should be retrieved when any order lookup is done. The default setting is true.


setQueryTotal

public void setQueryTotal(boolean pQueryTotal)
Sets the queryTotal


setSiteScope

public void setSiteScope(java.lang.String pSiteScope)
sets the property siteScope. This property specifies the default for the siteScope input parameter.


getSiteScope

public java.lang.String getSiteScope()
gets the property siteScope


service

public void service(DynamoHttpServletRequest pRequest,
                    DynamoHttpServletResponse pResponse)
             throws javax.servlet.ServletException,
                    java.io.IOException

Looks up all the orders that are pending approval for the approver with the passed in parameter: approverId. The getOrdersToBeApproved method is used to return the list of orderswhose state is one of orderStatesRequiringApproval.

Overrides:
service in class DynamoServlet
Parameters:
DynamoHttpServletRequest -
DynamoHttpServletResponse -
Throws:
javax.servlet.ServletException - an application specific error occurred processing this request
java.io.IOException - an error occurred reading data from the request or writing data to the response.

getOrdersToBeApproved

protected RepositoryItem[] getOrdersToBeApproved(java.lang.String pApproverId,
                                                 int pStartIndex,
                                                 int pNumOrders,
                                                 DynamoHttpServletRequest pRequest,
                                                 DynamoHttpServletResponse pResponse)
                                          throws RepositoryException,
                                                 javax.servlet.ServletException,
                                                 java.io.IOException
This method creates and executes the query that returns the orders for approval by the approver whose id is in pApproverId. In order to change the query, subclass this class and override this method. This method must return an array of repository items which are order repository items.

Parameters:
pApproverId - the approver id
pStartIndex - the startIndex of orders to retrieve
pNumOrders - the number of orders to retrieve
Throws:
RepositoryException - if a repository error occurs
javax.servlet.ServletException
java.io.IOException

getOrdersToBeApproved

protected RepositoryItem[] getOrdersToBeApproved(java.lang.String pApproverId,
                                                 int pStartIndex,
                                                 int pNumOrders,
                                                 java.util.Collection<java.lang.String> pSiteIds,
                                                 DynamoHttpServletRequest pRequest,
                                                 DynamoHttpServletResponse pResponse)
                                          throws RepositoryException,
                                                 javax.servlet.ServletException,
                                                 java.io.IOException
This method creates and executes the query that returns the orders for approval by the approver whose id is in pApproverId. The set of orders can be restricted to the sites listed in pSiteIds. In order to change the query, subclass this class and override this method. This method must return an array of repository items which are order repository items.

Parameters:
pApproverId - the approver id
pStartIndex - the startIndex of orders to retrieve
pNumOrders - the number of orders to retrieve
pSiteIds - the sites the orders should belong to, null for all sites
Throws:
RepositoryException - if a repository error occurs
javax.servlet.ServletException
java.io.IOException

getOrderCountToBeApproved

protected int getOrderCountToBeApproved(java.lang.String pApproverId)
                                 throws RepositoryException
This method creates and executes the query that returns the total count of orders for approval by the approver whose id is in pApproverId. In order to change the query, subclass this class and override this method. This method must return the total count of all orders requiring approval.

Parameters:
pApproverId - the approver id
Throws:
RepositoryException - if a repository error occurs

getOrderCountToBeApproved

protected int getOrderCountToBeApproved(java.lang.String pApproverId,
                                        java.util.Collection<java.lang.String> pSiteIds)
                                 throws RepositoryException
This method creates and executes the query that returns the total count of orders for approval by the approver whose id is in pApproverId. The set of orders can be restricted to the sites listed in pSiteIds. In order to change the query, subclass this class and override this method. This method must return the total count of all orders requiring approval.

Parameters:
pApproverId - the approver id
pSiteIds - the sites the orders should belong to, null for all sites
Throws:
RepositoryException - if a repository error occurs

getOrderQuery

protected Query getOrderQuery(java.lang.String pApproverId,
                              java.util.Collection<java.lang.String> pSiteIds,
                              RepositoryView pView)
                       throws RepositoryException
This method creates the query that returns the orders for approval by the approver whose id is in pApproverId. The set of orders can be restricted to the sites listed in pSiteIds. In order to change the query, subclass this class and override this method.

Parameters:
pApproverId - the approver id
pSiteIds - the sites the orders should belong to, null for all sites
Throws:
RepositoryException - if a repository error occurs

getCurrentProfileId

protected java.lang.String getCurrentProfileId(DynamoHttpServletRequest pRequest)
get the profile id of the current user


setDefaultLocale

public void setDefaultLocale(java.util.Locale pDefaultLocale)
Sets property DefaultLocale


getDefaultLocale

public java.util.Locale getDefaultLocale()
Returns property DefaultLocale. If the property value is null, then JVM's default locale is returned.


setUseRequestLocale

public void setUseRequestLocale(boolean pUseRequestLocale)
Sets property UseRequestLocale


isUseRequestLocale

public boolean isUseRequestLocale()
Returns property UseRequestLocale


getUserLocale

public java.util.Locale getUserLocale(DynamoHttpServletRequest pRequest,
                                      DynamoHttpServletResponse pResponse)
                               throws javax.servlet.ServletException,
                                      java.io.IOException
Returns the locale associated with the request. The method first searches for a request paramater named locale. This value can be either a java.util.Locale object or a String which represents the locale. Next if the useRequestLocale property is true, then the locale of the request will be returned. Finally, if the locale cannot be determined, the the defaultLocale property is used.

Throws:
javax.servlet.ServletException
java.io.IOException