cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1585092 - in /cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade: BaseUpgradeHandler.java v6/UpgradeHandler_V6.java v7/UpgradeHandler_V7.java
Date Sat, 05 Apr 2014 13:26:52 GMT
Author: aadamchik
Date: Sat Apr  5 13:26:51 2014
New Revision: 1585092

URL: http://svn.apache.org/r1585092
Log:
CAY-1924 Upgrade of a project to v7 with cross-map inheritance loses super entity

Modified:
    cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/BaseUpgradeHandler.java
    cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v6/UpgradeHandler_V6.java
    cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v7/UpgradeHandler_V7.java

Modified: cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/BaseUpgradeHandler.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/BaseUpgradeHandler.java?rev=1585092&r1=1585091&r2=1585092&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/BaseUpgradeHandler.java
(original)
+++ cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/BaseUpgradeHandler.java
Sat Apr  5 13:26:51 2014
@@ -23,6 +23,9 @@ import java.io.InputStream;
 import java.net.URL;
 
 import org.apache.cayenne.ConfigurationException;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.resource.Resource;
 import org.apache.cayenne.util.Util;
 import org.xml.sax.Attributes;
@@ -53,6 +56,19 @@ public abstract class BaseUpgradeHandler
 
         this.projectSource = projectSource;
     }
+    
+    /**
+     * Creates a single common EntityResolver for all project DataMaps, setting
+     * it as a namespace for all of them. This is needed for resolving cross-map
+     * relationships.
+     */
+    protected void attachToNamespace(DataChannelDescriptor channelDescriptor) {
+        EntityResolver entityResolver = new EntityResolver(channelDescriptor.getDataMaps());
+
+        for (DataMap map : entityResolver.getDataMaps()) {
+            map.setNamespace(entityResolver);
+        }
+    }
 
     public Resource getProjectSource() {
         return projectSource;

Modified: cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v6/UpgradeHandler_V6.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v6/UpgradeHandler_V6.java?rev=1585092&r1=1585091&r2=1585092&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v6/UpgradeHandler_V6.java
(original)
+++ cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v6/UpgradeHandler_V6.java
Sat Apr  5 13:26:51 2014
@@ -21,7 +21,6 @@ package org.apache.cayenne.project.upgra
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.cayenne.ConfigurationException;
@@ -29,8 +28,6 @@ import org.apache.cayenne.configuration.
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.project.Project;
 import org.apache.cayenne.project.ProjectSaver;
 import org.apache.cayenne.project.upgrade.BaseUpgradeHandler;
@@ -119,15 +116,8 @@ class UpgradeHandler_V6 extends BaseUpgr
         for (DataChannelDescriptor descriptor : domains) {
             Project project = new Project(new ConfigurationTree<DataChannelDescriptor>(
                     descriptor));
-
-            EntityResolver entityResolver = new EntityResolver(
-                    ((DataChannelDescriptor) project.getRootNode()).getDataMaps());
-
-            Iterator<DataMap> it = entityResolver.getDataMaps().iterator();
-            while (it.hasNext()) {
-                DataMap map = it.next();
-                map.setNamespace(entityResolver);
-            }
+            
+            attachToNamespace((DataChannelDescriptor) project.getRootNode());
 
             // side effect of that is deletion of the common "cayenne.xml"
             projectSaver.save(project);

Modified: cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v7/UpgradeHandler_V7.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v7/UpgradeHandler_V7.java?rev=1585092&r1=1585091&r2=1585092&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v7/UpgradeHandler_V7.java
(original)
+++ cayenne/main/trunk/cayenne-project/src/main/java/org/apache/cayenne/project/upgrade/v7/UpgradeHandler_V7.java
Sat Apr  5 13:26:51 2014
@@ -56,11 +56,16 @@ class UpgradeHandler_V7 extends BaseUpgr
             UpgradeHandler handlerV6 = upgraderV6.getUpgradeHandler(projectSource);
             projectSource = handlerV6.performUpgrade();
         }
+        
         XMLDataChannelDescriptorLoader loader = new XMLDataChannelDescriptorLoader();
         injector.injectMembers(loader);
         ConfigurationTree<DataChannelDescriptor> tree = loader.load(projectSource);
         Project project = new Project(tree);
-        // because listeners are no longer loaded they are not saved in upgraded project
+        
+        attachToNamespace((DataChannelDescriptor) project.getRootNode());
+        
+        // load and safe cycle removes objects no longer supported, specifically listeners.
+        
         projectSaver.save(project); 
         return project.getConfigurationResource();
     }



Mime
View raw message