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>
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.readCatalogRelationships
(String catalogId) Read all catalogs that are in a catalog inheritance line.protected void
rejectParentRelationship
(org.springframework.validation.Errors errors, CatalogRef parent) 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
-
update
-
replace
-
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
-