|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object atg.nucleus.logging.VariableArgumentApplicationLoggingImpl atg.nucleus.GenericService atg.commerce.catalog.comparison.ComparisonList atg.commerce.catalog.comparison.ProductComparisonList
public class ProductComparisonList
ProductComparisonList extends ComparisonList and manages list elements
Entry
that are specifically designed for comparing catalog-based
category/product/sku tuples rather than simple Java objects.
This class includes convenience methods that take product, category, and sku id's and retrieve the corresponding objects from the product catalog, making it easier to write form handlers and droplet that manipulate the list contents. It also endows each list element with an unambiguous unique id and allows callers to remove elements by specifying their ids, which eases the task of writing form handlers that display a sorted list of product entries with "remove" buttons or checkboxes associated with Entry.
Example:
The following JHTML fragment displays the names, category names, and inventory availability of all of the items in a product comparison list:
<droplet bean="ForEach"> <param name="array" value="bean:ComparisonList.items"> <param name="sortProperties" value="bean:ComparisonList.sortString"> <oparam name="output"> Product: <valueof param="element.product.displayName">unknown</valueof><br> Category: <valueof param="element.category.displayName">none</valueof><br> Inventory: <valueof param="element.inventoryInfo.availabilityStatusMsg">unknown</valueof>< </oparam> </droplet>
Nested Class Summary | |
---|---|
static class |
ProductComparisonList.Entry
Entry is specifically designed for comparing catalog-based category/product/sku tuples rather than simple Java objects. |
Field Summary | |
---|---|
static java.lang.String |
CATEGORY_KEY
|
static java.lang.String |
CATEGORY_LINK_KEY
|
static java.lang.String |
CATEGORY_PROPERTY
|
static java.lang.String |
CLASS_VERSION
|
static java.lang.String |
ID_KEY
|
static java.lang.String |
INVENTORY_KEY
|
protected CatalogTools |
mCatalogTools
|
protected atg.multisite.SiteURLManager |
mSiteURLManager
|
static java.lang.String |
MY_RESOURCE_NAME
|
static java.lang.String |
PRICE_INFO_KEY
|
static java.lang.String |
PRODUCT_KEY
|
static java.lang.String |
PRODUCT_LINK_KEY
|
static java.lang.String |
SITE_ID
|
static java.lang.String |
SKU_KEY
|
static java.lang.String |
SKULIST_PROPERTY
|
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 | |
---|---|
ProductComparisonList()
|
Method Summary | |
---|---|
boolean |
add(java.lang.String pProductId,
java.lang.String pCategoryId,
java.lang.String pSkuId,
java.lang.String pCatalogKey)
Add a product to the product comparison list, optionally specifying an associated category and sku. |
boolean |
add(java.lang.String pProductId,
java.lang.String pCategoryId,
java.lang.String pSkuId,
java.lang.String pCatalogKey,
java.lang.String pSiteId)
Add a product to the product comparison list, optionally specifying an associated category and sku. |
int |
addAllSkus(java.lang.String pProductId,
java.lang.String pCategoryId,
java.lang.String pCatalogKey)
Add entries to the comparison list for every sku associated with a given product. |
int |
addAllSkus(java.lang.String pProductId,
java.lang.String pCategoryId,
java.lang.String pCatalogKey,
java.lang.String pSiteId)
Add entries to the comparison list for every sku associated with a given product. |
protected boolean |
arrayContains(int[] pIds,
int pTarget)
Return true if the specified array of ints contains the target value. |
boolean |
contains(java.lang.String pProductId)
Return true if the product comparison list contains any Entry for the given product id, regardless of that Entry's category and sku. |
boolean |
contains(java.lang.String pProductId,
java.lang.String pSiteId)
Return true if the product comparison list contains any Entry for the given product id, regardless of that Entry's category and sku on chosen site. |
boolean |
contains(java.lang.String pProductId,
java.lang.String pCategoryId,
java.lang.String pCatalogKey)
Return true if the product comparison list contains any Entry for the given product id and category id, regardless of that Entry's sku. |
boolean |
contains(java.lang.String pProductId,
java.lang.String pCategoryId,
java.lang.String pSkuId,
java.lang.String pCatalogKey)
Return true if the product comparison list contains an Entry for the given product id, category id, and sku id. |
boolean |
contains(java.lang.String pProductId,
java.lang.String pCategoryId,
java.lang.String pSkuId,
java.lang.String pCatalogKey,
java.lang.String pSiteId,
boolean pMatchSku)
Return true if the product comparison list contains an Entry for the given product id, category id, and sku id. |
protected ProductComparisonList.Entry |
createListEntry(RepositoryItem pCategory,
RepositoryItem pProduct,
RepositoryItem pSku)
Create a product comparison list Entry for the given category, product, and sku. |
protected ProductComparisonList.Entry |
createListEntry(RepositoryItem pCategory,
RepositoryItem pProduct,
RepositoryItem pSku,
java.lang.String pSiteId)
Create a product comparison list Entry for the given category, product, and sku for given site. |
protected RepositoryItem |
defaultCategory(RepositoryItem pProduct)
Get the default parent category for a given product. |
protected RepositoryItem |
defaultSku(RepositoryItem pProduct)
Get the default sku for a given product. |
protected java.lang.String |
errorMsg(java.lang.String pResourceKey,
java.lang.Object[] pArgs)
Get a formatted error message string based on an error message resource key and an array of message arguments. |
CatalogTools |
getCatalogTools()
Get the CatalogTools object to use when looking up products, categories and skus. |
java.lang.String |
getCategoryLinkFormat()
Get the format of the HTML generated for a link to a category page. |
protected java.lang.String |
getDefaultCategoryId(RepositoryItem pProduct)
Get the id of the parent category, the is obtained via defaultCategory |
protected java.lang.String |
getDefaultSkuId(RepositoryItem pProduct)
Get the id of the default sku for given product. |
InventoryManager |
getInventoryManager()
Get the InventoryManager object to use when fetching inventory availability information for items in the product comparison list. |
ProductComparisonList.Entry |
getItems(int pEntryId)
Get a product comparison Entry given its uid. |
PricingTools |
getPricingTools()
Get the PricingTools object to use when fetching the ItemPriceInfo for each item in the product comparison list. |
java.lang.String |
getProductLinkFormat()
Get the format of the HTML generated for a link to a product page. |
atg.multisite.SiteURLManager |
getSiteURLManager()
|
protected ItemPriceInfo |
getUnitPrice(RepositoryItem pProduct,
RepositoryItem pSku)
Return an ItemPriceInfo object representing the unit price of the product and sku represented by pColumn; return null if the column has no sku information. |
protected boolean |
idMatch(java.lang.String pId,
RepositoryItem pItem)
Return true if pId is considered a match for pItem. |
boolean |
isEncodeLinkURLs()
Query whether to encode URLs on links created using productLinkFormat
and categoryLinkFormat . |
boolean |
isPreloadInventoryData()
Query whether to load inventory data for each Entry in the product comparison list when that Entry is created, or to leave the inventory information empty until a call is made to refreshInventoryData . |
protected java.lang.String |
makeLink(java.lang.String pFormat,
RepositoryItem pItem)
Expand the format string for a product or category, substituting in the name, repository id, and template url. |
protected java.lang.String |
makeLink(java.lang.String pFormat,
RepositoryItem pItem,
boolean pEncode,
java.lang.String pSiteId)
Expand the format string for a product or category, substituting in the name, repository id, and template url. |
protected java.lang.String |
makeLink(java.lang.String pFormat,
RepositoryItem pItem,
java.lang.String pSiteId)
Expand the format string for a product or category, substituting in the name, repository id, and template url. |
void |
refreshInventoryData()
Update the inventory information associated with each product in the product comparison list to obtain the latest inventory levels and status. |
void |
remove(java.util.Collection pEntryIds)
Remove the list entries with the specified uids. |
void |
remove(int pEntryId)
Remove the list Entry with the specified uid. |
void |
remove(int[] pEntryIds)
Remove the list entries with the specified uids. |
void |
remove(java.lang.String pProductId,
java.lang.String pCategoryId,
java.lang.String pSkuId,
java.lang.String pCatalogKey)
Remove the list Entry containing the given product id, category id, and sku id. |
void |
remove(java.lang.String pProductId,
java.lang.String pCategoryId,
java.lang.String pSkuId,
java.lang.String pCatalogKey,
java.lang.String pSiteId)
Remove the Entry containing the given product id, category id, and sku id. |
void |
removeAll(java.lang.String pProductId)
Remove all list entries for the specified product, regardless of the Entry's category or sku. |
void |
removeAll(java.lang.String pProductId,
java.lang.String pSiteId)
Remove all list entries for the specified product, regardless of the Entry's category or sku that belongs to specified site. |
void |
removeAll(java.lang.String pProductId,
java.lang.String pCategoryId,
java.lang.String pCatalogKey)
Remove all list entries for the specified product and category, regardless of the Entry's sku. |
void |
removeAll(java.lang.String pProductId,
java.lang.String pCategoryId,
java.lang.String pCatalogKey,
java.lang.String pSiteId)
Remove all list entries for the specified product and category, regardless of the Entry's sku. |
void |
removeCategory(java.lang.String pCategoryId)
Remove all list entries for the specified category, regardless of the Entry's product or sku. |
void |
removeCategory(java.lang.String pCategoryId,
java.lang.String pSiteId)
Remove all list entries for the specified category, regardless of the Entry's product or sku on chosen site. |
void |
setCatalogTools(CatalogTools pCatalogTools)
Set the CatalogTools object to use when looking up products, categories and skus. |
void |
setCategoryLinkFormat(java.lang.String pCategoryLinkFormat)
Set the format of the HTML generated for a link to a category page. |
void |
setEncodeLinkURLs(boolean pEncodeLinkURLs)
Specify whether or not to call DynamoHttpServletRequest.encodeURL
on links to products and categories built using productLinkFormat
and categoryLinkFormat . |
void |
setInventoryManager(InventoryManager pInventoryManager)
Set the InventoryManager object to use when fetching inventory availability information for items in the product comparison list. |
void |
setPreloadInventoryData(boolean pPreloadInventoryData)
Specifies whether to load inventory data for each Entry in the product comparison list when that Entry is created, or to leave the inventory information empty until a call is made to refreshInventoryData . |
void |
setPricingTools(PricingTools pPricingTools)
Set the PricingTools object to use when fetching the ItemPriceInfo for each item in the product comparison list. |
void |
setProductLinkFormat(java.lang.String pProductLinkFormat)
Set the format of the HTML generated for a link to a product page. |
void |
setRefreshInventoryData(java.lang.String pUnused)
"set" method to make the refreshInventoryData functionality available from jhtml. |
void |
setSiteURLManager(atg.multisite.SiteURLManager pSiteURLManager)
|
protected java.util.List |
skuList(RepositoryItem pProduct)
Get the list of skus for a given product. |
Methods inherited from class atg.commerce.catalog.comparison.ComparisonList |
---|
addItem, clear, containsItem, getItem, getItems, getPrimarySortString, getSortString, getTableColumns, getTableInfo, indexOf, removeItem, removeItem, setItems, setTableInfo, size |
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 |
---|
public static final java.lang.String CLASS_VERSION
public static final java.lang.String CATEGORY_PROPERTY
public static final java.lang.String SKULIST_PROPERTY
public static final java.lang.String CATEGORY_KEY
public static final java.lang.String CATEGORY_LINK_KEY
public static final java.lang.String PRODUCT_KEY
public static final java.lang.String PRODUCT_LINK_KEY
public static final java.lang.String SKU_KEY
public static final java.lang.String INVENTORY_KEY
public static final java.lang.String PRICE_INFO_KEY
public static final java.lang.String ID_KEY
public static final java.lang.String SITE_ID
public static final java.lang.String MY_RESOURCE_NAME
protected atg.multisite.SiteURLManager mSiteURLManager
protected CatalogTools mCatalogTools
Constructor Detail |
---|
public ProductComparisonList()
Method Detail |
---|
public atg.multisite.SiteURLManager getSiteURLManager()
public void setSiteURLManager(atg.multisite.SiteURLManager pSiteURLManager)
public ProductComparisonList.Entry getItems(int pEntryId)
pUID
- The unique id of the Entry to return.
public boolean add(java.lang.String pProductId, java.lang.String pCategoryId, java.lang.String pSkuId, java.lang.String pCatalogKey) throws RepositoryException
pProductId
- The repository id of the product being added.pCategoryId
- The repository id of the parent category to use for this Entry.
If null, the product's default parent category will be used instead.
If the product has no default parent category, the category in the
Entry will be null.pSkuId
- The repository id of the sku to use for this Entry. If null, the
first sku in the product's sku list will be used instead. If the product
has no skus, the sku in the Entry will be null.pCatalogKey
- An optional key that is passed to the CatalogTools component, which
uses it to locate an alternate product catalog from which to add
the product. If null, the default catalog is used.
RepositoryException
- if there is any repository error while looking up
categories, products, or skus.public boolean add(java.lang.String pProductId, java.lang.String pCategoryId, java.lang.String pSkuId, java.lang.String pCatalogKey, java.lang.String pSiteId) throws RepositoryException
pProductId
- The repository id of the product being added.pCategoryId
- The repository id of the parent category to use for this Entry.
If null, the product's default parent category will be used instead.
If the product has no default parent category, the category in the
Entry will be null.pSkuId
- The repository id of the sku to use for this Entry. If null, the
first sku in the product's sku list will be used instead. If the product
has no skus, the sku in the Entry will be null.pCatalogKey
- An optional key that is passed to the CatalogTools component, which
uses it to locate an alternate product catalog from which to add
the product. If null, the default catalog is used.pSiteId
- The site id.
RepositoryException
- if there is any repository error while looking up
categories, products, or skus.public int addAllSkus(java.lang.String pProductId, java.lang.String pCategoryId, java.lang.String pCatalogKey) throws RepositoryException
pProductId
- The repository id of the product being added.pCategoryId
- The repository id of the parent category to use for this Entry.
If null, the product's default parent category will be used instead.
If the product has no default parent category, the category in the
Entry will be null.pCatalogKey
- An optional key that is passed to the CatalogTools component, which
uses it to locate an alternate product catalog from which to add
the product. If null, the default catalog is used.
RepositoryException
- if there is any repository error while looking up
categories, products, or skus.public int addAllSkus(java.lang.String pProductId, java.lang.String pCategoryId, java.lang.String pCatalogKey, java.lang.String pSiteId) throws RepositoryException
pProductId
- The repository id of the product being added.pCategoryId
- The repository id of the parent category to use for this Entry.
If null, the product's default parent category will be used instead.
If the product has no default parent category, the category in the
Entry will be null.pCatalogKey
- An optional key that is passed to the CatalogTools component, which
uses it to locate an alternate product catalog from which to add
the product. If null, the default catalog is used.pSiteId
- The site id.
RepositoryException
- if there is any repository error while looking up
categories, products, or skus.public boolean contains(java.lang.String pProductId, java.lang.String pCategoryId, java.lang.String pSkuId, java.lang.String pCatalogKey) throws RepositoryException
The behavior of contains
therefore parallels the
behavior of add
, so that calling
add(productId, categoryId, skuId)
and then calling
contains(productId, categoryId, skuId)>
with the
same values will return true.
The pCatalogKey
parameter is used to select a
product catalog in cases where it is necessary to locate a
product's default parent category or default sku. A null
value means use the default product catalog.
RepositoryException
public boolean contains(java.lang.String pProductId, java.lang.String pCategoryId, java.lang.String pCatalogKey) throws RepositoryException
The pCatalogKey
parameter is used to select a
product catalog in cases where it is necessary to locate a
product's default parent category. A null value means use the
default product catalog.
RepositoryException
public boolean contains(java.lang.String pProductId) throws RepositoryException
RepositoryException
public boolean contains(java.lang.String pProductId, java.lang.String pSiteId) throws RepositoryException
RepositoryException
public boolean contains(java.lang.String pProductId, java.lang.String pCategoryId, java.lang.String pSkuId, java.lang.String pCatalogKey, java.lang.String pSiteId, boolean pMatchSku) throws RepositoryException
The behavior of contains
therefore parallels the
behavior of add
, so that calling
add(productId, categoryId, skuId)
and then calling
contains(productId, categoryId, skuId)>
with the
same values will return true.
The pCatalogKey
parameter is used to select a
product catalog in cases where it is necessary to locate a
product's default parent category or default sku. A null
value means use the default product catalog.
The pMatchSku
indicates is pSkuId parameter is used. If pMatchSku is false, then no ckek on sku.
RepositoryException
public void remove(java.lang.String pProductId, java.lang.String pCategoryId, java.lang.String pSkuId, java.lang.String pCatalogKey) throws RepositoryException
The behavior of remove
therefore parallels the behavior of
add
, so that calling add(productId, categoryId, skuId)
and then calling remove(productId, categoryId, skuId)>
with the
same values will remove the item just added.
The pCatalogKey
parameter is used to select a
product catalog in cases where it is necessary to locate a
product's default parent category or default sku. A null
value means use the default product catalog.
RepositoryException
public void remove(java.lang.String pProductId, java.lang.String pCategoryId, java.lang.String pSkuId, java.lang.String pCatalogKey, java.lang.String pSiteId) throws RepositoryException
The behavior of remove
therefore parallels the behavior of
add
, so that calling add(productId, categoryId, skuId)
and then calling remove(productId, categoryId, skuId)>
with the
same values will remove the item just added.
The pCatalogKey
parameter is used to select a
product catalog in cases where it is necessary to locate a
product's default parent category or default sku. A null
value means use the default product catalog.
The pSiteId
parameter is used to pass site id
RepositoryException
public void remove(int pEntryId)
public void remove(int[] pEntryIds)
public void remove(java.util.Collection pEntryIds)
pEntryIds
- A Collection of Integer objects representing the uid's of
the entries to remove.public void removeAll(java.lang.String pProductId)
public void removeAll(java.lang.String pProductId, java.lang.String pSiteId)
public void removeAll(java.lang.String pProductId, java.lang.String pCategoryId, java.lang.String pCatalogKey) throws RepositoryException
The pCatalogKey
parameter is used to select a
product catalog in cases where it is necessary to locate a
product's default parent category. A null value means use
the default product catalog.
RepositoryException
public void removeAll(java.lang.String pProductId, java.lang.String pCategoryId, java.lang.String pCatalogKey, java.lang.String pSiteId) throws RepositoryException
The pCatalogKey
parameter is used to select a
product catalog in cases where it is necessary to locate a
product's default parent category. A null value means use
the default product catalog.
pSiteId
site id
RepositoryException
public void removeCategory(java.lang.String pCategoryId)
public void removeCategory(java.lang.String pCategoryId, java.lang.String pSiteId)
protected java.lang.String getDefaultCategoryId(RepositoryItem pProduct)
defaultCategory
protected RepositoryItem defaultCategory(RepositoryItem pProduct)
protected java.util.List skuList(RepositoryItem pProduct)
protected java.lang.String getDefaultSkuId(RepositoryItem pProduct)
protected RepositoryItem defaultSku(RepositoryItem pProduct)
protected ProductComparisonList.Entry createListEntry(RepositoryItem pCategory, RepositoryItem pProduct, RepositoryItem pSku)
protected ProductComparisonList.Entry createListEntry(RepositoryItem pCategory, RepositoryItem pProduct, RepositoryItem pSku, java.lang.String pSiteId)
public void refreshInventoryData()
public void setRefreshInventoryData(java.lang.String pUnused)
protected java.lang.String errorMsg(java.lang.String pResourceKey, java.lang.Object[] pArgs)
protected boolean idMatch(java.lang.String pId, RepositoryItem pItem)
protected boolean arrayContains(int[] pIds, int pTarget)
public void setCatalogTools(CatalogTools pCatalogTools)
public CatalogTools getCatalogTools()
public void setInventoryManager(InventoryManager pInventoryManager)
public InventoryManager getInventoryManager()
public void setPreloadInventoryData(boolean pPreloadInventoryData)
refreshInventoryData
.
If your pages explicitly refresh the inventory data before displaying product comparison information, you can set this property to false and avoid one extra query to the inventory manager when each item is created. If your pages do not explicitly refresh the inventory data, you should set this property to true so your comparison list entries will contain a snapshot of the inventory data at the time each Entry was added to the list.
The default value for preloadInventoryData
is
true
.
public boolean isPreloadInventoryData()
refreshInventoryData
.
setPreloadInventoryData
public void setPricingTools(PricingTools pPricingTools)
public PricingTools getPricingTools()
public void setProductLinkFormat(java.lang.String pProductLinkFormat)
{0} is replaced by the display name of the product.
{1} is replaced by the repository id of the product.
{2} is replaced by the template url of the product.
The default format is <a href=templateURL?id=repositoryId>productName<a>
public java.lang.String getProductLinkFormat()
public void setCategoryLinkFormat(java.lang.String pCategoryLinkFormat)
{0} is replaced by the display name of the category.
{1} is replaced by the repository id of the category.
{2} is replaced by the template url of the category.
The default format is <a href=templateURL?id=repositoryId>categoryName<a>
public java.lang.String getCategoryLinkFormat()
public void setEncodeLinkURLs(boolean pEncodeLinkURLs)
DynamoHttpServletRequest.encodeURL
on links to products and categories built using productLinkFormat
and categoryLinkFormat
. Links should normally be encoded to
ensure that URL-based session tracking works, and that servlet context paths
are handled correctly when using the Dynamo Application Framework on other
application servers.
public boolean isEncodeLinkURLs()
productLinkFormat
and categoryLinkFormat
. The default value is true
.
protected java.lang.String makeLink(java.lang.String pFormat, RepositoryItem pItem)
pFormat
- The format string, in which {0} is replaced by the item's
displayName, {1} by its repository id, and {2} by its template
URL.pItem
- The product or category RepositoryItem to consult when expanding
the format string.protected java.lang.String makeLink(java.lang.String pFormat, RepositoryItem pItem, java.lang.String pSiteId)
pFormat
- The format string, in which {0} is replaced by the item's
displayName, {1} by its repository id, and {2} by its template
URL.pItem
- The product or category RepositoryItem to consult when expanding
the format string.pSiteId
- The site idprotected java.lang.String makeLink(java.lang.String pFormat, RepositoryItem pItem, boolean pEncode, java.lang.String pSiteId)
pFormat
- The format string, in which {0} is replaced by the item's
displayName, {1} by its repository id, and {2} by its template
URL.pItem
- The product or category RepositoryItem to consult when expanding
the format string.pEncode
- If true, call DynamoHttpServletRequest.encodeURL on the link
before returning it.pSiteId
- The site id.protected ItemPriceInfo getUnitPrice(RepositoryItem pProduct, RepositoryItem pSku)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |