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
ConstructorsConstructorDescriptionDefaultMenuItemService
(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 TypeMethodDescriptionOverridden 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 specifiedMenu
.readAllByParentMenuItemId
(String parentMenuItemId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Read all menu items that are direct children of the specifiedMenuItem
.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
-
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 interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends MenuItem>
- Overrides:
create
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends MenuItem>
- Parameters:
businessInstance
- The business domain instance. In general, theDomainMapperManager
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 interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends MenuItem>
- Overrides:
replace
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends MenuItem>
- Parameters:
id
- The instance id.businessInstance
- The business domain instance. In general, theDomainMapperManager
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 interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends MenuItem>
- Overrides:
update
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends MenuItem>
- Parameters:
id
- The instance id.businessInstance
- The business domain instance. In general, theDomainMapperManager
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 interfaceMenuItemService<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 returnedrootsOnly
- 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 nullpage
- the requested page of results from the databasecontextInfo
- 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 specifiedMenuItem
. In other words, find all menu items who have the given parentMenuItemId set as theirMenuItem.getParentMenuItemId()
.- Specified by:
readAllByParentMenuItemId
in interfaceMenuItemService<P extends MenuItem>
- Parameters:
parentMenuItemId
- the context ID of theMenuItem
whose direct children should be returnedcontextInfo
- 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 specifiedMenu
. In other words, find all menu items who have the given parentMenuId set as theirMenuItem.getParentMenuId()
. This effectively returns the entire set of MenuItems that are in a menu's tree.- Specified by:
readAllByParentMenuId
in interfaceMenuItemService<P extends MenuItem>
- Parameters:
parentMenuId
- the context ID of theMenu
whose children should be returnedcontextInfo
- 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 interfaceMenuItemService<P extends MenuItem>
- Parameters:
menuItemId
- the context ID of the menu item whose ancestors should be foundcontextInfo
- 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
- Specified by:
getRepositoryDomain
in interfaceMenuItemService<P extends MenuItem>
-
getRepository
@NonNull protected MenuItemRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
-