public class DefaultValidationService extends AbstractBusinessService implements ValidationService
AbstractService.SerializableDTOmodelService, sessionService, txManagertenant| Constructor and Description |
|---|
DefaultValidationService() |
| Modifier and Type | Method and Description |
|---|---|
java.util.Collection<ConstraintGroupModel> |
getActiveConstraintGroups()
Returns all active
constraint groups which are bound to the current session. |
ConstraintGroupModel |
getDefaultConstraintGroup()
Returns the default constraint group (which is created during creation of eccencial data).
|
protected Configuration |
getOrCreateConfiguration(boolean replace) |
protected boolean |
isMultiLanguageValidationDisabled() |
protected ConfigurableHybrisConstraintViolation |
lookupViolation() |
boolean |
needReloadOfValidationEngine(AbstractConstraintModel model)
Returns
true if the given constraint was modified (see ItemModel.getModifiedtime()) after the
last reload (ValidationService.reloadValidationEngine()) of the validation engine. |
void |
reloadValidationEngine()
Just set a flag , lazy with first validation engine will be reloaded.
|
void |
setActiveConstraintGroups(java.util.Collection<ConstraintGroupModel> groups)
Sets the given collection with the
ConstraintGroupModels to the current session context. |
void |
setConstraintDao(ConstraintDao constraintDao) |
void |
setConstraintsExtractor(ConstraintsExtractor constraintsExtractor) |
void |
setFlexibleSearchService(FlexibleSearchService flexibleSearchService) |
void |
setLocalizedConstraintsRegistry(LocalizedConstraintsRegistry registry) |
void |
setViolationFactory(ConstraintViolationFactory violationFactory) |
void |
unloadValidationEngine()
Method removes all constraints available for
Validator, since it call no violation should be noticed. |
<T> java.util.Set<HybrisConstraintViolation> |
validate(T object,
java.lang.Class<?>... groups)
Validates the given
model or Pojo. |
<T> java.util.Set<HybrisConstraintViolation> |
validate(T object,
java.util.Collection<ConstraintGroupModel> groups)
Validates the given
model or Pojo. |
void |
validateConstraint(AbstractConstraintModel model)
Creates TEST validation configuration using given constraint model.
|
<T> java.util.Set<HybrisConstraintViolation> |
validateProperty(T object,
java.lang.String propertyName,
java.lang.Class<?>... groups)
Validates all constraints placed on the property of
object named propertyName. |
<T> java.util.Set<HybrisConstraintViolation> |
validateProperty(T object,
java.lang.String propertyName,
java.util.Collection<ConstraintGroupModel> groups)
Validates all constraints placed on the property of
object named propertyName. |
<T> java.util.Set<HybrisConstraintViolation> |
validateValue(java.lang.Class<T> beanType,
java.lang.String propertyName,
java.lang.Object value,
java.lang.Class<?>... groups)
Validates all constraints placed on the property named
propertyName of the class
beanType would the property value be value. |
<T> java.util.Set<HybrisConstraintViolation> |
validateValue(java.lang.Class<T> beanType,
java.lang.String propertyName,
java.lang.Object value,
java.util.Collection<ConstraintGroupModel> groups)
Validates all constraints placed on the property named
propertyName of the class
beanType would the property value be value
ConstraintViolation objects return null for ConstraintViolation#getRootBean() and
ConstraintViolation#getLeafBean() |
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManagerafterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplaceprotected Configuration getOrCreateConfiguration(boolean replace)
public void reloadValidationEngine()
reloadValidationEngine in interface ValidationServicepublic boolean needReloadOfValidationEngine(AbstractConstraintModel model)
ValidationServicetrue if the given constraint was modified (see ItemModel.getModifiedtime()) after the
last reload (ValidationService.reloadValidationEngine()) of the validation engine.needReloadOfValidationEngine in interface ValidationServicemodel - the constraintfalse otherwisepublic void validateConstraint(AbstractConstraintModel model)
ValidationServicevalidateConstraint in interface ValidationServicemodel - the constraintpublic <T> java.util.Set<HybrisConstraintViolation> validate(T object, java.util.Collection<ConstraintGroupModel> groups)
ValidationServicemodel or Pojo.
If groups aren't provided - this method uses for the validation all constrains which are not in any group.validate in interface ValidationServiceobject - the Model or Pojo to validategroups - A collection of constraint groups. Each group contains some
constraints. Use an empty collection for validate agains the default
constraints.ConstraintViolations or an empty set if no validation was found.public <T> java.util.Set<HybrisConstraintViolation> validate(T object, java.lang.Class<?>... groups)
ValidationServicemodel or Pojo.
Same as ValidationService.validate(Object, Collection) but here the constraint group interfaces must be provided. If not
constraint group interface is provided the default constraint group is asumed per default.validate in interface ValidationServiceobject - the model or pojo to validategroups - a class array which contains the group marker interfaces.protected boolean isMultiLanguageValidationDisabled()
public <T> java.util.Set<HybrisConstraintViolation> validateProperty(T object, java.lang.String propertyName, java.util.Collection<ConstraintGroupModel> groups)
ValidationServiceobject named propertyName.validateProperty in interface ValidationServiceobject - object to validatepropertyName - property to validate (i.e. field and getter constraints)groups - A collection of constraint groups. Each group contains n
constraints. Use an empty collection for validate agains the default
constraints.public <T> java.util.Set<HybrisConstraintViolation> validateProperty(T object, java.lang.String propertyName, java.lang.Class<?>... groups)
ValidationServiceobject named propertyName.validateProperty in interface ValidationServiceobject - object to validatepropertyName - property to validate (ie field and getter constraints)groups - group or list of groups targeted for validation (default to javax.validation.groups.Default
)public <T> java.util.Set<HybrisConstraintViolation> validateValue(java.lang.Class<T> beanType, java.lang.String propertyName, java.lang.Object value, java.util.Collection<ConstraintGroupModel> groups)
ValidationServicepropertyName of the class
beanType would the property value be value
ConstraintViolation objects return null for ConstraintViolation#getRootBean() and
ConstraintViolation#getLeafBean()validateValue in interface ValidationServicebeanType - the bean typepropertyName - property to validatevalue - property value to validategroups - A collection of constraint groups. Each group contains n
constraints. Use an empty collection for validate agains the default
constraints.public <T> java.util.Set<HybrisConstraintViolation> validateValue(java.lang.Class<T> beanType, java.lang.String propertyName, java.lang.Object value, java.lang.Class<?>... groups)
ValidationServicepropertyName of the class
beanType would the property value be value.
ConstraintViolation objects return null for ConstraintViolation#getRootBean() and
ConstraintViolation#getLeafBean().validateValue in interface ValidationServicebeanType - the bean typepropertyName - property to validatevalue - property value to validategroups - group or list of groups targeted for validation (default to javax.validation.groups.Default
)protected ConfigurableHybrisConstraintViolation lookupViolation()
public java.util.Collection<ConstraintGroupModel> getActiveConstraintGroups()
ValidationServiceconstraint groups which are bound to the current session.getActiveConstraintGroups in interface ValidationServicepublic void setActiveConstraintGroups(java.util.Collection<ConstraintGroupModel> groups)
ValidationServiceConstraintGroupModels to the current session context. Those groups will
be used to validate any given model during modelService.save(...).setActiveConstraintGroups in interface ValidationServicegroups - a collection with ConstraintGroupModelpublic void unloadValidationEngine()
ValidationServiceValidator, since it call no violation should be noticed.unloadValidationEngine in interface ValidationServicepublic ConstraintGroupModel getDefaultConstraintGroup()
ValidationServiceConstraintGroupModel.getConstraints()) all constraints which ARE NOT in
any group. Meaning AbstractConstraintModel.getConstraintGroups() returns an empty set. Setting any
constraint to this default group or adding this default group to any constraint results in a
ModelSavingException! The getInterfaceName() returns
always "javax.validation.groups.Default" and the Id returns always
"default". Both values cannot be modified!getDefaultConstraintGroup in interface ValidationServicepublic void setConstraintsExtractor(ConstraintsExtractor constraintsExtractor)
public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
public void setConstraintDao(ConstraintDao constraintDao)
public void setLocalizedConstraintsRegistry(LocalizedConstraintsRegistry registry)
public void setViolationFactory(ConstraintViolationFactory violationFactory)
Copyright © 2018 SAP SE. All Rights Reserved.