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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJpaCustomizedCatalogRepository(com.broadleafcommerce.data.tracking.jpa.persistence.NativeSqlStrategyManager sqlStrategyManager, cz.jirutka.rsql.parser.ast.RSQLVisitor<javax.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 TypeMethodDescriptionvoidvoidbulkUpdateApplicationCatalogRefByCatalog(Catalog updatedCatalog) Bulk updatesApplicationCatalogRef.namefor 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) protected voidSend a message covering the changed catalog state via thePersistenceProducerchannel.protected voidprocessChild(Map<String, Long> levels, D deepChild) Update and persist theJpaTenantCatalog.getLevel()value for the passedJpaTenantCatalogby 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.Trackablesave(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) voidsetNotificationManager(com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager) voidsetRepository(JpaCatalogRepository<?> repository) protected DupdateBasedOnParents(D catalog, boolean isCreate) Update and persist theJpaTenantCatalog.getLevel()value for the passedJpaTenantCatalogby evaluating theJpaTenantCatalog.getParents()and their levels.protected voidupdateChildLevels(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<javax.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:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
setNotificationManager
@Autowired public void setNotificationManager(@Nullable com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager) -
setRepository
-
readCatalogRelationships
Description copied from interface:CustomizedCatalogRepositoryGiven 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:
readCatalogRelationshipsin 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
-
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:CustomizedCatalogRepositoryBulk updatesApplicationCatalogRef.namefor entries whose context id matches the given updated catalog id- Specified by:
bulkUpdateApplicationCatalogRefByCatalogin 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 passedJpaTenantCatalogby 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 thePersistenceProducerchannel.- Parameters:
catalog- The changed catalog instance
-
processChild
Update and persist theJpaTenantCatalog.getLevel()value for the passedJpaTenantCatalogby 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).
-