cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r464037 - /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java
Date Sat, 14 Oct 2006 21:47:04 GMT
Author: aadamchik
Date: Sat Oct 14 14:47:02 2006
New Revision: 464037

URL: http://svn.apache.org/viewvc?view=rev&rev=464037
Log:
CAY-682: Generic Cayenne POJO enhancer
(removing direct Fault API access from ObjectStore)

Modified:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java?view=diff&rev=464037&r1=464036&r2=464037
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java
Sat Oct 14 14:47:02 2006
@@ -30,7 +30,6 @@
 
 import org.apache.cayenne.DataObject;
 import org.apache.cayenne.DataRow;
-import org.apache.cayenne.Fault;
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.PersistenceState;
@@ -47,9 +46,12 @@
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
 import org.apache.cayenne.map.Procedure;
 import org.apache.cayenne.property.ClassDescriptor;
+import org.apache.cayenne.property.CollectionProperty;
+import org.apache.cayenne.property.Property;
+import org.apache.cayenne.property.PropertyVisitor;
+import org.apache.cayenne.property.SingleObjectArcProperty;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.QueryMetadata;
@@ -805,11 +807,11 @@
     void processIndirectlyModifiedIDs(Collection indirectlyModifiedIDs) {
         Iterator indirectlyModifiedIt = indirectlyModifiedIDs.iterator();
         while (indirectlyModifiedIt.hasNext()) {
-            Object oid = indirectlyModifiedIt.next();
+            ObjectId oid = (ObjectId) indirectlyModifiedIt.next();
 
             // access object map directly - the method should be called in a synchronized
             // context...
-            DataObject object = (DataObject) objectMap.get(oid);
+            final DataObject object = (DataObject) objectMap.get(oid);
 
             if (object == null
                     || object.getPersistenceState() != PersistenceState.COMMITTED) {
@@ -823,19 +825,30 @@
             DataContextDelegate delegate = context.nonNullDelegate();
 
             if (delegate.shouldMergeChanges(object, null)) {
-                ObjEntity entity = context.getEntityResolver().lookupObjEntity(object);
-                Iterator relationshipIterator = entity.getRelationships().iterator();
-                while (relationshipIterator.hasNext()) {
-                    ObjRelationship relationship = (ObjRelationship) relationshipIterator
-                            .next();
-
-                    if (relationship.isSourceIndependentFromTargetChange()) {
-                        Object fault = relationship.isToMany()
-                                ? Fault.getToManyFault()
-                                : Fault.getToOneFault();
-                        object.writePropertyDirectly(relationship.getName(), fault);
+
+                ClassDescriptor descriptor = context
+                        .getEntityResolver()
+                        .getClassDescriptor(oid.getEntityName());
+                descriptor.visitProperties(new PropertyVisitor() {
+
+                    public boolean visitCollectionArc(CollectionProperty property) {
+                        property.invalidate(object);
+                        return true;
                     }
-                }
+
+                    public boolean visitSingleObjectArc(SingleObjectArcProperty property)
{
+                        if (property
+                                .getRelationship()
+                                .isSourceIndependentFromTargetChange()) {
+                            property.invalidate(object);
+                        }
+                        return true;
+                    }
+
+                    public boolean visitProperty(Property property) {
+                        return true;
+                    }
+                });
 
                 delegate.finishedProcessDelete(object);
             }
@@ -1110,7 +1123,7 @@
         public ObjEntity getObjEntity() {
             return null;
         }
-        
+
         public ClassDescriptor getClassDescriptor() {
             return null;
         }



Mime
View raw message