Class 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 Detail

      • CampaignValidator

        public CampaignValidator()
    • 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 interface com.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 interface com.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 interface com.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 interface com.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