Class CategoryDaoImpl

java.lang.Object
org.broadleafcommerce.core.catalog.dao.CategoryDaoImpl
All Implemented Interfaces:
CategoryDao

@Repository("blCategoryDao") public class CategoryDaoImpl extends Object implements CategoryDao
Author:
Jeff Fischer
  • Field Details

    • currentDateResolution

      @Value("${query.dateResolution.category:10000}") protected Long currentDateResolution
    • cachedDate

      protected Date cachedDate
    • em

      protected jakarta.persistence.EntityManager em
    • entityConfiguration

      protected EntityConfiguration entityConfiguration
    • sandBoxHelper

      protected SandBoxHelper sandBoxHelper
    • extensionManager

      protected CategoryDaoExtensionManager extensionManager
  • Constructor Details

    • CategoryDaoImpl

      public CategoryDaoImpl()
  • Method Details

    • getCurrentDateAfterFactoringInDateResolution

      protected Date getCurrentDateAfterFactoringInDateResolution()
    • save

      public Category save(Category category)
      Description copied from interface: CategoryDao
      Persist a Category instance to the datastore
      Specified by:
      save in interface CategoryDao
      Parameters:
      category - the Category instance
      Returns:
      the updated state of the passed in Category after being persisted
    • readCategoryById

      public Category readCategoryById(Long categoryId)
      Description copied from interface: CategoryDao
      Retrieve a Category instance by its primary key
      Specified by:
      readCategoryById in interface CategoryDao
      Parameters:
      categoryId - the primary key of the Category
      Returns:
      the Category at the specified primary key
    • readCategoriesByIds

      public List<Category> readCategoriesByIds(List<Long> categoryIds)
      Description copied from interface: CategoryDao
      Retrieves a List of Category IDs
      Specified by:
      readCategoriesByIds in interface CategoryDao
      Returns:
    • readCategoryByExternalId

      public Category readCategoryByExternalId(@Nonnull String externalId)
      Description copied from interface: CategoryDao
      Retrieve a Category instance by the external id
      Specified by:
      readCategoryByExternalId in interface CategoryDao
      Returns:
    • readCategoryByName

      @Deprecated(forRemoval=true) public Category readCategoryByName(String categoryName)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: CategoryDao
      Retrieve a Category instance by its name.

      Broadleaf allows more than one category to have the same name. Calling this method could produce an exception in such situations. Use CategoryDao.readCategoriesByName(String) instead.

      Specified by:
      readCategoryByName in interface CategoryDao
      Parameters:
      categoryName - the name of the category
      Returns:
      the Category having the specified name
    • readCategoriesByName

      public List<Category> readCategoriesByName(String categoryName)
      Description copied from interface: CategoryDao
      Retrieve a list of Category instances by name.
      Specified by:
      readCategoriesByName in interface CategoryDao
      Parameters:
      categoryName - the name to search by
      Returns:
      the Category instances having the specified name
    • readCategoriesByName

      public List<Category> readCategoriesByName(String categoryName, int limit, int offset)
      Specified by:
      readCategoriesByName in interface CategoryDao
    • readCategoriesByNames

      @Nonnull public List<Category> readCategoriesByNames(List<String> names)
      Specified by:
      readCategoriesByNames in interface CategoryDao
    • readAllCategories

      public List<Category> readAllCategories()
      Description copied from interface: CategoryDao
      Retrieve all categories in the datastore
      Specified by:
      readAllCategories in interface CategoryDao
      Returns:
      a list of all the Category instances in the datastore
    • readAllCategories

      public List<Category> readAllCategories(int limit, int offset)
      Description copied from interface: CategoryDao
      Retrieve a subset of all categories
      Specified by:
      readAllCategories in interface CategoryDao
      Parameters:
      limit - the maximum number of results, defaults to 20
      offset - the starting point in the record set, defaults to 0
      Returns:
    • readTotalCategoryCount

      public Long readTotalCategoryCount()
      Specified by:
      readTotalCategoryCount in interface CategoryDao
    • readAllProducts

      public List<Product> readAllProducts()
      Description copied from interface: CategoryDao
      Retrieve all products in the datastore
      Specified by:
      readAllProducts in interface CategoryDao
      Returns:
      a list of all Category instances in the datastore, regardless of their category association
    • readAllProducts

      public List<Product> readAllProducts(int limit, int offset)
      Specified by:
      readAllProducts in interface CategoryDao
    • readAllSubCategories

      public List<Category> readAllSubCategories(Category category)
      Description copied from interface: CategoryDao
      Retrieve a list of all child categories of the passed in Category instance
      Specified by:
      readAllSubCategories in interface CategoryDao
      Parameters:
      category - the parent category
      Returns:
      a list of all child categories
    • readAllSubCategories

      public List<Category> readAllSubCategories(Long id)
      Description copied from interface: CategoryDao
      Retrieve a list of all child categories of the passed in Category instance
      Specified by:
      readAllSubCategories in interface CategoryDao
      Parameters:
      id - the parent category ID
      Returns:
      a list of all child categories
    • readAllSubCategories

      public List<Category> readAllSubCategories(Category category, int limit, int offset)
      Description copied from interface: CategoryDao
      Retrieve a list of all child categories of the passed in Category instance
      Specified by:
      readAllSubCategories in interface CategoryDao
      Parameters:
      category - the parent category
      limit - the maximum number of results to return
      offset - the starting point in the record set
      Returns:
      a list of all child categories
    • readActiveSubCategoriesByCategory

      public List<Category> readActiveSubCategoriesByCategory(Category category)
      Description copied from interface: CategoryDao
      Retrieve a list of all active child categories of the passed in Category instance. This method bases its search on a current time value. To make the retrieval of values more efficient, the current time is cached for a configurable amount of time. See CategoryDao.getCurrentDateResolution()
      Specified by:
      readActiveSubCategoriesByCategory in interface CategoryDao
      Parameters:
      category - the parent category
      Returns:
      a list of all active child categories
    • readActiveSubCategoriesByCategory

      public List<Category> readActiveSubCategoriesByCategory(Category category, int limit, int offset)
      Description copied from interface: CategoryDao
      Retrieve a list of all active child categories of the passed in Category instance. This method bases its search on a current time value. To make the retrieval of values more efficient, the current time is cached for a configurable amount of time. See CategoryDao.getCurrentDateResolution()
      Specified by:
      readActiveSubCategoriesByCategory in interface CategoryDao
      Parameters:
      category - the parent category
      limit - the maximum number of results to return
      offset - the starting point in the record set
      Returns:
      a list of all active child categories
    • getCurrentDateResolution

      public Long getCurrentDateResolution()
      Description copied from interface: CategoryDao
      Returns the number of milliseconds that the current date/time will be cached for queries before refreshing. This aids in query caching, otherwise every query that utilized current date would be different and caching would be ineffective.
      Specified by:
      getCurrentDateResolution in interface CategoryDao
      Returns:
      the milliseconds to cache the current date/time
    • setCurrentDateResolution

      public void setCurrentDateResolution(Long currentDateResolution)
      Description copied from interface: CategoryDao
      Sets the number of milliseconds that the current date/time will be cached for queries before refreshing. This aids in query caching, otherwise every query that utilized current date would be different and caching would be ineffective.
      Specified by:
      setCurrentDateResolution in interface CategoryDao
      Parameters:
      currentDateResolution - the milliseconds to cache the current date/time
    • delete

      public void delete(Category category)
      Description copied from interface: CategoryDao
      Removed the passed in Category instance from the datastore
      Specified by:
      delete in interface CategoryDao
      Parameters:
      category - the Category instance to remove
    • create

      public Category create()
      Description copied from interface: CategoryDao
      Create a new Category instance. The system will use the configuration in /BroadleafCommerce/core/BroadleafCommerceFramework/src/main/resources/bl-framework-applicationContext-entity.xml to determine which polymorphic version of Category to instantiate. To make Broadleaf instantiate your extension of Category by default, include an entity configuration bean in your application context xml similar to:

       
           <bean id="blEntityConfiguration" class="org.broadleafcommerce.common.persistence.EntityConfiguration">
                <property name="entityContexts">
                    <list>
                        <value>classpath:myCompany-applicationContext-entity.xml</value>
                    </list>
                </property>
            </bean>
       
       

      Declare the same key for your desired entity in your entity xml that is used in the Broadleaf entity xml, but change the value to the fully qualified classname of your entity extension.
      Specified by:
      create in interface CategoryDao
      Returns:
      a Category instance based on the Broadleaf entity configuration.
    • findCategoryByURI

      public Category findCategoryByURI(String uri)
      Specified by:
      findCategoryByURI in interface CategoryDao
    • readCountAllActiveProductsByCategory

      public Long readCountAllActiveProductsByCategory(Category category)
      Specified by:
      readCountAllActiveProductsByCategory in interface CategoryDao
    • findXrefByCategoryWithDefaultReference

      public List<CategoryProductXref> findXrefByCategoryWithDefaultReference(Long categoryId)
      Description copied from interface: CategoryDao
      returns a list of CategoryProductXref where provided category is default reference(xref.defaultReference=true)
      Specified by:
      findXrefByCategoryWithDefaultReference in interface CategoryDao
      Parameters:
      categoryId - long, id of the category
      Returns:
      returns a list of CategoryProductXref where provided category is default reference(xref.defaultReference=true)