cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgen...@apache.org
Subject svn commit: r1476950 - in /cayenne/main/branches/STABLE-3.1: docs/doc/src/main/resources/RELEASE-NOTES.txt framework/cayenne-project/src/main/java/org/apache/cayenne/project/validation/ObjEntityValidator.java
Date Mon, 29 Apr 2013 10:03:44 GMT
Author: mgentry
Date: Mon Apr 29 10:03:44 2013
New Revision: 1476950

URL: http://svn.apache.org/r1476950
Log:
Adds CAY-1813 Missing ObjEntity Attribute Validation with Duplicate DbEntity Columns.

Modified:
    cayenne/main/branches/STABLE-3.1/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/branches/STABLE-3.1/framework/cayenne-project/src/main/java/org/apache/cayenne/project/validation/ObjEntityValidator.java

Modified: cayenne/main/branches/STABLE-3.1/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1476950&r1=1476949&r2=1476950&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/branches/STABLE-3.1/docs/doc/src/main/resources/RELEASE-NOTES.txt Mon Apr
29 10:03:44 2013
@@ -11,6 +11,10 @@ https://issues.apache.org/jira/browse/CA
 Release: 3.1B3
 Date: not yet released
 ----------------------------------
+Changes/New Features Since 3.1B1:
+
+CAY-1813 Missing ObjEntity Attribute Validation with Duplicate DbEntity Columns
+
 Bug Fixes Since 3.1B2:
 
 CAY-1794 Duplicate attributes in discriminator columns of PersistentDescriptor

Modified: cayenne/main/branches/STABLE-3.1/framework/cayenne-project/src/main/java/org/apache/cayenne/project/validation/ObjEntityValidator.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/framework/cayenne-project/src/main/java/org/apache/cayenne/project/validation/ObjEntityValidator.java?rev=1476950&r1=1476949&r2=1476950&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/framework/cayenne-project/src/main/java/org/apache/cayenne/project/validation/ObjEntityValidator.java
(original)
+++ cayenne/main/branches/STABLE-3.1/framework/cayenne-project/src/main/java/org/apache/cayenne/project/validation/ObjEntityValidator.java
Mon Apr 29 10:03:44 2013
@@ -18,8 +18,12 @@
  ****************************************************************/
 package org.apache.cayenne.project.validation;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.util.Util;
 import org.apache.cayenne.validation.ValidationResult;
@@ -31,10 +35,10 @@ class ObjEntityValidator extends Configu
         validateName(entity, validationResult);
         validateClassName(entity, validationResult);
         validateSuperClassName(entity, validationResult);
+        validateAttributes(entity, validationResult);
 
         // validate DbEntity presence
         if (entity.getDbEntity() == null && !entity.isAbstract()) {
-
             addFailure(
                     validationResult,
                     entity,
@@ -108,7 +112,7 @@ class ObjEntityValidator extends Configu
                     entity.getName(),
                     superClassName);
         }
-        
+
         if (entity.getDbEntityName() != null && entity.getSuperEntityName() != null)
{
             addFailure(
                     validationResult,
@@ -124,6 +128,25 @@ class ObjEntityValidator extends Configu
         }
     }
 
+    private void validateAttributes(ObjEntity entity, ValidationResult validationResult)
{
+        Set<String> dbAttributeNames = new HashSet<String>();
+
+        for (ObjAttribute attribute : entity.getAttributes()) {
+            String dbAttributeName = attribute.getDbAttribute().getName();
+
+            if (Util.isEmptyString(dbAttributeName) == false) {
+                if (dbAttributeNames.contains(dbAttributeName)) {
+                    addFailure(validationResult,
+                               entity,
+                               "ObjEntity contains duplicate DbAttribute mappings (%s)",
+                               dbAttributeName);
+                }
+
+                dbAttributeNames.add(dbAttributeName);
+            }
+        }
+    }
+
     void validateName(ObjEntity entity, ValidationResult validationResult) {
         String name = entity.getName();
 



Mime
View raw message