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 TypeMethodDescriptionvoid
protected com.broadleafcommerce.common.extension.cache.CacheStateManager
protected ContentFieldService<ContentField>
protected ContentItemRepository<com.broadleafcommerce.data.tracking.core.Trackable>
protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected FieldDataService<FieldData>
protected ContentItemService<ContentItem>
protected ContentModelRepository<com.broadleafcommerce.data.tracking.core.Trackable>
protected com.broadleafcommerce.common.extension.TypeFactory
hydrateContentFields
(@NonNull List<P> models, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hydrates theContentFields
for eachContentModel
in 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 theContentFields
for aContentModel
void
readAllByContextIds
(@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 void
replaceOrCreateContentFieldsForContentModel
(P content, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Create or replaceContentField
for the passed-inContentModel
void
setCacheStateManager
(com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager) void
setContentFieldService
(ContentFieldService<ContentField> contentFieldService) void
setContentItemRepository
(ContentItemRepository<com.broadleafcommerce.data.tracking.core.Trackable> contentItemRepository) void
setContentModelCacheByNameKeyGen
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentModelCacheByNameKeyGen) void
setContentModelCacheByUriKeyGen
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentModelCacheByUriKeyGen) void
setItemService
(ContentItemService<ContentItem> itemService) 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, 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 org.springframework.context.ApplicationListener
supportsAsyncExecution
Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
createAll, createAllAllowingPartialSuccess, 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
-
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:ContentModelService
Read all content types, optionally filtered by name.- Specified by:
readAllByName
in 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:ContentModelService
Reads all the models with the givenmodelIds
.- Specified by:
readAllByContextIds
in 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:ContentModelService
Finds the content type with the given name (should only be one result, as content type names are unique).- Specified by:
readByName
in 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
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 interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ContentModel>
- Overrides:
create
in 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:
update
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ContentModel>
- Overrides:
update
in 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:
replace
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ContentModel>
- Overrides:
replace
in 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:ContentModelService
Reads the model by the givenuri
.uri
cannot be null.- Specified by:
readByUri
in 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:
delete
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends ContentModel>
- Overrides:
delete
in 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:ContentModelService
Hydrates theContentFields
for aContentModel
- Specified by:
hydrateContentFields
in 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:
hydrateContentFields
in 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:ContentModelService
Hydrates theContentFields
for eachContentModel
in the passed-in collection- Specified by:
hydrateContentFields
in 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 replaceContentField
for the passed-inContentModel
- Parameters:
content
- the content model to updatecontext
- information surrounding sandboxing and multitenant state
-
onApplicationEvent
- Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener<P extends ContentModel>
-
getRepository
protected ContentModelRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()- Overrides:
getRepository
in 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
.