Class DefaultMenuItemService<P extends MenuItem>

java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.menu.service.DefaultMenuItemService<P>
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>, MenuItemService<P>

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

    Constructors
    Constructor
    Description
    DefaultMenuItemService(MenuItemRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    create(P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Overridden to prevent persistence of URLs with trailing and/or leading spaces.
    protected MenuItemRepository<com.broadleafcommerce.data.tracking.core.Trackable>
     
     
    org.springframework.data.domain.Page<P>
    readAllByLabelAndParentMenuId(String labelQuery, String parentMenuId, boolean rootsOnly, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Read all menu items for a menu, optionally filtered by label (ignoring case).
    readAllByParentMenuId(String parentMenuId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Read all menu items that are children (both direct and indirect) of the specified Menu.
    readAllByParentMenuItemId(String parentMenuItemId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Read all menu items that are direct children of the specified MenuItem.
    readAncestors(String menuItemId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Accepts a menu item ID and returns a payload object containing the requested menu item and a list of its ancestors.
    replace(String id, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Overridden to prevent persistence of URLs with trailing and/or leading spaces.
    update(String id, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Overridden to prevent persistence of URLs with trailing and/or leading spaces.

    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, createAll, createAllAllowingPartialSuccess, delete, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, updateAll, updateAllAllowingPartialSuccess, updateSort

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService

    createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replaceAll, replaceAllAllowingPartialSuccess, updateAll, updateAllAllowingPartialSuccess, updateSort

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService

    readAll, readAll, readAll, readAll
  • Constructor Details

    • DefaultMenuItemService

      public DefaultMenuItemService(MenuItemRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser)
  • Method Details

    • create

      public P create(@NonNull P businessInstance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Overridden to prevent persistence of URLs with trailing and/or leading spaces.
      Specified by:
      create in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends MenuItem>
      Overrides:
      create in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends MenuItem>
      Parameters:
      businessInstance - The business domain instance. In general, the DomainMapperManager is responsible for converting to a repository platform type for persistence.
      context - Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications.
      Returns:
      newly created menuItem instance
    • replace

      public P replace(@NonNull String id, @NonNull P businessInstance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Overridden to prevent persistence of URLs with trailing and/or leading spaces.
      Specified by:
      replace in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends MenuItem>
      Overrides:
      replace in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends MenuItem>
      Parameters:
      id - The instance id.
      businessInstance - The business domain instance. In general, the DomainMapperManager is responsible for converting to a repository platform type for persistence.
      context - Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications.
      Returns:
      replaced menuItem instance
    • update

      public P update(@NonNull String id, @NonNull P businessInstance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Overridden to prevent persistence of URLs with trailing and/or leading spaces.
      Specified by:
      update in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends MenuItem>
      Overrides:
      update in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends MenuItem>
      Parameters:
      id - The instance id.
      businessInstance - The business domain instance. In general, the DomainMapperManager is responsible for converting to a repository platform type for persistence.
      context - Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications.
      Returns:
      updated menuItem instance
    • readAllByLabelAndParentMenuId

      public org.springframework.data.domain.Page<P> readAllByLabelAndParentMenuId(@Nullable String labelQuery, @NonNull String parentMenuId, boolean rootsOnly, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: MenuItemService
      Read all menu items for a menu, optionally filtered by label (ignoring case).
      Specified by:
      readAllByLabelAndParentMenuId in interface MenuItemService<P extends MenuItem>
      Parameters:
      labelQuery - (optional) the menu item label to filter by (ignoring case)
      parentMenuId - the context ID of the menu whose items should be returned
      rootsOnly - if true, restricts results to only the top-level menu items for the menu. Otherwise, returns all menu items for the menu.
      filters - additional filters to apply in the query, can be null
      page - the requested page of results from the database
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      all menu items, optionally filtered by name
    • readAllByParentMenuItemId

      public List<P> readAllByParentMenuItemId(@NonNull String parentMenuItemId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: MenuItemService
      Read all menu items that are direct children of the specified MenuItem. In other words, find all menu items who have the given parentMenuItemId set as their MenuItem.getParentMenuItemId().
      Specified by:
      readAllByParentMenuItemId in interface MenuItemService<P extends MenuItem>
      Parameters:
      parentMenuItemId - the context ID of the MenuItem whose direct children should be returned
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      all the menu items which are direct children of the specified menu item
    • readAllByParentMenuId

      public List<P> readAllByParentMenuId(@NonNull String parentMenuId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: MenuItemService
      Read all menu items that are children (both direct and indirect) of the specified Menu. In other words, find all menu items who have the given parentMenuId set as their MenuItem.getParentMenuId(). This effectively returns the entire set of MenuItems that are in a menu's tree.
      Specified by:
      readAllByParentMenuId in interface MenuItemService<P extends MenuItem>
      Parameters:
      parentMenuId - the context ID of the Menu whose children should be returned
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      all the menu items which are children of the specified menu
    • readAncestors

      @NonNull public MenuItemAncestorList readAncestors(@NonNull String menuItemId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: MenuItemService
      Accepts a menu item ID and returns a payload object containing the requested menu item and a list of its ancestors.
      Specified by:
      readAncestors in interface MenuItemService<P extends MenuItem>
      Parameters:
      menuItemId - the context ID of the menu item whose ancestors should be found
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a payload object containing the requested menu item and a list of its ancestors, sorted with the immediate parent at the beginning and the top-level parent at the end
    • getRepositoryDomain

      public String getRepositoryDomain()
      Specified by:
      getRepositoryDomain in interface MenuItemService<P extends MenuItem>
    • getRepository

      @NonNull protected MenuItemRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
      Overrides:
      getRepository in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends MenuItem>