Class DefaultMenuService<P extends Menu>

  • All Implemented Interfaces:
    com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>, MenuService<P>

    public class DefaultMenuService<P extends Menu>
    extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
    implements MenuService<P>
    Author:
    Samarth Dhruva (samarthd)
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultMenuService​(MenuRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, MenuItemService<MenuItem> menuItemService, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected MenuItemService<? extends MenuItem> getMenuItemService()  
      NavigableMenu getMenuWithNavigationTree​(String menuName, int depthLimit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Accepts a menu name and returns the menu with its submenu fully populated.
      protected MenuRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()  
      String getRepositoryDomain()  
      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()  
      org.springframework.data.domain.Page<P> readAllByName​(String nameQuery, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Read all menus, optionally filtered by name.
      Optional<P> readByName​(String menuName, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds the menu with the given name (should only be one result, as menu names are unique).
      • Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService

        getRsqlHelper, readAll, readAll, readAll, readAll
      • Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService

        convertFromPersistentDomain, convertToPersistentDomain, create, createAll, createAllAllowingPartialSuccess, delete, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSort
      • Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService

        create, createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSort
      • Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService

        readAll, readAll, readAll, readAll
    • Constructor Detail

      • DefaultMenuService

        public DefaultMenuService​(MenuRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository,
                                  MenuItemService<MenuItem> menuItemService,
                                  com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper,
                                  com.broadleafcommerce.common.extension.TypeFactory typeFactory,
                                  com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser)
    • Method Detail

      • readAllByName

        public org.springframework.data.domain.Page<P> readAllByName​(@Nullable
                                                                     String nameQuery,
                                                                     @NonNull
                                                                     cz.jirutka.rsql.parser.ast.Node filters,
                                                                     @Nullable
                                                                     org.springframework.data.domain.Pageable page,
                                                                     @Nullable
                                                                     com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Description copied from interface: MenuService
        Read all menus, optionally filtered by name.
        Specified by:
        readAllByName in interface MenuService<P extends Menu>
        Parameters:
        nameQuery - (optional) the menu name to filter by
        filters - additional filters to apply in the query, can be null
        page - the requested page of results from the database
        context - context information surrounding sandboxing and multitenant state
        Returns:
        all menus, optionally filtered by name
      • readByName

        public Optional<P> readByName​(@NonNull
                                      String menuName,
                                      @Nullable
                                      com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: MenuService
        Finds the menu with the given name (should only be one result, as menu names are unique).
        Specified by:
        readByName in interface MenuService<P extends Menu>
        Parameters:
        menuName - the menu name of the menu that should be retrieved
        contextInfo - context information surrounding sandboxing and multitenant state
        Returns:
        an Optional containing the menu with the given name, empty if not found
      • getMenuWithNavigationTree

        @Cacheable(value="menuCacheByMenu",
                   keyGenerator="menuCacheByMenu",
                   condition="@cacheStateManager.isEnabled(#root.caches, #root.args)")
        public NavigableMenu getMenuWithNavigationTree​(@NonNull
                                                       String menuName,
                                                       int depthLimit,
                                                       @Nullable
                                                       com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: MenuService
        Accepts a menu name and returns the menu with its submenu fully populated.
        Specified by:
        getMenuWithNavigationTree in interface MenuService<P extends Menu>
        Parameters:
        menuName - the name of the menu whose navigation tree should be returned
        depthLimit - the output will be limited to only the top depthLimit levels of the tree. This should generally be at least 1 to return any sub menus. Negative values return the entire hierarchy, and 0 returns no sub menus at all
        contextInfo - context information surrounding sandboxing and multitenant state
        Returns:
        the requested menu with its navigation tree, limited to the first depthLimit levels. Each level will be sorted by the displayOrder specified in each item in that level.
      • getRepository

        @NonNull
        protected MenuRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
        Overrides:
        getRepository in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends Menu>
      • getTypeFactory

        @NonNull
        protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()