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
-
Method Summary
Modifier and TypeMethodDescriptionprotected CampaignService<Campaign>
protected OfferCodeService<OfferCode>
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
setCampaignService
(CampaignService<Campaign> campaignService) Lazy injection since this validator is itself a service component.void
setOfferCodeService
(OfferCodeService<OfferCode> offerCodeService) 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) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
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
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
-