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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultContentModelService(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 Summary
Modifier and TypeMethodDescriptionvoidprotected com.broadleafcommerce.common.extension.cache.CacheStateManagerprotected ContentFieldService<ContentField>protected ContentItemRepository<com.broadleafcommerce.data.tracking.core.Trackable>protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGenprotected com.broadleafcommerce.common.extension.cache.key.ContextKeyGenprotected FieldDataService<FieldData>protected ContentItemService<ContentItem>protected ContentModelRepository<com.broadleafcommerce.data.tracking.core.Trackable>protected com.broadleafcommerce.common.extension.TypeFactoryhydrateContentFields(@NonNull List<P> models, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hydrates theContentFieldsfor eachContentModelin the passed-in collectionorg.springframework.data.domain.Page<P>hydrateContentFields(@NonNull org.springframework.data.domain.Page<P> paginated, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) hydrateContentFields(P model, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hydrates theContentFieldsfor aContentModelvoidreadAllByContextIds(@NonNull Collection<String> modelIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all the models with the givenmodelIds.org.springframework.data.domain.Page<P>readAllByName(String nameQuery, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Read all content types, optionally filtered by name.readByName(String modelName, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds the content type with the given name (should only be one result, as content type names are unique).Reads the model by the givenuri.protected voidreplaceOrCreateContentFieldsForContentModel(P content, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Create or replaceContentFieldfor the passed-inContentModelvoidsetCacheStateManager(com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager) voidsetContentFieldService(ContentFieldService<ContentField> contentFieldService) voidsetContentItemRepository(ContentItemRepository<com.broadleafcommerce.data.tracking.core.Trackable> contentItemRepository) voidsetContentModelCacheByNameKeyGen(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentModelCacheByNameKeyGen) voidsetContentModelCacheByUriKeyGen(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentModelCacheByUriKeyGen) voidsetItemService(ContentItemService<ContentItem> itemService) Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService
getRsqlHelper, readAll, readAll, readAll, readAllMethods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService
convertFromPersistentDomain, convertToPersistentDomain, createAll, createAllAllowingPartialSuccess, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecutionMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
createAll, createAllAllowingPartialSuccess, readAll, readAll, readAll, readAllByContextId, readByContextId, replaceAll, replaceAllAllowingPartialSuccess, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService
readAll, readAll, readAll, readAll
-
Field Details
-
CACHE_BY_NAME
Deprecated.UseBY_MODEL_NAME_CACHE. This was never used in previous versions.- See Also:
-
BY_MODEL_NAME_CACHE
- See Also:
-
BY_MODEL_URI_CACHE
- See Also:
-
-
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:ContentModelServiceRead all content types, optionally filtered by name.- Specified by:
readAllByNamein interfaceContentModelService<P extends ContentModel>- Parameters:
nameQuery- (optional) the content type name to filter byfilters- additional filters to apply in the query, can be nullpage- the requested page of results from the databasecontextInfo- 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:ContentModelServiceReads all the models with the givenmodelIds.- Specified by:
readAllByContextIdsin interfaceContentModelService<P extends ContentModel>- Parameters:
modelIds- Ids of the models to fetchcontextInfo- 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:ContentModelServiceFinds the content type with the given name (should only be one result, as content type names are unique).- Specified by:
readByNamein interfaceContentModelService<P extends ContentModel>- Parameters:
modelName- the name of the content type that should be retrievedcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- an
Optionalcontaining 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:
createin interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ContentModel>- Overrides:
createin classcom.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:
updatein interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ContentModel>- Overrides:
updatein classcom.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:
replacein interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ContentModel>- Overrides:
replacein classcom.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:ContentModelServiceReads the model by the givenuri.uricannot be null.- Specified by:
readByUriin interfaceContentModelService<P extends ContentModel>- Parameters:
uri- URI of the model to fetchcontextInfo- 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:
deletein interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ContentModel>- Overrides:
deletein classcom.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:ContentModelServiceHydrates theContentFieldsfor aContentModel- Specified by:
hydrateContentFieldsin interfaceContentModelService<P extends ContentModel>- Parameters:
model- content model to updatecontextInfo- 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- Specified by:
hydrateContentFieldsin interfaceContentModelService<P extends ContentModel>- Parameters:
paginated- paginated content models to updatecontextInfo- 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:ContentModelServiceHydrates theContentFieldsfor eachContentModelin the passed-in collection- Specified by:
hydrateContentFieldsin interfaceContentModelService<P extends ContentModel>- Parameters:
models- collection of content models to updatecontextInfo- information surrounding sandboxing and multitenant state
-
replaceOrCreateContentFieldsForContentModel
protected void replaceOrCreateContentFieldsForContentModel(@NonNull P content, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Create or replaceContentFieldfor the passed-inContentModel- Parameters:
content- the content model to updatecontext- information surrounding sandboxing and multitenant state
-
onApplicationEvent
- Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<P extends ContentModel>
-
getRepository
protected ContentModelRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()- Overrides:
getRepositoryin classcom.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
-
setContentFieldService
@Autowired public void setContentFieldService(ContentFieldService<ContentField> contentFieldService) -
getItemService
-
setItemService
-
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()
-
BY_MODEL_NAME_CACHE.