Class JpaCustomizedTranslationRepository<D extends JpaTranslation>

java.lang.Object
com.broadleafcommerce.translation.provider.jpa.repository.JpaCustomizedTranslationRepository<D>
All Implemented Interfaces:
CustomizedTranslationRepository<D>, org.springframework.beans.factory.InitializingBean

public class JpaCustomizedTranslationRepository<D extends JpaTranslation> extends Object implements CustomizedTranslationRepository<D>, org.springframework.beans.factory.InitializingBean
Author:
Sunny Yu
  • Field Details

  • Constructor Details

    • JpaCustomizedTranslationRepository

      public JpaCustomizedTranslationRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder filterRulesCriteriaBuilder, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager)
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • countNonProductionRecordsByEntityInTenant

      public long countNonProductionRecordsByEntityInTenant(@NonNull @NonNull String entityType, @NonNull @NonNull String entityId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: CustomizedTranslationRepository
      Returns the count of non-production records that match the given entity info and the given tenant context.

      This is useful to determine if there are outstanding sandbox changes before an entity can be deleted. For example, this is used for checking if any outstanding sandbox changes exist for Product translations before the Product can be deleted.

      Specified by:
      countNonProductionRecordsByEntityInTenant in interface CustomizedTranslationRepository<D extends JpaTranslation>
      Parameters:
      entityType - The type of the entity such as PRODUCT, CATEGORY, or OFFER.
      entityId - The context ID of the entity.
      context - context information related to multitenancy.
      Returns:
      the count of non-production records that match the given entity info and the given tenant context.
    • findAll

      public Stream<D> findAll(String entityType, String entityId, String entityField, Locale locale, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: CustomizedTranslationRepository
      Find All translations matching down to the field and locale. Under normal circumstances, there should only be one (or one per catalog). However, if there are duplicates, they will be exposed in the results.
      Specified by:
      findAll in interface CustomizedTranslationRepository<D extends JpaTranslation>
      Parameters:
      entityType - The type of the entity such as PRODUCT, CATEGORY, or OFFER.
      entityId - The context ID of the entity.
      entityField - The name of the field on the entity to which the translation applies.
      locale - The translation's locale.
      context - context information related to multitenancy.
      Returns:
      the translations for the given entity field.
    • archive

      public void archive(List<String> ids)
      Description copied from interface: CustomizedTranslationRepository
      Archive a list of translations based on the passed primary keys.
      Specified by:
      archive in interface CustomizedTranslationRepository<D extends JpaTranslation>
      Parameters:
      ids - The primary keys belonging to the translations to archive
    • findAllByEntityTypeAndEntityIdIn

      public List<D> findAllByEntityTypeAndEntityIdIn(String entityType, List<String> entityIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: CustomizedTranslationRepository
      Finds the translations for the given entity info.
      Specified by:
      findAllByEntityTypeAndEntityIdIn in interface CustomizedTranslationRepository<D extends JpaTranslation>
      Parameters:
      entityType - The type of the entity such as PRODUCT, CATEGORY, or OFFER.
      entityIds - The context IDs of the entities
      context - context information related to multitenancy. Often used to validate visibility and mutability of persistence operations for a catalog.
      Returns:
      the translations for the given entities
    • findAllByEntityTypeAndEntityIdInAndLocaleIn

      public List<D> findAllByEntityTypeAndEntityIdInAndLocaleIn(String entityType, List<String> entityIds, List<Locale> locales, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: CustomizedTranslationRepository
      Finds the translations for multiple entities.
      Specified by:
      findAllByEntityTypeAndEntityIdInAndLocaleIn in interface CustomizedTranslationRepository<D extends JpaTranslation>
      Parameters:
      entityType - The type of the entity such as PRODUCT, CATEGORY, or OFFER.
      entityIds - The context IDs of multiple entities to check.
      locales - The translation's locale(s).
      context - context information related to multitenancy. Often used to validate visibility and mutability of persistence operations for a catalog.
      Returns:
      the translations for the requested entities.
    • buildNonProductionTrackingLevelFilter

      protected jakarta.persistence.criteria.Predicate buildNonProductionTrackingLevelFilter(@NonNull @NonNull jakarta.persistence.criteria.Root<?> entity, @NonNull @NonNull jakarta.persistence.criteria.CriteriaBuilder builder)
      Builds a Predicate for non-production tracking level.
    • buildProductionTrackingLevelFilter

      protected jakarta.persistence.criteria.Predicate buildProductionTrackingLevelFilter(@NonNull @NonNull jakarta.persistence.criteria.Root<?> entity, @NonNull @NonNull jakarta.persistence.criteria.CriteriaBuilder builder)
    • buildTenantIdFilter

      protected jakarta.persistence.criteria.Predicate buildTenantIdFilter(@NonNull @NonNull jakarta.persistence.criteria.Root<?> entity, @NonNull @NonNull jakarta.persistence.criteria.CriteriaBuilder builder, @NonNull @NonNull Map<String,Object> params, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • buildNotArchivedFilter

      protected jakarta.persistence.criteria.Predicate buildNotArchivedFilter(@NonNull @NonNull jakarta.persistence.criteria.Root<?> entity, @NonNull @NonNull jakarta.persistence.criteria.CriteriaBuilder builder)
    • getTenantIdFromContext

      @Nullable protected String getTenantIdFromContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getManagedType

      protected Class<D> getManagedType()
    • getNarrowingHelper

      protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper getNarrowingHelper()
    • getEntityManager

      protected jakarta.persistence.EntityManager getEntityManager()
    • getRepository

      protected TranslationRepository<D> getRepository()
    • setRepository

      @Autowired @Lazy public void setRepository(TranslationRepository<D> repository)
    • getProperties

      protected TranslationCommonProperties getProperties()
    • setProperties

      @Autowired(required=false) public void setProperties(TranslationCommonProperties properties)