Class JpaCustomizedCampaignCodeRepository<D extends JpaCampaignCode>
- java.lang.Object
-
- com.broadleafcommerce.promotion.campaign.provider.jpa.repository.JpaCustomizedCampaignCodeRepository<D>
-
- All Implemented Interfaces:
CustomizedCampaignCodeRepository<D>
,org.springframework.beans.factory.InitializingBean
public class JpaCustomizedCampaignCodeRepository<D extends JpaCampaignCode> extends Object implements CustomizedCampaignCodeRepository<D>, org.springframework.beans.factory.InitializingBean
- Author:
- Nathan Moore (nathandmoore)
-
-
Constructor Summary
Constructors Constructor Description JpaCustomizedCampaignCodeRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder criteriaBuilder, List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> rsqlQueryTransformers, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor rsqlVisitor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
List<D>
findAllByCodes(Set<String> codes, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Finds allCampaignCodes
byCampaignCode.getCode()
.List<D>
findAllDuplicatesForCodesInCampaign(@NonNull String campaignId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Finds all duplicatesCampaignCodes
byCampaign.getId()
.Optional<D>
findByContextId(String contextId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Finds a code by ID.List<D>
findExistingByCodesIncludeExpiredForCampaignId(Set<String> codes, String campaignId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Search all non-expired campaign codes or expired but belonging to the specified campaignId.protected com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil
getBehaviorUtil()
protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder
getCriteriaBuilder()
protected javax.persistence.EntityManager
getEntityManager()
protected Class<D>
getManagedType()
Helper method to get the underlyingClass
for the managed entity.protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper
getNarrowingHelper()
protected CampaignCodeRepository<D>
getRepository()
protected com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager
getRepositoryEntityTypeManager()
protected List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer>
getRsqlQueryTransformers()
protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor
getRsqlVisitor()
Stream<D>
readAllByCampaignId(String campaignId, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Reads the campaign codes for the specified campaign id matching the given filters.void
setRepository(CampaignCodeRepository<D> repository)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.broadleafcommerce.promotion.campaign.repository.CustomizedCampaignCodeRepository
findAllByCode
-
-
-
-
Constructor Detail
-
JpaCustomizedCampaignCodeRepository
public JpaCustomizedCampaignCodeRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder criteriaBuilder, List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> rsqlQueryTransformers, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor rsqlVisitor)
-
-
Method Detail
-
setRepository
@Autowired public void setRepository(CampaignCodeRepository<D> repository)
-
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
findByContextId
public Optional<D> findByContextId(String contextId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CustomizedCampaignCodeRepository
Finds a code by ID.- Specified by:
findByContextId
in interfaceCustomizedCampaignCodeRepository<D extends JpaCampaignCode>
- Parameters:
contextId
- The ID to matchcontextInfo
- Request context information around sandbox and multitenant state- Returns:
- The code by ID, or
Optional.empty()
if none.
-
findAllByCodes
public List<D> findAllByCodes(Set<String> codes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:CustomizedCampaignCodeRepository
Finds allCampaignCodes
byCampaignCode.getCode()
.- Specified by:
findAllByCodes
in interfaceCustomizedCampaignCodeRepository<D extends JpaCampaignCode>
- Parameters:
codes
- The set of codes to matchcontext
- Request context information around sandbox and multitenant state- Returns:
- all
CampaignCodes
byCampaignCode.getCode()
.
-
findAllDuplicatesForCodesInCampaign
public List<D> findAllDuplicatesForCodesInCampaign(@NonNull @NonNull String campaignId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:CustomizedCampaignCodeRepository
Finds all duplicatesCampaignCodes
byCampaign.getId()
. Typically, this will be used to check for duplicate campaign codes of campaign.- Specified by:
findAllDuplicatesForCodesInCampaign
in interfaceCustomizedCampaignCodeRepository<D extends JpaCampaignCode>
- Parameters:
campaignId
- the campaign idcontext
- Request context information around sandbox and multitenant state- Returns:
- all duplicates
CampaignCodes
byCampaignCode.getId()
-
findExistingByCodesIncludeExpiredForCampaignId
public List<D> findExistingByCodesIncludeExpiredForCampaignId(Set<String> codes, String campaignId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:CustomizedCampaignCodeRepository
Search all non-expired campaign codes or expired but belonging to the specified campaignId. This is useful to validate that the campaign codes can be added or updated. NOTE: This method is used during import ofCampaignCode
and because different DBs has a different limitation on how many entries can be in "in" statement please make sure that the property "broadleaf.dataimport.processor.batch-size" not exited this limitation.- Specified by:
findExistingByCodesIncludeExpiredForCampaignId
in interfaceCustomizedCampaignCodeRepository<D extends JpaCampaignCode>
- Parameters:
codes
- The set of codes to matchcampaignId
- the campaign idcontext
- Request context information around sandbox and multitenant state- Returns:
- all
CampaignCodes
byCampaignCode.getCode()
that are also active or belonging to the specified campaignId - See Also:
CampaignCodeImportBatchHandler
-
readAllByCampaignId
@Policy(operationTypes=READ) public Stream<D> readAllByCampaignId(String campaignId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CustomizedCampaignCodeRepository
Reads the campaign codes for the specified campaign id matching the given filters.- Specified by:
readAllByCampaignId
in interfaceCustomizedCampaignCodeRepository<D extends JpaCampaignCode>
- Parameters:
campaignId
- the campaign idfilters
- additional filters to apply in the querycontextInfo
- Request context information around sandbox and multitenant state- Returns:
- the campaign codes for the specified campaign id matching the given filters
-
getManagedType
protected Class<D> getManagedType()
Helper method to get the underlyingClass
for the managed entity. The result is usually determined byRepositoryEntityTypeManager.getManagedType(Class, Class, EntityManager)
.- Returns:
- the
Class
for the managed entity.
-
getBehaviorUtil
protected com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil getBehaviorUtil()
-
getRepositoryEntityTypeManager
protected com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager getRepositoryEntityTypeManager()
-
getCriteriaBuilder
protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder getCriteriaBuilder()
-
getNarrowingHelper
protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper getNarrowingHelper()
-
getEntityManager
protected javax.persistence.EntityManager getEntityManager()
-
getRepository
protected CampaignCodeRepository<D> getRepository()
-
getRsqlQueryTransformers
protected List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> getRsqlQueryTransformers()
-
getRsqlVisitor
protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor getRsqlVisitor()
-
-