Class JpaCustomizedCatalogRepository<D extends JpaTenantCatalog>
java.lang.Object
com.broadleafcommerce.tenant.provider.jpa.repository.JpaCustomizedCatalogRepository<D>
- All Implemented Interfaces:
CustomizedCatalogRepository
,org.springframework.beans.factory.InitializingBean
public class JpaCustomizedCatalogRepository<D extends JpaTenantCatalog>
extends Object
implements org.springframework.beans.factory.InitializingBean, CustomizedCatalogRepository
Fragment repository override to handle specialized persistence behavior for
JpaTenantCatalog
instances.- Author:
- Jeff Fischer
-
Field Summary
-
Constructor Summary
ConstructorDescriptionJpaCustomizedCatalogRepository
(com.broadleafcommerce.data.tracking.jpa.persistence.NativeSqlStrategyManager sqlStrategyManager, cz.jirutka.rsql.parser.ast.RSQLVisitor<jakarta.persistence.criteria.Predicate, Class<?>> rsqlVisitor, com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder builder) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
bulkUpdateApplicationCatalogRefByCatalog
(Catalog updatedCatalog) Bulk updatesApplicationCatalogRef.name
for entries whose context id matches the given updated catalog idfindAllByContextIdInAndHiddenNot
(List<String> catalogIds, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) org.springframework.data.domain.Page<D>
findAllByOwningApplicationIsNullAndHiddenNot
(cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) findByTypeAndTenantIdAndOwningApplicationIsNull
(String catalogType, String tenantId) Finds all catalogs by type and tenant ID that do not belong to an application.protected void
Send a message covering the changed catalog state via thePersistenceProducer
channel.protected void
processChild
(Map<String, Long> levels, D deepChild) Update and persist theJpaTenantCatalog.getLevel()
value for the passedJpaTenantCatalog
by evaluating theJpaTenantCatalog.getParents()
and their levels.readCatalogRelationships
(@NonNull String catalogId) Given a catalog ID, read itself and all catalogs that are descendants (direct or indirect) of it.com.broadleafcommerce.data.tracking.core.Trackable
save
(com.broadleafcommerce.data.tracking.core.Trackable catalog, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Iterable<com.broadleafcommerce.data.tracking.core.Trackable>
saveAll
(Iterable<com.broadleafcommerce.data.tracking.core.Trackable> trackable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) void
setNotificationManager
(com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager) void
setRepository
(JpaCatalogRepository<?> repository) protected D
updateBasedOnParents
(D catalog, boolean isCreate) Update and persist theJpaTenantCatalog.getLevel()
value for the passedJpaTenantCatalog
by evaluating theJpaTenantCatalog.getParents()
and their levels.protected void
updateChildLevels
(D catalog) Increment theJpaTenantCatalog.getLevel()
values for all children of the passedJpaTenantCatalog
.
-
Field Details
-
CHILD_CATALOGS_SQL
- See Also:
-
CATALOG_RELATIONSHIPS_SQL
- See Also:
-
APPLICATION_CATALOG_REF_BULK_UPDATE_SQL
- See Also:
-
-
Constructor Details
-
JpaCustomizedCatalogRepository
public JpaCustomizedCatalogRepository(com.broadleafcommerce.data.tracking.jpa.persistence.NativeSqlStrategyManager sqlStrategyManager, cz.jirutka.rsql.parser.ast.RSQLVisitor<jakarta.persistence.criteria.Predicate, Class<?>> rsqlVisitor, com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder builder)
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
setNotificationManager
@Autowired public void setNotificationManager(@Nullable com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager) -
setRepository
-
readCatalogRelationships
Description copied from interface:CustomizedCatalogRepository
Given a catalog ID, read itself and all catalogs that are descendants (direct or indirect) of it. Order is not guaranteed.For example, given catalog IDs A, B, and C, and a catalog graph of A <- B <- C (with A being the parent of B and B the parent of C):
- a query of 'A' will return A, B, and C
- a query of 'B' will return B and C
- a query of 'C' will return C
- Specified by:
readCatalogRelationships
in interfaceCustomizedCatalogRepository<D extends JpaTenantCatalog>
- Parameters:
catalogId
- The ID of the catalog for which to read descendants.- Returns:
- A list of catalog IDs for which to read descendants
-
findAllByOwningApplicationIsNullAndHiddenNot
@NonNull public org.springframework.data.domain.Page<D> findAllByOwningApplicationIsNullAndHiddenNot(@Nullable cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) -
findAllByContextIdInAndHiddenNot
-
findByTypeAndTenantIdAndOwningApplicationIsNull
@NonNull public List<D> findByTypeAndTenantIdAndOwningApplicationIsNull(@NonNull String catalogType, @Nullable String tenantId) Description copied from interface:CustomizedCatalogRepository
Finds all catalogs by type and tenant ID that do not belong to an application.- Specified by:
findByTypeAndTenantIdAndOwningApplicationIsNull
in interfaceCustomizedCatalogRepository<D extends JpaTenantCatalog>
- Parameters:
catalogType
- the catalog type to filter ontenantId
- the tenant ID to filter on- Returns:
- all catalogs by type and tenant ID that do not belong to an application
-
save
public com.broadleafcommerce.data.tracking.core.Trackable save(com.broadleafcommerce.data.tracking.core.Trackable catalog, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
saveAll
-
bulkUpdateApplicationCatalogRefByCatalog
@Transactional public void bulkUpdateApplicationCatalogRefByCatalog(@NonNull Catalog updatedCatalog) Description copied from interface:CustomizedCatalogRepository
Bulk updatesApplicationCatalogRef.name
for entries whose context id matches the given updated catalog id- Specified by:
bulkUpdateApplicationCatalogRefByCatalog
in interfaceCustomizedCatalogRepository<D extends JpaTenantCatalog>
- Parameters:
updatedCatalog
- the updated catalog
-
updateChildLevels
Increment theJpaTenantCatalog.getLevel()
values for all children of the passedJpaTenantCatalog
.- Parameters:
catalog
- The parent catalog for whom all children should be update for level values. This includes deep children (i.e. children that are greater than immediate descendants).
-
updateBasedOnParents
Update and persist theJpaTenantCatalog.getLevel()
value for the passedJpaTenantCatalog
by evaluating theJpaTenantCatalog.getParents()
and their levels. Generally, this catalog's level should be incremented greater than the max level displayed in the parents.- Parameters:
catalog
- The catalog whose level value should be updatedisCreate
- Whether or not the passed catalog is new
-
notify
Send a message covering the changed catalog state via thePersistenceProducer
channel.- Parameters:
catalog
- The changed catalog instance
-
processChild
Update and persist theJpaTenantCatalog.getLevel()
value for the passedJpaTenantCatalog
by evaluating theJpaTenantCatalog.getParents()
and their levels. Generally, this catalog's level should be incremented greater than the max level displayed in the parents. The passed catalog is considered a deep child of the originally changed catalog.- Parameters:
levels
- Library of contextIds to levels. Generally used during review of the passed catalog's parents.deepChild
- A child catalog of the originally changed catalog. This is possibly a deep child (i.e. not an immediate child of the original).
-