atg.repository.search.refinement
Class RefinementValueDroplet

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.search.refinement.RefinementValueDroplet
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

public class RefinementValueDroplet
extends DynamoServlet

A Droplet that parses refinement values into human-readable strings.

The droplet has 2 input parameters: "refinementId" - The repository item id of the refineElement (facet) in the refinement repository. "refinementValue" - A String value for the facet as returned by the search response (i.e. in the format it is stored in the search index).

The output of the droplet is the refinementValue converted into a more human readable form (if needed).

So for example, date values like the creationDate are stored in the index in a strange format, basically it is the timestamp as a long divided by 1000. When we get this back in a search response we don't want to show it in this format in the UI so we use this droplet to convert it into a nicer locale string date format.

The first thing the droplet does is to get the refineElement item from the repository and then lookup the MetaPropertiesHelper to get the MetaProperty object for that refinement property. The droplet then converts the value using a MetaPropertyValueFormatter component. It first checks the MetaPropertyValueFormatterRegistry to see if there is a MetaPropertyValueFormatter registered for this refinement property name. If there isn't then it just uses the DefaultMetaPropertyValueFormatter.

MetaPropertyValueFormatter is an interface with this method: public String formatDisplayValue(MetaProperty pProperty, Locale pLocale, String pValue);

OOTB we provide 1 implementation of this interface - DefaultMetaPropertyValueFormatter which should handle most property types. This class will handle properties in this way:

Since the droplet uses the MetaPropertyValueFormatterRegistry then it is possible for a customer to configure a property to have its own MetaPropertyValueFormatter to return customized strings. E.g. you could register the "price" property with your own MetaPropertyValueFormatter that for instance might return prices prefixed with $ symbols. i.e. instead of showing on the UI: 100-200 it would show $100-$200

Also for range values the droplet splits the range into start and end values and formats each separately before recombining again. So in the example above it would call the formatter for 100 and then for 200 and then concatenate the returned values with a -.

The droplet doesn't take a locale parameter so the locale used in the default formatter is ServletUtils.getUserLocale() or failing that it will use the atg.service.dynamo.LangLicense.getLicensedDefault() locale.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String DISPLAY_VALUE
           
static java.lang.String RANGES_SEPARATOR
           
static ParameterName S_ERROR
           
static java.lang.String S_LOCALE
           
static ParameterName S_OUTPUT
           
static java.lang.String S_REFINEMENT
           
static java.lang.String S_REFINEMENT_VALUE
           
 
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
RefinementValueDroplet()
           
 
Method Summary
 MetaPropertyValueFormatter getDefaultValueFormatter()
          Return default MetaPropertyValueFormatter
 FacetManager getFacetManager()
          Returns FacetManager
 MetaPropertiesHelper getMetaPropertiesHelper()
          Return MetaPropertisHelper
 java.lang.String getRangeDelimiter()
           
 MetaPropertyValueFormatterRegistry getValueFormatterRegistry()
          Return registry of value foramtters
 void service(DynamoHttpServletRequest req, DynamoHttpServletResponse res)
          Generates a human readable string from refinement value.
 void setDefaultValueFormatter(MetaPropertyValueFormatter pDefaultValueFormatter)
          Sets default value formatter
 void setFacetManager(FacetManager pFacetManager)
          Se FacetManager
 void setMetaPropertiesHelper(MetaPropertiesHelper pMetaPropertiesHelper)
          Sets MetaPropertiesHelper
 void setRangeDelimiter(java.lang.String pRangeDelimiter)
           
 void setValueFormatterRegistry(MetaPropertyValueFormatterRegistry pValueFormatterRegistry)
          Set registry of formatters
 
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, 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
Class version string


S_OUTPUT

public static final ParameterName S_OUTPUT

S_ERROR

public static final ParameterName S_ERROR

S_REFINEMENT

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

S_REFINEMENT_VALUE

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

S_LOCALE

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

DISPLAY_VALUE

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

RANGES_SEPARATOR

public static final java.lang.String RANGES_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

RefinementValueDroplet

public RefinementValueDroplet()
Method Detail

getDefaultValueFormatter

public MetaPropertyValueFormatter getDefaultValueFormatter()
Return default MetaPropertyValueFormatter

Returns:
default meta property value formatter

setDefaultValueFormatter

public void setDefaultValueFormatter(MetaPropertyValueFormatter pDefaultValueFormatter)
Sets default value formatter

Parameters:
pDefaultValueFormatter - default MetaPropertyValueFormatter

getValueFormatterRegistry

public MetaPropertyValueFormatterRegistry getValueFormatterRegistry()
Return registry of value foramtters

Returns:
registry of formatters

setValueFormatterRegistry

public void setValueFormatterRegistry(MetaPropertyValueFormatterRegistry pValueFormatterRegistry)
Set registry of formatters

Parameters:
pValueFormatterRegistry - registry of formatters

getFacetManager

public FacetManager getFacetManager()
Returns FacetManager

Returns:
FacetManager

setFacetManager

public void setFacetManager(FacetManager pFacetManager)
Se FacetManager

Parameters:
pFacetManager - facet manager

getMetaPropertiesHelper

public MetaPropertiesHelper getMetaPropertiesHelper()
Return MetaPropertisHelper

Returns:
MetaPropertiesHelper

setMetaPropertiesHelper

public void setMetaPropertiesHelper(MetaPropertiesHelper pMetaPropertiesHelper)
Sets MetaPropertiesHelper

Parameters:
pMetaPropertiesHelper - MetaPropertiesHelper

getRangeDelimiter

public java.lang.String getRangeDelimiter()
Returns:
range delimiter

setRangeDelimiter

public void setRangeDelimiter(java.lang.String pRangeDelimiter)
Parameters:
pRangeDelimeter - range delimiter

service

public void service(DynamoHttpServletRequest req,
                    DynamoHttpServletResponse res)
             throws javax.servlet.ServletException,
                    java.io.IOException
Generates a human readable string from refinement value.

Overrides:
service in class DynamoServlet
Parameters:
req - dynamo http request
res - dynamo http response
Throws:
javax.servlet.ServletException
java.io.IOException