You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2007/08/06 20:02:32 UTC

svn commit: r563209 - in /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map: DataMap.java Relationship.java

Author: aadamchik
Date: Mon Aug  6 11:02:31 2007
New Revision: 563209

URL: http://svn.apache.org/viewvc?view=rev&rev=563209
Log:
CAY-843 Remove arbitrary reverse relationship mapping limitations 
(adding a concept of runtime relationships)

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/Relationship.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java?view=diff&rev=563209&r1=563208&r2=563209
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java Mon Aug  6 11:02:31 2007
@@ -323,7 +323,15 @@
         while (it.hasNext()) {
             Map.Entry entry = (Map.Entry) it.next();
             Entity entity = (Entity) entry.getValue();
-            encoder.print(entity.getRelationships());
+
+            // filter out synthetic
+            Iterator relationships = entity.getRelationships().iterator();
+            while (relationships.hasNext()) {
+                Relationship relationship = (Relationship) relationships.next();
+                if (!relationship.isRuntime()) {
+                    relationship.encodeAsXML(encoder);
+                }
+            }
         }
     }
 
@@ -333,7 +341,15 @@
         while (it.hasNext()) {
             Map.Entry entry = (Map.Entry) it.next();
             ObjEntity entity = (ObjEntity) entry.getValue();
-            encoder.print(entity.getDeclaredRelationships());
+            
+            // filter out synthetic
+            Iterator relationships = entity.getDeclaredRelationships().iterator();
+            while (relationships.hasNext()) {
+                Relationship relationship = (Relationship) relationships.next();
+                if (!relationship.isRuntime()) {
+                    relationship.encodeAsXML(encoder);
+                }
+            }
         }
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/Relationship.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/Relationship.java?view=diff&rev=563209&r1=563208&r2=563209
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/Relationship.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/Relationship.java Mon Aug  6 11:02:31 2007
@@ -41,6 +41,14 @@
     protected boolean toMany;
 
     /**
+     * A flag that specifies whether a Relationship was mapped by the user or added
+     * dynamically by Cayenne runtime.
+     * 
+     * @since 3.0
+     */
+    protected boolean runtime;
+
+    /**
      * Creates an unnamed relationship.
      */
     public Relationship() {
@@ -153,5 +161,13 @@
         return new ToStringBuilder(this).append("name", getName()).append(
                 "toMany",
                 isToMany()).toString();
+    }
+
+    public boolean isRuntime() {
+        return runtime;
+    }
+
+    public void setRuntime(boolean synthetic) {
+        this.runtime = synthetic;
     }
 }