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

    Constructors
    Constructor
    Description
    DefaultCatalogService(CatalogRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, ApplicationService<? extends Application> applicationService, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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
    getErrors(P businessInstance)
     
    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.
    protected List<String>
    Read all catalogs that are in a catalog inheritance line.
    protected void
    rejectParentRelationship(org.springframework.validation.Errors errors, CatalogRef parent)
     
    replace(String id, P catalog, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
     
    update(String id, P catalog, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
     
    protected void
    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 for ApplicationCatalogRef.isVisibleAsAssigned().
      Specified by:
      readAllByOwningApplication in interface CatalogService<P extends Catalog>
      Parameters:
      filters - additional filters to apply in the query. Should be EmptyNode if no additional filters should be applied.
      pageable - the requested page of results from the database
      context - 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 for ApplicationCatalogRef.isVisibleAsAssigned(). This implementation also filters out any catalogs where the hidden property is true (see Catalog.isHidden()).
      Specified by:
      readAllByOwningApplicationWithVisibility in interface CatalogService<P extends Catalog>
      Parameters:
      filters - additional filters to apply in the query. Should be EmptyNode if no additional filters should be applied.
      pageable - the requested page of results from the database
      context - 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 interface CatalogService<P extends Catalog>
      Parameters:
      catalogIds - the catalog context IDs to search for
      filters - additional filters to apply in the query. Should be EmptyNode 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 for ApplicationCatalogRef.isVisibleAsAssigned(). This will exclude the catalog supplied in excludingCatalogId 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 interface CatalogService<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 be EmptyNode if no additional filters should be applied.
      pageable - the requested page of results from the database
      context - 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 for ApplicationCatalogRef.isVisibleAsAssigned(). Any catalogs where the hidden property is true (see Catalog.isHidden()) will be filtered, as well as the catalog ID supplied in excludeCatalogId 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 interface CatalogService<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 be EmptyNode if no additional filters should be applied.
      pageable - the requested page of results from the database
      context - context information surrounding sandboxing and multitenant state
      Returns:
      catalogs for the given owning application
    • update

      public P update(@NonNull String id, @NonNull P catalog, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      update in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends Catalog>
      Overrides:
      update in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends Catalog>
    • replace

      public P replace(@NonNull String id, @NonNull P catalog, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      replace in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends Catalog>
      Overrides:
      replace in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends Catalog>
    • validateForCircularCatalogRelationships

      protected void validateForCircularCatalogRelationships(String id, P catalog)
      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

      public String getRepositoryDomain()
      Specified by:
      getRepositoryDomain in interface CatalogService<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. Enhances filters if there are existing filters.
      Parameters:
      catalogId - The ID of the catalog
      filters - Filter to be enhanced. May be null or EmptyNode.
      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

      protected List<String> readCatalogRelationships(String catalogId)
      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

      protected org.springframework.validation.Errors getErrors(P businessInstance)
    • getRepository

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

      @NonNull protected ApplicationService<? extends Application> getApplicationService()