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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected InventoryLocationService<InventoryLocation>
protected SkuInventoryService<SkuInventory>
void
setInventoryLocationService
(InventoryLocationService<InventoryLocation> inventoryLocationService) void
setSkuInventoryService
(SkuInventoryService<SkuInventory> skuInventoryService) boolean
supports
(Class<?> serviceClass, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) void
validate
(@NonNull Object businessInstance, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected void
validateAsParentOfSerializedInventory
(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates theSkuInventory
as the parent of serialized inventories, determined bySkuInventory.hasChildren()
.protected void
validateAsSerializedInventory
(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates theSkuInventory
as the serialized inventory itself, determined bySkuInventory.isSerialized()
.void
validateForCreate
(@NonNull Object businessInstance, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) void
validateForReplace
(@NonNull Object businessInstance, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) void
validateForUpdate
(@NonNull Object updatedBusinessInstance, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected void
validateInventoryLocation
(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected void
validateNoDuplicateSkuReferences
(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected void
validateParentExistsAndSkuRefsMatch
(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates the parent of the serializedSkuInventory
exists.protected void
validateQuantities
(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected void
validateQuantitiesForSerializedInventory
(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors) Validates that the quantity fields of serializedSkuInventory
is either 0 or 1.protected void
validateSerializedInventory
(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates theSkuInventory
for serialized inventory setup, either the parent or the serialized inventory itself.protected void
validateSkuComponent
(@NonNull SkuInventory skuInventory, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected void
validateSkuReferencesNotChanged
(@NonNull SkuInventory updatedInstance, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates theSkuInventory.getSkuRef()
is not updated.protected boolean
validateSkuRefsMatch
(@NonNull SkuInventory sku1, @NonNull SkuInventory sku2) Validates that theSkuRefs
between the two givenSkuInventories
match.
-
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 interfacecom.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 interfacecom.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 interfacecom.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 interfacecom.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 interfacecom.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 theSkuInventory.getSkuRef()
is not updated.- Parameters:
updatedInstance
- theSkuInventory
that was updatederrors
- an errors object bound to theskuInventory
to be validatedcontext
- 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 theSkuInventory
for serialized inventory setup, either the parent or the serialized inventory itself.- Parameters:
skuInventory
- theSkuInventory
to validateerrors
- an errors object bound to theskuInventory
to be validatedcontext
- 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 theSkuInventory
as the parent of serialized inventories, determined bySkuInventory.hasChildren()
.- Parameters:
skuInventory
- theSkuInventory
to validateerrors
- An errors object bound to theskuInventory
to be validatedcontext
- 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 theSkuInventory
as the serialized inventory itself, determined bySkuInventory.isSerialized()
.- Parameters:
skuInventory
- theSkuInventory
to validateerrors
- An errors object bound to theskuInventory
to be validatedcontext
- 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 serializedSkuInventory
exists.- Parameters:
skuInventory
- theSkuInventory
to validateerrors
- An errors object bound to theskuInventory
to be validatedcontext
- The current context
-
validateSkuRefsMatch
protected boolean validateSkuRefsMatch(@NonNull @NonNull SkuInventory sku1, @NonNull @NonNull SkuInventory sku2) Validates that theSkuRefs
between the two givenSkuInventories
match.Typically used to ensure that the
SkuRef
between a parent and a serialized inventories match or that theSkuRef
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 serializedSkuInventory
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
-
getSkuInventoryService
-