cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1196974 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/
Date Thu, 03 Nov 2011 06:47:21 GMT
Author: aadamchik
Date: Thu Nov  3 06:47:21 2011
New Revision: 1196974

URL: http://svn.apache.org/viewvc?rev=1196974&view=rev
Log:
CAY-1638 [PATCH] Can't disable validation for CayenneContext

patch by John Huss

Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1196974&r1=1196973&r2=1196974&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Thu Nov  3 06:47:21 2011
@@ -17,6 +17,7 @@ CAY-1603 Improve custom ExtendedType reg
 CAY-1608 Implement constructor injection support for DefaultAdhocObjectFactory
 CAY-1618 Create database adapters instances with proper injection
 CAY-1637 [PATCH] DataContextFactory is cumbersome to customize
+CAY-1638 [PATCH] Can't disable validation for CayenneContext
 
 Bug Fixes Since 3.1M3:
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java?rev=1196974&r1=1196973&r2=1196974&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java
Thu Nov  3 06:47:21 2011
@@ -96,6 +96,8 @@ public abstract class BaseContext implem
     protected transient DataChannel channel;
     protected transient QueryCache queryCache;
     protected transient EntityResolver entityResolver;
+    
+    protected boolean validatingObjectsOnCommit = true;
 
     /**
      * Graph action that handles property changes
@@ -204,6 +206,26 @@ public abstract class BaseContext implem
     }
 
     /**
+     * Returns whether this ObjectContext performs object validation before commit is
+     * executed.
+     * 
+     * @since 1.1
+     */
+    public boolean isValidatingObjectsOnCommit() {
+        return validatingObjectsOnCommit;
+    }
+
+    /**
+     * Sets the property defining whether this ObjectContext should perform object
+     * validation before commit is executed.
+     * 
+     * @since 1.1
+     */
+    public void setValidatingObjectsOnCommit(boolean flag) {
+        this.validatingObjectsOnCommit = flag;
+    }
+    
+    /**
      * @since 3.1
      */
     public <T> T localObject(T objectFromAnotherContext) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java?rev=1196974&r1=1196973&r2=1196974&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
Thu Nov  3 06:47:21 2011
@@ -132,7 +132,7 @@ public class CayenneContext extends Base
     CayenneContextGraphManager internalGraphManager() {
         return graphManager;
     }
-
+    
     /**
      * Commits changes to uncommitted objects. First checks if there are changes in this
      * context and if any changes are detected, sends a commit message to remote Cayenne
@@ -155,28 +155,30 @@ public class CayenneContext extends Base
 
             if (graphManager.hasChanges()) {
 
-                ValidationResult result = new ValidationResult();
-                Iterator<?> it = graphManager.dirtyNodes().iterator();
-                while (it.hasNext()) {
-                    Persistent p = (Persistent) it.next();
-                    if (p instanceof Validating) {
-                        switch (p.getPersistenceState()) {
-                            case PersistenceState.NEW:
-                                ((Validating) p).validateForInsert(result);
-                                break;
-                            case PersistenceState.MODIFIED:
-                                ((Validating) p).validateForUpdate(result);
-                                break;
-                            case PersistenceState.DELETED:
-                                ((Validating) p).validateForDelete(result);
-                                break;
+            	if (isValidatingObjectsOnCommit()) {
+                    ValidationResult result = new ValidationResult();
+                    Iterator<?> it = graphManager.dirtyNodes().iterator();
+                    while (it.hasNext()) {
+                        Persistent p = (Persistent) it.next();
+                        if (p instanceof Validating) {
+                            switch (p.getPersistenceState()) {
+                                case PersistenceState.NEW:
+                                    ((Validating) p).validateForInsert(result);
+                                    break;
+                                case PersistenceState.MODIFIED:
+                                    ((Validating) p).validateForUpdate(result);
+                                    break;
+                                case PersistenceState.DELETED:
+                                    ((Validating) p).validateForDelete(result);
+                                    break;
+                            }
                         }
                     }
-                }
-
-                if (result.hasFailures()) {
-                    throw new ValidationException(result);
-                }
+    
+                    if (result.hasFailures()) {
+                        throw new ValidationException(result);
+                    }
+            	}
 
                 graphManager.graphCommitStarted();
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java?rev=1196974&r1=1196973&r2=1196974&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
Thu Nov  3 06:47:21 2011
@@ -76,7 +76,6 @@ public class DataContext extends BaseCon
 
     private DataContextDelegate delegate;
     protected boolean usingSharedSnaphsotCache;
-    protected boolean validatingObjectsOnCommit;
     protected ObjectStore objectStore;
 
     protected transient DataContextMergeHandler mergeHandler;
@@ -1076,26 +1075,6 @@ public class DataContext extends BaseCon
         this.usingSharedSnaphsotCache = flag;
     }
 
-    /**
-     * Returns whether this DataContext performs object validation before commit is
-     * executed.
-     * 
-     * @since 1.1
-     */
-    public boolean isValidatingObjectsOnCommit() {
-        return validatingObjectsOnCommit;
-    }
-
-    /**
-     * Sets the property defining whether this DataContext should perform object
-     * validation before commit is executed.
-     * 
-     * @since 1.1
-     */
-    public void setValidatingObjectsOnCommit(boolean flag) {
-        this.validatingObjectsOnCommit = flag;
-    }
-
     // ---------------------------------------------
     // Serialization Support
     // ---------------------------------------------



Mime
View raw message