Interface OfferCodeService<P extends OfferCode>

All Superinterfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
All Known Implementing Classes:
DefaultOfferCodeService

public interface OfferCodeService<P extends OfferCode> extends com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
  • Method Details

    • readByContextIdAndActive

      @Policy(operationTypes=READ) default P readByContextIdAndActive(String contextId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds an active offer code by ID.
      Parameters:
      contextId - The ID to match
      contextInfo - Request context information around sandbox and multitenant state
      Returns:
      The offer code by ID
    • findOffersAndOfferCodesByCodes

      Map<P,List<Offer>> findOffersAndOfferCodesByCodes(@NonNull List<String> codes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • findByCampaignId

      @NonNull org.springframework.data.domain.Page<P> findByCampaignId(@NonNull String campaignId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • findByOfferId

      @NonNull org.springframework.data.domain.Page<P> findByOfferId(@NonNull String offerId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • readAllByCode

      @NonNull List<P> readAllByCode(@NonNull String code, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Finds all of the OfferCodes by code.
      Parameters:
      code - Code to match
      context - Additional sandbox and multitenant state data
      Returns:
      all of the OfferCodes by code
    • readAllByCodes

      @NonNull List<P> readAllByCodes(@NonNull Set<String> codes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Finds all of the OfferCodes by codes.
      Parameters:
      codes - Codes to match
      context - Additional sandbox and multitenant state data
      Returns:
      all of the OfferCodes by code
    • saveAll

      List<com.broadleafcommerce.data.tracking.core.Trackable> saveAll(List<P> businessInstances, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • persistCodesAndReturnNumber

      int persistCodesAndReturnNumber(CodeGenerator info, Set<String> currentCodeSet, Class<P> payloadType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • persistCodesAndReturn

      List<P> persistCodesAndReturn(CodeGenerator info, Set<String> currentCodeSet, Class<P> payloadType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • readAllByCampaignId

      Stream<P> readAllByCampaignId(String campaignId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Reads the offer codes for the specified campaign id matching the given filters.
      Parameters:
      campaignId - the campaign id
      filters - additional filters to apply in the query
      context - Request context information around sandbox and multitenant state
      Returns:
      the offer codes for the specified campaign id matching the given filters
    • readAllByOfferId

      Stream<P> readAllByOfferId(String offerId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Reads the offer codes for the specified offer id matching the given filters.
      Parameters:
      offerId - the offer id
      filters - additional filters to apply in the query
      context - Request context information around sandbox and multitenant state
      Returns:
      the offer codes for the specified offer id matching the given filters
    • findExistingByCodesIncludeExpiredForCampaignId

      List<P> findExistingByCodesIncludeExpiredForCampaignId(Set<String> codes, String campaignId, Instant endAfterDate, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Search all non-expired offer codes or expired but belonging to the specified campaignId. This is useful to validate that the offer codes can be added or updated. NOTE: This method is used during import of OfferCode and due to the varying limitations on how many entries can be in an "in" statement please make sure that the property "broadleaf.dataimport.processor.batch-size" does not exceed this limitation.
      Parameters:
      codes - The set of codes to match
      campaignId - the campaign id
      endAfterDate - Date after which code should be active
      context - Request context information around sandbox and multitenant state
      Returns:
      all OfferCodes by OfferCode.getCode() that are also active or belonging to the specified campaignId
      See Also:
      • com.broadleafcommerce.promotion.offer.dataimport.CampaignCodeImportBatchHandler
    • findExistingByCodesIncludingInactive

      List<P> findExistingByCodesIncludingInactive(List<String> codes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Search all non-expired offer codes or expired but belonging to the specified offerId. This is useful to validate that the offer codes can be added or updated. NOTE: This method is used during import of OfferCode and due to the varying limitations on how many entries can be in an "in" statement please make sure that the property "broadleaf.dataimport.processor.batch-size" does not exceed this limitation.
      Parameters:
      codes - The set of codes to match
      context - Request context information around sandbox and multitenant state
      Returns:
      all OfferCodes by OfferCode.getCode() that are also active or belonging to the specified offerId
      See Also:
    • findAllDuplicatesForCodesInCampaign

      List<P> findAllDuplicatesForCodesInCampaign(@NonNull @NonNull String campaignId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Finds all duplicates OfferCodes by Campaign.getId(). Typically, this will be used to check for duplicate campaign codes of campaign.
      Parameters:
      campaignId - the campaign id
      context - Request context information around sandbox and multitenant state
      Returns:
      all duplicates OfferCodes by Campaign.getId()
    • findAllUnassignedByGeneratorId

      default List<P> findAllUnassignedByGeneratorId(@NonNull @NonNull String generatorId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Finds all the unassigned OfferCodes by OfferCode.getGeneratorId().
      Parameters:
      generatorId - the id of the code generator that these codes were generated from
      context - Request context information around sandbox and multitenant state
      Returns:
      all the unassigned OfferCodes by OfferCode.getGeneratorId()
    • findAllByGeneratorIdAndAssigned

      List<P> findAllByGeneratorIdAndAssigned(@NonNull @NonNull String generatorId, boolean isAssigned, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Parameters:
      generatorId - the id of the code generator that these codes were generated from
      isAssigned - whether the offer codes are assigned
      context - Request context information around sandbox and multitenant state
      Returns:
      all the unassigned OfferCodes by OfferCode.getGeneratorId()
    • warmCache

      Call to launch an async process to warm the full code cache, if enabled. This method may be safely called repeatedly. If it is determined the cache has not been warmed yet, a new thread will spawn to fully populate the cache. Otherwise, the status of the cache warm process will simply be returned. For callers interested in the status, this method may be called repeatedly until the status FullCacheInitializationStatus.READY is returned, indicating the cache is fully warm.

      This method should only be called prior to the service accepting traffic. It is most useful as part of a readiness probe, for example, as part of a kubernetes pod readiness check.
      Returns:
      The status of the cache warm process.