Search in sources :

Example 6 with PropertyDescriptor

use of javax.validation.metadata.PropertyDescriptor in project hibernate-orm by hibernate.

the class TypeSafeActivator method applyDDL.

private static void applyDDL(String prefix, PersistentClass persistentClass, Class<?> clazz, ValidatorFactory factory, Set<Class<?>> groups, boolean activateNotNull, Dialect dialect) {
    final BeanDescriptor descriptor = factory.getValidator().getConstraintsForClass(clazz);
    for (PropertyDescriptor propertyDesc : descriptor.getConstrainedProperties()) {
        Property property = findPropertyByName(persistentClass, prefix + propertyDesc.getPropertyName());
        boolean hasNotNull;
        if (property != null) {
            hasNotNull = applyConstraints(propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull, dialect);
            if (property.isComposite() && propertyDesc.isCascaded()) {
                Class<?> componentClass = ((Component) property.getValue()).getComponentClass();
                /*
					 * we can apply not null if the upper component let's us activate not null
					 * and if the property is not null.
					 * Otherwise, all sub columns should be left nullable
					 */
                final boolean canSetNotNullOnColumns = activateNotNull && hasNotNull;
                applyDDL(prefix + propertyDesc.getPropertyName() + ".", persistentClass, componentClass, factory, groups, canSetNotNullOnColumns, dialect);
            }
        // FIXME add collection of components
        }
    }
}
Also used : PropertyDescriptor(javax.validation.metadata.PropertyDescriptor) BeanDescriptor(javax.validation.metadata.BeanDescriptor) Component(org.hibernate.mapping.Component) Property(org.hibernate.mapping.Property)

Aggregations

PropertyDescriptor (javax.validation.metadata.PropertyDescriptor)6 BeanDescriptor (javax.validation.metadata.BeanDescriptor)5 MinijaxPropertyDescriptor (org.minijax.validator.metadata.MinijaxPropertyDescriptor)3 MinijaxBeanDescriptor (org.minijax.validator.metadata.MinijaxBeanDescriptor)2 HashMap (java.util.HashMap)1 Component (org.hibernate.mapping.Component)1 Property (org.hibernate.mapping.Property)1 DynamicModelConstraints (org.kie.workbench.common.forms.dynamic.service.shared.impl.validation.DynamicModelConstraints)1 FieldConstraint (org.kie.workbench.common.forms.dynamic.service.shared.impl.validation.FieldConstraint)1 JavaFormModel (org.kie.workbench.common.forms.model.JavaFormModel)1