org.broadleafcommerce.openadmin.server.service.persistence.validation
Class EntityValidatorServiceImpl

java.lang.Object
  extended by org.broadleafcommerce.openadmin.server.service.persistence.validation.EntityValidatorServiceImpl
All Implemented Interfaces:
EntityValidatorService, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
BeanValidationEntityValidatorServiceImpl

@Service(value="blEntityValidatorService")
public class EntityValidatorServiceImpl
extends Object
implements EntityValidatorService, org.springframework.context.ApplicationContextAware

This implementation validates each Property from the given Entity according to the ValidationConfigurations associated with it.

Author:
Phillip Verheyden
See Also:
EntityValidatorService}, ValidationConfiguration}

Field Summary
protected  org.springframework.context.ApplicationContext applicationContext
           
protected  List<GlobalPropertyValidator> globalEntityValidators
           
 
Constructor Summary
EntityValidatorServiceImpl()
           
 
Method Summary
 List<GlobalPropertyValidator> getGlobalEntityValidators()
           
protected  List<String> getTypeHierarchy(Entity entity)
           
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
           
 void setGlobalEntityValidators(List<GlobalPropertyValidator> globalEntityValidators)
          Set the global validators that will be run on every entity that is attempted to be saved in the admin.
 void validate(Entity submittedEntity, Serializable instance, Map<String,FieldMetadata> propertiesMetadata, RecordHelper recordHelper)
          Validate the given entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

globalEntityValidators

protected List<GlobalPropertyValidator> globalEntityValidators

applicationContext

protected org.springframework.context.ApplicationContext applicationContext
Constructor Detail

EntityValidatorServiceImpl

public EntityValidatorServiceImpl()
Method Detail

validate

public void validate(Entity submittedEntity,
                     Serializable instance,
                     Map<String,FieldMetadata> propertiesMetadata,
                     RecordHelper recordHelper)
Description copied from interface: EntityValidatorService
Validate the given entity. Implementers should set Entity.setValidationFailure(boolean) appropriately. Validation is invoked after the entire instance has been populated according to BasicPersistenceModule.createPopulatedInstance(Serializable, Entity, Map, Boolean).

Specified by:
validate in interface EntityValidatorService
instance - actual domain representation of entity
propertiesMetadata - all of the merged properties metadata for the given Entity

getTypeHierarchy

protected List<String> getTypeHierarchy(Entity entity)

getGlobalEntityValidators

public List<GlobalPropertyValidator> getGlobalEntityValidators()
Specified by:
getGlobalEntityValidators in interface EntityValidatorService
Returns:
the global validators that will be executed for every Entity

setGlobalEntityValidators

public void setGlobalEntityValidators(List<GlobalPropertyValidator> globalEntityValidators)
Description copied from interface: EntityValidatorService

Set the global validators that will be run on every entity that is attempted to be saved in the admin. Global validators are useful to operate on things like field types and other scenarios that could occur with a number of entities. Rather than being required to define a ValidationConfiguration on all of those properties, this can more conveniently validate that set of properties.

An example of a global validator in Broadleaf is the RequiredPropertyValidator which will ensure that every property that is marked as required will fail validation if a value is unset.

Specified by:
setGlobalEntityValidators in interface EntityValidatorService
Parameters:
globalEntityValidators - the globalEntityValidators to set

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException


Copyright © 2013. All Rights Reserved.