cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r421953 - in /incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src: cayenne/java/org/objectstyle/cayenne/ cayenne/java/org/objectstyle/cayenne/access/ tests/java/org/objectstyle/cayenne/access/
Date Fri, 14 Jul 2006 17:16:22 GMT
Author: aadamchik
Date: Fri Jul 14 10:16:21 2006
New Revision: 421953

URL: http://svn.apache.org/viewvc?rev=421953&view=rev
Log:
CAY-598 removing validating interface requirement from DataObject

Removed:
    incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/ObjectStoreValidationTst.java
Modified:
    incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/CayenneDataObject.java
    incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/DataObject.java
    incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectStore.java
    incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectStoreGraphDiff.java

Modified: incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/CayenneDataObject.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/CayenneDataObject.java?rev=421953&r1=421952&r2=421953&view=diff
==============================================================================
--- incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/CayenneDataObject.java
(original)
+++ incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/CayenneDataObject.java
Fri Jul 14 10:16:21 2006
@@ -90,7 +90,7 @@
  * 
  * @author Andrei Adamchik
  */
-public class CayenneDataObject implements DataObject, XMLSerializable {
+public class CayenneDataObject implements DataObject, Validating, XMLSerializable {
 
     protected long snapshotVersion = DEFAULT_VERSION;
 

Modified: incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/DataObject.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/DataObject.java?rev=421953&r1=421952&r2=421953&view=diff
==============================================================================
--- incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/DataObject.java
(original)
+++ incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/DataObject.java
Fri Jul 14 10:16:21 2006
@@ -62,7 +62,7 @@
  * 
  * @author Andrei Adamchik
  */
-public interface DataObject extends Persistent, Validating {
+public interface DataObject extends Persistent {
 
     public static final long DEFAULT_VERSION = Long.MIN_VALUE;
 

Modified: incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectStore.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectStore.java?rev=421953&r1=421952&r2=421953&view=diff
==============================================================================
--- incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectStore.java
(original)
+++ incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectStore.java
Fri Jul 14 10:16:21 2006
@@ -84,8 +84,6 @@
 import org.objectstyle.cayenne.map.ObjEntity;
 import org.objectstyle.cayenne.map.ObjRelationship;
 import org.objectstyle.cayenne.query.ObjectIdQuery;
-import org.objectstyle.cayenne.validation.ValidationException;
-import org.objectstyle.cayenne.validation.ValidationResult;
 
 /**
  * ObjectStore stores objects using their ObjectId as a key. It works as a dedicated
@@ -847,83 +845,6 @@
                 ? (ObjectContext) event.getPostedBy()
                 : null;
         context.fireDataChannelChanged(originatingContext, diff);
-    }
-
-    /**
-     * Performs validation of all uncommitted objects in the ObjectStore. If validation
-     * fails, a ValidationException is thrown, listing all encountered failures. This is
a
-     * utility method for the users to call. Cayenne itself uses a different mechanism to
-     * validate objects on commit.
-     * 
-     * @since 1.1
-     * @throws ValidationException
-     * @deprecated since 1.2 - This method is no longer used in Cayenne internally.
-     */
-    public synchronized void validateUncommittedObjects() throws ValidationException {
-
-        // we must iterate over a copy of object list,
-        // as calling validateFor* on DataObjects can have a side effect
-        // of modifying this ObjectStore, and thus resulting in
-        // ConcurrentModificationExceptions in the Iterator
-
-        Collection deleted = null;
-        Collection inserted = null;
-        Collection updated = null;
-
-        Iterator allIt = getObjectIterator();
-        while (allIt.hasNext()) {
-            DataObject dataObject = (DataObject) allIt.next();
-            switch (dataObject.getPersistenceState()) {
-                case PersistenceState.NEW:
-                    if (inserted == null) {
-                        inserted = new ArrayList();
-                    }
-                    inserted.add(dataObject);
-                    break;
-                case PersistenceState.MODIFIED:
-                    if (updated == null) {
-                        updated = new ArrayList();
-                    }
-                    updated.add(dataObject);
-                    break;
-                case PersistenceState.DELETED:
-                    if (deleted == null) {
-                        deleted = new ArrayList();
-                    }
-                    deleted.add(dataObject);
-                    break;
-            }
-        }
-
-        ValidationResult validationResult = new ValidationResult();
-
-        if (deleted != null) {
-            Iterator it = deleted.iterator();
-            while (it.hasNext()) {
-                DataObject dataObject = (DataObject) it.next();
-                dataObject.validateForDelete(validationResult);
-            }
-        }
-
-        if (inserted != null) {
-            Iterator it = inserted.iterator();
-            while (it.hasNext()) {
-                DataObject dataObject = (DataObject) it.next();
-                dataObject.validateForInsert(validationResult);
-            }
-        }
-
-        if (updated != null) {
-            Iterator it = updated.iterator();
-            while (it.hasNext()) {
-                DataObject dataObject = (DataObject) it.next();
-                dataObject.validateForUpdate(validationResult);
-            }
-        }
-
-        if (validationResult.hasFailures()) {
-            throw new ValidationException(validationResult);
-        }
     }
 
     /**

Modified: incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectStoreGraphDiff.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectStoreGraphDiff.java?rev=421953&r1=421952&r2=421953&view=diff
==============================================================================
--- incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectStoreGraphDiff.java
(original)
+++ incubator/cayenne/main/branches/PROTO-3.0/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectStoreGraphDiff.java
Fri Jul 14 10:16:21 2006
@@ -61,10 +61,10 @@
 import java.util.List;
 import java.util.Map;
 
-import org.objectstyle.cayenne.DataObject;
 import org.objectstyle.cayenne.ObjectId;
 import org.objectstyle.cayenne.PersistenceState;
 import org.objectstyle.cayenne.Persistent;
+import org.objectstyle.cayenne.Validating;
 import org.objectstyle.cayenne.graph.CompoundDiff;
 import org.objectstyle.cayenne.graph.GraphChangeHandler;
 import org.objectstyle.cayenne.graph.GraphDiff;
@@ -113,17 +113,20 @@
                 noop = false;
 
                 // accessing objectMap directly to avoid unneeded synchronization.
-                DataObject object = (DataObject) objectStore.getNodeNoSync(entry.getKey());
-                switch (object.getPersistenceState()) {
-                    case PersistenceState.NEW:
-                        object.validateForInsert(result);
-                        break;
-                    case PersistenceState.MODIFIED:
-                        object.validateForUpdate(result);
-                        break;
-                    case PersistenceState.DELETED:
-                        object.validateForDelete(result);
-                        break;
+                Persistent object = (Persistent) objectStore.getNodeNoSync(entry.getKey());
+                
+                if (object instanceof Validating) {
+                    switch (object.getPersistenceState()) {
+                        case PersistenceState.NEW:
+                            ((Validating) object).validateForInsert(result);
+                            break;
+                        case PersistenceState.MODIFIED:
+                            ((Validating) object).validateForUpdate(result);
+                            break;
+                        case PersistenceState.DELETED:
+                            ((Validating) object).validateForDelete(result);
+                            break;
+                    }
                 }
             }
         }



Mime
View raw message