Class DefaultApplicationService<P extends Application>

java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.tenant.service.DefaultApplicationService<P>
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>, ApplicationService<P>

public class DefaultApplicationService<P extends Application> extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P> implements ApplicationService<P>
  • Constructor Details

    • DefaultApplicationService

      public DefaultApplicationService(ApplicationRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, TenantApplicationProperties applicationProperties, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper)
  • Method Details

    • create

      public P create(@NonNull P businessInstance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      create in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends Application>
      Overrides:
      create in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends Application>
    • update

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

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

      public Optional<P> readOptionalByContextId(@NonNull @NonNull String contextId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ApplicationService
      Similar to CrudEntityService.readByContextId(String, ContextInfo), but returns an Optional instead.
      Specified by:
      readOptionalByContextId in interface ApplicationService<P extends Application>
      Parameters:
      contextId - the ID of the application to find
      contextInfo - context information surrounding multitenant state
      Returns:
      an Optional containing the entity if found, Optional.empty() otherwise
    • readByToken

      public Optional<P> readByToken(String applicationToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ApplicationService
      Finds and returns the application associated with the provided application token.
      Specified by:
      readByToken in interface ApplicationService<P extends Application>
      Parameters:
      applicationToken - the application token
      contextInfo - the context info
      Returns:
      the application
    • readCatalogsForAdd

      public org.springframework.data.domain.Page<ApplicationCatalogRef> readCatalogsForAdd(String id, @NonNull @NonNull org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: ApplicationService
      Finds and returns the catalog's for the given owning application that are available to be added when selecting a catalog for add operations.
      Specified by:
      readCatalogsForAdd in interface ApplicationService<P extends Application>
      Parameters:
      id - the application's id for which to return catalogs for adding
      pageable - the requested page of results from the database
      context - context information surrounding sandboxing and multitenant state
      Returns:
      catalogs available for add operations for the given application
      See Also:
    • readAllActive

      public org.springframework.data.domain.Page<P> readAllActive(@Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: ApplicationService
      Reads all Applications where Application.isDeactivated() is false.
      Specified by:
      readAllActive in interface ApplicationService<P extends Application>
      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:
      all Applications where Application.isDeactivated() is false.
    • readByActiveStatus

      public org.springframework.data.domain.Page<P> readByActiveStatus(boolean isActive, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: ApplicationService
      Finds and returns all Applications where Application.isDeactivated() satisfies the isActive parameter.
      Specified by:
      readByActiveStatus in interface ApplicationService<P extends Application>
      Parameters:
      isActive - true if only active applications should be returned, false if only deactivated applications should be returned
      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:
      all Applications where Application.isDeactivated() satisfies the isActive parameter
    • readActiveByApplicationIdentifierIgnoreCaseAndIdentifierType

      public Optional<P> readActiveByApplicationIdentifierIgnoreCaseAndIdentifierType(String identifier, @Nullable String identifierType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ApplicationService
      Reads the application by its Application.getIdentifierValue() (case-insensitive) and, optionally, by Application.getIdentifierType(). If not provided, identifier will default to ResolutionIdentifierType.DOMAIN.
      Specified by:
      readActiveByApplicationIdentifierIgnoreCaseAndIdentifierType in interface ApplicationService<P extends Application>
      Parameters:
      identifier - the Application.getIdentifierValue()
      identifierType - the Application.getIdentifierType()
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      the Application with the matching Application.getIdentifierValue()
    • readActiveByApplicationIdentifierAndIdentifierType

      public Optional<P> readActiveByApplicationIdentifierAndIdentifierType(String identifier, @Nullable String identifierType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ApplicationService
      Reads the application by its Application.getIdentifierValue() and, optionally, by Application.getIdentifierType(). If not provided, identifier will default to ResolutionIdentifierType.DOMAIN.
      Specified by:
      readActiveByApplicationIdentifierAndIdentifierType in interface ApplicationService<P extends Application>
      Parameters:
      identifier - the Application.getIdentifierValue()
      identifierType - the Application.getIdentifierType()
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      the Application with the matching Application.getIdentifierValue()
    • getRepositoryDomain

      public String getRepositoryDomain()
      Specified by:
      getRepositoryDomain in interface ApplicationService<P extends Application>
    • readAllByApplicationIdIn

      public org.springframework.data.domain.Page<P> readAllByApplicationIdIn(Collection<String> applicationIds, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Specified by:
      readAllByApplicationIdIn in interface ApplicationService<P extends Application>
    • readByActiveStatusAndApplicationIdIn

      public org.springframework.data.domain.Page<P> readByActiveStatusAndApplicationIdIn(Collection<String> applicationIds, boolean active, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Specified by:
      readByActiveStatusAndApplicationIdIn in interface ApplicationService<P extends Application>
    • createForTenantCustomerContext

      protected P createForTenantCustomerContext(@NonNull P businessInstance, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Handles the create operation for CustomerContextResolverMethod.TENANT.
      Parameters:
      businessInstance - Instance to be persisted
      context - context information surrounding sandboxing and multitenant state
      Returns:
      The new entity instance in the form of a projection type instance.
    • createForApplicationCustomerContext

      protected P createForApplicationCustomerContext(@NonNull P businessInstance, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Handles the create operation for CustomerContextResolverMethod.APPLICATION.
      Parameters:
      businessInstance - Instance to be persisted
      context - context information surrounding sandboxing and multitenant state
      Returns:
      The new entity instance in the form of a projection type instance.
    • createWithRelatedEntities

      protected P createWithRelatedEntities(@NonNull P businessInstance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Handles creating the Application along with any required related entities such as a DefaultCatalogType.SEARCH_GROUP type Catalog.

      To disable created the search group catalog, set TenantApplicationProperties.isInitializeSearchGroupCatalogForNewApplicationsEnabled() to false.

      Parameters:
      businessInstance - The request payload representing the application to create.
      context - Additional multitenant and sandbox information.
      Returns:
      The created application.
    • getRepository

      protected ApplicationRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
      Overrides:
      getRepository in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends Application>
    • getApplicationProperties

      protected TenantApplicationProperties getApplicationProperties()
    • setApplicationCatalogGenerationService

      @Autowired @Lazy public void setApplicationCatalogGenerationService(ApplicationCatalogGenerationService<P> applicationCatalogGenerationService)
    • getApplicationCatalogGenerationService

      protected ApplicationCatalogGenerationService<P> getApplicationCatalogGenerationService()