atg.commerce.dp
Class InventoryLevelDerivation

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

public class InventoryLevelDerivation
extends atg.repository.dp.DerivationMethodImpl

This derivation method is used to obtain inventory information for a specified catalogRefId. The catalogRefId that is used to query the atg.commerce.inventory.InventoryManagerInventoryManager is obtained from a value in the expression list. Because the property is dervied via logic (querying an inventory manager), it is impossible to query based upon this property. This property can only be accessed for read-only information.

An example of how this method property might be used is as follows: <property name="inventoryLevel"> <derivation method="InventoryLevel"> <expression>catalogRefId</expression> </derivation> </property>

This configuration assumes that the repository item on which this property is configured has a property named catalogRefId . That String value of the catalogRefId property is obtained and is used to query the inventory system. This information can then be used in a variety of ways:

See Also:
Serialized Form

Field Summary
static java.lang.String CLASS_VERSION
           
 
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_REFERENCES_DP, 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_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
InventoryLevelDerivation()
          Set the name, display name and short description properties.
 
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 creating a query.
 java.lang.Object derivePropertyValue(java.lang.Object pBean)
          This method is not supported.
 java.lang.Object derivePropertyValue(RepositoryItemImpl pItem)
          This method will return the inventory level associated with the passed in catalogRefId.
protected  java.lang.String getCatalogRefId(java.util.List pList, RepositoryItemImpl pItem)
          Given a list of PropertyExpressionPropertyExpression objects, return the catalogRefId.
 InventoryManager getInventoryManager()
          Return the inventoryManager property.
 atg.repository.dp.Expression getPropertyOrigin(RepositoryItemImpl pItem)
          Determine from where the specified property value is derived, if applicable.
 boolean isQueryable()
          Because this property derives its value from a InventoryManager service, it is impossible to query on it.
 boolean isThrowExceptionOnInventoryException()
          Return the throwExceptionOnInventoryException property.
 void setThrowExceptionOnInventoryException(boolean pThrowExceptionOnInventoryException)
          Set the throwExceptionOnInventoryException property.
 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, 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
See Also:
Constant Field Values
Constructor Detail

InventoryLevelDerivation

public InventoryLevelDerivation()
Set the name, display name and short description properties. These are set from the value extracted from the class.

Method Detail

getInventoryManager

public InventoryManager getInventoryManager()
Return the inventoryManager property.

Returns:
the inventory manager

isThrowExceptionOnInventoryException

public boolean isThrowExceptionOnInventoryException()
Return the throwExceptionOnInventoryException property. This property controls whether or not an inventory exception thrown by the InventoryManager will be propogated. This defaults to true.

Returns:
whether or not inventory exceptions should be propogated

setThrowExceptionOnInventoryException

public void setThrowExceptionOnInventoryException(boolean pThrowExceptionOnInventoryException)
Set the throwExceptionOnInventoryException property.

Parameters:
pThrowExceptionOnInventoryException -

getPropertyOrigin

public atg.repository.dp.Expression getPropertyOrigin(RepositoryItemImpl pItem)
Determine from where the specified property value is derived, if applicable. For some derivations there is no identifiable origin for a derived property. This returns null.

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

validate

public java.util.List validate()
Validate the derivation. This derivation only works if the expression list contains at least one expression element and that expression element will return false for the question isMultiValued Only the first <Element> is checked for its multivalue status since this implementation only extracts the catalogRefId value from the first <Element> in the list.

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.

getCatalogRefId

protected java.lang.String getCatalogRefId(java.util.List pList,
                                           RepositoryItemImpl pItem)
                                    throws RepositoryException
Given a list of PropertyExpressionPropertyExpression objects, return the catalogRefId.

This implementation will return the String value of the first object extracted from the list. This means that the repository definition file is expected to define a single <Express> tag that can evaluate to a catalogRefId.

Parameters:
pList - a list of PropertyExpression elements
Returns:
a catalogRefId object, or null if no items in pList
Throws:
RepositoryException - if error evaluating PropertyExpression

derivePropertyValue

public java.lang.Object derivePropertyValue(RepositoryItemImpl pItem)
                                     throws RepositoryException
This method will return the inventory level associated with the passed in catalogRefId. This catalogRefId is obtained from the one of the PropertyExpressions in the PropertyExpression list. This means that if an item-desciptor has a property named catalogRefId which refers to the catalogRefId we would configure this derivation method in our repository configuration file to look like
<property name="inventoryLevel"> <derivation method="InventoryLevel"> <expression>catalogRefId</expression> </derivation> </property>

Parameters:
pItem - a RepositoryItemImpl value
Returns:
an Object value
Throws:
RepositoryException

derivePropertyValue

public java.lang.Object derivePropertyValue(java.lang.Object pBean)
                                     throws RepositoryException
This method is not supported. We can infer from the method arguments that this method is being called from the client side. We can not derive the property value from the client side with out accessing the InventoryManager directly. This is not possible as such. Clients wishing to access inventory level information should use the derivePropertyValue method that uses a RepositoryItemImpl, or that is called server side.

Parameters:
pBean - an Object value to be computed
Returns:
an Object value
Throws:
RepositoryException - if an error occurs

isQueryable

public boolean isQueryable()
Because this property derives its value from a InventoryManager service, it is impossible to query on it. That is, the QueryBuilder interface does not allow one to query non Repository based information stores.

Returns:
true if queryable

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 creating a query. 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 derivation logic without having to instanceof and cast query objects all over the place. 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 first non null query
Throws:
RepositoryException - if there is problem building the query