myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r1429501 - /myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
Date Sun, 06 Jan 2013 12:14:06 GMT
Author: gpetracek
Date: Sun Jan  6 12:14:06 2013
New Revision: 1429501

URL: http://svn.apache.org/viewvc?rev=1429501&view=rev
Log:
EXTVAL-148 @GroupSequence support for @BeanValidation

Modified:
    myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java

Modified: myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java?rev=1429501&r1=1429500&r2=1429501&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
Sun Jan  6 12:14:06 2013
@@ -43,6 +43,7 @@ import javax.faces.component.UIComponent
 import javax.faces.context.FacesContext;
 import javax.faces.validator.ValidatorException;
 import javax.validation.ConstraintViolation;
+import javax.validation.GroupSequence;
 import javax.validation.Payload;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -538,7 +539,9 @@ class ExtValBeanValidationMetaDataIntern
     {
         ModelValidationEntry modelValidationEntry = new ModelValidationEntry();
 
-        modelValidationEntry.setGroups(Arrays.asList(beanValidation.useGroups()));
+        List<Class> groupClassList = createGroupClassList(beanValidation);
+
+        modelValidationEntry.setGroups(groupClassList);
         modelValidationEntry.setDisplayMessageInline(beanValidation.modelValidation().displayInline());
         modelValidationEntry.setCustomMessage(beanValidation.modelValidation().message());
         modelValidationEntry.setMetaDataSourceObject(metaDataSourceObject);
@@ -581,7 +584,9 @@ class ExtValBeanValidationMetaDataIntern
                                List<Class> foundGroupsForPropertyValidation,
                                List<Class> restrictedGroupsForPropertyValidation)
     {
-        foundGroupsForPropertyValidation.addAll(Arrays.asList(beanValidation.useGroups()));
+        List<Class> groupClassList = createGroupClassList(beanValidation);
+
+        foundGroupsForPropertyValidation.addAll(groupClassList);
 
         if (beanValidation.restrictGroups().length > 0)
         {
@@ -692,4 +697,25 @@ class ExtValBeanValidationMetaDataIntern
                     facesMessageHolder.getClientId(), facesMessageHolder.getFacesMessage());
         }
     }
+
+    private List<Class> createGroupClassList(BeanValidation beanValidation)
+    {
+        List<Class> groupClassList = new ArrayList<Class>();
+
+        GroupSequence groupSequence;
+        for (Class<?> groupClass : beanValidation.useGroups())
+        {
+            groupSequence = groupClass.getAnnotation(GroupSequence.class);
+
+            if (groupSequence != null)
+            {
+                groupClassList.addAll(Arrays.asList(groupSequence.value()));
+            }
+            else
+            {
+                groupClassList.add(groupClass);
+            }
+        }
+        return groupClassList;
+    }
 }



Mime
View raw message