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 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).void
setCampaignCodeService(CampaignCodeService<CampaignCode> campaignCodeService)
Lazy injection since this validator is itself a service component.void
setCampaignService(CampaignService<Campaign> campaignService)
Lazy injection since this validator is itself a service component.boolean
supports(Class<?> serviceClass, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
void
validate(Object businessInstance, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
protected void
validateActiveEndDate(Campaign campaign, org.springframework.validation.Errors errors)
protected void
validateActiveStartDate(Campaign campaign, org.springframework.validation.Errors errors)
protected void
validateCodePrefix(org.springframework.validation.Errors errors)
protected void
validateExpirationDateChange(Campaign updatedCampaign, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
void
validateForReplace(Object businessInstance, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
void
validateForUpdate(Object updatedBusinessInstance, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
protected void
validateName(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:
supports
in 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:
validate
in 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:
validateForUpdate
in 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:
validateForReplace
in 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()
-
-