atg.repository.servlet
Class PossibleValues

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.repository.servlet.PossibleValues
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, ParameterServlet, java.util.EventListener, javax.servlet.Servlet
Direct Known Subclasses:
CatalogPossibleValues, FilteringCatalogPossibleValues

public class PossibleValues
extends DynamoServlet

This servlet queries a repository and returns all tag values or repository items for a given itemDescriptorName and propertyName depending on the type of the property identified by propertyName. If the optional parameter propertyName is omitted, the droplet will return all repository values for itemType.

A complete description of the parameters to the servlet are:

itemDescriptorName
This is the name of the item-descriptor in the repository XML file If null or unset, will check repositoryItem.
repositoryItem
This is an optional repository item from which to get itemDescriptorName and repository. Only consulted if itemDescriptorName and/or repository parameter(s) are not set.
returnValueObjects
If true, return value PossibleValue objects, rather than the raw values in the "values" parameter.
maxRepositoryItems
If defined, limit the number of repository items returns to the specified number. If maxRepositoryItems is not specified as a parameter, will use the maxRepositoryItems property, instead. A negative value means no limit.
output
This parameter is rendered for once with the results of the search
propertyName
The optional value that, if used, must refer to a linked property. If this parameter is specified, repository items of the linked type will be returned.
repository
This parameter defines the repository to search. It can also be set via a properties file.
sortProperties
A string that specifies how to sort the list of repository items. This parameter is specified as a comma separated list of property names. The first name specifies the primary sort, the second specifies the secondary sort, etc. If the first character of each keyword is a -, this sort is performed in descending order. If it is a + or it is not a -, it is sorted in ascending order.

Note: This parameter is only valid for repository items, it will not work with enumerated data-types.

values
Within the body of the "output" oparam, this parameter is set to the list of possible values for the named item descriptor and property. The value will either be a list of tags (for enumerated properties) or an array of repository items.
displayValues

Note: This parameter is only valid for enumerated data-types. For repository items this parameter will contain an empty map.

Within the body of the "output" oparam, this parameter is set to the map of possible values for the named item descriptor and property. This parameter is mainly used to display internationalized enumerated option values. The map key is set to the PossibleValues.PossibleValue.getSettableValue(). The could be a value or an option code. This key is determined based on the EnumPropertyDescriptor.EnumeratedOption.getUseCodeForValue().

The map value object could contain the following values.


Nested Class Summary
 class PossibleValues.EnumeratedOptionPossibleValue
          A possible item based by a repository item.
 class PossibleValues.PossibleValue
          Class representing a possible value.
 class PossibleValues.RepositoryItemPossibleValue
          A possible item based by a repository item.
 
Field Summary
static java.lang.String CLASS_VERSION
           
static java.lang.String DISPLAY_VALUES
           
static java.lang.String ENUMERATED
           
static ParameterName ITEM_NAME
           
static ParameterName MAX_REPOSITORY_ITEMS
           
static ParameterName OUTPUT
           
static ParameterName PROPERTY_NAME
           
static ParameterName REPOSITORY
           
static ParameterName REPOSITORY_ITEM
           
static java.lang.String RESOURCE_BUNDLE
           
static ParameterName RETURN_VALUE_OBJECTS
           
protected static java.util.ResourceBundle smResourceBundle
           
static ParameterName SORT_PROPERTIES
           
static ParameterName USE_CODE_FOR_VALUE
           
static java.lang.String VALUES
           
 
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
PossibleValues()
           
 
Method Summary
static SortDirectives buildSortDirectives(java.lang.String[] pSortProperties)
          Build sort directives
protected  int getCurrentMaxRepositoryItemsValue()
          Method to get the current "maxRepositoryItems" parameter value.
protected  boolean getCurrentReturnValueObjectsValue()
          Method to get the current "returnValueObjects" parameter value.
 java.util.Map<java.lang.Object,java.lang.Object> getDisplayValues(Repository pRepository, java.lang.String pItemDescriptorName, java.lang.String pPropertyName)
          This method returns a map.
 PossibleValues.EnumeratedOptionPossibleValue[] getEnumeratedPossibleObjectValues(Repository pRepository, java.lang.String pItemDescriptorName, java.lang.String pPropertyName)
          This method returns an array of PossibleValues.EnumeratedOptionPossibleValue objects.
 int getMaxRepositoryItems()
          Gets the default maximum number of repository items to be returned from a query.
 Repository getRepository()
          Get the repository
protected  Query getRepositoryItemQuery(RepositoryItemDescriptor pItemDescriptor, QueryBuilder pBuilder)
          Get the query that is used by getRepositoryItems By default, this is just an unconstrained query
protected  RepositoryItem[] getRepositoryItems(RepositoryItemDescriptor pItemDescriptor, RepositoryPropertyDescriptor pPropertyDescriptor, SortDirectives pSortDirectives)
          Get repository items
 java.lang.Object getRepositoryValues(Repository pRepository, java.lang.String pItemDescriptorName, java.lang.String pPropertyName, boolean pUseCodeForValue, SortDirectives pSortDirectives)
          Get repository values for either enumerated types or for linked property values, using the specified repository
protected  java.lang.Object getRepositoryValues(java.lang.String pItemDescriptorName, java.lang.String pPropertyName, java.lang.String pUseCodeForValue, SortDirectives pSortDirectives)
          Get repository values for either enumerated types or for linked property values, use the configured repository
 void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Service routine
 void setMaxRepositoryItems(int pMaxRepositoryItems)
          Sets the default maximum number of repository items to be returned from a query.
 void setRepository(Repository pRepository)
          Set the repository
 
Methods inherited from class atg.servlet.DynamoServlet
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, init, service, service, setParameter
 
Methods inherited from class atg.nucleus.servlet.ServletService
destroy, getServletConfig, getServletInfo, 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, 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 java.lang.String CLASS_VERSION

RESOURCE_BUNDLE

public static java.lang.String RESOURCE_BUNDLE

ENUMERATED

public static java.lang.String ENUMERATED

VALUES

public static java.lang.String VALUES

DISPLAY_VALUES

public static java.lang.String DISPLAY_VALUES

REPOSITORY

public static final ParameterName REPOSITORY

ITEM_NAME

public static final ParameterName ITEM_NAME

REPOSITORY_ITEM

public static final ParameterName REPOSITORY_ITEM

RETURN_VALUE_OBJECTS

public static final ParameterName RETURN_VALUE_OBJECTS

PROPERTY_NAME

public static final ParameterName PROPERTY_NAME

SORT_PROPERTIES

public static final ParameterName SORT_PROPERTIES

USE_CODE_FOR_VALUE

public static final ParameterName USE_CODE_FOR_VALUE

MAX_REPOSITORY_ITEMS

public static final ParameterName MAX_REPOSITORY_ITEMS

OUTPUT

public static final ParameterName OUTPUT

smResourceBundle

protected static java.util.ResourceBundle smResourceBundle
Constructor Detail

PossibleValues

public PossibleValues()
Method Detail

setRepository

public void setRepository(Repository pRepository)
Set the repository

Parameters:
pRepository - a repository

getRepository

public Repository getRepository()
Get the repository

Returns:
the repository or null

setMaxRepositoryItems

public void setMaxRepositoryItems(int pMaxRepositoryItems)
Sets the default maximum number of repository items to be returned from a query. A negative value means no limit.


getMaxRepositoryItems

public int getMaxRepositoryItems()
Gets the default maximum number of repository items to be returned from a query. A negative value means no limit.


service

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

Overrides:
service in class DynamoServlet
Parameters:
pRequest - the request to be processed
pResponse - the response object for this request
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.

buildSortDirectives

public static SortDirectives buildSortDirectives(java.lang.String[] pSortProperties)
Build sort directives

Parameters:
pSortProperties - a list of sort directives
Returns:
a possibly empty SortDirectives object

getRepositoryValues

protected java.lang.Object getRepositoryValues(java.lang.String pItemDescriptorName,
                                               java.lang.String pPropertyName,
                                               java.lang.String pUseCodeForValue,
                                               SortDirectives pSortDirectives)
Get repository values for either enumerated types or for linked property values, use the configured repository

Parameters:
pItemDescriptorName - item descriptor name
pPropertyName - the property name
pSortProperties - sort directives
Returns:
results or null

getRepositoryValues

public java.lang.Object getRepositoryValues(Repository pRepository,
                                            java.lang.String pItemDescriptorName,
                                            java.lang.String pPropertyName,
                                            boolean pUseCodeForValue,
                                            SortDirectives pSortDirectives)
Get repository values for either enumerated types or for linked property values, using the specified repository

Parameters:
pRepository - the repository
pItemDescriptorName - item descriptor name
pPropertyName - the property name
pSortProperties - sort directives
Returns:
results or null

getRepositoryItems

protected RepositoryItem[] getRepositoryItems(RepositoryItemDescriptor pItemDescriptor,
                                              RepositoryPropertyDescriptor pPropertyDescriptor,
                                              SortDirectives pSortDirectives)
Get repository items

Parameters:
pItemDescriptorName - the name of the item descriptor
pPropertyName - an optional linked property name
pSortDirectives - a possibly empty or null SortDirectives object
Returns:
an array of repository items or null

getRepositoryItemQuery

protected Query getRepositoryItemQuery(RepositoryItemDescriptor pItemDescriptor,
                                       QueryBuilder pBuilder)
                                throws RepositoryException
Get the query that is used by getRepositoryItems By default, this is just an unconstrained query

Parameters:
pItemDescriptor - The type of item that is return by this query
pBuilder - The query builder used to build the query
Returns:
A query object
Throws:
RepositoryException

getCurrentReturnValueObjectsValue

protected boolean getCurrentReturnValueObjectsValue()
Method to get the current "returnValueObjects" parameter value. By default, looks at the local "returnValueObjects" parameter of the current request. If this method returns true, then the "values" result parameter will be an array of PossibleValue objects, rather than an array of repository items or enumeration values directly.


getCurrentMaxRepositoryItemsValue

protected int getCurrentMaxRepositoryItemsValue()
Method to get the current "maxRepositoryItems" parameter value. By default, looks at the local "maxRepositoryItems" parameter of the current request. The value returned indicates the maximum number of repository item. Defaults to the maxRepositoryItems() property value, if a value could not be obtained from the current request. A negative value means no limit.


getEnumeratedPossibleObjectValues

public PossibleValues.EnumeratedOptionPossibleValue[] getEnumeratedPossibleObjectValues(Repository pRepository,
                                                                                        java.lang.String pItemDescriptorName,
                                                                                        java.lang.String pPropertyName)
This method returns an array of PossibleValues.EnumeratedOptionPossibleValue objects.

If the property is of enumerated type, then this method returns an array of PossibleValues.EnumeratedOptionPossibleValue objects. Otherwise returns null.

Parameters:
pRepository - The repository in which a property needs to be looked up
pItemDescriptorName - The item descriptor in which a property needs to be looked up
pPropertyName - The property name to be looked up
Returns:
a array of PossibleValues.EnumeratedOptionPossibleValue objects

getDisplayValues

public java.util.Map<java.lang.Object,java.lang.Object> getDisplayValues(Repository pRepository,
                                                                         java.lang.String pItemDescriptorName,
                                                                         java.lang.String pPropertyName)
This method returns a map.

If the property that needs to be looked up is an enumerated property, the following possible map values are returned.

The map key is the PossibleValues.PossibleValue.getSettableValue(). The could be a value or an option code. This key is determined based on the EnumPropertyDescriptor.EnumeratedOption.getUseCodeForValue().

The map value object could contain the following values.

Parameters:
pRepository - The repository in which a property needs to be looked up
pItemDescriptorName - The item descriptor in which a property needs to be looked up
pPropertyName - The property name to be looked up
Returns:
returns a map based on the above criteria.
See Also:
getEnumeratedPossibleObjectValues(Repository, String, String), getCurrentReturnValueObjectsValue()