Class DefaultCatalogService<P extends Catalog>
java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.tenant.service.DefaultCatalogService<P>
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>
,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
,CatalogService<P>
public class DefaultCatalogService<P extends Catalog>
extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
implements CatalogService<P>
-
Constructor Summary
ConstructorDescriptionDefaultCatalogService
(CatalogRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, ApplicationService<? extends Application> applicationService, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper) -
Method Summary
Modifier and TypeMethodDescriptionprotected cz.jirutka.rsql.parser.ast.Node
buildExclusionsFilter
(String catalogId, cz.jirutka.rsql.parser.ast.Node filters) Builds an exclusion filter that will exclude any catalogs that would cause a circular catalog inheritance graph.protected ApplicationService<? extends Application>
protected org.springframework.validation.Errors
protected CatalogRepository<com.broadleafcommerce.data.tracking.core.Trackable>
protected com.broadleafcommerce.common.messaging.notification.DetachedDurableMessageSender
protected com.broadleafcommerce.common.extension.TypeFactory
readAllByContextIds
(List<String> catalogIds, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Return all of the catalogs with IDs in the supplied list.org.springframework.data.domain.Page<P>
readAllByOwningApplication
(cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Find and return the catalogs for the given owning application.org.springframework.data.domain.Page<P>
readAllByOwningApplicationWithExclusion
(String excludingCatalogId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Find and return the catalogs for the given owning application.org.springframework.data.domain.Page<P>
readAllByOwningApplicationWithVisibility
(cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Find and return the catalogs for the given owning application.org.springframework.data.domain.Page<P>
readAllByOwningApplicationWithVisibilityAndExclusion
(String excludingCatalogId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Find and return the catalogs for the given owning application.readAllTopLevelNonApplicationCatalogsByType
(String type, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds all catalogs by type and tenant ID that do not belong to an application & are top-level catalogs, meaning they do not have a parent.readCatalogRelationships
(String catalogId) Read all catalogs that are in a catalog inheritance line.protected void
rejectParentRelationship
(org.springframework.validation.Errors errors, CatalogRef parent) void
sendTenantSearchGroupNotification
(P searchGroup, @NonNull Tenant tenant, @NonNull com.broadleafcommerce.data.tracking.core.type.OperationType operationType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends a notification after creating or deleting aDefaultCatalogType.SEARCH_GROUP
typeCatalog
when aTenant
is created or deleted.void
setSender
(com.broadleafcommerce.common.messaging.notification.DetachedDurableMessageSender sender) void
setTypeFactory
(com.broadleafcommerce.common.extension.TypeFactory typeFactory) protected void
validateForCircularCatalogRelationships
(String id, P catalog) Validates that a catalog update will not cause a circular catalog inheritance graph.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, 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
create, 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
-
DefaultCatalogService
public DefaultCatalogService(CatalogRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, ApplicationService<? extends Application> applicationService, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper)
-
-
Method Details
-
readAllByOwningApplication
@NonNull public org.springframework.data.domain.Page<P> readAllByOwningApplication(@Nullable cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Pageable pageable, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CatalogService
Find and return the catalogs for the given owning application. For global catalogs, owning application's id will be null. This will only return catalogs marked true forApplicationCatalogRef.isVisibleAsAssigned()
.- Specified by:
readAllByOwningApplication
in interfaceCatalogService<P extends Catalog>
- Parameters:
filters
- additional filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.pageable
- the requested page of results from the databasecontext
- context information surrounding sandboxing and multitenant state- Returns:
- catalogs for the given owning application
-
readAllByOwningApplicationWithVisibility
@NonNull public org.springframework.data.domain.Page<P> readAllByOwningApplicationWithVisibility(@Nullable cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Pageable pageable, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CatalogService
Find and return the catalogs for the given owning application. For global catalogs, owning application's id will be null. This will only return catalogs marked true forApplicationCatalogRef.isVisibleAsAssigned()
. This implementation also filters out any catalogs where the hidden property is true (seeCatalog.isHidden()
).- Specified by:
readAllByOwningApplicationWithVisibility
in interfaceCatalogService<P extends Catalog>
- Parameters:
filters
- additional filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.pageable
- the requested page of results from the databasecontext
- context information surrounding sandboxing and multitenant state- Returns:
- catalogs for the given owning application
-
readAllByContextIds
@NonNull public List<P> readAllByContextIds(@NonNull List<String> catalogIds, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CatalogService
Return all of the catalogs with IDs in the supplied list.- Specified by:
readAllByContextIds
in interfaceCatalogService<P extends Catalog>
- Parameters:
catalogIds
- the catalog context IDs to search forfilters
- additional filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.context
- context information surrounding sandboxing and multitenant state- Returns:
- the catalogs that matched with the IDs in the given list
-
readAllByOwningApplicationWithExclusion
public org.springframework.data.domain.Page<P> readAllByOwningApplicationWithExclusion(String excludingCatalogId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CatalogService
Find and return the catalogs for the given owning application. For global catalogs, owning application's id will be null. This will only return catalogs marked true forApplicationCatalogRef.isVisibleAsAssigned()
. This will exclude the catalog supplied inexcludingCatalogId
and any of that catalog's children.The primary usage of this method is filtering out catalogs that would cause a cycle. For example, given catalogs A and B we would want to prevent a scenario where catalog A is a parent of B and B is a parent of A, or the simpler scenario where catalog A is a parent of itself.
- Specified by:
readAllByOwningApplicationWithExclusion
in interfaceCatalogService<P extends Catalog>
- Parameters:
excludingCatalogId
- The id of the catalog to exclude. This catalog, as well as any children of this catalog, will be filtered from the results.filters
- additional filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.pageable
- the requested page of results from the databasecontext
- context information surrounding sandboxing and multitenant state- Returns:
- catalogs for the given owning application
-
readAllByOwningApplicationWithVisibilityAndExclusion
public org.springframework.data.domain.Page<P> readAllByOwningApplicationWithVisibilityAndExclusion(String excludingCatalogId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CatalogService
Find and return the catalogs for the given owning application. For global catalogs, owning application's id will be null. This will only return catalogs marked true forApplicationCatalogRef.isVisibleAsAssigned()
. Any catalogs where the hidden property is true (seeCatalog.isHidden()
) will be filtered, as well as the catalog ID supplied inexcludeCatalogId
and any of that catalog's children.The primary usage of this method is filtering out catalogs that would cause a cycle. For example, given catalogs A and B we would want to prevent a scenario where catalog A is a parent of B and B is a parent of A, or the simpler scenario where catalog A is a parent of itself.
- Specified by:
readAllByOwningApplicationWithVisibilityAndExclusion
in interfaceCatalogService<P extends Catalog>
- Parameters:
excludingCatalogId
- The id of the catalog to exclude. This catalog, as well as any children of this catalog, will be filtered from the results.filters
- additional filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.pageable
- the requested page of results from the databasecontext
- context information surrounding sandboxing and multitenant state- Returns:
- catalogs for the given owning application
-
readAllTopLevelNonApplicationCatalogsByType
@NonNull public List<P> readAllTopLevelNonApplicationCatalogsByType(@NonNull String type, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CatalogService
Finds all catalogs by type and tenant ID that do not belong to an application & are top-level catalogs, meaning they do not have a parent.- Specified by:
readAllTopLevelNonApplicationCatalogsByType
in interfaceCatalogService<P extends Catalog>
- Parameters:
type
- the type of catalog to filter oncontextInfo
- the context info of this request- Returns:
- all top-level tenant catalogs of the specified type and tenant
-
update
-
replace
-
sendTenantSearchGroupNotification
public void sendTenantSearchGroupNotification(@NonNull P searchGroup, @NonNull @NonNull Tenant tenant, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.type.OperationType operationType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CatalogService
Sends a notification after creating or deleting aDefaultCatalogType.SEARCH_GROUP
typeCatalog
when aTenant
is created or deleted. There should be a single Search Group Catalog created for each Tenant or Application.- Specified by:
sendTenantSearchGroupNotification
in interfaceCatalogService<P extends Catalog>
- Parameters:
searchGroup
- The affected search grouptenant
- The parent tenantoperationType
- The type of operation-create or delete.contextInfo
- Additional context info.
-
validateForCircularCatalogRelationships
Validates that a catalog update will not cause a circular catalog inheritance graph.- Parameters:
id
- The ID of the catalog being updated.catalog
- The updated catalog.
-
rejectParentRelationship
protected void rejectParentRelationship(org.springframework.validation.Errors errors, CatalogRef parent) -
getRepositoryDomain
- Specified by:
getRepositoryDomain
in interfaceCatalogService<P extends Catalog>
-
buildExclusionsFilter
@Nullable protected cz.jirutka.rsql.parser.ast.Node buildExclusionsFilter(String catalogId, @Nullable cz.jirutka.rsql.parser.ast.Node filters) Builds an exclusion filter that will exclude any catalogs that would cause a circular catalog inheritance graph. Enhancesfilters
if there are existing filters.- Parameters:
catalogId
- The ID of the catalogfilters
- Filter to be enhanced. May be null orEmptyNode
.- Returns:
- An enhanced filter, excluding catalogs that would cause a circular hierarchy. May
return null if
filters
is null and there are no exclusions.
-
readCatalogRelationships
Read all catalogs that are in a catalog inheritance line.- Parameters:
catalogId
- The catalog ID- Returns:
- The IDs of catalogs in the inheritance line.
-
getErrors
-
getRepository
@NonNull protected CatalogRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository() -
getApplicationService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()- Since:
- 2.1.0-GA
-
setTypeFactory
@Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory) - Since:
- 2.1.0-GA
-
getSender
@Nullable protected com.broadleafcommerce.common.messaging.notification.DetachedDurableMessageSender getSender()- Since:
- 2.1.0-GA
-
setSender
@Autowired(required=false) public void setSender(@Nullable com.broadleafcommerce.common.messaging.notification.DetachedDurableMessageSender sender) - Since:
- 2.1.0-GA
-