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 Summary

    Constructors
    Constructor
    Description
    DefaultApplicationService(ApplicationRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, TenantApplicationProperties applicationProperties, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    create(P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
     
    protected P
    createForApplicationCustomerContext(P businessInstance, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Handles the create operation for CustomerContextResolverMethod.APPLICATION.
    protected P
    createForTenantCustomerContext(P businessInstance, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Handles the create operation for CustomerContextResolverMethod.TENANT.
     
    protected ApplicationRepository<com.broadleafcommerce.data.tracking.core.Trackable>
     
     
    readActiveByApplicationIdentifierAndIdentifierType(String identifier, String identifierType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Reads the application by its Application.getIdentifierValue() and, optionally, by Application.getIdentifierType().
    org.springframework.data.domain.Page<P>
    readAllActive(cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Reads all Applications where Application.isDeactivated() is false.
    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)
     
    org.springframework.data.domain.Page<P>
    readByActiveStatus(boolean isActive, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Finds and returns all Applications where Application.isDeactivated() satisfies the isActive parameter.
    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)
     
    readByToken(String applicationToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Finds and returns the application associated with the provided application token.
    org.springframework.data.domain.Page<ApplicationCatalogRef>
    readCatalogsForAdd(String id, @NonNull org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Finds and returns the catalog's for the given owning application that are available to be added when selecting a catalog for add operations.
    readOptionalByContextId(@NonNull String contextId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Similar to CrudEntityService.readByContextId(String, ContextInfo), but returns an Optional instead.
    replace(String id, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
     
    update(String id, P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
     

    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

    • 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
    • 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.
    • 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()