Class SkuInventoryValidator

java.lang.Object
com.broadleafcommerce.inventory.service.validation.SkuInventoryValidator
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator

public class SkuInventoryValidator extends Object implements com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
Validator to validate SkuInventory.
Author:
Kelly Tisdell (ktisdell)
  • Constructor Details

    • SkuInventoryValidator

      public SkuInventoryValidator()
  • Method Details

    • setSkuInventoryService

      @Autowired @Lazy public void setSkuInventoryService(SkuInventoryService<SkuInventory> skuInventoryService)
    • setInventoryLocationService

      @Autowired @Lazy public void setInventoryLocationService(InventoryLocationService<InventoryLocation> inventoryLocationService)
    • supports

      public boolean supports(Class<?> serviceClass, @Nullable 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 @NonNull Object businessInstance, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      validate in interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
    • validateForCreate

      public void validateForCreate(@NonNull @NonNull Object businessInstance, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      validateForCreate in interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
    • validateForUpdate

      public void validateForUpdate(@NonNull @NonNull Object updatedBusinessInstance, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable 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(@NonNull @NonNull Object businessInstance, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      validateForReplace in interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
    • validateSkuComponent

      protected void validateSkuComponent(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • validateQuantities

      protected void validateQuantities(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • validateSkuReferencesNotChanged

      protected void validateSkuReferencesNotChanged(@NonNull @NonNull SkuInventory updatedInstance, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Validates the SkuInventory.getSkuRef() is not updated.
      Parameters:
      updatedInstance - the SkuInventory that was updated
      errors - an errors object bound to the skuInventory to be validated
      context - the current context
    • validateSerializedInventory

      protected void validateSerializedInventory(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Validates the SkuInventory for serialized inventory setup, either the parent or the serialized inventory itself.
      Parameters:
      skuInventory - the SkuInventory to validate
      errors - an errors object bound to the skuInventory to be validated
      context - the current context
    • validateAsParentOfSerializedInventory

      protected void validateAsParentOfSerializedInventory(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Validates the SkuInventory as the parent of serialized inventories, determined by SkuInventory.hasChildren().
      Parameters:
      skuInventory - the SkuInventory to validate
      errors - An errors object bound to the skuInventory to be validated
      context - The current context
    • validateAsSerializedInventory

      protected void validateAsSerializedInventory(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Validates the SkuInventory as the serialized inventory itself, determined by SkuInventory.isSerialized().
      Parameters:
      skuInventory - the SkuInventory to validate
      errors - An errors object bound to the skuInventory to be validated
      context - The current context
    • validateParentExistsAndSkuRefsMatch

      protected void validateParentExistsAndSkuRefsMatch(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Validates the parent of the serialized SkuInventory exists.
      Parameters:
      skuInventory - the SkuInventory to validate
      errors - An errors object bound to the skuInventory to be validated
      context - The current context
    • validateSkuRefsMatch

      protected boolean validateSkuRefsMatch(@NonNull @NonNull SkuInventory sku1, @NonNull @NonNull SkuInventory sku2)
      Validates that the SkuRefs between the two given SkuInventories match.

      Typically used to ensure that the SkuRef between a parent and a serialized inventories match or that the SkuRef isn't updated.

      SkuRef.getSkuName() is intentionally skipped as it's not used to identify any specific sku inventories.

    • validateQuantitiesForSerializedInventory

      protected void validateQuantitiesForSerializedInventory(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors)
      Validates that the quantity fields of serialized SkuInventory is either 0 or 1.
    • validateInventoryLocation

      protected void validateInventoryLocation(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • validateNoDuplicateSkuReferences

      protected void validateNoDuplicateSkuReferences(@NonNull @NonNull SkuInventory skuInventory, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • getInventoryLocationService

      protected InventoryLocationService<InventoryLocation> getInventoryLocationService()
    • getSkuInventoryService

      protected SkuInventoryService<SkuInventory> getSkuInventoryService()