atg.commerce.catalog
Class AncestorGeneratorService

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.scheduler.SchedulableService
              extended by atg.service.scheduler.SingletonSchedulableService
                  extended by atg.commerce.catalog.CMSService
                      extended by atg.commerce.catalog.AncestorGeneratorService
All Implemented Interfaces:
atg.commerce.catalog.CMSConstants, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, Schedulable, java.util.EventListener

public class AncestorGeneratorService
extends atg.commerce.catalog.CMSService

Available service functions: AGS_GENANCESTORS - generate ancestors (for products and skus)

The primary public method in this class, performService, generates the set of ancestor categories for each category and product in the product catalog, and updates the ancestorCategories property for each category and product to contain the appropriate set. This set is used in hierarchical search.

Methods generateCategoryAncestors and generateProductAncestors can be called to update the ancestors for only categories or products, respectively.

See Also:


Nested Class Summary
 
Nested classes/interfaces inherited from class atg.commerce.catalog.CMSService
atg.commerce.catalog.CMSService.BookkeepingForThread
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.service.scheduler.SchedulableService
mJobId
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.commerce.catalog.CMSConstants
AGS_GENANCESTORS, AGS_GENCATALOGS, AGS_GENPARENTCATS, ANCESTORS_GENERATED, CATALOGS_UPDATED, CATALOGS_VERIFIED, CATEGORIES_VERIFIED, CUS_UPDATECATALOGS, CVS_VERIFYCATALOGS, CVS_VERIFYCATEGORIES, CVS_VERIFYPRODUCTS, CVS_VERIFYSKUS, DEFAULT_CATALOG_ITEM_TYPE, DEFAULT_MAP_SIZE, GENERATED_ANCESTORS, INFOS_GENERATED, IS_ANCESTORS_GENERATED, LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO, LEVEL_WARNING, NO_PATH, NOT_GENERATOR, TYPE_ANCESTOR, TYPE_CATALOGMAINTENANCE, TYPE_CUSTOM_MIGRATION, TYPE_MIGRATION, TYPE_UPDATE, TYPE_VERIFY, VALID_PATH
 
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
AncestorGeneratorService()
           
 
Method Summary
 void generateAncestors()
          Generate and update the values of the ancestorCategories property for all categories and products in all specified product catalogs.
 void generateAncestors(Repository pRepository)
          Generate and update the values of the ancestorCategories property for all categories and products in all specified product catalogs.
protected  java.util.Set generateAncestorsForCategory(RepositoryItem pCategory, Repository pCatalog)
          Recursive subroutine for topLevelGenerateAncestorsForCategory
 void generateCategoryAncestors()
          Generate and update the values of the ancestorCategories property for all categories in all specified product catalogs.
 void generateCategoryAncestors(Repository pRepository)
          Generate and update the values of the ancestorCategories property for all categories in all specified product catalogs.
protected  void generateCategoryAncestorsForCurrentCatalog(Repository pCatalog)
          Generate and update the values of the ancestorCategories property for all categories in the current product catalog.
protected  java.util.Set generateEmptySet()
          Helper method to return an empty set.
 void generateProductAncestors()
          Generate and update the values of the ancestorCategories property for all products in all specified product catalogs.
 void generateProductAncestors(Repository pRepository)
          Generate and update the values of the ancestorCategories property for all products in all specified product catalogs.
protected  void generateProductAncestorsForCurrentCatalog(Repository pCatalog)
          Generate and update the values of the ancestorCategories property for all products in the current product catalog.
 java.lang.String getAncestorCategoriesPropertyName()
          Returns property ancestorCategoriesPropertyName
 java.lang.String[] getCatalogs()
          Returns property catalogs
 CatalogTools getCatalogTools()
          Returns property catalogTools
 java.lang.String getCategoryItemName()
          Returns property categoryItemName
protected  RepositoryView getCategoryRepositoryView(Repository pCatalog)
          Helper method to get the RepositoryView for finding category items
 java.util.Stack getCategoryStack()
          Returns property useShortTransactions
 java.lang.String getChildCategoriesPropertyName()
          Returns property childCategoriesPropertyName
 java.lang.String getChildProductsPropertyName()
          Returns property childProductsPropertyName
 java.lang.String getIdPropertyName()
          The name of the id property for categories, products, and skus
 java.lang.String getJobDescription()
          Get property jobDescription
 java.lang.String getJobName()
          Get property jobName
 int getMaxItemsPerTransaction()
          Returns property maxItemsPerTransaction
 java.lang.String getProductItemName()
          Returns property productItemName
protected  RepositoryView getProductRepositoryView(Repository pCatalog)
          Helper method to get the RepositoryView for finding product items
 Scheduler getScheduler()
          Returns property Scheduler
 java.lang.String getServiceName()
           
 javax.transaction.TransactionManager getTransactionManager()
          Returns property transactionManager
 Schedule getUpdateSchedule()
          Returns property UpdateSchedule
 boolean performService(Repository pRepository, java.util.Collection pCatalogIds, java.util.List pServiceFunctions)
          Performs this services functions
 void setAncestorCategoriesPropertyName(java.lang.String pAncestorCategoriesPropertyName)
          Sets property ancestorCategoriesPropertyName
protected  void setAncestorsForCategory(RepositoryItem pCategory, java.util.Collection pAncestors, Repository pCatalog)
          Helper method to set the ancestorCategories property for a category
protected  void setAncestorsForProduct(RepositoryItem pProduct, java.util.Collection pAncestors, Repository pCatalog)
          Helper method to set the ancestorCategories property for a product
 void setCatalogs(java.lang.String[] pCatalogs)
          Sets property catalogs
 void setCatalogTools(CatalogTools pCatalogTools)
          Sets property catalogTools
 void setCategoryItemName(java.lang.String pCategoryItemName)
          Sets property categoryItemName
 void setCategoryStack(java.util.Stack pCategoryStack)
          Sets property categoryStack
 void setChildCategoriesPropertyName(java.lang.String pChildCategoriesPropertyName)
          Sets property childCategoriesPropertyName
 void setChildProductsPropertyName(java.lang.String pChildProductsPropertyName)
          Sets property childProductsPropertyName
 void setIdPropertyName(java.lang.String pIdPropertyName)
           
 void setMaxItemsPerTransaction(int pMaxItemsPerTransaction)
          Sets property maxItemsPerTransaction
 void setProductItemName(java.lang.String pProductItemName)
          Sets property productItemName
 void setScheduler(Scheduler pScheduler)
          Sets property Scheduler
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Sets property transactionManager
 void setUpdateSchedule(Schedule pUpdateSchedule)
          Sets property UpdateSchedule
protected  java.util.Set topLevelGenerateAncestorsForCategory(RepositoryItem pCategory, Repository pCatalog)
          Generate the set of all ancestor categories for a given category, using the recursive method generateAncestorsForCategory
protected  void updateAncestorsForProduct(RepositoryItem pProduct, Repository pCatalog)
          Generate the set of ancestor categories for a given product and set its ancestorCategories property to that set
 
Methods inherited from class atg.commerce.catalog.CMSService
addErrorMessage, addInfoMessage, addWarningMessage, clearBookkeepingForThread, clearMessages, createCMSMessage, doScheduledTask, doService, getAvailableFunctions, getBookkeepingForThread, getCurrentMessages, getErrorMessages, getFunctionsToPerformByDefault, getInfoMessages, getServiceLock, getTotalNumberOfErrorMessages, getTotalNumberOfInfoMessages, getTotalNumberOfMessages, getTotalNumberOfWarningMessages, getWarningMessages, hasFunction, isSaveMessages, logDebug, logError, logInfo, logWarning, performService, postService, preService, removeServiceLock, setAvailableFunctions, setFunctionsToPerformByDefault, setSaveMessages, stringIt, stringIt
 
Methods inherited from class atg.service.scheduler.SingletonSchedulableService
acquireLock, getClientLockManager, getLockName, getLockTimeOut, performScheduledTask, releaseLock, setClientLockManager, setLockName, setLockTimeOut
 
Methods inherited from class atg.service.scheduler.SchedulableService
doStartService, doStopService, getSchedule, getThreadMethod, isTransactional, setJobDescription, setJobName, setSchedule, setThreadMethod, setTransactional, startScheduledJob, stopScheduledJob
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logError, logError, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
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

CLASS_VERSION

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

See Also:
Constant Field Values
Constructor Detail

AncestorGeneratorService

public AncestorGeneratorService()
Method Detail

getServiceName

public java.lang.String getServiceName()
Specified by:
getServiceName in class atg.commerce.catalog.CMSService

getJobName

public java.lang.String getJobName()
Get property jobName

Overrides:
getJobName in class SchedulableService
Returns:
jobName

getJobDescription

public java.lang.String getJobDescription()
Get property jobDescription

Overrides:
getJobDescription in class SchedulableService
Returns:
jobDescription

setScheduler

public void setScheduler(Scheduler pScheduler)
Sets property Scheduler

Overrides:
setScheduler in class SchedulableService
Parameters:
pScheduler - new value to set

getScheduler

public Scheduler getScheduler()
Returns property Scheduler

Overrides:
getScheduler in class SchedulableService
Returns:
scheduler

setUpdateSchedule

public void setUpdateSchedule(Schedule pUpdateSchedule)
Sets property UpdateSchedule


getUpdateSchedule

public Schedule getUpdateSchedule()
Returns property UpdateSchedule


setAncestorCategoriesPropertyName

public void setAncestorCategoriesPropertyName(java.lang.String pAncestorCategoriesPropertyName)
Sets property ancestorCategoriesPropertyName


getAncestorCategoriesPropertyName

public java.lang.String getAncestorCategoriesPropertyName()
Returns property ancestorCategoriesPropertyName


setChildCategoriesPropertyName

public void setChildCategoriesPropertyName(java.lang.String pChildCategoriesPropertyName)
Sets property childCategoriesPropertyName


getChildCategoriesPropertyName

public java.lang.String getChildCategoriesPropertyName()
Returns property childCategoriesPropertyName


setChildProductsPropertyName

public void setChildProductsPropertyName(java.lang.String pChildProductsPropertyName)
Sets property childProductsPropertyName


getChildProductsPropertyName

public java.lang.String getChildProductsPropertyName()
Returns property childProductsPropertyName


setIdPropertyName

public void setIdPropertyName(java.lang.String pIdPropertyName)

getIdPropertyName

public java.lang.String getIdPropertyName()
The name of the id property for categories, products, and skus


setCatalogTools

public void setCatalogTools(CatalogTools pCatalogTools)
Sets property catalogTools


getCatalogTools

public CatalogTools getCatalogTools()
Returns property catalogTools


setCatalogs

public void setCatalogs(java.lang.String[] pCatalogs)
Sets property catalogs


getCatalogs

public java.lang.String[] getCatalogs()
Returns property catalogs


setCategoryItemName

public void setCategoryItemName(java.lang.String pCategoryItemName)
Sets property categoryItemName


getCategoryItemName

public java.lang.String getCategoryItemName()
Returns property categoryItemName


setProductItemName

public void setProductItemName(java.lang.String pProductItemName)
Sets property productItemName


getProductItemName

public java.lang.String getProductItemName()
Returns property productItemName


setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Sets property transactionManager

Overrides:
setTransactionManager in class atg.commerce.catalog.CMSService

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Returns property transactionManager

Overrides:
getTransactionManager in class atg.commerce.catalog.CMSService

setMaxItemsPerTransaction

public void setMaxItemsPerTransaction(int pMaxItemsPerTransaction)
Sets property maxItemsPerTransaction


getMaxItemsPerTransaction

public int getMaxItemsPerTransaction()
Returns property maxItemsPerTransaction


setCategoryStack

public void setCategoryStack(java.util.Stack pCategoryStack)
Sets property categoryStack


getCategoryStack

public java.util.Stack getCategoryStack()
Returns property useShortTransactions


performService

public boolean performService(Repository pRepository,
                              java.util.Collection pCatalogIds,
                              java.util.List pServiceFunctions)
Performs this services functions

Specified by:
performService in class atg.commerce.catalog.CMSService
Parameters:
pRepository - - Catalog repository to operate against
pCatalogIds - - a collection of catalogs to process
pServiceFunctions - - a list of strings that identify service functions. used to conditionally executed specific functions of a service
Returns:
boolean - service success or failure

generateAncestors

public void generateAncestors()
Generate and update the values of the ancestorCategories property for all categories and products in all specified product catalogs.


generateAncestors

public void generateAncestors(Repository pRepository)
Generate and update the values of the ancestorCategories property for all categories and products in all specified product catalogs.

Parameters:
pRepository - - Catalog repository to operate against

generateCategoryAncestors

public void generateCategoryAncestors()
Generate and update the values of the ancestorCategories property for all categories in all specified product catalogs.


generateCategoryAncestors

public void generateCategoryAncestors(Repository pRepository)
Generate and update the values of the ancestorCategories property for all categories in all specified product catalogs.

Parameters:
pRepository - - Catalog repository to operate against

generateProductAncestors

public void generateProductAncestors()
Generate and update the values of the ancestorCategories property for all products in all specified product catalogs.


generateProductAncestors

public void generateProductAncestors(Repository pRepository)
Generate and update the values of the ancestorCategories property for all products in all specified product catalogs.

Parameters:
pRepository - - Catalog repository to operate against

generateCategoryAncestorsForCurrentCatalog

protected void generateCategoryAncestorsForCurrentCatalog(Repository pCatalog)
Generate and update the values of the ancestorCategories property for all categories in the current product catalog.

Parameters:
pCatalog - current catalog to operate on

generateProductAncestorsForCurrentCatalog

protected void generateProductAncestorsForCurrentCatalog(Repository pCatalog)
Generate and update the values of the ancestorCategories property for all products in the current product catalog.

Parameters:
pCatalog - current catalog to operate on

updateAncestorsForProduct

protected void updateAncestorsForProduct(RepositoryItem pProduct,
                                         Repository pCatalog)
                                  throws RepositoryException
Generate the set of ancestor categories for a given product and set its ancestorCategories property to that set

N.B. This assumes that all categories already have their ancestorCategories property set correctly.

Parameters:
pProduct - the product whose ancestorCategories property should be set
pCatalog - current catalog to operate on
Throws:
RepositoryException

generateEmptySet

protected java.util.Set generateEmptySet()
Helper method to return an empty set. This method could be rewritten to make it easy to modify this class if we decided that the ancestorCategories property should be implemented as a List instead of a Set


setAncestorsForCategory

protected void setAncestorsForCategory(RepositoryItem pCategory,
                                       java.util.Collection pAncestors,
                                       Repository pCatalog)
                                throws RepositoryException
Helper method to set the ancestorCategories property for a category

Parameters:
pCategory - the category whose ancestorCategories property should be set
pAncestors - what to set it to
pCatalog - current catalog to operate on
Throws:
RepositoryException

setAncestorsForProduct

protected void setAncestorsForProduct(RepositoryItem pProduct,
                                      java.util.Collection pAncestors,
                                      Repository pCatalog)
                               throws RepositoryException
Helper method to set the ancestorCategories property for a product

Parameters:
pProduct - the product whose ancestorCategories property should be set
pAncestors - what to set it to
pCatalog - current catalog to operate on
Throws:
RepositoryException

topLevelGenerateAncestorsForCategory

protected java.util.Set topLevelGenerateAncestorsForCategory(RepositoryItem pCategory,
                                                             Repository pCatalog)
                                                      throws RepositoryException
Generate the set of all ancestor categories for a given category, using the recursive method generateAncestorsForCategory

Also detect cycles of parentage

Parameters:
pCategory - the category whose ancestors should be found
pCatalog - current catalog to operate on
Returns:
a Set of all the ancestor categories
Throws:
RepositoryException
See Also:
generateAncestorsForCategory

generateAncestorsForCategory

protected java.util.Set generateAncestorsForCategory(RepositoryItem pCategory,
                                                     Repository pCatalog)
                                              throws RepositoryException
Recursive subroutine for topLevelGenerateAncestorsForCategory

Parameters:
pCategory - the category whose ancestors should be found
pCatalog - current catalog to operate on
Returns:
a Set of all the ancestor categories
Throws:
RepositoryException
See Also:
topLevelGenerateAncestorsForCategory

getCategoryRepositoryView

protected RepositoryView getCategoryRepositoryView(Repository pCatalog)
                                            throws RepositoryException
Helper method to get the RepositoryView for finding category items

Parameters:
pCatalog - current catalog to operate on
Returns:
the RepositoryView
Throws:
RepositoryException

getProductRepositoryView

protected RepositoryView getProductRepositoryView(Repository pCatalog)
                                           throws RepositoryException
Helper method to get the RepositoryView for finding product items

Parameters:
pCatalog - current catalog to operate on
Returns:
the RepositoryView
Throws:
RepositoryException