Class CampaignValidator
java.lang.Object
com.broadleafcommerce.promotion.offer.service.validation.CampaignValidator
- All Implemented Interfaces:
 com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
public class CampaignValidator
extends Object
implements com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
Validations for 
Campaign.- Author:
 - Samarth Dhruva (samarthd)
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionprotected CampaignService<Campaign>protected OfferCodeService<OfferCode>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).voidsetCampaignService(CampaignService<Campaign> campaignService) Lazy injection since this validator is itself a service component.voidsetOfferCodeService(OfferCodeService<OfferCode> offerCodeService) 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) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
validateForCreate 
- 
Constructor Details
- 
CampaignValidator
public CampaignValidator() 
 - 
 - 
Method Details
- 
setCampaignService
Lazy injection since this validator is itself a service component. This avoids circular dependency exceptions- Parameters:
 campaignService- the campaign service
 - 
setOfferCodeService
Lazy injection since this validator is itself a service component. This avoids circular dependency exceptions- Parameters:
 offerCodeService- the offer 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
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
 - 
getOfferCodeService
 
 -