Class CampaignValidator
- java.lang.Object
-
- com.broadleafcommerce.promotion.campaign.service.validation.CampaignValidator
-
-
Constructor Summary
Constructors Constructor Description CampaignValidator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CampaignCodeService<CampaignCode>getCampaignCodeService()protected CampaignService<Campaign>getCampaignService()protected booleanisExpiredCampaignDateChange(Campaign updatedCampaign, Campaign existingCampaign)For an update/replace operation, checks if the campaign currently has an active end date in the past (is expired) and has been updated to a value in the future (not expired).voidsetCampaignCodeService(CampaignCodeService<CampaignCode> campaignCodeService)Lazy injection since this validator is itself a service component.voidsetCampaignService(CampaignService<Campaign> campaignService)Lazy injection since this validator is itself a service component.booleansupports(Class<?> serviceClass, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)voidvalidate(Object businessInstance, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)protected voidvalidateActiveEndDate(Campaign campaign, org.springframework.validation.Errors errors)protected voidvalidateActiveStartDate(Campaign campaign, org.springframework.validation.Errors errors)protected voidvalidateCodePrefix(org.springframework.validation.Errors errors)protected voidvalidateExpirationDateChange(Campaign updatedCampaign, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)voidvalidateForReplace(Object businessInstance, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)voidvalidateForUpdate(Object updatedBusinessInstance, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)protected voidvalidateName(org.springframework.validation.Errors errors)
-
-
-
Method Detail
-
setCampaignService
@Autowired @Lazy public void setCampaignService(CampaignService<Campaign> campaignService)
Lazy injection since this validator is itself a service component. This avoids circular dependency exceptions- Parameters:
campaignService- the campaign service
-
setCampaignCodeService
@Autowired @Lazy public void setCampaignCodeService(CampaignCodeService<CampaignCode> campaignCodeService)
Lazy injection since this validator is itself a service component. This avoids circular dependency exceptions- Parameters:
campaignCodeService- the campaign code service
-
supports
public boolean supports(Class<?> serviceClass, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
supportsin interfacecom.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
-
validate
public void validate(@NonNull Object businessInstance, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)- Specified by:
validatein interfacecom.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
-
validateForUpdate
public void validateForUpdate(Object updatedBusinessInstance, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
validateForUpdatein interfacecom.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
-
validateForReplace
public void validateForReplace(Object businessInstance, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
- Specified by:
validateForReplacein interfacecom.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
-
validateName
protected void validateName(org.springframework.validation.Errors errors)
-
validateCodePrefix
protected void validateCodePrefix(org.springframework.validation.Errors errors)
-
validateActiveStartDate
protected void validateActiveStartDate(Campaign campaign, org.springframework.validation.Errors errors)
-
validateActiveEndDate
protected void validateActiveEndDate(Campaign campaign, org.springframework.validation.Errors errors)
-
validateExpirationDateChange
protected void validateExpirationDateChange(Campaign updatedCampaign, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
-
isExpiredCampaignDateChange
protected boolean isExpiredCampaignDateChange(Campaign updatedCampaign, Campaign existingCampaign)
For an update/replace operation, checks if the campaign currently has an active end date in the past (is expired) and has been updated to a value in the future (not expired).- Parameters:
updatedCampaign- the campaign instance after updates are applied (but before persistence)existingCampaign- the campaign instance as it exists currently in the data store- Returns:
- true if the existing campaign is expired and the active end date has been changed to a future time
-
getCampaignService
@NonNull protected CampaignService<Campaign> getCampaignService()
-
getCampaignCodeService
@NonNull protected CampaignCodeService<CampaignCode> getCampaignCodeService()
-
-