Class DefaultContentModelService<P extends ContentModel>

java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.content.service.DefaultContentModelService<P>
All Implemented Interfaces:
ContentModelService<P>, com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>, EventListener, org.springframework.context.ApplicationListener<ContentCacheInvalidationEvent>

public class DefaultContentModelService<P extends ContentModel> extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P> implements ContentModelService<P>, org.springframework.context.ApplicationListener<ContentCacheInvalidationEvent>
Author:
Jon Fleschler (jfleschler)
  • Field Details

  • Constructor Details

    • DefaultContentModelService

      public DefaultContentModelService(ContentModelRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, FieldDataService<FieldData> fieldDataService, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
  • Method Details

    • readAllByName

      public org.springframework.data.domain.Page<P> readAllByName(@Nullable String nameQuery, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ContentModelService
      Read all content types, optionally filtered by name.
      Specified by:
      readAllByName in interface ContentModelService<P extends ContentModel>
      Parameters:
      nameQuery - (optional) the content type name to filter by
      filters - additional filters to apply in the query, can be null
      page - the requested page of results from the database
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      all models, optionally filtered by name
    • readAllByContextIds

      public List<P> readAllByContextIds(@NonNull @NonNull Collection<String> modelIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ContentModelService
      Reads all the models with the given modelIds.
      Specified by:
      readAllByContextIds in interface ContentModelService<P extends ContentModel>
      Parameters:
      modelIds - Ids of the models to fetch
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      All the models with the given modelIds.
    • readByName

      public Optional<P> readByName(String modelName, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ContentModelService
      Finds the content type with the given name (should only be one result, as content type names are unique).
      Specified by:
      readByName in interface ContentModelService<P extends ContentModel>
      Parameters:
      modelName - the name of the content type that should be retrieved
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      an Optional containing the content type with the given name, empty if not found
    • create

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

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

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

      public Optional<P> readByUri(String uri, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ContentModelService
      Reads the model by the given uri. uri cannot be null.
      Specified by:
      readByUri in interface ContentModelService<P extends ContentModel>
      Parameters:
      uri - URI of the model to fetch
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      The model by the given uri.
    • delete

      public void delete(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      delete in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ContentModel>
      Overrides:
      delete in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ContentModel>
    • hydrateContentFields

      public P hydrateContentFields(@NonNull P model, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ContentModelService
      Hydrates the ContentFields for a ContentModel
      Specified by:
      hydrateContentFields in interface ContentModelService<P extends ContentModel>
      Parameters:
      model - content model to update
      contextInfo - information surrounding sandboxing and multitenant state
      Returns:
      The updated paginated content models
    • hydrateContentFields

      public org.springframework.data.domain.Page<P> hydrateContentFields(@NonNull @NonNull org.springframework.data.domain.Page<P> paginated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ContentModelService
      Hydrates the ContentFields for each ContentModel in the passed-in Page object
      Specified by:
      hydrateContentFields in interface ContentModelService<P extends ContentModel>
      Parameters:
      paginated - paginated content models to update
      contextInfo - information surrounding sandboxing and multitenant state
      Returns:
      The updated paginated content models
    • hydrateContentFields

      public List<P> hydrateContentFields(@NonNull @NonNull List<P> models, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: ContentModelService
      Hydrates the ContentFields for each ContentModel in the passed-in collection
      Specified by:
      hydrateContentFields in interface ContentModelService<P extends ContentModel>
      Parameters:
      models - collection of content models to update
      contextInfo - information surrounding sandboxing and multitenant state
    • replaceOrCreateContentFieldsForContentModel

      protected void replaceOrCreateContentFieldsForContentModel(@NonNull P content, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Create or replace ContentField for the passed-in ContentModel
      Parameters:
      content - the content model to update
      context - information surrounding sandboxing and multitenant state
    • onApplicationEvent

      public void onApplicationEvent(ContentCacheInvalidationEvent event)
      Specified by:
      onApplicationEvent in interface org.springframework.context.ApplicationListener<P extends ContentModel>
    • getRepository

      protected ContentModelRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
      Overrides:
      getRepository in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends ContentModel>
    • getContentItemRepository

      protected ContentItemRepository<com.broadleafcommerce.data.tracking.core.Trackable> getContentItemRepository()
    • setContentItemRepository

      @Autowired public void setContentItemRepository(ContentItemRepository<com.broadleafcommerce.data.tracking.core.Trackable> contentItemRepository)
    • getContentFieldService

      protected ContentFieldService<ContentField> getContentFieldService()
    • setContentFieldService

      @Autowired public void setContentFieldService(ContentFieldService<ContentField> contentFieldService)
    • getItemService

      protected ContentItemService<ContentItem> getItemService()
    • setItemService

      @Autowired public void setItemService(ContentItemService<ContentItem> itemService)
    • getFieldDataService

      protected FieldDataService<FieldData> getFieldDataService()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getCacheStateManager

      @Nullable protected com.broadleafcommerce.common.extension.cache.CacheStateManager getCacheStateManager()
    • setCacheStateManager

      @Autowired(required=false) public void setCacheStateManager(@Nullable com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager)
    • setContentModelCacheByNameKeyGen

      @Autowired(required=false) @Qualifier("contentModelCacheByName") public void setContentModelCacheByNameKeyGen(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentModelCacheByNameKeyGen)
    • getContentModelCacheByNameKeyGen

      @Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getContentModelCacheByNameKeyGen()
    • setContentModelCacheByUriKeyGen

      @Autowired(required=false) @Qualifier("contentModelCacheByUri") public void setContentModelCacheByUriKeyGen(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentModelCacheByUriKeyGen)
    • getContentModelCacheByUriKeyGen

      @Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getContentModelCacheByUriKeyGen()