@Service(value="blSandboxFieldConfigValidator") public class SandBoxFieldConfigValidator extends Object implements org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
Modifier and Type | Field and Description |
---|---|
protected org.broadleafcommerce.common.persistence.EntityConfiguration |
entityConfiguration |
protected javax.persistence.EntityManager |
entityManager |
protected javax.persistence.EntityManagerFactory |
entityManagerFactory |
Constructor and Description |
---|
SandBoxFieldConfigValidator() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkIgnore(Field field)
Check if
Field should be ignored or excluded |
protected Annotation |
getAnnotationForClass(List<Annotation> annotationsToCheck,
Class clazz)
Returns the
Annotation that is of the specified Class. |
protected Annotation |
getAnnotationWithQuanityRule(List<Annotation> annotationsToCheck)
Returns the
Annotation that has SupportedFieldType.RULE_WITH_QUANTITY |
protected List<Annotation> |
getMapAnnotations(List<Annotation> annotationsToCheck)
|
protected Class |
getTargetedEntity(Annotation[] annotations)
Returns the targetEntity of a field.
|
protected boolean |
hasCollectionAnnotation(List<Annotation> annotationsToCheck)
Iterates to see if any
Annotation indicates that the field is a collection. |
protected boolean |
isMapAnnotation(Annotation annotation) |
void |
onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) |
protected void |
validateField(Field field,
Class<com.broadleafcommerce.enterprise.common.domain.SandBoxDiscriminator> cls)
Validate field against their annotations using standard reflection
|
protected void |
validateMapCollectionConfigs(Field field,
Class<com.broadleafcommerce.enterprise.common.domain.SandBoxDiscriminator> cls,
List<Annotation> annotations,
Class targetedEntity)
Validates fields that are annotated with
AdminPresentationMapFields or AdminPresentationMap
have a specified toOneParentProperty and a toOneTargetPropery. |
protected void |
validateOneToMany(Field field,
Class<com.broadleafcommerce.enterprise.common.domain.SandBoxDiscriminator> cls,
Annotation annotation)
Validates that an OneToMany field has properties
OneToMany.mappedBy() and OneToMany.targetEntity() . |
protected void |
validateQuantityRule(Field field,
Class<com.broadleafcommerce.enterprise.common.domain.SandBoxDiscriminator> cls,
Annotation annotation,
Class targetedEntity)
Validate that the QuantityBasedRule interface is implemented for quantity rule types
|
protected void |
validateTargetDirectCopyTransformConfig(Field field,
Class<com.broadleafcommerce.enterprise.common.domain.SandBoxDiscriminator> cls,
Class targetedEntity)
Validate that the target entity for a field is sandboxable
|
protected javax.persistence.EntityManagerFactory entityManagerFactory
protected org.broadleafcommerce.common.persistence.EntityConfiguration entityConfiguration
protected javax.persistence.EntityManager entityManager
public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
onApplicationEvent
in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
protected void validateField(Field field, Class<com.broadleafcommerce.enterprise.common.domain.SandBoxDiscriminator> cls) throws IllegalArgumentException
field
- cls
- IllegalArgumentException
protected Annotation getAnnotationWithQuanityRule(List<Annotation> annotationsToCheck)
Annotation
that has SupportedFieldType.RULE_WITH_QUANTITY
annotationsToCheck
- protected Annotation getAnnotationForClass(List<Annotation> annotationsToCheck, Class clazz)
Annotation
that is of the specified Class.
Once the annotation is found, it is removed from the list so that algorithmic complexity
is reduced for all other functions that use the same list.annotationsToCheck
- clazz
- protected List<Annotation> getMapAnnotations(List<Annotation> annotationsToCheck)
annotationsToCheck
- protected boolean isMapAnnotation(Annotation annotation)
annotation
- protected boolean hasCollectionAnnotation(List<Annotation> annotationsToCheck)
Annotation
indicates that the field is a collection.annotationsToCheck
- protected Class getTargetedEntity(Annotation[] annotations)
annotations
- protected void validateMapCollectionConfigs(Field field, Class<com.broadleafcommerce.enterprise.common.domain.SandBoxDiscriminator> cls, List<Annotation> annotations, Class targetedEntity) throws IllegalArgumentException
AdminPresentationMapFields
or AdminPresentationMap
have a specified toOneParentProperty and a toOneTargetPropery. If the properties are stored in an AdminPresentationMapFields
annotation, then check that target entity implements SimpleRule
field
- cls
- annotations
- targetedEntity
- IllegalArgumentException
protected void validateQuantityRule(Field field, Class<com.broadleafcommerce.enterprise.common.domain.SandBoxDiscriminator> cls, Annotation annotation, Class targetedEntity) throws IllegalArgumentException
field
- cls
- annotation
- targetedEntity
- IllegalArgumentException
protected void validateTargetDirectCopyTransformConfig(Field field, Class<com.broadleafcommerce.enterprise.common.domain.SandBoxDiscriminator> cls, Class targetedEntity) throws IllegalArgumentException
field
- cls
- targetedEntity
- IllegalArgumentException
protected void validateOneToMany(Field field, Class<com.broadleafcommerce.enterprise.common.domain.SandBoxDiscriminator> cls, Annotation annotation) throws IllegalArgumentException
OneToMany.mappedBy()
and OneToMany.targetEntity()
.
Also validates that the targetEntity is annotated with ManyToOne
on the corresponding field being mappedBy.field
- cls
- annotation
- IllegalArgumentException
Copyright © 2021. All rights reserved.