atg.repository.dp
Class SearchConfigLocale

java.lang.Object
  extended by java.beans.FeatureDescriptor
      extended by atg.beans.SerializableFeatureDescriptor
          extended by atg.repository.dp.DerivationMethodImpl
              extended by atg.repository.dp.SearchConfigLocale
All Implemented Interfaces:
atg.repository.dp.Constants, atg.repository.dp.DerivationMethod, java.io.Serializable

public class SearchConfigLocale
extends atg.repository.dp.DerivationMethodImpl

This class provides a mechanism for finding the locale for a search config. Every searchConfig item has a 'derivedLocale' property. This property is a read only property whose value is calculated via a custom derivation method. The custom derivation method uses the following logic to determine this property: 1. If 'locale' property is not null then use it (generally only baseSearchConfig items will have their locale property set) else 2. If parentDimensionFolder.dimensionService = getLanguageDimensionService().getDimensionName() then derivedLocale = getLanguageDimensionService().getLocale(dimensionValue) else 3. Traverse up the tree until a folder is found where folder[i] = dimensionService=getLanguageDimensionService().getDimensionName(). If found then derivedLocale = getLanguageDimensionService().getLocale(folder[i-1].dimensionValue) else 4. If 'baseSearchConfig.derivedLocale' is not null then use it else 5. getLanguageDimensionService().getDefaultLocale() It is possible to use this derivation without configuring a language dimension service in which case it will only do steps 1 & 4.

See Also:
Serialized Form

Field Summary
protected static java.lang.String BASE_CONFIG_PROP
           
static java.lang.String CLASS_VERSION
          Class version string
protected static java.lang.String DERIVATION_NAME
           
protected static java.lang.String DERIVED_LOCALE_PROP
           
protected static java.lang.String DIM_FOLDER_PARENT_FOLDERS_PROP
           
protected static java.lang.String DIMENSION_SERVICE_PROP
           
protected static java.lang.String DIMENSION_VALUE_PROP
           
protected static java.lang.String DISPLAY_NAME
           
protected static java.lang.String LANGUAGE_SERVICE
           
protected static java.lang.String LOCALE_PROP
           
protected static java.lang.String SHORT_DESCRIPTION
           
protected static SearchConfigurationPropertyManager sPropertyManager
           
protected static java.lang.String SRCH_CONFIG_PARENT_FOLDERS_PROP
           
 
Fields inherited from class atg.repository.dp.DerivationMethodImpl
COMPARISON_QUERY, INCLUDES_ALL_QUERY, INCLUDES_ANY_QUERY, INCLUDES_ITEM_QUERY, INCLUDES_QUERY, IS_NULL_QUERY, PATTERN_MATCH_QUERY, sZero, TEXT_SEARCH_QUERY
 
Fields inherited from class atg.beans.SerializableFeatureDescriptor
BUNDLE_ATTRIBUTE_NAME, LOCALE_ATTRIBUTE_NAME
 
Fields inherited from interface atg.repository.dp.Constants
ATTR_METHOD, ATTR_OVERRIDE_PROPERTY, ATTR_USER_METHOD, DEFAULT_METHOD_NAME, DEFAULT_RECURSION_DEPTH, DP_COUNT_ATTR_NAME, ERR_COLLECTION_EXPRESSION_TYPE, ERR_COLLECTION_ITEM_TYPE, ERR_DP_EXP_NOT_ARRAY, ERR_DP_EXP_NOT_COLLECTION, ERR_DP_EXP_NOT_SET_LIST, ERR_DP_EXP_NOT_SET_LIST_MAP, ERR_DP_EXP_REFERENCES_DP, ERR_DP_EXP_TYPE_MISMATCH, ERR_DP_NOT_SET_LIST_MAP, ERR_DP_QUERYABLE_OP_NOT, ERR_DP_READABLE_OP_NOT, ERR_DP_WRITABLE_OP_NOT, ERR_DP_WRITABLE_WITH_NULL_OP, ERR_EMPTY_EXPRESSION, ERR_EXACTLY_ONE_EXPRESSION, ERR_INCOMPATIBLE_DP_EXP, ERR_INCOMPATIBLE_OP, ERR_INVALID_OVERRIDE_PROPERTY_NAME, ERR_INVALID_PROPERTY, ERR_METHOD_AND_USER_METHOD, ERR_MISSING_DERIVATION, ERR_NO_DP, ERR_NO_EXP, ERR_NO_EXPRESSION, ERR_NO_METHOD, ERR_NO_PROPERTY_FOR_LOCALE, ERR_NO_PROPERTY_TYPE, ERR_NO_SET_LIST, ERR_NULL_ITEM_DESCRIPTOR, ERR_OP_SAME_AS_DP, ERR_PROP_COLLECTION_TYPE, ERR_SET_NOT_WRITABLE, PROPERTY_SEPARATOR, RECURSION_DEPTH_ATTR_NAME, RESOURCE_BUNDLE_NAME, TAG_DERIVATION, TAG_EXPRESSION
 
Constructor Summary
SearchConfigLocale()
           
 
Method Summary
protected  Query createQuery(int pQueryType, boolean pDerivedPropertyOnLeft, boolean pCountDerivedProperty, QueryExpression pOther, int pOperator, boolean pIgnoreCase, QueryExpression pMinScore, QueryExpression pSearchStringFormat, Query pItemQuery, QueryBuilder pBuilder, atg.repository.query.PropertyQueryExpression pParentProperty, java.util.List pChildPropertyList)
          Do the real work of implementing a query to find the correct map value.
 java.lang.Object derivePropertyValue(java.lang.Object pBean)
          Determine the derived property value.
 java.lang.Object derivePropertyValue(RepositoryItemImpl pItem)
          Determine the derived property value.
protected  LanguageDimensionService getLanguageDimensionService()
          Return the value of the "languageSearchDimensionService" attribute.
 atg.repository.dp.Expression getPropertyOrigin(RepositoryItemImpl pItem)
          Determine from where the specified property value is derived.
protected  boolean isFolderDimension(java.lang.Object pFolder, java.lang.String pDimensionName)
          Utility method to check a folder has a specific dimension service.
 boolean isQueryable()
          Determine whether the specified property can be used in a query.
protected  void setLanguageDimensionService(LanguageDimensionService pLanguageDimensionService)
          Set the mLanguageDimensionService.
 java.util.List validate()
          Validate the derivation.
 
Methods inherited from class atg.repository.dp.DerivationMethodImpl
createComparisonQuery, createExpression, createIncludesAllQuery, createIncludesAnyQuery, createIncludesItemQuery, createIncludesQuery, createIsNullQuery, createPatternMatchQuery, createQuery, createReferencedByQuery, createTextSearchQuery, getAllowNoExpressions, getDerivation, getFeatureDescriptor, getPropertyDescriptor, getPropertyOrigin, getPropertyOrigin, getPropertyOrigin, isEmpty, isWritable, rebuildExpression, setDerivation, setFrom, setPropertyDescriptor, setPropertyValue, setPropertyValue, wrap
 
Methods inherited from class atg.beans.SerializableFeatureDescriptor
copyFeatureDescriptor, getDisplayName, getDisplayNameResource, getDisplaySortString, getLocalizedResourceBundle, getResourceBundle, getShortDescription, getShortDescriptionResource, getSortString, setDisplayNameResource, setShortDescriptionResource, toString
 
Methods inherited from class java.beans.FeatureDescriptor
attributeNames, getName, getValue, isExpert, isHidden, isPreferred, setDisplayName, setExpert, setHidden, setName, setPreferred, setShortDescription, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values

DERIVATION_NAME

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

DISPLAY_NAME

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

SHORT_DESCRIPTION

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

LANGUAGE_SERVICE

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

sPropertyManager

protected static SearchConfigurationPropertyManager sPropertyManager

LOCALE_PROP

protected static final java.lang.String LOCALE_PROP

DIM_FOLDER_PARENT_FOLDERS_PROP

protected static final java.lang.String DIM_FOLDER_PARENT_FOLDERS_PROP

SRCH_CONFIG_PARENT_FOLDERS_PROP

protected static final java.lang.String SRCH_CONFIG_PARENT_FOLDERS_PROP

DIMENSION_VALUE_PROP

protected static final java.lang.String DIMENSION_VALUE_PROP

BASE_CONFIG_PROP

protected static final java.lang.String BASE_CONFIG_PROP

DERIVED_LOCALE_PROP

protected static final java.lang.String DERIVED_LOCALE_PROP

DIMENSION_SERVICE_PROP

protected static final java.lang.String DIMENSION_SERVICE_PROP
Constructor Detail

SearchConfigLocale

public SearchConfigLocale()
Method Detail

getLanguageDimensionService

protected LanguageDimensionService getLanguageDimensionService()
Return the value of the "languageSearchDimensionService" attribute. This service is used to find the correct locale


setLanguageDimensionService

protected void setLanguageDimensionService(LanguageDimensionService pLanguageDimensionService)
Set the mLanguageDimensionService.

Parameters:
pLanguageDimensionService - the service to set.

validate

public java.util.List validate()
Validate the derivation.

Specified by:
validate in interface atg.repository.dp.DerivationMethod
Overrides:
validate in class atg.repository.dp.DerivationMethodImpl
Returns:
a non-null, possibly empty List of RepositoryExceptions if the derivation is not valid. The size of the list is the number of errors found.

derivePropertyValue

public java.lang.Object derivePropertyValue(RepositoryItemImpl pItem)
                                     throws RepositoryException
Determine the derived property value. Every searchConfig item has a 'derivedLocale' property. This property is a read only property whose value is calculated via a custom derivation method. The custom derivation method uses the following logic to determine this property: 1. If 'locale' property is not null then use it (generally only baseSearchConfig items will have their locale property set) else 2. If parentDimensionFolder.dimensionService = getLanguageDimensionService().getDimensionName() then derivedLocale = getLanguageDimensionService().getLocale(dimensionValue) else 3. Traverse up the tree until a folder is found where folder[i] = dimensionService=getLanguageDimensionService().getDimensionName(). If found then derivedLocale = getLanguageDimensionService().getLocale(folder[i-1].dimensionValue) else 4. If 'baseSearchConfig.derivedLocale' is not null then use it else 5. getLanguageDimensionService().getDefaultLocale()

Parameters:
pItem - the item whose property value is desired
Returns:
the derived String locale value
Throws:
RepositoryException - if a property referenced in this expression could not be found in the specified bean

derivePropertyValue

public java.lang.Object derivePropertyValue(java.lang.Object pBean)
                                     throws RepositoryException
Determine the derived property value. Every searchConfig item has a 'derivedLocale' property. This property is a read only property whose value is calculated via a custom derivation method. The custom derivation method uses the following logic to determine this property: 1. If 'locale' property is not null then use it (generally only baseSearchConfig items will have their locale property set) else 2. If parentDimensionFolder.dimensionService = getLanguageDimensionService().getDimensionName() then derivedLocale = getLanguageDimensionService().getLocale(dimensionValue) else 3. Traverse up the tree until a folder is found where folder[i] = dimensionService=getLanguageDimensionService().getDimensionName(). If found then derivedLocale = getLanguageDimensionService().getLocale(folder[i-1].dimensionValue) else 4. If 'baseSearchConfig.derivedLocale' is not null then use it else 5. getLanguageDimensionService().getDefaultLocale()

Parameters:
pBean - the bean representing a repository item whose property value is desired
Returns:
the derived value
Throws:
RepositoryException - if a property referenced in this expression could not be found in the specified bean

getPropertyOrigin

public atg.repository.dp.Expression getPropertyOrigin(RepositoryItemImpl pItem)
                                               throws RepositoryException
Determine from where the specified property value is derived.

Specified by:
getPropertyOrigin in interface atg.repository.dp.DerivationMethod
Overrides:
getPropertyOrigin in class atg.repository.dp.DerivationMethodImpl
Parameters:
pItem - the item whose property value origin is desired
Returns:
the orgin of this property, or null if not applicable
Throws:
RepositoryException

isQueryable

public boolean isQueryable()
Determine whether the specified property can be used in a query.

Returns:
true if it can be queried, else false

createQuery

protected Query createQuery(int pQueryType,
                            boolean pDerivedPropertyOnLeft,
                            boolean pCountDerivedProperty,
                            QueryExpression pOther,
                            int pOperator,
                            boolean pIgnoreCase,
                            QueryExpression pMinScore,
                            QueryExpression pSearchStringFormat,
                            Query pItemQuery,
                            QueryBuilder pBuilder,
                            atg.repository.query.PropertyQueryExpression pParentProperty,
                            java.util.List pChildPropertyList)
                     throws RepositoryException
Do the real work of implementing a query to find the correct map value. The various translate methods call this helper method. The arguments may seem a little strange. By passing all the arguments to all the types of queries we can centralize the logic without having to instanceof and cast query objects (again).

All of the QueryExpression arguments to this method were created by pBuilder and thus can be used as is without being translated.

Specified by:
createQuery in class atg.repository.dp.DerivationMethodImpl
Parameters:
pQueryType - the type of the original query
pDerivedPropertyOnLeft - if true the derived property is used as the left hand side in the query and pOtherExpression is used as the right hand side. If false the derived property is used as the right hand side and pOtherExpression is used as the left hand side.
pCountDerivedProperty - if true the derived property is used in a count query expression
pOther - the other expression involved in binary queries
pOperator - the binary operator involved in binary queries
pIgnoreCase - whether to ignore case in pattern match queries
pMinScore - min score for text queries
pSearchStringFormat - search string format for text queries
pItemQuery - query to use in includes item queries only
pBuilder - query builder to use
pParentProperty - the parent of the derived property, if the derived property is not a direct child of the Item being queried.
pChildPropertyList - a list of the children of the derived property, if the derived property is not the last expression in the query.
Returns:
the specified query
Throws:
RepositoryException - if there is problem building the query

isFolderDimension

protected boolean isFolderDimension(java.lang.Object pFolder,
                                    java.lang.String pDimensionName)
                             throws PropertyNotFoundException
Utility method to check a folder has a specific dimension service. Can handles a Set with a single folder in it also.

Parameters:
pFolder - dimensionFolder or Set with a single dimensionFolder repository item.
pDimensionName - String name to check
Returns:
true if the folder dimensionService property matches the name.
Throws:
PropertyNotFoundException